/* App frame: top bar, empty middle, bottom bar. */
.app {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: var(--gutter);
  text-shadow: 0 1px 14px color-mix(in srgb, var(--bg) 70%, transparent);
}

.ui { transition: opacity var(--fade) var(--ease); }
body.idle { cursor: none; }
body.idle .ui { opacity: 0; pointer-events: none; }

/* The bottom bar fades piece by piece, so a timer that has been started can stay, barely
   visible. The clock (if switched on) stays the same way, moving into the avatar's place. */
.bottombar > *, .modes > * { transition: opacity var(--fade) var(--ease); }
body.idle .bottombar > :not(.modes),
body.idle .modes > :not(.timer) { opacity: 0; pointer-events: none; }
body.idle .timer[data-state="idle"] { opacity: 0; }
body.idle .timer:not([data-state="idle"]),
body.idle .clock { opacity: 0.35; }

/* Top bar */
.topbar { display: flex; align-items: center; }

.wordmark {
  font-family: var(--font-mono);
  font-size: calc(var(--fs-label) * 1.35);
  letter-spacing: 0.42em;
}

.nav { display: flex; align-items: center; gap: calc(var(--gutter) * 0.9); margin-left: calc(var(--gutter) * 2.5); }

.nav button,
.modes [data-mode] {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.5em 0;
  border: 0;
  background: none;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.3s, opacity var(--fade) var(--ease);
}
.nav button:hover,
.modes [data-mode]:hover { color: var(--fg); }
.nav b { font-weight: 400; color: var(--fg); letter-spacing: 0; }

.avatar {
  flex: none;
  width: 2.4em;
  height: 2.4em;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--fg) 30%, transparent);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  display: grid;
  place-items: center;
  padding: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  transition: border-color 0.3s;
}
.avatar:hover { border-color: var(--accent); }
.avatar-ring { width: 1.6em; height: 1.6em; }

/* Clock: the timer's twin, top right. */
.clock {
  flex: none;
  margin-right: calc(var(--gutter) * 0.8);
  font-family: var(--font-mono);
  font-size: calc(var(--fs-label) * 1.7);
  letter-spacing: 0.08em;
  transition: opacity var(--fade) var(--ease), transform var(--fade) var(--ease);
}
.clock[hidden] { display: none; }
body.idle .clock { transform: translateX(calc(var(--gutter) * 0.8 + var(--fs-label) * 2.4)); } /* its margin plus the avatar's width */

/* Goal line: lives in the top bar, centred in the space between the bell and the avatar. */
.goal {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 1em;
  margin: 0 calc(var(--gutter) * 1.5);
  font-size: calc(var(--fs-body) * 1.05);
  transition: opacity var(--fade) var(--ease);
}
.goal .label { flex: none; font-size: 1em; }
/* The goal is set in the same type as its label: same face, size, spacing, capitals. */
.goal-input, .goal-text { font-family: var(--font-mono); letter-spacing: 0.24em; text-transform: uppercase; }
.goal-input::placeholder { text-transform: uppercase; }
body.idle .goal { opacity: 0.8; }
body.idle .goal[data-state="empty"] { opacity: 0; pointer-events: none; } /* nothing set: fade with the rest */

.goal-input {
  width: min(44ch, 100%);
  padding: 0.2em 0;
  border: 0;
  border-bottom: 1px solid transparent;
  background: none;
  text-align: center;
  outline: none;
  transition: border-color 0.4s;
}
.goal-input:hover { border-color: color-mix(in srgb, var(--fg) 20%, transparent); }
.goal-input:focus { border-color: var(--accent); }
.goal-input::placeholder { color: color-mix(in srgb, var(--fg) 40%, transparent); }

.goal-view { display: flex; align-items: baseline; gap: 0.8em; min-width: 0; }
.goal-text { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: text; }

.goal-done {
  width: 1.7em;
  height: 1.7em;
  flex: none;
  border: 1px solid color-mix(in srgb, var(--fg) 30%, transparent);
  border-radius: 50%;
  background: none;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 0.75em;
  color: var(--muted);
  transition: color 0.3s, border-color 0.3s, opacity var(--fade);
}
.goal-done { align-self: center; } /* on the middle of the goal, not its baseline */
.goal-done .icon { width: 1.25em; height: 1.25em; stroke-width: 1.8; } /* drawn, not a ✓ glyph: a font puts that off centre */
.goal-done:hover { color: var(--accent); border-color: var(--accent); }
body.idle .goal-done { opacity: 0; pointer-events: none; }

.goal[data-state="set"] .goal-input,
.goal:not([data-state="set"]) .goal-view { display: none; }

.goal.kept .goal-view {
  opacity: 0;
  letter-spacing: 0.3em;
  filter: blur(6px);
  transform: translateY(-0.6em);
  transition: all 1.4s var(--ease);
}

/* Bottom bar */
.bottombar { display: flex; align-items: flex-end; justify-content: space-between; }

.radio { display: flex; align-items: center; gap: 1em; }
.radio-play {
  display: grid;
  place-items: center;
  width: 2.8em;
  height: 2.8em;
  border: 1px solid color-mix(in srgb, var(--fg) 30%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  color: var(--muted);
}
.radio-play .icon { stroke-width: 1.8; }
.radio.on .icon-play,
.radio:not(.on) .icon-pause { display: none; }
.radio.on .radio-play { color: var(--fg); }

.radio-meta { position: relative; display: grid; gap: 0.1em; }
/* Two small notes above the radio: the whole name of a cut-off title once the pointer has
   rested on it for a second, and why the listener count is what it is. */
.radio-meta[data-full]::after,
.radio-meta[data-tip]::before {
  position: absolute;
  left: 0;
  bottom: calc(100% + 0.7em);
  padding: 0.5em 0.8em;
  border: 1px solid color-mix(in srgb, var(--fg) 14%, transparent);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  white-space: nowrap;
  text-shadow: none;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.radio-meta[data-full]::after { content: attr(data-full); }
.radio-meta[data-tip]::before { content: attr(data-tip); }
.radio-meta[data-full][data-show="full"]::after { opacity: 1; transition-delay: 1s; }
.radio-meta[data-tip][data-show="tip"]::before { opacity: 1; transition-delay: 0.4s; }
.radio-title { max-width: min(46ch, 36vw); padding: 0; border: 0; background: none; overflow: hidden; color: var(--fg); text-align: left; white-space: nowrap; text-overflow: ellipsis; }
.radio-title:hover { color: var(--accent); }

/* The list of stations, slid up above the name it was opened from. */
.radio-meta.listing::before,
.radio-meta.listing::after { display: none; }
.radio-list {
  position: absolute;
  left: -1em;
  bottom: calc(100% + 1em);
  z-index: 2;
  display: grid;
  min-width: 22em;
  padding: 0.5em 0;
  border: 1px solid color-mix(in srgb, var(--fg) 14%, transparent);
  background: color-mix(in srgb, var(--surface) 46%, transparent);
  text-shadow: none;
  animation: list-up 0.35s var(--ease);
}
@keyframes list-up { from { opacity: 0; transform: translateY(1.2em); } }
.radio-list button {
  display: block;
  padding: 0.55em 1em;
  border: 0;
  border-left: 2px solid transparent;
  background: none;
  color: var(--fg);
  text-align: left;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}
.radio-list button:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); }
.radio-list button:disabled { color: var(--muted); opacity: 0.55; cursor: default; } /* an internet station in offline mode */
.radio-list button:disabled:hover { background: none; }
.radio-list [aria-selected="true"] { border-left-color: var(--accent); color: var(--accent); }
/* What a station plays, after its name in the same type: "Radio Swiss Classic (calm classical music)". */
.radio-about { color: var(--muted); }
.radio-list [aria-selected="true"] .radio-about { color: inherit; }

.radio-live {
  padding: 0;
  border: 0;
  background: none;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
}
.radio-live.is-live { color: var(--accent); }
.radio-live.is-offline { color: #ff6b6b; } /* offline mode: red, and a click turns it off (radio.js) */
.radio-live.is-offline:hover { color: #ff9a9a; }
.radio-live:enabled:hover { color: var(--fg); }

/* Next station and volume stay quiet until the radio card is hovered. */
.radio-extra { display: flex; align-items: center; gap: 0.9em; margin-left: 0.6em; opacity: 0.35; transition: opacity 0.4s; }
.radio:hover .radio-extra,
.radio-extra:focus-within { opacity: 1; }

.radio-skip { display: grid; place-items: center; padding: 0.3em; border: 0; background: none; color: var(--muted); transition: color 0.3s; }
.radio-skip:hover { color: var(--fg); }

.radio-volume, .panel-range { width: 6.5em; height: 1.4em; margin: 0; background: none; appearance: none; -webkit-appearance: none; cursor: pointer; }
.radio-volume::-webkit-slider-runnable-track, .panel-range::-webkit-slider-runnable-track { height: 1px; background: color-mix(in srgb, var(--fg) 40%, transparent); }
.radio-volume::-webkit-slider-thumb, .panel-range::-webkit-slider-thumb { width: 0.7em; height: 0.7em; margin-top: calc(-0.35em + 0.5px); border: 0; border-radius: 50%; background: var(--fg); -webkit-appearance: none; }
.radio-volume::-moz-range-track, .panel-range::-moz-range-track { height: 1px; background: color-mix(in srgb, var(--fg) 40%, transparent); }
.radio-volume::-moz-range-thumb, .panel-range::-moz-range-thumb { width: 0.7em; height: 0.7em; border: 0; border-radius: 50%; background: var(--fg); }

.modes { display: flex; align-items: center; gap: calc(var(--gutter) * 0.8); }
.modes [data-mode][aria-pressed="true"] { color: var(--fg); box-shadow: inset 0 -1px 0 var(--accent); }

/* Timer: click to start/pause, scroll (or arrow keys) to change the length before starting. */
.timer {
  min-width: 5ch;
  padding: 0.1em 0;
  border: 0;
  background: none;
  font-family: var(--font-mono);
  font-size: calc(var(--fs-label) * 1.7);
  letter-spacing: 0.08em;
  text-align: right;
  transition: color 0.4s, opacity var(--fade) var(--ease);
}
/* Pink while it counts work or study, green while it counts the rest; a paused one is dimmer. */
.timer { --ink: #ff8fb1; color: var(--ink); }
:root[data-mode="relax"] .timer { --ink: #86e36c; }
.timer[data-state="paused"] { color: color-mix(in srgb, var(--ink) 55%, var(--muted)); }

.timer-reset { display: grid; place-items: center; margin-right: -0.4em; padding: 0.3em; border: 0; background: none; color: var(--muted); transition: color 0.3s, opacity var(--fade) var(--ease); }
.timer-reset:hover { color: var(--fg); }

/* Work and study look the same on purpose; relax warms the light a little. */
/* Absolute, not fixed: a fixed element is its own stacking context and would isolate the blend mode. */
.tint { position: absolute; inset: 0; pointer-events: none; }
.tint::after {
  content: "";
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--accent-2) 22%, #fff);
  mix-blend-mode: multiply;
  opacity: 0;
  transition: opacity 2.5s var(--ease);
}
:root[data-mode="relax"] .tint::after { opacity: 1; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--gutter) * 3.4);
  transform: translate(-50%, 0.6em);
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.16em;
  color: var(--fg);
  text-shadow: 0 1px 14px var(--bg);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.big { font-size: calc(var(--fs-label) * 1.3); } /* the station just tuned to */

/* Login gate */
.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 35%, transparent);
  transition: opacity var(--fade) var(--ease);
}
.gate.leaving { opacity: 0; pointer-events: none; }

/* While the gate is up the scene sits out of focus and the app is hidden; entering reveals both. */
.scene, .app { transition: filter var(--fade) var(--ease), transform var(--fade) var(--ease), opacity var(--fade) var(--ease); }
body.gated .scene { filter: blur(14px) brightness(0.75); transform: scale(1.04); }
body.gated .app { opacity: 0; }

/* Hidden until the texts are in, so no other language (or older wording) shows first. */
.gate-card { display: grid; gap: 1.2em; width: min(24em, 80vw); text-align: center; opacity: 0; transition: opacity 0.4s var(--ease); }
.worded .gate-card { opacity: 1; }
/* What this is, which release, and what it was made for: small, in the corner, out of the way. */
.gate-note {
  position: absolute;
  right: var(--gutter);
  bottom: var(--gutter);
  margin: 0;
  font: var(--fs-label) / 1.7 var(--font-mono);
  letter-spacing: 0.08em;
  text-align: right;
  color: var(--fg);
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}
.worded .gate-note { opacity: 0.45; }
.gate-title {
  margin: 0;
  padding-left: 0.5em; /* balances trailing letter-spacing */
  font: 400 calc(var(--fs-goal) * 1.3) var(--font-mono);
  letter-spacing: 0.5em;
}
.gate-sub { display: grid; gap: 0.5em; margin: 0 0 1.6em; color: var(--muted); }
.gate-sub p { margin: 0; }
.gate-sub p:first-child { color: var(--fg); }

.field {
  padding: 0.5em 0;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--fg) 25%, transparent);
  background: none;
  text-align: center;
  outline: none;
  transition: border-color 0.4s;
}
.field:focus { border-color: var(--accent); }
.field:placeholder-shown { caret-color: transparent; } /* no blinking caret until something is typed */
.field::placeholder { color: color-mix(in srgb, var(--fg) 45%, transparent); }

.btn {
  margin-top: 0.8em;
  padding: 0.9em 1em;
  border: 1px solid color-mix(in srgb, var(--accent) 70%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  transition: background 0.3s;
}
.btn:hover { background: color-mix(in srgb, var(--accent) 24%, transparent); }


/* Phones: the goal and the profile on top, then the radio, its volume and the modes in three
   rows at the bottom. No wordmark and no social items (fakes.css hides help and pictures). */
@media (max-width: 720px), (pointer: coarse) and (max-height: 520px) {
  :root { --fs-label: 12px; --fs-body: 15px; }
  html, body { height: 100dvh; }
  /* Opened from the home screen (full screen), the page reaches under the phone's notch and bars. */
  .app { padding: max(var(--gutter), env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) max(var(--gutter), env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left)); }
  .app { grid-template-columns: minmax(0, 1fr); } /* a long goal is cut, not allowed to widen the page */

  .topbar { align-items: flex-start; gap: 1em; }
  .wordmark, .nav { display: none; }
  .goal { flex-direction: column; align-items: stretch; gap: 0.3em; margin: 0; }
  .goal-input { width: 100%; font-size: 16px; text-align: left; } /* 16px: below that iPhones zoom in on focus */
  .goal-view { justify-content: space-between; }
  .goal-text { white-space: normal; overflow-wrap: anywhere; } /* a long goal wraps onto more lines */
  .clock { margin-right: 0; }
  body.idle .clock { transform: translateX(calc(1em + var(--fs-label) * 2.4)); }
  .field { font-size: 16px; }

  .bottombar { position: relative; z-index: 2; display: grid; justify-content: stretch; gap: 1.1em; } /* the station list over the cookie banner */
  .radio { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.9em 1em; }
  .radio-title { max-width: 100%; }
  .radio-meta[data-full]::after, .radio-meta[data-tip]::before { max-width: calc(100vw - 2 * var(--gutter) - 3.8em); white-space: normal; }
  .radio-list { left: -3.8em; min-width: 0; width: calc(100vw - 2 * var(--gutter)); max-height: 60dvh; overflow-y: auto; background: color-mix(in srgb, var(--surface) 92%, transparent); }
  .radio-list button { white-space: normal; }
  .radio-extra { grid-column: 1 / -1; margin-left: 0; opacity: 1; gap: 1em; }
  .radio-skip { width: 2.8em; } /* under the play button */
  .radio-volume { flex: none; width: var(--line, 10em); height: 2.2em; } /* as long as the line above it (radio.js, fitVolume); taller, for a thumb */
  .modes { justify-content: space-between; gap: 0.6em; }
  .modes [data-mode] { padding: 0.8em 0; }
  .modes [data-mode="relax"] { margin-right: auto; } /* the reset button, when there is one, stays by the timer */

  .toast { bottom: calc(var(--gutter) + 13em); max-width: calc(100vw - 2 * var(--gutter)); white-space: normal; text-align: center; }
  .gate-note { left: var(--gutter); text-align: center; }
  .loading { bottom: calc(var(--gutter) + 21em); width: calc(100vw - 2 * var(--gutter)); }
  .loading .label { white-space: normal; text-align: center; }
}
