:root {
  --bg: #f3efe6;
  --surface: #e9e3d6;
  --ink: #1a1714;
  --muted: #5e584f;
  --line: rgba(26, 23, 20, 0.16);
  --accent: #b42318;
  --accent-ink: #f3efe6;
  --plate: #1a1714;
  --display: "Fraunces", "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --text: "Source Serif 4", Palatino, "Palatino Linotype", Georgia, serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.0625rem;
  font-weight: 400;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  display: block;
  height: 5px;
  background: var(--accent);
}

img,
video,
canvas {
  max-width: 100%;
}

button,
input {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: 1rem;
  top: 0.4rem;
  transform: translateY(-140%);
  background: var(--ink);
  color: var(--bg);
  padding: 0.4rem 0.7rem;
  z-index: 30;
}

.skip:focus {
  transform: none;
}

[hidden] {
  display: none !important;
}

.wrap {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
}

.mast {
  padding: 1.05rem 0 0.95rem;
  border-bottom: 1px solid var(--line);
}

.mast-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.mast-top p {
  margin: 0;
}

.mast-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.72rem;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variation-settings: "opsz" 48, "SOFT" 30, "WONK" 1;
}

.logo-mark {
  width: 0.72rem;
  height: 0.72rem;
  background: var(--accent);
  flex: none;
}

.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--line);
  padding: 0.4rem 0.7rem;
  cursor: pointer;
}

.nav {
  display: flex;
  align-items: baseline;
  gap: 1.4rem;
}

.nav a {
  text-decoration: none;
  font-size: 1.02rem;
}

.nav a:hover {
  text-decoration: underline;
  text-underline-offset: 0.28em;
}

.nav a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 0.28em;
  text-decoration-color: var(--accent);
}

.spread {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  grid-template-areas:
    "copy plate"
    "read plate"
    "note plate";
  column-gap: 2.75rem;
  row-gap: 1.15rem;
  padding: 2.4rem 0 2.6rem;
  align-items: start;
}

.copy { grid-area: copy; }
.plate { grid-area: plate; }
.readout { grid-area: read; }
.marginal { grid-area: note; }

.kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.kicker span {
  color: var(--accent);
  font-family: var(--display);
  font-style: italic;
  margin-right: 0.35rem;
}

h1 {
  margin: 0.4rem 0 0.9rem;
  font-family: var(--display);
  font-weight: 560;
  font-size: clamp(2.7rem, 5.2vw, 4.25rem);
  line-height: 0.96;
  letter-spacing: -0.035em;
  font-variation-settings: "opsz" 80, "SOFT" 40, "WONK" 1;
}

.lead {
  margin: 0;
  max-width: 34rem;
  font-size: 1.16rem;
  line-height: 1.5;
}

.marginal {
  margin: 0.3rem 0 0;
  max-width: 32rem;
  padding-left: 0.9rem;
  border-left: 2px solid var(--accent);
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.45;
}

.plate {
  align-self: stretch;
}

.finder {
  position: relative;
  background: var(--plate);
  aspect-ratio: 4 / 3;
  overflow: hidden;
}

.finder video,
.finder img,
.finder canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.finder video {
  object-fit: cover;
}

.finder img,
.finder canvas {
  object-fit: contain;
}

.idle {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.35rem;
  padding: 1.15rem 1.2rem 1.25rem;
  color: var(--bg);
}

.idle strong {
  font-family: var(--display);
  font-weight: 560;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.idle p {
  margin: 0;
  max-width: 22rem;
  color: rgba(243, 239, 230, 0.78);
  font-size: 0.98rem;
}

.corner {
  position: absolute;
  width: 1.35rem;
  height: 1.35rem;
  border: 0 solid var(--bg);
  pointer-events: none;
}

.corner-tl { top: 0.8rem; left: 0.8rem; border-top-width: 2px; border-left-width: 2px; }
.corner-tr { top: 0.8rem; right: 0.8rem; border-top-width: 2px; border-right-width: 2px; }
.corner-bl { bottom: 0.8rem; left: 0.8rem; border-bottom-width: 2px; border-left-width: 2px; }
.corner-br { bottom: 0.8rem; right: 0.8rem; border-bottom-width: 2px; border-right-width: 2px; }

.scanline {
  display: none;
  position: absolute;
  left: 12%;
  right: 12%;
  height: 2px;
  background: var(--accent);
  top: 18%;
  pointer-events: none;
}

.plate.is-live .scanline {
  display: block;
  animation: sweep 2.6s ease-in-out infinite;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.55rem 1.05rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  cursor: pointer;
  line-height: 1.2;
  transition: transform 280ms var(--ease), box-shadow 280ms var(--ease);
}

.btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 24px rgba(180, 35, 24, 0.24);
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: rgba(26, 23, 20, 0.4);
  position: relative;
}

.btn.ghost:hover {
  box-shadow: 0 8px 18px rgba(26, 23, 20, 0.08);
}

.btn:disabled {
  cursor: default;
  transform: none;
  box-shadow: none;
}

#copy:disabled {
  background: transparent;
  color: var(--muted);
  border-color: rgba(26, 23, 20, 0.28);
}

.file-btn input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.readout {
  border-top: 3px solid var(--accent);
  padding-top: 0.8rem;
  min-height: 8.5rem;
}

.readout .label {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

#status {
  margin: 0.45rem 0 0;
  font-size: 1.05rem;
}

#hint {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

#output {
  margin: 0.7rem 0 0.85rem;
  font-family: var(--text);
  font-size: 1.14rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 9.5rem;
  overflow: auto;
}

#output:empty {
  display: none;
}

.readout-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.notes {
  display: grid;
  grid-template-columns: 1.25fr 1fr 0.82fr;
  border-top: 1px solid var(--line);
}

.notes article {
  padding: 1.7rem 1.6rem 1.8rem 0;
  margin-right: 1.6rem;
  border-right: 1px solid var(--line);
}

.notes article:last-child {
  border-right: 0;
  margin-right: 0;
  padding-right: 0;
}

.notes .num {
  margin: 0;
  font-family: var(--display);
  font-style: italic;
  color: var(--accent);
  font-size: 1.05rem;
}

.notes h2 {
  margin: 0.3rem 0 0.5rem;
  font-family: var(--display);
  font-weight: 560;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.notes p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.close {
  display: grid;
  grid-template-columns: 1.35fr 0.9fr;
  gap: 2rem;
  align-items: end;
  padding: 2.2rem 0 0.4rem;
  border-top: 1px solid var(--line);
  margin-top: 0.2rem;
}

.close p {
  margin: 0;
  max-width: 38rem;
  color: var(--muted);
}

.close a {
  font-family: var(--display);
  font-weight: 560;
  font-size: clamp(1.8rem, 3vw, 2.45rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
  text-decoration: none;
  justify-self: end;
  text-align: right;
  max-width: 16ch;
}

.close a:hover {
  color: var(--accent);
}

.foot {
  display: grid;
  grid-template-columns: 1.35fr 1fr 0.8fr;
  gap: 1.5rem 2rem;
  margin-top: 2.4rem;
  padding: 1.6rem 0 2.4rem;
  border-top: 1px solid var(--line);
}

.foot-name {
  margin: 0 0 0.45rem;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.foot p {
  margin: 0 0 0.35rem;
}

.foot-brand p:last-child,
.foot-legal p:last-child {
  margin-bottom: 0;
}

.foot a {
  color: var(--ink);
}

.foot-nav {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.foot-nav a {
  text-decoration: none;
}

.foot-nav a:hover {
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

.foot-copy {
  grid-column: 1 / -1;
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.doc {
  display: grid;
  grid-template-columns: minmax(9.5rem, 14rem) minmax(0, 68ch);
  gap: 2.5rem 3rem;
  padding: 2.5rem 0 3.5rem;
}

.doc-meta {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.doc-meta strong {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--ink);
  font-weight: 560;
}

.doc-meta p {
  margin: 0 0 0.7rem;
}

.prose h1 {
  font-size: clamp(2.35rem, 4.4vw, 3.5rem);
}

.prose h2 {
  margin: 1.9rem 0 0.45rem;
  font-family: var(--display);
  font-weight: 560;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.prose p,
.prose li {
  font-size: 1.06rem;
  line-height: 1.6;
}

.prose p {
  margin: 0 0 0.85rem;
}

.prose ul,
.prose ol {
  margin: 0 0 0.9rem;
  padding-left: 1.2rem;
}

.prose a {
  color: var(--accent);
}

.req {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 0.45rem 1rem;
  margin: 1.2rem 0 0;
}

.req dt {
  color: var(--muted);
}

.req dd {
  margin: 0;
}

.cookie {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 1.15rem;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.92rem;
}

.cookie[hidden] {
  display: none !important;
}

.cookie p {
  margin: 0;
}

.cookie a {
  color: var(--bg);
}

.cookie button {
  flex: none;
  background: transparent;
  color: var(--bg);
  border: 1px solid rgba(243, 239, 230, 0.55);
  padding: 0.28rem 0.85rem;
  cursor: pointer;
}

body.has-cookie {
  padding-bottom: 3.2rem;
}

@keyframes sweep {
  0% { top: 16%; }
  50% { top: 80%; }
  100% { top: 16%; }
}

@keyframes sheet {
  from { transform: translateY(12px); }
  to { transform: translateY(0); }
}

.readout.is-ready {
  animation: sheet 420ms var(--ease);
}

@media (max-width: 860px) {
  .spread {
    grid-template-columns: 1fr;
    grid-template-areas:
      "copy"
      "plate"
      "read"
      "note";
    row-gap: 1rem;
    padding-top: 1.6rem;
  }

  .notes {
    grid-template-columns: 1fr;
  }

  .notes article {
    margin-right: 0;
    padding-right: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .notes article:last-child {
    border-bottom: 0;
  }

  .close,
  .foot,
  .doc {
    grid-template-columns: 1fr;
  }

  .close a {
    justify-self: start;
    text-align: left;
  }
}

@media (max-width: 720px) {
  .wrap {
    width: min(1120px, calc(100% - 32px));
  }

  .nav-toggle {
    display: inline-flex;
  }

  .mast-row {
    flex-wrap: wrap;
  }

  .nav {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 0.7rem;
    padding-top: 0.35rem;
  }

  .nav.is-open {
    display: flex;
  }

  h1 {
    font-size: clamp(2.25rem, 11vw, 3rem);
  }

  .cookie {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.55rem;
  }

  .req {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .req div,
  .req dt {
    margin-top: 0.45rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
