/* ComeAndGo — mobile-first. Designed at 375px, scaled up.
   The product is a clock. Everything else stays quiet. */

:root {
  /* Warm neutrals — bark, soil, paper. A cold blue-grey would read as a
     dashboard; this product is about a natural cycle, so the whole surface
     is warm, not just the accent. */
  --bg: #12100c;
  --bg-soft: #1a1712;
  --panel: #1e1a15;
  --line: #302a22;
  --line-soft: #241f19;
  --fg: #f1ece3;
  --fg-dim: #a99f90;
  --fg-faint: #8a8173;

  /* The leaf cycle: เกิดขึ้น ตั้งอยู่ ดับไป.
     New growth, then gold, then fallen earth. Two properties matter:
     1. Luminance descends at every step, so the signal survives with hue
        removed entirely — the ~8% of men with red/green colour blindness
        still read it, because it is light fading rather than a hue swap.
     2. It ends in earth, not alarm. Ending is ordinary here, and a warning
        red would argue against the premise the product is built on. */
  --calm: #a1cc76;   /* new leaf   L 0.521 */
  --soon: #dfa23f;   /* turning    L 0.419 */
  --dusk: #c06a40;   /* fallen     L 0.219 */
  --accent: var(--calm);

  /* True red is reserved for destructive actions and errors, so that it still
     carries weight when it appears. The time ramp never uses it. */
  --danger: #e4695f;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fbf9f5;
    --bg-soft: #f2eee7;
    --panel: #ffffff;
    --line: #e7e1d6;
    --line-soft: #f0ebe3;
    --fg: #1c1814;
    --fg-dim: #6a6155;
    --fg-faint: #63594c;
    /* Same ramp, solved again: white button text needs darker values, and the
       descent has to hold inside a much narrower luminance range. */
    --calm: #607a46;   /* new leaf   L 0.168 */
    --soon: #7e5c23;   /* turning    L 0.122 */
    --dusk: #7c4429;   /* fallen     L 0.086 */
    --danger: #b4342c;
    --shadow: 0 1px 2px rgba(40, 32, 22, 0.06), 0 10px 28px rgba(40, 32, 22, 0.07);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

/* [hidden] hides via the UA stylesheet, which any author `display` beats.
   .stage sets display:flex, so without this every screen renders at once. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.55 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── layout ───────────────────────────────────────────────────────────── */

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 32px 20px;
  gap: 18px;
  text-align: center;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ── brand ────────────────────────────────────────────────────────────── */

.wordmark {
  font-size: 30px;
  font-weight: 680;
  letter-spacing: -0.028em;
  margin: 0;
}
.wordmark .go { color: var(--accent); }
.wordmark .and { color: var(--fg-faint); font-weight: 500; }

.lede {
  margin: 0;
  max-width: 30ch;
  color: var(--fg-dim);
  font-size: 15.5px;
}

/* ── card ─────────────────────────────────────────────────────────────── */

.card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.field { display: flex; flex-direction: column; gap: 7px; }

label, .label {
  font-size: 12.5px;
  font-weight: 560;
  color: var(--fg-dim);
}

/* ── duration pills ───────────────────────────────────────────────────── */

.pills { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; }
.pills input { position: absolute; opacity: 0; pointer-events: none; }

.pills label {
  flex: 0 0 auto;
  min-width: 0;
  text-align: center;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--fg-dim);
  font-size: 14px;
  font-weight: 560;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.pills label:hover { border-color: var(--fg-faint); }
.pills input:checked + label {
  border-color: var(--accent);
  color: var(--fg);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.pills input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── controls ─────────────────────────────────────────────────────────── */

input[type="text"], select {
  font: inherit;
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--fg);
  transition: border-color 0.15s;
}
input[type="text"]::placeholder { color: var(--fg-faint); }
input[type="text"]:focus, select:focus { outline: none; border-color: var(--accent); }

button, .btn {
  font: inherit;
  font-weight: 620;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }

.primary { background: var(--accent); color: #17130d; }
@media (prefers-color-scheme: light) { .primary { color: #fff; } }
.primary:hover:not(:disabled) { opacity: 0.9; }

.ghost {
  background: transparent; color: var(--fg-dim);
  border-color: var(--line); font-weight: 560;
}
.ghost:hover { border-color: var(--fg-faint); color: var(--fg); }

.danger { background: transparent; color: var(--danger); border-color: var(--line); font-weight: 560; }
.danger:hover { border-color: var(--danger); }

.linkish {
  background: none; border: none; padding: 6px;
  color: var(--fg-faint); font-size: 13px; text-decoration: underline;
  text-underline-offset: 3px; cursor: pointer;
}
.linkish:hover { color: var(--fg-dim); }

/* ── promise / notes ──────────────────────────────────────────────────── */

.promise {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--fg-faint);
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
}
.err { color: var(--danger); font-size: 13.5px; margin: 0; }
.note { font-size: 12.5px; color: var(--fg-faint); margin: 0; }

/* ── the timer: the hero of the product ───────────────────────────────── */

.timer { position: relative; width: 128px; height: 128px; flex: 0 0 auto; margin: 0 auto; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 5; }
.ring-track { stroke: var(--line); }
.ring-fill {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 0.6s ease;
}

.timer-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px;
}
.clock {
  font-size: 27px; font-weight: 660;
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
  color: var(--fg);
}
.timer-label {
  font-size: 9.5px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--fg-faint); max-width: 84px; line-height: 1.25;
}

/* Urgency ramp — set by room.js on <body>. */
body.soon   { --accent: var(--soon); }
body.urgent { --accent: var(--dusk); }
body.urgent .clock { animation: pulse 2s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ── room ─────────────────────────────────────────────────────────────── */

.bar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 0 12px; border-bottom: 1px solid var(--line-soft);
}
.bar .timer { width: 62px; height: 62px; margin: 0; }
.bar .clock { font-size: 15px; }
.bar .timer-label { display: none; }

.bar-meta { display: flex; flex-direction: column; gap: 1px; text-align: left; min-width: 0; }
.bar-brand { font-size: 14px; font-weight: 620; letter-spacing: -0.02em; }
.bar-sub { font-size: 12px; color: var(--fg-faint); }

.log:empty::after {
  content: "Nothing here yet. Share the invite link to bring someone in.";
  margin: auto;
  max-width: 26ch;
  text-align: center;
  color: var(--fg-faint);
  font-size: 13.5px;
}

.log {
  flex: 1; overflow-y: auto; padding: 16px 0;
  display: flex; flex-direction: column; gap: 11px; min-height: 0;
}

.line { display: flex; flex-direction: column; gap: 2px; max-width: 88%; }
.line .who { font-size: 12.5px; font-weight: 620; color: var(--fg-dim); }
.line .body { overflow-wrap: anywhere; white-space: pre-wrap; }
.line .ts { font-size: 10.5px; color: var(--fg-faint); font-variant-numeric: tabular-nums; }

.line .translate {
  align-self: flex-start; background: none; border: none; padding: 1px 0;
  font-size: 11.5px; color: var(--fg-faint); text-decoration: underline;
  text-underline-offset: 3px; cursor: pointer; opacity: 0; transition: opacity 0.15s;
}
.line:hover .translate, .line .translate:focus-visible { opacity: 1; }
@media (hover: none) { .line .translate { opacity: 1; } }

.line .translated {
  font-size: 14.5px; color: var(--fg-dim); font-style: italic;
  border-left: 2px solid var(--line); padding-left: 9px; margin-top: 3px;
}
.line.mine .translated { border-left: none; border-right: 2px solid var(--line);
  padding-left: 0; padding-right: 9px; }

.line.mine { align-self: flex-end; align-items: flex-end; text-align: right; }
.line.mine .who { color: var(--accent); }

.line.sys { align-self: center; max-width: 100%; align-items: center; }
.line.sys .body {
  font-size: 12.5px; color: var(--fg-faint);
  background: var(--bg-soft); padding: 4px 11px; border-radius: 999px;
}
.line.sys .who, .line.sys .ts { display: none; }

.composer {
  display: flex; gap: 8px; padding: 12px 0;
  border-top: 1px solid var(--line-soft); background: var(--bg);
}
.composer input { flex: 1; }
.composer button { flex: 0 0 auto; }

.actions { display: flex; gap: 7px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.actions button { flex: 1; font-size: 13px; padding: 9px 10px; }

/* ── parting summary ──────────────────────────────────────────────────── */

.summary {
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
  padding: 16px; margin: 4px 0 14px;
  text-align: left; width: 100%; max-width: 420px;
  animation: rise 0.45s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.summary h2 {
  font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 8px;
}
.summary p { margin: 0 0 12px; white-space: pre-wrap; font-size: 14.5px; }
.summary button { width: 100%; }
.summary .note { margin-top: 9px; }

/* ── destroyed ────────────────────────────────────────────────────────── */

.gone-mark { font-size: 44px; font-weight: 700; letter-spacing: -0.035em; margin: 0; }

/* Night, after dusk. Everything recedes except the one way forward. */
#dead .ring-track { stroke: var(--line-soft); }
#dead .clock { color: var(--fg-faint); font-size: 20px; }
#dead .lede { color: var(--fg-dim); }

.turnstile { min-height: 65px; display: flex; justify-content: center; }

@media (min-width: 640px) {
  .wordmark { font-size: 38px; }
  .lede { font-size: 16.5px; max-width: 34ch; }
  .gone-mark { font-size: 58px; }
}

/* ── long-form documents ──────────────────────────────────────────────── */

.doc { max-width: 660px; margin: 0 auto; padding: 40px 20px 72px; }
.doc h1 { font-size: 28px; letter-spacing: -0.025em; margin: 0 0 6px; }
.doc .updated { color: var(--fg-faint); font-size: 13px; margin: 0 0 28px; }
.doc h2 {
  font-size: 17px; margin: 32px 0 10px; letter-spacing: -0.01em;
  padding-top: 20px; border-top: 1px solid var(--line-soft);
}
.doc h2:first-of-type { border-top: none; padding-top: 0; }
.doc p, .doc li { color: var(--fg-dim); font-size: 15px; }
.doc li { margin-bottom: 6px; }
.doc strong { color: var(--fg); }
.doc table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 14px; }
.doc th, .doc td {
  text-align: left; padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft); color: var(--fg-dim); vertical-align: top;
}
.doc th { color: var(--fg); font-weight: 620; font-size: 13px; }
.doc a { color: var(--accent); }
.doc .callout {
  border: 1px solid var(--line); background: var(--bg-soft);
  border-radius: var(--radius-sm); padding: 14px 16px; margin: 18px 0;
}
.doc .callout p { margin: 0; font-size: 14px; }
.docnav { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 40px; padding-top: 20px;
  border-top: 1px solid var(--line-soft); font-size: 13px; }
.docnav a { color: var(--fg-faint); }

.footer {
  display: flex; gap: 14px; justify-content: center; flex-wrap: wrap;
  font-size: 12.5px; margin-top: 4px;
}
.footer a { color: var(--fg-faint); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
