/* Tokens, theme (lamp off = dark noir, lamp on = warm), paper textures, shared bits. */

:root {
  --font-type: 'Special Elite', 'Courier New', monospace;
  --font-body: 'Courier Prime', 'Courier New', monospace;
  --font-hand: 'Caveat', 'Segoe Print', cursive;
  --font-deco: 'Limelight', Georgia, serif;
  --font-old: 'IM Fell English', Georgia, serif;
  --font-sign: 'Pinyon Script', 'Segoe Script', cursive;

  --ink: #1d1914;
  --ink-soft: #3d362c;
  --ink-blue: #1f2f55;
  --ink-red: #8e1f1a;
  --stamp-red: #a3241c;
  --stamp-blue: #2a3f78;
  --graphite: #2f2d2a;
  --brass: #b48f3e;
  --brass-hi: #ecd189;
  --brass-lo: #6d5320;
  --steel: #3a4146;

  --paper: #d2c8b0;
  --paper-2: #c6baa0;
  --paper-line: rgba(70, 92, 120, 0.28);
  --paper-margin: rgba(150, 40, 30, 0.45);
  --manila: #b39461;
  --manila-2: #a1834f;
  --manila-edge: #6e5426;
  --label: #ddd3bd;

  --wall: #0d1013;
  --wall-2: #161a1f;
  --night: #0b1520;
  --desk: #1c120c;
  --desk-2: #2b1b11;

  --lamp-glow: 0;
  --scene-bright: 0.82;
  --ui-shadow: 0 18px 40px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.5);

  --tex-noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .32 0 0 0 0 .24 0 0 0 0 .13 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.12'/%3E%3C/svg%3E");
  --tex-fibre: none;
  --tex-grain-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");

  color-scheme: dark;
}

html[data-theme='light'] {
  --paper: #efe8d6;
  --paper-2: #e3dac3;
  --manila: #d8bb80;
  --manila-2: #c8aa6c;
  --manila-edge: #8a6930;
  --label: #f3ecda;
  --lamp-glow: 1;
  --scene-bright: 1;
  --wall: #1a1612;
  --wall-2: #261f18;
  --desk: #2d1c10;
  --desk-2: #432a17;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #07090b;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px dashed var(--ink-red); outline-offset: 3px; }

/* ---------- Paper ---------- */

.paper {
  position: relative;
  background-color: var(--paper);
  background-image:
    linear-gradient(170deg, rgba(255, 252, 242, 0.16), transparent 35%, transparent 70%, rgba(90, 65, 30, 0.08)),
    radial-gradient(130% 100% at 50% 40%, transparent 62%, rgba(95, 70, 35, 0.12)),
    var(--img-paper, none);
  background-size: auto, auto, 700px 700px;
  background-blend-mode: normal, normal, multiply;
  color: var(--ink);
  box-shadow: 0 0 0 0.5px rgba(70, 55, 35, 0.35), 0 1px 1.5px rgba(0, 0, 0, 0.28), 0 8px 18px rgba(0, 0, 0, 0.28);
}

/* Coffee ring, used sparingly. */
.stain::after {
  content: '';
  position: absolute;
  width: 150px; height: 150px;
  right: 6%; bottom: 8%;
  border-radius: 50%;
  border: 9px solid rgba(110, 70, 30, 0.12);
  box-shadow: inset 0 0 18px rgba(110, 70, 30, 0.12);
  transform: rotate(-12deg) scaleY(0.94);
  pointer-events: none;
  mix-blend-mode: multiply;
}

.ruled {
  background-image:
    linear-gradient(90deg, transparent 54px, var(--paper-margin) 54px, var(--paper-margin) 56px, transparent 56px),
    repeating-linear-gradient(180deg, transparent 0 31px, var(--paper-line) 31px 32px),
    var(--tex-noise);
}

/* ---------- Writing ---------- */

.typed { font-family: var(--font-type); letter-spacing: 0.02em; }
.hand {
  font-family: var(--font-hand);
  color: var(--graphite);
  font-size: 1.35em;
  line-height: 1.1;
}
.pencil { filter: url(#pencil); }
.sig { font-family: var(--font-sign); color: var(--ink-blue); }

.stamp {
  display: inline-block;
  font-family: var(--font-type);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--stamp-red);
  border: 3px double currentColor;
  padding: 0.2em 0.6em;
  transform: rotate(-6deg);
  opacity: 0.85;
  mix-blend-mode: multiply;
  filter: url(#ink-bleed);
}
.stamp.blue { color: var(--stamp-blue); }

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

.btn {
  --c: var(--ink);
  appearance: none;
  border: 2px solid var(--c);
  background: transparent;
  color: var(--c);
  font-family: var(--font-type);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.9rem;
  padding: 0.55em 1.1em;
  cursor: pointer;
  border-radius: 2px;
  transition: transform 0.12s ease, background-color 0.2s ease;
  mix-blend-mode: multiply;
}
.btn:hover { background: rgba(0, 0, 0, 0.06); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn.red { --c: var(--stamp-red); }
.btn.blue { --c: var(--stamp-blue); }
.btn.stampish { border-style: double; border-width: 4px; transform: rotate(-1.5deg); }
.btn.stampish:active { transform: rotate(-1.5deg) translateY(2px) scale(0.97); }
.btn.small { font-size: 0.75rem; padding: 0.35em 0.7em; }
.btn.link { border: 0; padding: 0.2em 0.1em; text-decoration: underline; text-underline-offset: 3px; }

.brass-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  background: radial-gradient(circle at 35% 30%, var(--brass-hi), var(--brass) 45%, var(--brass-lo) 100%);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6), inset 0 -2px 3px rgba(0, 0, 0, 0.35), inset 0 2px 2px rgba(255, 255, 255, 0.35);
  color: #2a1d08;
}

/* ---------- Form fields written in pencil ---------- */

.field { display: grid; gap: 2px; }
.field > span, .label {
  font-family: var(--font-type);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
}
.line-input, .line-select, .line-area {
  width: 100%;
  border: 0;
  border-bottom: 1.5px dotted rgba(40, 30, 20, 0.55);
  background: transparent;
  font-family: var(--font-hand);
  font-size: 1.5rem;
  color: var(--graphite);
  padding: 2px 4px 0;
  outline: none;
  border-radius: 0;
}
.line-area {
  border: 1.5px dotted rgba(40, 30, 20, 0.45);
  min-height: 5.5em;
  resize: vertical;
  line-height: 1.2;
  background: repeating-linear-gradient(180deg, transparent 0 1.75rem, var(--paper-line) 1.75rem calc(1.75rem + 1px));
}
.line-input:focus, .line-select:focus, .line-area:focus { border-color: var(--ink-blue); background-color: rgba(255, 255, 255, 0.12); }
.line-input::placeholder, .line-area::placeholder { color: rgba(50, 40, 30, 0.35); }
.line-select { appearance: none; cursor: pointer; padding-right: 22px;
  background-image: linear-gradient(45deg, transparent 50%, var(--graphite) 50%), linear-gradient(135deg, var(--graphite) 50%, transparent 50%);
  background-position: calc(100% - 12px) 60%, calc(100% - 7px) 60%;
  background-size: 5px 5px; background-repeat: no-repeat; }
.line-select option { font-family: var(--font-body); font-size: 1rem; color: #111; background: #efe6d0; }

/* ---------- Notes (toasts) ---------- */

#notes {
  position: fixed;
  z-index: 60;
  right: 84px;
  bottom: 18px;
  display: grid;
  gap: 10px;
  justify-items: end;
  pointer-events: none;
}
.note {
  pointer-events: auto;
  max-width: min(360px, 80vw);
  padding: 12px 16px 12px 18px;
  font-family: var(--font-hand);
  font-size: 1.35rem;
  line-height: 1.15;
  color: var(--graphite);
  background: #e9dfb8;
  background-image: var(--tex-noise);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.5);
  transform-origin: top center;
  animation: note-in 0.35s cubic-bezier(.2, .9, .3, 1.3) both;
  position: relative;
}
.note::before { /* tape */
  content: '';
  position: absolute;
  top: -9px; left: 50%;
  width: 64px; height: 18px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(235, 228, 200, 0.6);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.note.bad { color: var(--ink-red); }
.note.out { animation: note-out 0.3s ease-in both; }
@keyframes note-in { from { opacity: 0; transform: translateY(14px) rotate(4deg) scale(0.9); } to { opacity: 1; transform: rotate(-1deg); } }
@keyframes note-out { to { opacity: 0; transform: translateY(10px) rotate(3deg); } }

/* ---------- Corner controls ---------- */

#mute {
  position: fixed;
  z-index: 55;
  right: 18px;
  bottom: 18px;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
}
#mute svg { width: 26px; height: 26px; }
#mute .waves { transition: opacity 0.2s; }
#mute[aria-pressed='true'] .waves { opacity: 0; }
#mute[aria-pressed='true'] .cross { opacity: 1; }
#mute .cross { opacity: 0; transition: opacity 0.2s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Credits memo */
.credits ul { padding-left: 1.2em; }
.credits li { margin-bottom: 8px; line-height: 1.45; }
.credits a { color: var(--ink-blue); }
.safe-tag .safe-credits { margin-top: 6px; font-size: 0.66rem; opacity: 0.7; }
