/* ==========================================================================
   style.css — 234 Guest in System 7 dress. 1-bit: only "ink" and
   "paper", patterns of 2 px dots, Chicago-like type in window chrome and
   buttons, Geneva-like in body text. --px is "one classic pixel"
   (2 CSS px ≈ 72 dpi scaled to a tablet).

   Theme: light = black on white, dark = inverted (white on black), like
   "Invert screen" on old Macs. Auto follows the system; the choice in the
   menu is stored. The paper itself (preview and print) is always white.
   Geist is only loaded for the canvas that draws the badge.
   ========================================================================== */

@font-face {
  font-family: "Geist";
  src: url("fonts/Geist-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: block;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Geist";
  src: url("fonts/Geist-var-ext.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: block;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+1E00-1EFF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Want real Chicago? Put e.g. ChicagoFLF (freeware) in fonts/ and
   uncomment this:
@font-face {
  font-family: "ChicagoFLF";
  src: url("fonts/ChicagoFLF.ttf") format("truetype");
  font-display: swap;
}
*/

:root {
  --chicago: "Chicago", "ChicagoFLF", "Charcoal", "Geneva", "Monaco", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --geneva: "Geneva", "Monaco", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --px: 2px;
  --ink: #000;
  --paper: #fff;
  --gray50: repeating-conic-gradient(var(--ink) 0 25%, var(--paper) 0 50%) 0 0 / calc(var(--px) * 2) calc(var(--px) * 2);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --ink: #fff;
  --paper: #000;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #fff;
    --paper: #000;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--paper); -webkit-text-size-adjust: 100%; }
body { transition: none; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font: 18px/1.35 var(--geneva);
  background: var(--gray50);
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

.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;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: var(--px) dotted var(--ink); outline-offset: 2px; }

/* --------------------------------------------------------------------------
   Menu bar
   -------------------------------------------------------------------------- */

.menubar {
  position: relative;
  z-index: 50;
  height: 40px;
  background: var(--paper);
  border-bottom: var(--px) solid var(--ink);
  display: flex;
  align-items: stretch;
  padding: 0 10px;
  font: bold 20px/40px var(--chicago);
}
.menu-title { padding: 0 14px; color: var(--ink); white-space: nowrap; }
.menu-title.apple { font-size: 26px; padding: 0 12px 0 6px; }
button.menu-title.open, button.menu-title:active { background: var(--ink); color: var(--paper); }
.menubar-clock { margin-left: auto; padding: 0 6px; font: 18px/40px var(--geneva); }

.settings-wrap { position: relative; }
.menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 340px;
  background: var(--paper);
  border: var(--px) solid var(--ink);
  border-top: 0;
  box-shadow: var(--px) var(--px) 0 var(--ink);
  padding: 4px 0;
  z-index: 60;
  font: bold 19px/1.2 var(--chicago);
}
.menu-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 24px 9px 42px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.menu-item:hover:not(.static) { background: var(--ink); color: var(--paper); }
.menu-item.static { font: 15px/1.3 var(--geneva); cursor: default; padding-top: 5px; padding-bottom: 5px; }
.menu-item.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.menu-item.check input:checked ~ span::before,
.menu-item.opt-btn.active span::before { content: "✓"; position: absolute; left: 16px; }
.menu-item.opt-btn.active { font-weight: bold; }
.menu-sep { height: var(--px); margin: 5px 0; background: repeating-linear-gradient(90deg, var(--ink) 0 var(--px), var(--paper) var(--px) calc(var(--px) * 2)); }

/* --------------------------------------------------------------------------
   Window
   -------------------------------------------------------------------------- */

.desktop { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding: 26px 14px calc(36px + env(safe-area-inset-bottom)); }
.window {
  width: min(100%, 600px);
  background: var(--paper);
  border: var(--px) solid var(--ink);
  box-shadow: var(--px) var(--px) 0 var(--ink);
}
.titlebar {
  position: relative;
  height: 40px;
  border-bottom: var(--px) solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stripes {
  position: absolute;
  inset: 6px 8px;
  background: repeating-linear-gradient(var(--ink) 0 var(--px), var(--paper) var(--px) calc(var(--px) * 2));
}
.closebox {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translateY(-50%);
  border: var(--px) solid var(--ink);
  background: var(--paper);
  box-shadow: 0 0 0 4px var(--paper);
}
.title-btn { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.title-btn:active { background: var(--ink); color: var(--paper); }
.titlebar .title {
  position: relative;
  margin: 0;
  padding: 0 14px;
  background: var(--paper);
  font: bold 21px/1 var(--chicago);
}
/* All the steps sit in the same grid cell: hidden steps take up space but are
   invisible, so the window keeps the same height throughout – also when the paper arrives. */
.content { padding: 22px 22px 18px; display: grid; }
.content > .view { grid-area: 1 / 1; }
.content > .view[hidden] { display: flex !important; visibility: hidden; pointer-events: none; }
.statusbar {
  border-top: var(--px) solid var(--ink);
  padding: 8px 14px;
  font: 16px/1.2 var(--geneva);
  display: flex;
  justify-content: center;
}
.printer-status { margin: 0; display: inline-flex; align-items: center; gap: 8px; }
.printer-status .dot { width: 12px; height: 12px; border: var(--px) solid var(--ink); background: var(--paper); }
.printer-status.ok .dot { background: var(--ink); }
.printer-status.bad .dot { background: var(--gray50); }

/* --------------------------------------------------------------------------
   Controls
   -------------------------------------------------------------------------- */

.mac-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 150px;
  padding: 11px 26px;
  font: bold 19px/1 var(--chicago);
  color: var(--ink);
  background: var(--paper);
  border: var(--px) solid var(--ink);
  border-radius: 12px;
  cursor: pointer;
}
.mac-btn:active { background: var(--ink); color: var(--paper); }
.mac-btn.default { outline: 6px solid var(--ink); outline-offset: 2px; }
.mac-btn.default:focus-visible { outline: 6px solid var(--ink); }
.row { display: flex; flex-wrap: wrap; justify-content: center; gap: 26px; margin: 10px 0 4px; }

.mac-check, .mac-checkbox { display: inline-flex; align-items: center; gap: 12px; font: 18px/1.2 var(--geneva); color: var(--ink); cursor: pointer; }
.mac-check::before, .mac-checkbox input {
  content: "";
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  margin: 0;
  border: var(--px) solid var(--ink);
  background: var(--paper);
  appearance: none;
  -webkit-appearance: none;
}
/* System 7 checks boxes with an X */
.mac-check.on::before, .mac-checkbox input:checked {
  background:
    linear-gradient(45deg, transparent 43%, var(--ink) 43% 57%, transparent 57%),
    linear-gradient(-45deg, transparent 43%, var(--ink) 43% 57%, transparent 57%),
    var(--paper);
}

.text-input {
  width: 100%;
  font: 20px/1.2 var(--geneva);
  color: var(--ink);
  background: var(--paper);
  border: var(--px) solid var(--ink);
  border-radius: 0;
  padding: 8px 10px;
  -webkit-user-select: text;
  user-select: text;
}
.text-input::placeholder { color: var(--ink); opacity: 0.45; }
.text-input:focus { outline: none; box-shadow: inset 0 0 0 var(--px) var(--ink); }

/* --------------------------------------------------------------------------
   The steps
   -------------------------------------------------------------------------- */

.view { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.step { align-self: flex-start; margin: 0; font: bold 20px/1.2 var(--chicago); }
.micro { margin: 0; font: 16px/1.3 var(--geneva); text-align: center; }

/* The camera frame is exactly the same card as the preview in step 1b:
   a white sheet with a 12 px margin and a 4 px black border around a 448×560 crop.
   The viewfinder (.viewfinder) is content-box, so the border sits on the outside. */
    .frame {
  width: 100%;
  max-width: 420px;
  padding: 12px;
  background: #fff;
  border: var(--px) solid var(--ink);
  box-shadow: var(--px) var(--px) 0 var(--ink);
}
.viewfinder {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  aspect-ratio: 456 / 568; /* outer box incl. the 4 px frame → 448×560 inside at full size */
  border: 4px solid #000;
  background: #000;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.viewfinder video, .viewfinder canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.viewfinder .live { z-index: 1; background: #fff; }
.countdown {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  font: bold 180px/1 var(--chicago);
  color: #000;
  -webkit-text-stroke: 10px #fff;
  paint-order: stroke fill;
  pointer-events: none;
}
.camera-error {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  background: var(--paper);
  color: var(--ink);
  text-align: center;
}
.camera-error p { margin: 0; }
.camera-title { font: bold 19px/1.2 var(--chicago); }
.camera-hint { font: 16px/1.4 var(--geneva); max-width: 320px; }
.camera-detail { font: 13px/1.3 var(--geneva); }
.camera-alt { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }

.photo-paper {
  width: 100%;
  max-width: 420px;
  padding: 12px;
  background: #fff;
  border: var(--px) solid var(--ink);
  box-shadow: var(--px) var(--px) 0 var(--ink);
}
.photo-paper canvas { display: block; width: 100%; height: auto; border: 4px solid #000; }

.form-card { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font: bold 18px/1.2 var(--chicago); }
.name-hint { margin: -6px 0 0; font: 16px/1.3 var(--geneva); }
.name-hint::before { content: "⚠ "; }
.copy-row { align-items: center; padding: 4px 0; }
.copy-text { display: flex; flex-direction: column; gap: 2px; }
.copy-title { font: bold 18px/1.2 var(--chicago); }
.copy-sub { font: 15px/1.3 var(--geneva); }

/* --------------------------------------------------------------------------
   Printer animation (same structure as style.css, but 1-bit)
   -------------------------------------------------------------------------- */

.printer { position: relative; --paper-w: 300px; --feed-ms: 3000ms; display: flex; flex-direction: column; align-items: center; width: 100%; padding-top: 4px; min-height: 660px; /* head 64 + paper ≤ 608 + air 36: fixed, whatever the badge */ }
.printer-head {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: calc(var(--paper-w) + 72px);
  height: 64px;
  background: var(--paper);
  border: var(--px) solid var(--ink);
  box-shadow: var(--px) var(--px) 0 var(--ink);
}
.printer-head::before { /* two buttons on the panel */
  content: "";
  position: absolute;
  left: 16px;
  top: 14px;
  width: 44px;
  height: 12px;
  border: var(--px) solid var(--ink);
  background: repeating-linear-gradient(90deg, var(--paper) 0 20px, var(--ink) 20px 22px);
}
.printer-slot { position: absolute; left: 20px; right: 20px; bottom: 0; height: 12px; background: var(--ink); }
.printer-led { position: absolute; top: 14px; right: 18px; width: 12px; height: 12px; border: var(--px) solid var(--ink); background: var(--ink); }
.printer.feeding .printer-led { animation: blink 0.8s steps(1) infinite; }
.printer.done .printer-led { animation: none; }
.printer.failed .printer-led { background: var(--gray50); animation: none; }
@keyframes blink { 50% { background: var(--paper); } }
.printer-feed {
  position: relative;
  z-index: 1;
  pointer-events: none; /* the paper is display only; never swallow taps meant for what is under it */
  width: 100%;
  max-width: calc(var(--paper-w) + 72px);
  margin-top: -6px;
  padding: 0 36px 36px;
  overflow: hidden;
}
/* The whole paper slides down out of the slot as one piece. Four drop-shadows
   of 1 classic pixel in each direction draw a black edge around the whole paper,
   tear-off edge included (a normal border would be clipped by the clip-path);
   the last one is the classic Mac shadow down to the right. */
.receipt {
  filter:
    drop-shadow(var(--px) 0 0 var(--ink))
    drop-shadow(calc(-1 * var(--px)) 0 0 var(--ink))
    drop-shadow(0 var(--px) 0 var(--ink))
    drop-shadow(0 calc(-1 * var(--px)) 0 var(--ink))
    drop-shadow(calc(var(--px) * 2) calc(var(--px) * 2) 0 var(--ink));
  transform: translateY(-101%);
}
.printer.feeding .receipt { animation: feed var(--feed-ms) linear forwards; }
.printer.failed .receipt { animation: retract 500ms ease-in forwards; }
.receipt-paper { background: #fff; padding-bottom: 8px; }
.receipt-paper canvas { display: block; width: 100%; height: auto; }
@keyframes feed { from { transform: translateY(-101%); } to { transform: translateY(0); } }
@keyframes retract { to { transform: translateY(-101%); } }

.status { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; min-height: 96px; /* text and button alternate without the window moving */ }
.status-text { margin: 0; font: bold 22px/1.3 var(--chicago); }
.status-text.ok::before { content: "✓ "; }
.status-text .dots { display: inline-block; min-width: 1.4em; text-align: left; } /* fixed width: the text does not move as the dots count */
.status-extra { margin: -4px 0 0; font: 16px/1.3 var(--geneva); max-width: 380px; }

/* --------------------------------------------------------------------------
   Flash + reduced motion
   -------------------------------------------------------------------------- */

.flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 200; transition: opacity 0.45s ease-out; }
.flash.on { opacity: 1; transition: none; }

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


/* Waiting for the printer to fetch the job: a pixel hourglass under the head, sand running.
   The status text is lifted up to sit right under it (transform, so the window keeps its height). */
.printer.waiting ~ .status { transform: translateY(-370px); position: relative; z-index: 3; } /* above the (empty, invisible) paper box so the button is tappable */
.hourglass {
  position: absolute;
  top: 190px;
  left: 50%;
  width: 84px;
  height: 100px;
  transform: translateX(-50%);
  image-rendering: pixelated;
  z-index: 0;
}

/* --------------------------------------------------------------------------
   Phones: the window follows the visible step instead of reserving tablet
   height (no dead scrolling), tighter margins, and the menu fits the screen.
   -------------------------------------------------------------------------- */
@media (max-width: 600px) {
  .desktop { padding: 12px 8px calc(24px + env(safe-area-inset-bottom)); }
  .content { padding: 16px 14px 14px; }
  .content > .view[hidden] { display: none !important; }
  .printer { min-height: 0; }
  .printer.waiting { min-height: 420px; }
  .printer.waiting ~ .status { transform: translateY(-40px); }
  .hourglass { top: 130px; }
  .row { gap: 12px; }
  .row .mac-btn { min-width: 0; flex: 1 1 0; padding: 11px 12px; }
  .menubar { padding: 0 4px; font-size: 18px; }
  .menu-title { padding: 0 10px; }
  .menu { left: auto; right: -4px; min-width: 0; width: calc(100vw - 8px); }
  .countdown { font-size: 140px; }
}

/* After a photo: the fields rise in under it while the picture develops */
.form-card.enter { animation: rise 500ms ease-out 500ms both; }
@keyframes rise { from { opacity: 0.01; transform: translateY(10px); } to { opacity: 1; transform: none; } }
