/* Pendel
   Read at 7am on a phone, often in motion, sometimes with no signal.
   Dark ground, one amber signal colour borrowed from platform indicators,
   and a single live element: the bar that shows an episode burning down
   to its deletion. Everything else stays quiet. */

:root {
  --ink:     #0C1116;
  --panel:   #151C23;
  --raised:  #1C242C;
  --line:    #26313A;
  --text:    #E4EBF0;
  --dim:     #7E8E9A;
  --signal:  #FFB33D;
  --expiry:  #E86A5C;
  --ok:      #6FD08C;

  --step-0: 0.9375rem;
  --step-1: 1.0625rem;
  --step-2: 1.5rem;
  --step-3: 2.25rem;

  --sans: ui-sans-serif, system-ui, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;

  --gap: 1.125rem;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* Author `display` rules below outrank the user-agent [hidden] rule, which
   would otherwise leave the sign-in screen, the scrubber and the pause icon
   all visible at once. Keep this above everything that sets display. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

main, .gate-card {
  max-width: 34rem;
  margin: 0 auto;
  padding: 1.25rem 1.125rem 3rem;
}

h1, h2, p, ul { margin: 0; }
ul { list-style: none; padding: 0; }

.wordmark {
  font-size: var(--step-2);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1;
}

/* --- Sign in ------------------------------------------------------------ */

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
}

.gate-card { width: 100%; display: grid; gap: var(--gap); }

.gate-line {
  color: var(--dim);
  margin-top: -0.5rem;
  max-width: 26rem;
}

/* --- App bar ------------------------------------------------------------ */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1.5rem;
}

/* --- Compose ------------------------------------------------------------ */

.compose { display: grid; gap: var(--gap); }

.drop {
  display: grid;
  gap: 0.3rem;
  padding: 2rem 1.25rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: center;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.drop:hover, .drop:focus-within { border-color: var(--signal); }
.drop.dragover { border-color: var(--signal); background: var(--raised); }
.drop.loaded { border-style: solid; border-color: var(--ok); }

.drop-title { font-size: var(--step-1); font-weight: 550; }
.drop-note { color: var(--dim); font-size: 0.8125rem; }

.controls { display: grid; gap: var(--gap); }

.field { display: grid; gap: 0.4rem; }
.field > span { color: var(--dim); font-size: 0.8125rem; }

select, input[type="password"] {
  appearance: none;
  width: 100%;
  padding: 0.7rem 0.85rem;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
}

select:disabled { color: var(--dim); }

input[type="range"] {
  appearance: none;
  width: 100%;
  height: 2rem;
  background: transparent;
  margin: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px; background: var(--line); border-radius: 2px;
}
input[type="range"]::-moz-range-track {
  height: 3px; background: var(--line); border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 20px; height: 20px; margin-top: -8.5px;
  border-radius: 50%; background: var(--signal); border: none;
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%; background: var(--signal); border: none;
}

/* --- Buttons ------------------------------------------------------------ */

button { font: inherit; cursor: pointer; }

.primary {
  padding: 0.8rem 1rem;
  background: var(--signal);
  color: #12181D;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
}

.primary:disabled { background: var(--line); color: var(--dim); cursor: not-allowed; }

.ghost {
  padding: 0.35rem 0.6rem;
  background: none;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 0.8125rem;
}

.ghost:hover { color: var(--text); border-color: var(--dim); }
.ghost.danger:hover { color: var(--expiry); border-color: var(--expiry); }

:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

/* --- Episodes ----------------------------------------------------------- */

.episodes { margin-top: 2.5rem; display: grid; gap: 0.875rem; }

.section-head {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--dim);
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--line);
}

.empty { color: var(--dim); max-width: 28rem; }

.list { display: grid; gap: 0.875rem; }

.episode {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.875rem;
  display: grid;
  gap: 0.75rem;
}

.episode-head { display: flex; gap: 0.75rem; align-items: center; }

.play {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--raised);
  display: grid; place-items: center;
  padding: 0;
}

.play svg { width: 22px; height: 22px; fill: var(--signal); }
.play:disabled { opacity: 0.4; cursor: not-allowed; }
.play:disabled svg { fill: var(--dim); }

.episode-meta { min-width: 0; }
.episode-title { font-weight: 550; line-height: 1.3; }
.episode-sub { color: var(--dim); font-size: 0.8125rem; }

.episode-status { color: var(--signal); font-size: 0.875rem; margin-bottom: 0.15rem; }
.episode-status:empty { display: none; }
.episode-status.failed { color: var(--expiry); }

.scrub { display: flex; align-items: center; gap: 0.6rem; }
.scrub .seek { flex: 1; }
.elapsed { color: var(--dim); font-size: 0.8125rem; flex: 0 0 auto; }

/* The signature element: how much life this episode has left.
   Live data, updated every second, and the only thing that moves. */
.life {
  height: 2px;
  background: var(--line);
  border-radius: 1px;
  overflow: hidden;
}

.life-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--signal);
  transform-origin: left;
  transition: width 1s linear, background-color 600ms ease;
}

.life-fill.late { background: var(--expiry); }

.episode-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* Sits immediately under the bar it describes, so the two read as one thing. */
.countdown {
  margin-top: -0.45rem;
  color: var(--dim);
  font-size: 0.8125rem;
}

.countdown.late { color: var(--expiry); }
.save.saved { color: var(--ok); border-color: var(--ok); }

.summary {
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
  color: var(--text);
  font-size: 0.9375rem;
  white-space: pre-wrap;
}

/* --- Footer ------------------------------------------------------------- */

.foot {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.75rem;
  justify-items: start;
  color: var(--dim);
  font-size: 0.8125rem;
}

.audit {
  width: 100%;
  max-height: 16rem;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem;
  font-size: 0.75rem;
  line-height: 1.7;
  white-space: pre;
  color: var(--dim);
}

.error { color: var(--expiry); font-size: 0.875rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
