/* Outbox (docs/outbox.md): Limen's look, from src/styles/tokens.css (copied here: the app is served by its own Worker,
   not the site). The line means what it means on the site: above it is waiting, on it is the bench, below it has
   crossed over (posted), and the accent is only for what has crossed. */

@font-face {
  font-family: 'Bricolage Grotesque Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(/fonts/bricolage.woff2) format('woff2-variations');
}
@font-face { font-family: 'DM Mono'; font-weight: 400; font-display: swap; src: url(/fonts/dm-mono-400.woff2) format('woff2'); }
@font-face { font-family: 'DM Mono'; font-weight: 500; font-display: swap; src: url(/fonts/dm-mono-500.woff2) format('woff2'); }

:root {
  --chalk: #f4f4f1;
  --char: #160b06;
  --accent: #ff4a1c;
  --pencil: #5a4e47;
  --smoke: #8c837d;
  --rule: #cfcbc3;
  --paper: #ffffff;
  --night-text: #b3a9a2;
  --font-display: 'Bricolage Grotesque Variable', 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --t-title: 44px;
  --t-sheet: 28px;
  --t-post: 20px;
  --t-body: 16px;
  --t-small: 15px;
  --t-label: 11px;
  --track-label: 0.06em;
  --track-display: -0.045em;
  --line: 2px solid var(--char);
  --hair: 1px solid var(--rule);
  --r-pill: 999px;
  --r-card: 24px;
  --r-figure: 16px;
  --control: 48px;
  --gutter: 20px;
  --ease-out: cubic-bezier(0.2, 0.7, 0.1, 1);
  --dur-leave: 260ms;
  --dur-rise: 420ms;
  --dur-sheet: 320ms;
  --on-accent: #160b06; /* text on the accent is always char, in both themes */
  color-scheme: light;
}

/* dark: the page turns char and the ink turns chalk, so ink buttons, lines and the toast swap with it. Follows the
   device unless Settings says light or dark (data-theme, from public/theme.js). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --chalk: #160b06;
    --char: #f4f4f1;
    --paper: #21150f;
    --rule: #3a2c24;
    --pencil: #b3a9a2;
    --smoke: #7d716a;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --chalk: #160b06;
  --char: #f4f4f1;
  --paper: #21150f;
  --rule: #3a2c24;
  --pencil: #b3a9a2;
  --smoke: #7d716a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--chalk);
  color: var(--char);
  font-family: var(--font-display);
  font-size: var(--t-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
#app { max-width: 520px; margin: 0 auto; min-height: 100svh; display: flex; flex-direction: column; }
button, textarea, input { font: inherit; color: inherit; }
a { color: var(--char); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.mono { font-family: var(--font-mono); font-size: var(--t-label); letter-spacing: var(--track-label); text-transform: uppercase; }
.quiet { color: var(--pencil); }
.boot { padding: var(--gutter); }
[hidden] { display: none !important; }

/* buttons: one ink pill per screen; the rest outline or text */
.pill {
  height: var(--control);
  padding: 0 20px;
  border-radius: var(--r-pill);
  border: 2px solid var(--char);
  background: transparent;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.pill.ink { background: var(--char); color: var(--chalk); }
.pill.text { border-color: transparent; padding: 0 12px; }
.pill.wide { width: 100%; }
.pill:disabled { opacity: 0.4; cursor: default; }
.link {
  all: unset;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* the top line of every screen */
.top { padding: 18px var(--gutter) 6px; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; }
.top a, .top .link { text-decoration: none; }
h1.title { margin: 0; font-size: var(--t-title); font-weight: 800; letter-spacing: var(--track-display); line-height: 1; }

/* home: the line */
.band { padding: 8px var(--gutter) 14px; }
.band h2 { margin: 0 0 4px; font-weight: 500; }
.row {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 11px 0;
  border-bottom: var(--hair);
  min-height: 44px;
}
.row:last-of-type { border-bottom: 0; }
.row .when { width: 76px; flex: none; }
.row p { margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
button.row { all: unset; display: flex; gap: 12px; align-items: baseline; padding: 11px 0; border-bottom: var(--hair); width: 100%; cursor: pointer; min-height: 44px; box-sizing: border-box; }
.horizon { position: relative; height: 2px; background: var(--char); margin: 18px 0 6px; }
.horizon::before { content: ''; position: absolute; left: var(--gutter); top: -5px; width: 12px; height: 12px; border-radius: 50%; background: var(--char); }
.horizon span { position: absolute; right: var(--gutter); top: -20px; }
.crossed { margin-top: auto; background: var(--accent); color: var(--on-accent); padding: 16px var(--gutter) 28px; border-top: 2px solid var(--on-accent); }
.crossed .row { border-color: rgba(22, 11, 6, 0.25); }
.crossed .quiet, .crossed a { color: var(--on-accent); }
.crossed :focus-visible { outline-color: var(--on-accent); }
.empty { padding: 8px 0 4px; color: var(--pencil); }

/* going through: the stack */
.progress { display: grid; gap: 4px; padding: 0 var(--gutter); }
.progress span { height: 2px; background: var(--rule); }
.progress span.done { background: var(--char); }
.progress span.now { height: 4px; margin-top: -1px; background: var(--char); }
.stage { flex: 1; padding: 18px var(--gutter) 0; }
.deck { position: relative; padding-top: 12px; }
.peek { position: absolute; left: 12px; right: 12px; top: 0; height: calc(100% - 12px); border: 2px solid var(--rule); border-radius: var(--r-card); background: var(--paper); }
.card {
  position: relative;
  border: var(--line);
  border-radius: var(--r-card);
  background: var(--paper);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  touch-action: pan-y;
  will-change: transform;
}
.card.rise { animation: rise var(--dur-rise) var(--ease-out) both; }
.card.leave-right { transition: transform var(--dur-leave) ease-in, opacity var(--dur-leave) ease-in; transform: translateX(120%) rotate(6deg); opacity: 0; }
.card.leave-left { transition: transform var(--dur-leave) ease-in, opacity var(--dur-leave) ease-in; transform: translateX(-120%) rotate(-6deg); opacity: 0; }
.card.leave-up { transition: transform var(--dur-leave) ease-in, opacity var(--dur-leave) ease-in; transform: translateY(-40%); opacity: 0; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.tag { padding: 5px 9px; border: 1px solid var(--char); border-radius: var(--r-pill); }
.words {
  width: 100%;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  font-size: var(--t-post);
  line-height: 1.45;
  resize: none;
  overflow: hidden;
}
.words:focus-visible { outline: none; box-shadow: 0 2px 0 var(--char); }
.part { display: flex; gap: 10px; }
.part .mono { padding-top: 7px; flex: none; }
.count { display: block; text-align: right; margin-top: 4px; }
.count.over { color: var(--accent); font-weight: 500; }
.clip {
  margin: 0;
  border-radius: var(--r-figure);
  overflow: hidden;
  background: #1d2433;
  height: 170px;
  position: relative;
  color: #f4f4f1; /* the clip is always night, in both themes */
}
.clip::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 46px; background: #2b3448; }
.clip svg { position: absolute; left: 50%; bottom: 30px; z-index: 1; image-rendering: pixelated; }
.clip figcaption { position: absolute; left: 12px; top: 10px; z-index: 1; }
.clip img, .clip video { width: 100%; height: 100%; object-fit: cover; position: relative; z-index: 2; }
.why { border-top: var(--hair); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; font-size: var(--t-small); color: var(--pencil); }
.ask { border: 1px solid var(--char); border-radius: var(--r-figure); padding: 10px 12px; font-size: var(--t-small); }
.actions { position: sticky; bottom: 0; background: var(--chalk); border-top: var(--hair); margin-top: 16px; padding: 14px var(--gutter) calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.alt { margin: -4px 0 0; font-size: var(--t-small); color: var(--pencil); }
.actions .buttons { display: flex; gap: 10px; align-items: center; }
.actions .buttons .grow { flex: 1; }
.hint { text-align: center; }

/* what came back from the desk */
.back { padding-top: 4px; display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.back p { margin: 0; color: var(--pencil); font-size: var(--t-small); }
del { color: var(--smoke); text-decoration-thickness: 1px; }
ins { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.diff { margin: 0; font-size: var(--t-post); line-height: 1.45; }

/* the Changes sheet */
.scrim { position: fixed; inset: 0; background: rgba(22, 11, 6, 0.35); animation: fade var(--dur-sheet) ease-out both; }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 520px;
  margin: 0 auto;
  background: var(--chalk);
  border-top: var(--line);
  border-radius: var(--r-card) var(--r-card) 0 0;
  padding: 14px var(--gutter) calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: up var(--dur-sheet) var(--ease-out) both;
  max-height: 92svh;
  overflow: auto;
}
.sheet .grab { align-self: center; width: 40px; height: 4px; border-radius: 4px; background: var(--rule); }
.sheet h2 { margin: 0; font-size: var(--t-sheet); font-weight: 800; letter-spacing: -0.03em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 44px; padding: 0 16px; border-radius: var(--r-pill); border: 1px solid var(--rule); background: var(--paper); cursor: pointer; font-weight: 500; }
.chip[aria-pressed='true'] { border: 2px solid var(--char); background: var(--char); color: var(--chalk); }
.field { display: flex; flex-direction: column; gap: 8px; }
.field textarea { font-size: 18px; line-height: 1.45; padding: 14px; border: var(--line); border-radius: var(--r-figure); background: var(--paper); resize: vertical; min-height: 110px; }
.sheet .say { font-size: var(--t-small); color: var(--pencil); margin: 0; }
.sheet .buttons { display: flex; gap: 10px; justify-content: flex-end; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* replies */
.head { padding: 6px var(--gutter) 14px; border-bottom: var(--line); display: flex; flex-direction: column; gap: 6px; }
.head h1 { margin: 0; font-size: 32px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.head p { margin: 0; color: var(--pencil); font-size: var(--t-small); }
.q { padding: 18px var(--gutter); border-bottom: var(--hair); display: flex; flex-direction: column; gap: 10px; }
.q p { margin: 0; font-size: 17px; }
.q textarea { font-size: var(--t-body); line-height: 1.45; padding: 12px; border: 1px solid var(--char); border-radius: 14px; background: var(--paper); resize: vertical; min-height: 84px; }
.q .buttons { display: flex; gap: 8px; justify-content: flex-end; }

/* the door: setting up, signing in */
.gate { display: flex; flex-direction: column; gap: 16px; padding-top: 18vh; }
.gate p { margin: 0; font-size: 18px; max-width: 34ch; }
.gate-form { display: flex; flex-direction: column; gap: 14px; }
.gate-form input { height: var(--control); padding: 0 14px; border: var(--line); border-radius: var(--r-figure); background: var(--paper); font-size: 18px; }
.gate .pill { align-self: flex-start; }

/* settings */
.settings { padding: 8px var(--gutter) 28px; display: flex; flex-direction: column; gap: 22px; }
.settings section { display: flex; flex-direction: column; gap: 8px; }
.settings h2 { margin: 0; padding-bottom: 8px; border-bottom: var(--line); font-weight: 500; }

/* the one line at the bottom for what went wrong */
.toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 496px;
  margin: 0 auto;
  background: var(--char);
  color: var(--chalk);
  border-radius: 16px;
  padding: 14px 16px;
  font-size: var(--t-small);
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}
.toast button { all: unset; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; min-height: 44px; display: inline-flex; align-items: center; }

/* keys: only where there's likely a keyboard */
kbd { display: none; font-family: var(--font-mono); font-size: var(--t-label); font-weight: 400; border: 1px solid currentColor; border-radius: 5px; padding: 1px 5px; margin-left: 6px; opacity: 0.7; }
.home-link { text-decoration: none; color: inherit; }

/* wide screens (desktop A, 22 Oct): the week as a rail on the left, the draft open on the right */
@media (min-width: 1024px) {
  @media (hover: hover) { kbd { display: inline; } }
  #app.split { max-width: none; margin: 0; display: grid; grid-template-columns: 400px minmax(0, 1fr); align-items: start; }
  .rail { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; border-right: var(--line); }
  .rail .top { padding: 26px 28px 6px; }
  .rail .band { padding: 8px 28px 14px; }
  .rail .horizon::before { left: 28px; }
  .rail .horizon span { right: 28px; }
  .rail .crossed { padding: 16px 28px 22px; }
  .rail .row.sel { position: relative; font-weight: 600; }
  .rail .row.sel::before { content: ''; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 4px; border-radius: 2px; background: var(--char); }
  .main { min-width: 0; min-height: 100vh; display: flex; flex-direction: column; overflow-x: clip; }
  .main .top a[href='#/'] { visibility: hidden; }
  .main .top, .main .head, .main .q, .main .settings { padding-left: 40px; padding-right: 40px; }
  .main .q, .main .settings { max-width: 820px; }
  .main .stage { padding: 26px 40px 0; }
  .bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 20px 40px; border-bottom: var(--hair); }
  .desk { flex: 1; padding: 26px 40px 28px; display: grid; grid-template-columns: minmax(0, 680px) minmax(200px, 280px); gap: 40px; align-items: start; }
  .desk .deck { padding-top: 0; }
  .desk .card { padding: 24px; }
  .desk .words, .desk .diff { font-size: 22px; }
  .margin { display: flex; flex-direction: column; gap: 18px; font-size: var(--t-small); padding-top: 2px; }
  .margin > div { border-top: var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
  .margin > .ask { border: 1px solid var(--char); border-radius: var(--r-figure); padding: 10px 12px; }
  .main .actions { margin-top: 0; padding: 16px 40px 20px; }
  .main .pill { height: 44px; }
  /* sheets come in from the right, beside what they're about */
  .scrim { background: rgba(22, 11, 6, 0.25); }
  .sheet { left: auto; right: 0; top: 0; bottom: 0; width: 460px; max-width: none; max-height: none; margin: 0; border-top: 0; border-left: var(--line); border-radius: 0; padding: 28px; animation-name: in-right; }
  .sheet .grab { display: none; }
  .sheet .buttons { margin-top: auto; }
  .toast { left: auto; right: 24px; bottom: 24px; margin: 0; max-width: 420px; }
}
/* a laptop-sized window: a narrower rail, and the desk's notes go under the draft instead of beside it */
@media (min-width: 1024px) and (max-width: 1279px) {
  #app.split { grid-template-columns: 340px minmax(0, 1fr); }
  .desk { grid-template-columns: minmax(0, 680px); gap: 24px; }
}
@keyframes in-right { from { transform: translateX(100%); } to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .card.rise, .sheet, .scrim { animation: fade 1ms both; }
  .card.leave-right, .card.leave-left, .card.leave-up { transform: none; transition: opacity 120ms linear; }
}
