/* The Remainder — kitchen-table interface */
@font-face {
  font-family: "Fraunces";
  src: url("fonts/Fraunces-Variable.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("fonts/Fraunces-Italic-Variable.ttf") format("truetype");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("fonts/Newsreader-Variable.ttf") format("truetype");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("fonts/Newsreader-Italic-Variable.ttf") format("truetype");
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("fonts/IBMPlexSans-Variable.ttf") format("truetype");
  font-weight: 100 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/IBMPlexMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/IBMPlexMono-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #1a1612;
  --ink-soft: #3b342c;
  --paper: #f3ead6;
  --paper-2: #e7d9b8;
  --rule: #c9b792;
  --biro: #6d2e2e;
  --harbour: #0f1a1c;
  --harbour-mid: #1c2e32;
  --gold: #c4a15a;
  --oak: #6a5136;
  --oak-light: #8a6a45;
  --notice: #243830;
  --focus: #d7c48a;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--harbour);
  color: var(--paper);
  font-family: "Newsreader", "Palatino Linotype", Palatino, "Times New Roman", serif;
  font-size: 20px;
  line-height: 1.45;
}
body {
  background:
    radial-gradient(1200px 700px at 50% -10%, #2a3e42 0%, transparent 60%),
    linear-gradient(180deg, #152226 0%, #0c1416 70%, #0a1012 100%);
}
button, input {
  font: inherit;
}
button {
  cursor: pointer;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.screen { min-height: 100vh; }
.hidden { display: none !important; }

/* Title */
#title-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 12vh 6vw 8vh;
  min-height: 100vh;
}
#title-screen .eyebrow {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 1.4rem;
}
#title-screen h1 {
  font-family: "Fraunces", "Palatino Linotype", serif;
  font-weight: 400;
  font-style: italic;
  font-size: clamp(4.2rem, 14vw, 8.5rem);
  line-height: 0.85;
  margin: 0;
  color: #f6efe0;
  letter-spacing: -0.03em;
}
#title-screen .sub {
  margin: 1.6rem 0 0;
  max-width: 26rem;
  font-size: 1.05rem;
  font-style: italic;
  color: #d7cdb6;
}
#title-screen .begin {
  margin-top: 3rem;
  background: transparent;
  color: var(--paper);
  border: 1px solid #b9a57a;
  padding: 0.7rem 1.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 0.72rem;
}
#title-screen .begin:hover { background: #f3ead6; color: var(--harbour); }
#title-screen .colophon-hint {
  margin-top: 4rem;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: #8d9a96;
  max-width: 22rem;
}

/* Table */
#table-screen { position: relative; }
.chrome {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1.2rem;
  background: linear-gradient(180deg, rgba(10,16,18,0.92), rgba(10,16,18,0.7) 70%, transparent);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c9d2cf;
}
.chrome h1 {
  font-family: "Fraunces", serif;
  font-style: italic;
  font-weight: 400;
  font-size: 1.15rem;
  letter-spacing: 0;
  text-transform: none;
  margin: 0;
  color: #f6efe0;
}
.chrome-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.chrome button, .text-btn {
  background: transparent;
  color: inherit;
  border: 1px solid #4a5c5a;
  padding: 0.35rem 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 0.68rem;
}
.chrome button[aria-pressed="true"], .chrome button:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.chrome button.ready {
  border-color: var(--gold);
  color: #111;
  background: var(--gold);
}

.intro-strip {
  max-width: 40rem;
  margin: 0 auto;
  padding: 0.5rem 1.2rem 1rem;
  font-style: italic;
  color: #d5ddd8;
  font-size: 1.02rem;
}

.table-wrap {
  position: relative;
  margin: 0 1rem 2rem;
  min-height: 78vh;
  border-radius: 4px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255,220,160,0.08), transparent 50%),
    repeating-linear-gradient(90deg, rgba(40,24,10,0.08) 0 2px, transparent 2px 7px),
    linear-gradient(180deg, #7a5a38 0%, #5c4229 40%, #4a351f 100%);
  box-shadow:
    inset 0 0 80px rgba(20,10,0,0.45),
    0 20px 60px rgba(0,0,0,0.45);
  overflow: hidden;
}
.table-surface {
  position: relative;
  width: 100%;
  min-height: 78vh;
  height: 78vh;
}

.item {
  position: absolute;
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
  width: min(190px, 28vw);
  background: var(--paper);
  color: var(--ink);
  border: 0;
  text-align: left;
  padding: 0.7rem 0.75rem 0.8rem;
  box-shadow: 2px 3px 0 rgba(40,24,8,0.18), 4px 10px 22px rgba(20,10,0,0.28);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.25;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.item:hover, .item:focus-visible {
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(1.04);
  box-shadow: 3px 6px 0 rgba(40,24,8,0.16), 8px 18px 28px rgba(20,10,0,0.35);
  z-index: 15 !important;
  outline: none;
}
.item.opened::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2c4a44;
}
.item.new-item {
  box-shadow: 0 0 0 2px var(--gold), 4px 10px 22px rgba(20,10,0,0.28);
}
.item .kind {
  display: block;
  font-size: 0.58rem;
  color: #7a6344;
  margin-bottom: 0.3rem;
  letter-spacing: 0.12em;
}
.item.kind-photo { background: #1b1b1b; color: #f0e6d4; width: min(150px, 22vw); min-height: 110px; }
.item.kind-photo .kind { color: #b9a57a; }
.item.kind-notebook { background: #1e1c1a; color: #f0e6d4; }
.item.kind-notebook .kind { color: #b9a57a; }
.item.kind-phone { background: #d8d2c4; }
.item.kind-key { background: #c9a15a; color: #1a1612; width: min(130px, 20vw); }
.item.kind-folder { background: #c4a882; }

/* Reading pane */
.reader, .ledger, .morning, .notice, .about {
  position: fixed;
  z-index: 40;
}
.reader, .morning, .about {
  inset: auto 0 0 auto;
  width: min(34rem, 100vw);
  max-height: 100vh;
  overflow: auto;
  background: var(--paper);
  color: var(--ink);
  box-shadow: -16px 0 40px rgba(0,0,0,0.35);
  padding: 1.6rem 1.6rem 2.4rem;
}
.reader header, .morning header, .about header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}
.reader h2, .morning h2, .about h2, .ledger h2 {
  font-family: "Fraunces", serif;
  font-weight: 500;
  font-size: 1.7rem;
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.02em;
}
.kicker, .dated {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6a5a40;
  margin: 0 0 0.6rem;
}
.close-btn {
  background: transparent;
  border: 0;
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.2rem;
}
.prose p, .handwritten p, .afterword p, .folder p, .leaflet p, .official p {
  margin: 0 0 0.9rem;
}
.handwritten p {
  font-family: "Newsreader", serif;
  font-style: italic;
  font-size: 1.12rem;
}
.afterword {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 0.95rem;
}
.statement-table {
  width: 100%;
  border-collapse: collapse;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  margin: 0.8rem 0 1rem;
}
.statement-table td {
  padding: 0.35rem 0.2rem;
  border-bottom: 1px solid #e0d3b6;
  vertical-align: top;
}
.statement-table td:last-child { text-align: right; white-space: nowrap; }
.invoice-lines p {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.86rem;
}
.notebook-page { margin-bottom: 1.2rem; }
.notebook-page h3 {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 0.4rem;
  color: #6a5a40;
}
.notebook-page ul { list-style: none; padding: 0; margin: 0; }
.notebook-page li { margin: 0 0 0.4rem; }
.photo-recto {
  background: #111;
  color: #f0e6d4;
  padding: 1.2rem 1rem;
  margin: 0 0 1rem;
  min-height: 10rem;
  font-style: italic;
}
.messages { list-style: none; padding: 0; margin: 0; }
.messages li {
  margin: 0 0 1.1rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--rule);
}
.messages .when, .messages .from {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6a5a40;
}

/* Ledger */
.ledger {
  left: 1rem;
  top: auto;
  bottom: 1rem;
  width: min(26rem, calc(100vw - 2rem));
  background: #f7f1e4;
  color: var(--ink);
  padding: 1rem 1.1rem 1.1rem;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  max-height: 70vh;
  overflow: auto;
}
.ledger h2 { font-size: 1.25rem; margin-bottom: 0.6rem; }
.ledger ul { list-style: none; padding: 0; margin: 0; }
.ledger li {
  margin: 0 0 0.7rem;
  font-size: 0.92rem;
  line-height: 1.3;
}
.ledger .label {
  display: block;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6a5a40;
}
.ledger .debt .value { color: var(--biro); }
.ledger .warning .value { color: #5a3a16; }
.ledger .empty { font-style: italic; color: #6a5a40; }

/* Notices */
.notice-stack {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(26rem, calc(100vw - 2rem));
}
.notice {
  position: static;
  background: var(--notice);
  color: #f3ead6;
  padding: 0.8rem 1rem;
  font-size: 0.95rem;
  box-shadow: 0 10px 24px rgba(0,0,0,0.35);
  border-left: 3px solid var(--gold);
}

/* Morning / endings */
.ending-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.ending-list button {
  display: block;
  width: 100%;
  text-align: left;
  background: #efe4c9;
  border: 1px solid #c9b792;
  color: var(--ink);
  padding: 0.9rem 1rem;
  margin: 0 0 0.6rem;
}
.ending-list button:hover { border-color: var(--ink); }
.ending-list strong {
  display: block;
  font-family: "Fraunces", serif;
  font-weight: 500;
  font-size: 1.15rem;
  margin-bottom: 0.25rem;
}
.ending-list span { font-size: 0.95rem; color: var(--ink-soft); }
.ending-body p { margin: 0 0 0.9rem; }

.about p { margin: 0 0 0.9rem; font-size: 0.98rem; }

@media (max-width: 720px) {
  .table-surface { height: 92vh; min-height: 92vh; }
  .item { font-size: 0.62rem; width: min(42vw, 160px); }
  html { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .item, .item:hover, .item:focus-visible { transition: none; }
}
