/* Thermal-receipt look shared by the desk, booth and admin pages. */

@font-face {
  font-family: "Doto";
  src: url("fonts/doto-latin-900-normal.woff2") format("woff2");
  font-weight: 900;
  font-display: swap;
}
@font-face {
  font-family: "Doto";
  src: url("fonts/doto-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Fragment Mono";
  src: url("fonts/fragment-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #f6f7f4;          /* thermal paper is a cool white */
  --ink: #26272b;            /* thermal "black" prints slightly soft */
  --ink-faded: #6f7176;
  --rule: #a9adb2;
  --stamp: #c3302a;          /* rubber-stamp red */
  --surface: #c7d0d7;        /* the desk the receipt lies on */
  --surface-light: #dfe5ea;
  --mono: "Fragment Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --dots: "Doto", var(--mono);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .10 0 0 0 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root { --surface: #262b30; --surface-light: #343b42; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(120% 70% at 50% 0%, var(--surface-light), transparent 70%),
    var(--surface);
  color: var(--ink);
  font: 15px/1.55 var(--mono);
  padding: 28px 16px 56px;
}
body.booth-page {
  --surface: var(--booth, #f3c4d2);
  --surface-light: color-mix(in srgb, var(--booth, #f3c4d2) 55%, #fff);
}

/* ---------- the strip of paper ---------- */

.sheet {
  max-width: 430px;
  margin: 0 auto;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .06)) drop-shadow(0 14px 22px rgba(30, 38, 46, .22));
}
.receipt {
  --tooth: 12px;
  position: relative;
  background: var(--grain), linear-gradient(172deg, #fff 0%, var(--paper) 38%, #eef0ec 100%);
  padding: 40px 24px 44px;
  /* torn zig-zag edges, top and bottom */
  -webkit-mask:
    conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / var(--tooth) 51% repeat-x,
    conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) top / var(--tooth) 51% repeat-x;
  mask:
    conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / var(--tooth) 51% repeat-x,
    conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) top / var(--tooth) 51% repeat-x;
}

.title {
  font: 900 clamp(46px, 15vw, 66px)/0.95 var(--dots);
  text-transform: uppercase;
  letter-spacing: .01em;
  text-align: center;
  margin: 0;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.subtitle {
  text-align: center;
  color: var(--ink-faded);
  margin: 10px 0 0;
}

.cut {
  border: 0;
  border-top: 2px dashed var(--rule);
  margin: 22px -24px;
}

/* key ....... value lines */
.line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
}
.line > :first-child { text-transform: uppercase; }
.line .leader {
  flex: 1;
  border-bottom: 2px dotted var(--rule);
  transform: translateY(-4px);
  min-width: 12px;
}
.ticket-no { font: 700 18px/1 var(--dots); letter-spacing: .04em; }

/* inputs that look like blanks on a form */
.blank {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 6px 0 0;
}
.blank span { text-transform: uppercase; white-space: nowrap; }
.blank input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--ink);
  border-radius: 0;
  padding: 4px 2px;
}
.blank input::placeholder { color: var(--ink-faded); opacity: .8; }

/* write a note / send a photo */
.choice {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  margin: 0 0 14px;
  border: 0;
  padding: 0;
}
.choice label { cursor: pointer; white-space: nowrap; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .box::before { content: "( ) "; white-space: pre; }
.choice input:checked + .box::before { content: "(x) "; font-weight: bold; }
.choice input:focus-visible + .box { outline: 2px dashed var(--ink); outline-offset: 3px; }

textarea {
  display: block;
  width: 100%;
  min-height: 190px;
  resize: vertical;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, .55);
  border: 2px dashed var(--rule);
  border-radius: 2px;
  padding: 12px;
}
textarea::placeholder { color: var(--ink-faded); }
.count {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: var(--ink-faded);
  font-size: 13px;
}
.count .n { color: var(--ink); white-space: nowrap; }
.count .over { color: var(--stamp); }
.hint { color: var(--stamp); font-size: 13px; margin: 6px 0 0; min-height: 0; }
.hint:empty { display: none; }

/* photo slot */
.frame {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 5;
  width: 100%;
  border: 2px dashed var(--rule);
  background: rgba(255, 255, 255, .55);
  cursor: pointer;
  overflow: hidden;
  text-align: center;
  padding: 16px;
}
.frame.short { aspect-ratio: 4 / 3; }
.frame .empty strong { display: block; font-size: 17px; }
.frame .empty small { color: var(--ink-faded); }
.frame img {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* rough idea of black-and-white thermal output */
  filter: grayscale(1) contrast(1.25) brightness(1.05);
}
.frame.has-photo { border-style: solid; border-color: var(--ink); padding: 0; }
.frame.has-photo img { display: block; }
.frame.has-photo .empty { display: none; }
.frame.has-photo.no-preview .empty { display: block; }
.frame:focus-within { outline: 2px dashed var(--ink); outline-offset: 3px; }
.frame input, .file-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.alt {
  display: block;
  margin: 10px auto 0;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: none;
  border: 0;
  text-decoration: underline dotted;
  text-underline-offset: 4px;
  cursor: pointer;
}

/* star banner */
.banner {
  text-align: center;
  margin: 24px 0;
  overflow: hidden;
  white-space: nowrap;
}
.banner .stars { color: var(--ink-faded); letter-spacing: .12em; display: block; overflow: hidden; }
.banner strong { display: block; text-transform: uppercase; margin-top: 6px; white-space: normal; }
.banner p { margin: 2px 0 8px; color: var(--ink-faded); white-space: normal; }

/* main button */
.print {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 16px;
  font: inherit;
  font-size: 17px;
  color: var(--paper);
  background: var(--ink);
  border: 0;
  border-radius: 3px;
  cursor: pointer;
}
.print:disabled { opacity: .35; cursor: default; }
.print.ghost { background: transparent; color: var(--ink); border: 2px solid var(--ink); }
:focus-visible { outline: 2px dashed var(--ink); outline-offset: 3px; }
.print:focus-visible { outline-offset: 4px; }

.error { color: var(--stamp); margin: 12px 0 0; min-height: 1.5em; text-align: center; }
.fineprint { text-align: center; color: var(--ink-faded); font-size: 13px; margin: 18px 0 0; }
.page-note { max-width: 430px; margin: 18px auto 0; text-align: center; color: var(--ink-faded); font-size: 13px; }
@media (prefers-color-scheme: dark) { body:not(.booth-page) .page-note { color: #9aa3ab; } }

fieldset.fields { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.fields:disabled .blank,
fieldset.fields:disabled .choice,
fieldset.fields:disabled .alt,
fieldset.fields:disabled textarea,
fieldset.fields:disabled .count { opacity: .5; }

/* after sending */
.status { margin-top: 6px; }
.status .state { font-weight: bold; }
.status .state.busy::after {
  content: "";
  display: inline-block;
  width: 3ch;
  text-align: left;
  animation: dots 1.2s steps(4) infinite;
}
@keyframes dots {
  0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; }
}
.status .print { margin-top: 20px; }

.stamp {
  position: absolute;
  left: 50%;
  top: 46%;
  z-index: 2;
  padding: 6px 16px 8px;
  font: 900 44px/1 var(--dots);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--stamp);
  border: 4px double var(--stamp);
  border-radius: 6px;
  background: rgba(246, 247, 244, .82);
  box-shadow: 0 2px 10px rgba(30, 38, 46, .18);
  transform: translate(-50%, -50%) rotate(-11deg);
  opacity: .95;
  pointer-events: none;
  animation: stamp .22s cubic-bezier(.2, 1.6, .4, 1) both;
}
.stamp.void { color: var(--ink-faded); border-color: var(--ink-faded); }
@keyframes stamp {
  from { transform: translate(-50%, -50%) rotate(-4deg) scale(1.9); opacity: 0; }
  to { transform: translate(-50%, -50%) rotate(-11deg) scale(1); opacity: .95; }
}

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .stamp { animation: none; }
  .status .state.busy::after { animation: none; content: "..."; }
}

/* ---------- admin ---------- */

.admin { max-width: 1100px; margin: 0 auto; }
.admin header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}
.admin h1 { font: 900 40px/1 var(--dots); margin: 0; }
.admin h2 { font-size: 15px; margin: 30px 0 10px; font-weight: normal; }
.admin .meta-bar, .admin h2 { color: var(--ink); }
@media (prefers-color-scheme: dark) {
  .admin h1, .admin h2, .admin .meta-bar { color: #e8ecef; }
  .admin .meta-bar a { color: #e8ecef; }
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.job {
  background: var(--grain), var(--paper);
  border-radius: 2px;
  box-shadow: 0 8px 18px rgba(30, 38, 46, .18);
  display: flex;
  flex-direction: column;
}
.job img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; filter: grayscale(1); cursor: zoom-in; }
.job .note {
  aspect-ratio: 1;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
  font-size: 13px;
  border-bottom: 2px dashed var(--rule);
}
.job .meta { padding: 10px 12px 4px; font-size: 13px; }
.job .meta .err { color: var(--stamp); word-break: break-word; }
.job .actions { display: flex; gap: 8px; padding: 8px 12px 12px; margin-top: auto; }
.job button {
  flex: 1;
  padding: 9px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
  background: transparent;
  border: 2px solid var(--ink);
  border-radius: 3px;
}
.job button.go { background: var(--ink); color: var(--paper); }
.job button.no { border-color: var(--stamp); color: var(--stamp); }
.tag { display: inline-block; padding: 0 6px; border: 1px solid var(--ink); border-radius: 2px; font-size: 12px; }
.empty-note { color: var(--ink-faded); }
@media (prefers-color-scheme: dark) { .empty-note { color: #9aa3ab; } }
#lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .85); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
#lightbox img { max-width: 100%; max-height: 100%; }

/* ---------- booth camera ---------- */

.instructions {
  text-align: center;
  margin: 14px auto 20px;
  max-width: 34ch;
  text-wrap: balance;
}
.viewfinder {
  position: relative;
  aspect-ratio: 4 / 3;
  border: 2px solid var(--ink);
  background:
    repeating-linear-gradient(45deg, transparent 0 6px, rgba(38, 39, 43, .06) 6px 7px),
    rgba(255, 255, 255, .5);
  overflow: hidden;
}
/* Live view: the real camera video, cropped like the print and shown in black and white. */
.viewfinder video,
.viewfinder canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;  /* same crop as the captured photo: keeps heads in */
  filter: grayscale(1) contrast(1.12) brightness(1.04);
  opacity: 0;
}
.viewfinder video.mirror { transform: scaleX(-1); }
.viewfinder.live video { opacity: 1; }
.viewfinder.still canvas { opacity: 1; }
.viewfinder.still video { opacity: 0; }
.vf-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
  text-wrap: balance;
}
.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 900 clamp(110px, 40vw, 170px)/1 var(--dots);
  color: var(--stamp);
  text-shadow: 0 0 2px var(--paper), 0 0 18px rgba(246, 247, 244, .9);
  pointer-events: none;
}
.countdown.pop { animation: pop 1s ease-out both; }
@keyframes pop {
  0% { transform: scale(1.35); opacity: 0; }
  12% { transform: scale(1); opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: .2; }
}
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.go { animation: flash .45s ease-out; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

.slots {
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  gap: 8px;
  margin: 10px 0 0;
}
.slot {
  position: relative;
  aspect-ratio: 4 / 3;
  border: 2px dashed var(--rule);
  display: grid;
  place-items: center;
  color: var(--ink-faded);
  font: 700 18px/1 var(--dots);
}
.slot canvas { position: absolute; inset: 0; width: 100%; height: 100%; filter: grayscale(1) contrast(1.12); opacity: 0; }
.slot.filled { border-style: solid; border-color: var(--ink); }
.slot.filled canvas { opacity: 1; }
.print.start { margin-top: 16px; font-size: 19px; letter-spacing: .08em; text-transform: uppercase; }

@media (prefers-reduced-motion: reduce) {
  .countdown.pop { animation: none; }
}

/* ---------- admin pages ---------- */

.admin-nav { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 22px; }
.admin-nav a { color: var(--ink); text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.admin-nav a[aria-current="page"] { border-bottom-color: var(--ink); font-weight: bold; }
@media (prefers-color-scheme: dark) { .admin-nav a { color: #e8ecef; } .admin-nav a[aria-current="page"] { border-bottom-color: #e8ecef; } }
.panel {
  background: var(--grain), var(--paper);
  color: var(--ink);
  border: 0;
  border-radius: 2px;
  box-shadow: 0 8px 18px rgba(30, 38, 46, .18);
  padding: 18px 20px 20px;
  margin: 0 0 18px;
  min-width: 0;
}
.panel legend {
  float: left;
  width: 100%;
  font: 900 26px/1 var(--dots);
  margin: 0 0 14px;
  padding: 0;
}
.settings { max-width: 640px; }
.settings .field { display: block; margin: 0 0 14px; clear: both; }
.settings .field > span { display: block; font-size: 13px; color: var(--ink-faded); margin-bottom: 4px; }
.settings input[type=text], .settings input[type=url], .settings input[type=number], .settings select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, .7);
  border: 2px solid var(--rule);
  border-radius: 3px;
  padding: 9px 10px;
}
.settings input[type=number] { max-width: 9em; }
.settings input[type=color] { width: 64px; height: 40px; border: 2px solid var(--rule); border-radius: 3px; padding: 2px; background: #fff; }
.settings small { display: block; color: var(--ink-faded); margin-top: 4px; font-size: 12px; overflow-wrap: anywhere; }
.settings .check { display: flex; gap: 10px; align-items: center; margin: 0 0 12px; clear: both; cursor: pointer; }
.settings .check input { width: 20px; height: 20px; accent-color: var(--ink); }
.settings .print { max-width: 640px; }
.notice { max-width: 640px; padding: 12px 16px; border-radius: 3px; margin: 0 0 18px; background: var(--paper); color: var(--ink); border-left: 6px solid var(--ink); }
.notice.ok { border-left-color: #2f7d4f; }
.notice.bad { border-left-color: var(--stamp); }
.notice ul { margin: 6px 0 0; padding-left: 20px; }
.notice code { font-size: 13px; overflow-wrap: anywhere; }
.share-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; max-width: 900px; }
.share { text-align: center; }
.share h2 { font: 900 24px/1.1 var(--dots); margin: 4px 0 14px; color: var(--ink); }
.share img { display: block; margin: 0 auto; width: 260px; max-width: 100%; height: auto; image-rendering: pixelated; }
.share .url { overflow-wrap: anywhere; font-size: 13px; margin: 12px 0 14px; }
.share .url a { color: var(--ink); }
.share .actions { display: grid; gap: 8px; }
.share .actions .print { font-size: 15px; padding: 12px; text-decoration: none; text-align: center; }
.sign-status { min-height: 1.4em; font-size: 13px; color: var(--ink-faded); margin: 10px 0 0; }
