@import url("https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&display=swap");

/* Snooze: a bedside table at dawn. One canvas draws the room; the counter, the captions, the phone's
   notification card and the end card are real text on top so they stay crisp. */
:root {
  --font: "Geist", system-ui, -apple-system, sans-serif;
  --ink: #f4e9dc;
  --panel: rgba(18, 16, 24, 0.7);
  --line: rgba(255, 226, 190, 0.2);
  --led: #ff4a3c;
}

*,*::before,*::after { box-sizing: border-box; }
html, body {
  -webkit-tap-highlight-color: transparent; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body { font-family: var(--font); color: var(--ink); background: #0b0d16; touch-action: none; }

canvas#scene {
  display: block; position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; z-index: 1;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}

/* the invisible button over the clock: the real tap target and the keyboard focus stop */
.hit {
  position: fixed; z-index: 5; appearance: none; background: transparent; border: 0; padding: 0; margin: 0;
  cursor: pointer; border-radius: 14px; touch-action: manipulation;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.hit:focus-visible { outline: 2px dashed rgba(255, 210, 150, 0.95); outline-offset: 3px; }

.top {
  position: fixed; z-index: 8; left: 50%; transform: translateX(-50%); width: min(92vw, 520px);
  top: calc(max(12px, env(safe-area-inset-top)) + 34px); display: flex; flex-direction: column; align-items: center; gap: 7px;
  pointer-events: none;
}
.counter {
  display: inline-flex; align-items: baseline; gap: 7px; white-space: nowrap;
  padding: 9px 16px 9px 15px; border-radius: 999px; font-size: 0.95rem; letter-spacing: 0.005em;
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.07) inset, 0 8px 22px rgba(0, 0, 0, 0.42);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.counter__k { color: rgba(244, 233, 220, 0.62); font-weight: 500; }
.counter b { font-weight: 700; font-variant-numeric: tabular-nums; }
.counter.is-bump { animation: bump 0.34s ease-out; }
@keyframes bump { 0% { transform: scale(1); } 35% { transform: scale(1.07); } 100% { transform: scale(1); } }

.caption {
  margin: 0; text-align: center; font-size: 0.64rem; font-weight: 600; letter-spacing: 0.13em; text-transform: uppercase; line-height: 1.55;
  color: rgba(244, 233, 220, 0.82); text-shadow: 0 1px 8px rgba(0, 0, 0, 0.95), 0 0 2px rgba(0, 0, 0, 0.8);
  min-height: 1.55em; transition: opacity 0.5s;
}
.caption.is-hidden { opacity: 0; }

.sound-btn {
  appearance: none; position: fixed; z-index: 12; cursor: pointer; padding: 0;
  top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: transform 0.12s ease, opacity 0.15s ease; touch-action: manipulation;
}
.sound-btn:active { transform: scale(0.94); }
.sound-btn[aria-pressed="false"] { opacity: 0.55; }
.sound-btn[aria-pressed="false"] .sound-btn__wave { opacity: 0; }
.sound-btn:focus-visible, .getup:focus-visible, .btn:focus-visible, .opt-share:focus-visible { outline: 2px dashed rgba(255, 210, 150, 0.95); outline-offset: 2px; }

.getup {
  appearance: none; position: fixed; z-index: 9; cursor: pointer; font-family: var(--font);
  right: max(16px, env(safe-area-inset-right)); bottom: calc(max(14px, env(safe-area-inset-bottom)) + 52px);
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px 0 11px; border-radius: 999px;
  font-size: 0.74rem; font-weight: 600; letter-spacing: 0.02em; color: rgba(244, 233, 220, 0.9);
  background: rgba(14, 12, 20, 0.52); border: 1px solid rgba(255, 226, 190, 0.22);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); touch-action: manipulation;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.2s;
}
.getup svg { width: 14px; height: 14px; }
.getup:hover { background: rgba(32, 26, 36, 0.78); }
.getup:active { transform: scale(0.96); }
.getup[hidden] { display: none; }

.notif {
  position: fixed; z-index: 7; width: min(236px, 74vw); display: flex; gap: 9px; align-items: flex-start; padding: 9px 11px 10px 9px;
  border-radius: 15px; background: rgba(246, 243, 238, 0.94); color: #1b1a1f; pointer-events: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 1px 0 rgba(255, 255, 255, 0.7) inset;
  opacity: 0; transform: translateY(8px) scale(0.96); transition: opacity 0.22s ease, transform 0.26s cubic-bezier(.2, 1.3, .4, 1);
}
.notif.is-on { opacity: 1; transform: none; }
.notif[hidden] { display: none; }
.notif__av { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; font-style: normal; font-weight: 700; font-size: 0.8rem; color: #fff; }
.notif__b { min-width: 0; flex: 1; }
.notif__h { display: flex; justify-content: space-between; gap: 8px; font-size: 0.74rem; }
.notif__h b { font-weight: 700; } .notif__h span { color: #7a7780; font-size: 0.66rem; }
.notif p { margin: 2px 0 0; font-size: 0.8rem; line-height: 1.32; color: #2a2830; }

.shade { position: fixed; inset: 0; z-index: 14; background: rgba(6, 6, 12, 0.55); animation: fade 0.5s ease both; }
.shade[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.card {
  position: fixed; z-index: 15; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(88vw, 360px); max-height: calc(100% - 24px);
  padding: 22px 22px 18px; border-radius: 22px; text-align: center;
  background: linear-gradient(180deg, rgba(34, 28, 34, 0.94), rgba(20, 17, 24, 0.95)); border: 1px solid rgba(255, 226, 190, 0.2);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65), 0 1px 0 rgba(255, 255, 255, 0.08) inset;
  animation: cardIn 0.5s cubic-bezier(.2, .9, .3, 1) both;
}
.card[hidden] { display: none; }
@keyframes cardIn { from { opacity: 0; transform: translate(-50%, -46%); } to { opacity: 1; transform: translate(-50%, -50%); } }
.card__eyebrow { margin: 0 0 8px; font-size: 0.6rem; font-weight: 700; letter-spacing: 0.24em; text-transform: uppercase; color: var(--led); }
.card__t { margin: 0; font-size: 1.55rem; line-height: 1.12; font-weight: 700; letter-spacing: -0.01em; }
.card__sub { margin: 8px 0 0; font-size: 1.02rem; color: rgba(244, 233, 220, 0.9); }
.card__quip { margin: 10px 0 0; font-size: 0.86rem; line-height: 1.4; color: rgba(244, 233, 220, 0.62); }
.card__best { margin: 10px 0 0; font-size: 0.66rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(244, 233, 220, 0.5); }
.card__best:empty { display: none; }
.card__row { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.btn {
  appearance: none; cursor: pointer; font-family: var(--font); height: 40px; padding: 0 20px; border-radius: 999px; border: 0;
  font-size: 0.86rem; font-weight: 700; color: #1d0b09; background: linear-gradient(180deg, #ff7a63, #ff4a3c);
  box-shadow: 0 8px 20px rgba(255, 74, 60, 0.32), 0 1px 0 rgba(255, 255, 255, 0.4) inset; touch-action: manipulation;
  transition: transform 0.12s ease;
}
.btn:active { transform: scale(0.96); }
.share-host { display: inline-flex; }
.share-host:empty { display: none; }
.card .opt-share.opt-share { margin: 0; color: rgba(244, 233, 220, 0.85); }

.frame { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.frame__corner {
  position: absolute; font-size: clamp(0.58rem, 1.2vw, 0.7rem); font-weight: 600;
  letter-spacing: 0.22em; text-transform: uppercase; color: rgba(255, 238, 220, 0.55);
  white-space: nowrap; font-family: var(--font); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
}
.frame__corner--tl { top: calc(max(12px, env(safe-area-inset-top)) + 13px); left: max(18px, env(safe-area-inset-left)); }
.frame__corner--tr { top: calc(max(12px, env(safe-area-inset-top)) + 13px); right: calc(max(12px, env(safe-area-inset-right)) + 54px); }
.frame__corner--bl { bottom: max(18px, env(safe-area-inset-bottom)); left: max(18px, env(safe-area-inset-left)); }
.frame__corner a { color: inherit; text-decoration: none; pointer-events: auto; border-bottom: 1px solid transparent; transition: color .14s, border-color .14s; }
.frame__corner a:hover { color: #fff; border-bottom-color: rgba(255, 255, 255, 0.5); }

/* tip-jar and fullscreen badges: bottom right, off the play area */
.opt-tipjar.opt-tipjar { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); transform: none; }
.opt-fs.opt-fs { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); right: calc(max(14px, env(safe-area-inset-right)) + 54px); transform: none; }
.opt-tipjar.opt-tipjar.tj-nudge { animation: none; }

/* a phone on its side is short: counter up in the corner row, the end card in two columns */
@media (orientation: landscape) and (max-height: 500px) {
  .top { top: max(10px, env(safe-area-inset-top)); }
  .getup { bottom: max(14px, env(safe-area-inset-bottom)); right: calc(max(14px, env(safe-area-inset-right)) + 108px); }
  .card { width: min(86vw, 640px); padding: 14px 20px 14px; display: grid; grid-template-columns: 1fr auto; column-gap: 24px; align-items: center; text-align: left; }
  .card__eyebrow { grid-column: 1; margin-bottom: 4px; }
  .card__t { grid-column: 1; font-size: 1.3rem; }
  .card__sub { grid-column: 1; margin-top: 4px; font-size: 0.95rem; }
  .card__quip { grid-column: 1; margin-top: 6px; font-size: 0.8rem; }
  .card__best { grid-column: 1; margin-top: 6px; }
  .card__row { grid-column: 2; grid-row: 1 / span 5; flex-direction: column; margin-top: 0; }
}
@media (max-width: 520px) { .caption { font-size: 0.6rem; letter-spacing: 0.1em; } }
@media (prefers-reduced-motion: reduce) {
  .counter.is-bump, .shade, .card { animation: none; }
  .notif, .caption, .sound-btn, .getup, .btn { transition: none; }
}
