/* No Forwarding Address: daily case site.
   Lake-at-night interface around clean paper records. Stamp red is the only
   loud color; streetlight amber is reserved for money. */

:root {
  --lake: #17222e;
  --lake-2: #1f2d3b;
  --lake-3: #2a3b4c;
  --line: #3a4d60;
  --fog: #a7b4c0;
  --snow: #e9edf1;
  --paper: #ede8dd;
  --paper-edge: #d6cfbf;
  --ink: #24282c;
  --ink-soft: #5b6066;
  --stamp: #a8282b;
  --stamp-dark: #861d20;
  --lamp: #e3a64a;

  --ui: "Zilla Slab", Rockwell, "Roboto Slab", Georgia, serif;
  --typed: "Courier Prime", "Courier New", Courier, monospace;
  --radius-sheet: 2px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--lake);
  color: var(--snow);
  font-family: var(--ui);
  font-size: 18px;
  line-height: 1.5;
}
img { max-width: 100%; height: auto; display: block; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--lamp); outline-offset: 2px; }

.skip { position: absolute; left: -999px; top: 0; background: var(--snow); color: var(--lake); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

/* ---------- hero ---------- */

.hero {
  background:
    linear-gradient(90deg, rgba(23, 34, 46, 0.97) 0%, rgba(23, 34, 46, 0.86) 42%, rgba(23, 34, 46, 0.25) 100%),
    url("/img/keyart.jpg") center 40% / cover no-repeat;
  border-bottom: 1px solid var(--line);
}
.hero-inner { max-width: 1180px; margin: 0 auto; padding: 28px 24px 30px; }
.logo { width: min(360px, 78vw); margin: 0 0 18px -6px; }
.case-head { max-width: 34em; }
.case-date { margin: 0; color: var(--fog); font-size: 1rem; }
.hero h1 { font-size: clamp(2rem, 4.2vw, 2.9rem); line-height: 1.08; margin: 2px 0 10px; font-weight: 700; letter-spacing: -0.01em; }
.brief { margin: 0 0 6px; font-size: 1.15rem; }
.client { margin: 0; color: var(--fog); }
.hero-links { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 18px; }

.link {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--snow); text-decoration: underline; text-decoration-color: var(--fog);
  text-underline-offset: 4px; font-size: 1rem;
}
.link:hover { text-decoration-color: var(--snow); }

/* ---------- desk layout ---------- */

.desk {
  max-width: 1180px; margin: 0 auto; padding: 32px 24px 56px;
  display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 36px; align-items: start;
}
.docs { position: relative; outline: none; }
.sheets { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; }

/* ---------- paper ---------- */

.sheet {
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius-sheet);
  border: 1px solid var(--paper-edge);
  box-shadow: 0 1px 0 rgba(0,0,0,0.25), 0 14px 28px -18px rgba(0,0,0,0.7);
  padding: 22px 26px 24px;
  font-family: var(--typed);
  font-size: 1rem;
  line-height: 1.6;
  scroll-margin-top: 80px;
}
.sheet.is-new { animation: slip 260ms ease-out; }
@keyframes slip { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet-meta {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-family: var(--ui); color: var(--ink-soft); font-size: 0.95rem;
  border-bottom: 1px dashed #bdb5a4; padding-bottom: 8px; margin-bottom: 12px;
}
.sheet h2 { font-family: var(--typed); font-weight: 700; font-size: 1.1rem; margin: 0 0 10px; }
.sheet .body { white-space: pre-line; margin: 0; }
.sheet.start { border-left: 6px solid var(--stamp); }

.ent {
  font: inherit; color: inherit; background: none; border: 0; padding: 0 1px; cursor: pointer;
  text-decoration: underline; text-decoration-style: dotted; text-decoration-color: var(--stamp);
  text-decoration-thickness: 2px; text-underline-offset: 3px;
}
.ent:hover, .ent[aria-expanded="true"] { background: rgba(168, 40, 43, 0.1); }
.ent.plain { cursor: default; text-decoration: none; }
.ent.plain:hover { background: none; }
.ent.done { text-decoration-style: solid; text-decoration-color: #9a958a; }

.photo {
  margin: 14px 0 0; background: #f7f5f0; padding: 10px 10px 14px; max-width: 420px;
  border: 1px solid var(--paper-edge); transform: rotate(-0.6deg);
  box-shadow: 0 6px 14px -10px rgba(0,0,0,0.5);
}
.photo-frame {
  background: linear-gradient(160deg, #2b3a49, #1b2632); color: #cfd8e0;
  font-family: var(--ui); font-style: italic; font-size: 0.98rem; line-height: 1.45;
  padding: 26px 20px; min-height: 120px; display: flex; align-items: center;
}
.photo figcaption { font-family: var(--ui); color: var(--ink-soft); font-size: 0.85rem; margin-top: 6px; }

/* ---------- search menu ---------- */

.menu {
  position: absolute; z-index: 40; min-width: 240px;
  background: var(--snow); color: var(--ink); border-radius: 4px;
  box-shadow: 0 16px 40px -12px rgba(0,0,0,0.6); padding: 6px; font-family: var(--ui);
}
.menu-title { font-weight: 700; padding: 6px 10px 4px; font-size: 0.95rem; }
.menu button {
  display: flex; justify-content: space-between; gap: 18px; width: 100%;
  background: none; border: 0; padding: 8px 10px; text-align: left; cursor: pointer; border-radius: 3px; font-size: 1rem;
}
.menu button:hover:not(:disabled), .menu button:focus-visible { background: #dde3e8; }
.menu button:disabled { color: #8b9198; cursor: not-allowed; }
.menu .cost { color: #8a5a12; font-weight: 700; }
.menu .note { padding: 6px 10px 8px; color: var(--ink-soft); font-size: 0.92rem; max-width: 280px; }

/* ---------- ledger ---------- */

.ledger {
  position: sticky; top: 20px;
  background: var(--lake-2); border: 1px solid var(--line); border-radius: 4px; padding: 20px 22px 24px;
}
.ledger h2 { margin: 0 0 8px; font-size: 1.35rem; }
.ledger h3 { margin: 22px 0 4px; font-size: 1.12rem; }
.budget-left { margin: 0; font-size: 1rem; color: var(--fog); }
.budget-left span { font-size: 2.6rem; font-weight: 700; color: var(--lamp); line-height: 1; margin-right: 4px; font-variant-numeric: tabular-nums; }
.budget-of { margin: 2px 0 10px; color: var(--fog); font-size: 0.95rem; }
.meter { height: 6px; background: var(--lake-3); border-radius: 3px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 100%; background: var(--lamp); transition: width 300ms ease; }

.receipt { list-style: none; margin: 14px 0 0; padding: 0; font-size: 0.98rem; }
.receipt li { display: flex; gap: 6px; align-items: baseline; padding: 3px 0; }
.receipt li .what { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.receipt li .dots { flex: 1 1 auto; border-bottom: 1px dotted var(--line); transform: translateY(-4px); min-width: 12px; }
.receipt li .amt { font-variant-numeric: tabular-nums; color: var(--lamp); }
.receipt li.nothing { color: var(--fog); font-style: italic; display: block; }

.hint { color: var(--fog); font-size: 0.95rem; margin: 0 0 10px; }
fieldset { border: 0; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; }
.addr { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 3px; cursor: pointer; font-size: 1rem; line-height: 1.35; }
.addr:hover { border-color: var(--fog); }
.addr input { accent-color: var(--stamp); margin-top: 3px; }
.addr:has(input:checked) { border-color: var(--stamp); background: rgba(168, 40, 43, 0.14); }

.close-btn {
  display: inline-block; background: var(--stamp); color: #fff; border: 0; border-radius: 3px;
  padding: 11px 18px; font-weight: 700; font-size: 1.05rem; cursor: pointer;
}
.close-btn:hover:not(:disabled) { background: var(--stamp-dark); }
.close-btn:disabled { background: var(--lake-3); color: var(--fog); cursor: not-allowed; }
.confirm { border-top: 1px solid var(--line); padding-top: 12px; }
.confirm-actions { display: flex; gap: 18px; align-items: center; }

/* ---------- result ---------- */

.result { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 6px; }
.result h3 { font-size: 1.5rem; margin: 6px 0 6px; }
.result .line { margin: 0 0 6px; }
.result .squares { font-size: 1.3rem; letter-spacing: 2px; margin: 8px 0; }
.result ul { padding-left: 1.1em; margin: 6px 0 14px; }
.result .next { color: var(--fog); margin: 14px 0 0; }
.copied { color: var(--lamp); margin-left: 10px; }

/* ---------- the stamp ---------- */

.stamp {
  position: absolute; z-index: 5; top: 58px; right: 18px; pointer-events: none;
  font-family: var(--typed); font-weight: 700; font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: 0.04em;
  color: var(--stamp); border: 5px double var(--stamp); padding: 4px 16px; border-radius: 4px;
  transform: rotate(-8deg); opacity: 0.88; mix-blend-mode: multiply; background: rgba(237, 232, 221, 0.15);
}
.stamp.miss { color: #6d3b8a; border-color: #6d3b8a; }
.stamp.land { animation: thump 420ms cubic-bezier(.2,.9,.3,1.2); }
@keyframes thump {
  0% { transform: rotate(-14deg) scale(1.9); opacity: 0; }
  60% { transform: rotate(-7deg) scale(0.96); opacity: 0.95; }
  100% { transform: rotate(-8deg) scale(1); opacity: 0.88; }
}

/* ---------- dialogs ---------- */

dialog {
  max-width: 560px; width: calc(100% - 32px); border: 1px solid var(--line); border-radius: 6px;
  background: var(--lake-2); color: var(--snow); padding: 24px 26px;
}
dialog::backdrop { background: rgba(8, 12, 17, 0.72); }
dialog h2 { margin: 0 0 10px; }
.steps { padding-left: 1.2em; margin: 0 0 18px; }
.steps li { margin-bottom: 8px; }
.town { border-top: 1px solid var(--line); padding: 12px 0; }
.town h3 { margin: 0 0 4px; font-size: 1.15rem; }
.town p { margin: 0 0 6px; color: var(--fog); font-size: 0.98rem; }
.town ul { margin: 0; padding-left: 1.1em; font-size: 0.98rem; }
.statgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0 12px; text-align: center; }
.statgrid strong { display: block; font-size: 1.8rem; color: var(--lamp); }
.statgrid span { color: var(--fog); font-size: 0.9rem; }

/* ---------- empty / footer ---------- */

.empty { max-width: 640px; margin: 60px auto; padding: 0 24px; }
.empty h1 { margin: 0 0 8px; }
.foot { max-width: 1180px; margin: 0 auto; padding: 22px 24px 40px; color: var(--fog); font-size: 0.92rem; border-top: 1px solid var(--line); }
.foot p { margin: 0 0 4px; }

/* ---------- phones ---------- */

.budgetbar { display: none; }

@media (max-width: 860px) {
  body { font-size: 17px; }
  .desk { grid-template-columns: 1fr; gap: 24px; padding: 20px 16px 48px; }
  .ledger { position: static; order: 2; }
  .docs { order: 1; }
  .hero-inner { padding: 20px 16px 22px; }
  .hero {
    background:
      linear-gradient(180deg, rgba(23, 34, 46, 0.55) 0%, rgba(23, 34, 46, 0.9) 45%, rgba(23, 34, 46, 0.97) 100%),
      url("/img/keyart.jpg") 70% 30% / cover no-repeat;
  }
  .sheet { padding: 18px 16px 20px; font-size: 0.97rem; }
  .budgetbar:not([hidden]) {
    display: flex; justify-content: space-between; align-items: center;
    position: sticky; top: 0; z-index: 30; padding: 10px 16px;
    background: var(--lake-2); border-bottom: 1px solid var(--line);
  }
  .budgetbar strong { color: var(--lamp); font-size: 1.2rem; }
  .budgetbar a { color: var(--snow); }
  .stamp { top: 14px; right: 8px; }
  .statgrid { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .sheet.is-new, .stamp.land { animation: none; }
  .meter span { transition: none; }
}
