@font-face {
  font-family: Alegreya;
  src: url('./assets/alegreya.woff2') format('woff2');
  font-weight: 500 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #edf0e8;
  --surface: #e2e8dc;
  --ink: #232923;
  --muted: #555a4a;
  --line: #b8b8a6;
  --accent: #8e3927;
  --action: #2d4035;
  --action-text: #fff7e9;
  --cover: #2d4035;
  --cover-grid: #859278;
  --paper-ink: #42372b;
  --paper: #e9d9b5;
  --shadow: #232a2332;
  --serif: Alegreya, Georgia, serif;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #191d18;
  --surface: #232b23;
  --ink: #f5f0df;
  --muted: #c0c5b0;
  --line: #626b59;
  --accent: #ffb59b;
  --action: #dbe3ac;
  --action-text: #20291e;
  --cover: #27372e;
  --cover-grid: #72866c;
  --shadow: #060a0750;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font: 1rem/1.55 system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .25em; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
::selection { color: var(--action-text); background: var(--action); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
[hidden] { display: none !important; }
.shell { width: min(100% - 2.5rem, 72rem); margin-inline: auto; }

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 5rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  text-decoration: none;
  font: 650 clamp(1.05rem, 4vw, 1.36rem)/1.2 var(--serif);
}

.brand-mark {
  display: inline-block;
  width: .86rem;
  aspect-ratio: 1;
  border: 2px solid var(--accent);
  border-radius: 50% 50% 12% 50%;
  rotate: -13deg;
}

.masthead-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  column-gap: 1.25rem;
  font-size: .88rem;
}

.masthead-actions a, .quiet {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
}

.quiet {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.quiet:hover, a:hover { color: var(--accent); }
.case-intro {
  display: grid;
  grid-template-columns: .9fr 1.1fr;
  align-items: center;
  gap: clamp(1.5rem, 5vw, 5rem);
  padding-block: clamp(2rem, 6vw, 5rem);
}

h1, h2 { margin: 0; font-family: var(--serif); text-wrap: balance; }
h1 {
  font-size: clamp(3.3rem, 8.5vw, 6rem);
  font-weight: 650;
  letter-spacing: -.04em;
  line-height: .98;
}

h2 { font-size: clamp(1.65rem, 4vw, 2.4rem); font-weight: 600; line-height: 1.13; }
p { margin: .6rem 0 0; max-width: 68ch; text-wrap: pretty; }
.intro-copy p { max-width: 37ch; margin-block: 1.3rem 1.55rem; font-size: clamp(1rem, 2vw, 1.14rem); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .9rem;
  min-height: 2.8rem;
  padding: .62rem 1rem;
  border: 1px solid transparent;
  border-radius: .22rem;
  text-decoration: none;
  font-size: .91rem;
  font-weight: 650;
  text-align: center;
  line-height: 1.25;
}

.primary { color: var(--action-text); background: var(--action); }
.primary:hover { color: var(--action-text); filter: brightness(.94); }
.secondary { color: var(--ink); background: transparent; border-color: var(--line); }
.secondary:hover { border-color: var(--accent); }
.button:disabled { opacity: .6; cursor: default; }

.case-art {
  display: grid;
  position: relative;
  place-items: center;
  min-height: 22rem;
  margin: 0;
  overflow: clip;
  isolation: isolate;
  background-color: var(--cover);
}

.drawing-grid {
  position: absolute;
  inset: 0;
  opacity: .26;
  background-image: linear-gradient(var(--cover-grid) 1px, transparent 1px), linear-gradient(90deg, var(--cover-grid) 1px, transparent 1px);
  background-position: center;
  background-size: 1.55rem 1.55rem;
}

.folder-paper {
  position: relative;
  width: min(71%, 23rem);
  padding: 1.5rem clamp(1.25rem, 4vw, 2.45rem) 2rem;
  rotate: -7deg;
  translate: -8% -4%;
  background: var(--paper);
  color: var(--paper-ink);
  box-shadow: .35rem .7rem 1.4rem var(--shadow);
}

.folder-title { font: 620 1.32rem/1.2 var(--serif); }
.folder-time {
  margin: .42rem 0 .8rem;
  font: 630 clamp(3rem, 10vw, 5rem)/.94 var(--serif);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.04em;
}
.folder-line { width: 100%; height: 1px; background: #9e8d6d; }
.folder-caption { margin-top: .84rem; font-size: .85rem; }
.seal {
  position: absolute;
  bottom: 12%;
  right: 9%;
  display: grid;
  aspect-ratio: 1;
  width: clamp(4.5rem, 13vw, 8rem);
  place-items: center;
  rotate: 11deg;
  border: .34rem double #e2a77e;
  border-radius: 50%;
  background: #8f402e;
  box-shadow: .3rem .55rem 1rem var(--shadow);
}
.seal i { width: 44%; aspect-ratio: 1; border: .18rem double #e2a77e; rotate: 45deg; }

.workbench {
  display: grid;
  grid-template-columns: 1.28fr 1fr;
  gap: clamp(1.2rem, 5vw, 5rem);
  padding-block: .6rem 2.85rem;
}
.section-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .4rem; }
.progress { margin: 0; color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.evidence-list { list-style: none; padding: 0; margin: .95rem 0 0; border-top: 1px solid var(--line); }
.evidence-list li {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: .75rem;
  min-height: 4.95rem;
  align-items: start;
  padding-block: .95rem;
  border-bottom: 1px solid var(--line);
}
.evidence-list li > span { color: var(--accent); font: 650 1.4rem/1.1 var(--serif); }
.evidence-list li > div > p { margin-top: .22rem; color: var(--muted); font-size: .93rem; }
.evidence-list li[data-open='true'] > div > p { color: var(--ink); }

.scanner { padding: clamp(1.1rem, 3.5vw, 1.75rem); background: var(--surface); scroll-margin-top: 1rem; }
.scanner h2 { font-size: clamp(1.55rem, 3.5vw, 1.95rem); }
.scanner > p, .verdict > p { color: var(--muted); }
.scan-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1rem; }
.camera { display: block; width: 100%; margin-top: 1rem; background: var(--cover); border: 1px solid var(--line); }
.code-form { margin-top: 1.35rem; }
label { display: block; font-size: .89rem; font-weight: 650; }
.code-fields { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .45rem; margin-top: .35rem; }
input:not([hidden]), select {
  width: 100%;
  min-height: 2.8rem;
  padding: .55rem .65rem;
  border: 1px solid var(--line);
  border-radius: .22rem;
  background: var(--bg);
  color: var(--ink);
  caret-color: var(--accent);
}
input::placeholder { color: var(--muted); }
.feedback { margin-top: .65rem; font-size: .9rem; }
.feedback[data-tone='error'] { color: var(--accent); }
.feedback[data-tone='success'] { color: var(--ink); }
.feedback:empty { margin: 0; }
.text-link { display: inline-block; margin-top: .9rem; font-size: .92rem; }

.verdict { padding-block: 1.85rem 2.3rem; border-top: 1px solid var(--line); }
.verdict fieldset { border: 0; padding: 0; margin: 1rem 0 0; }
.answer-fields { display: flex; flex-wrap: wrap; gap: .8rem; margin-bottom: .9rem; }
.answer-fields label { flex: 0 1 16rem; }
.answer-fields select { display: block; margin-top: .32rem; }
fieldset:disabled select { cursor: default; opacity: .68; }
.verdict-result { min-height: 1.4em; }
.footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .5rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; }

.sheet { padding-block: 2.5rem; }
.sheet-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.6rem; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.sheet h1 { font-size: clamp(2.4rem, 6vw, 4.4rem); }
.print-cards { margin: 0; padding: 0; list-style: none; }
.print-cards li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .65rem 1.3rem;
  border: 1px dashed var(--line);
}
.print-cards li + li { border-top: 0; }
.print-cards img { width: min(40%, 12rem); height: auto; }
.print-cards strong { display: block; color: var(--accent); font-variant-numeric: tabular-nums; }

@media (max-width: 700px) {
  .case-intro, .workbench { grid-template-columns: 1fr; }
  .case-intro { padding-block: 2rem 2.15rem; gap: 1.7rem; }
  .case-intro h1 br { display: none; }
  .case-art { min-height: 13rem; }
  .folder-paper { padding-block: .95rem 1rem; }
  .folder-time { margin-block: .2rem .45rem; }
  .folder-caption { margin-top: .44rem; }
  .workbench { gap: 1.65rem; padding-bottom: 1.6rem; }
  .sheet-heading { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 390px) {
  .shell { width: calc(100% - 2rem); }
  .masthead-actions { column-gap: .65rem; }
  .masthead-actions a, .quiet { min-height: 2.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@page { size: A4 portrait; margin: 13mm; }
@media print {
  .print-page { background: white; color: #191919; }
  .print-page .masthead, .print-action { display: none; }
  .sheet { width: 100%; margin: 0; padding: 0; }
  .sheet h1 { font-size: 32pt; }
  .sheet-heading { margin-bottom: 5mm; }
  .print-cards li { break-inside: avoid; padding: 2mm 5mm; border-color: #555; }
  .print-cards img { width: 59mm; height: 59mm; }
  .print-cards strong { color: #181818; }
}
