/* public/app.css: the Address Catalog world. The page is the Hall Catalog (newsprint, the department grid, the
   carbon pen circle); the flow is the Ticket Wallet (coupons, perforation, notches, stamps, barcode stub).
   Light mode only. Red is for stamps, required marks, field codes, errors and the masthead rule; carbon is
   for what the student wrote and their own cell. */

:root {
  color-scheme: light;
  --news: #E4E1D9;
  --stock: #F8F6F1;
  --ink: #161616;
  --red: #A8291A;
  --carbon: #43307A;
  --paper: #FFFFFF;
  --grey: rgba(22, 22, 22, .8);
  --hair: rgba(22, 22, 22, .3);
  --display: "Oswald", sans-serif;
  --mono: "IBM Plex Mono", monospace;
  --hand: "Courier Prime", monospace;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--ink) var(--news);
}

html, body { margin: 0; background: var(--news); color: var(--ink); }

body {
  min-height: 100vh;
  font: 400 14px/1.45 var(--mono);
  background-image: radial-gradient(rgba(22, 22, 22, .05) 1px, transparent 1.2px);
  background-size: 3px 3px;
  -webkit-tap-highlight-color: transparent;
}

::selection { background: var(--carbon); color: var(--paper); }

[hidden] { display: none !important; }

.vh {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.page { max-width: 430px; margin: 0 auto; padding: 16px 16px 32px; }

/* ── Masthead ─────────────────────────────────────────────────────────── */

.mast {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--red);
}
.mast h1 { margin: 0; font: 700 30px/.95 var(--display); text-transform: uppercase; }
.mast p { margin: 0; font: 500 12px/1.35 var(--mono); text-align: right; text-transform: uppercase; }

.lede { margin: 10px 0 16px; max-width: 60ch; font-size: 13px; line-height: 1.5; color: var(--grey); }

/* ── Department grid ──────────────────────────────────────────────────── */

.dept { margin: 0 0 16px; }
.dept-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 6px;
  font: 600 12px/1.3 var(--mono);
  text-transform: uppercase;
}
.dept-head h2 { min-width: 0; margin: 0; font: inherit; }
.dept-count { flex: none; margin: 0; font-variant-numeric: tabular-nums; }

.grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.c {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--ink);
  background: rgba(255, 255, 255, .25);
  font: 500 11.5px/1 var(--mono);
  font-variant-numeric: tabular-nums;
}
.c.long { grid-column: span 2; aspect-ratio: 2 / 1; font-size: 10.5px; }
.c.done { color: var(--grey); }
.c.done::after {
  content: "";
  position: absolute;
  left: 10%; right: 10%; top: 50%;
  border-top: 1.5px solid var(--ink);
  transform: rotate(-20deg);
}
.c.me { font-weight: 600; color: var(--carbon); }
.c.me svg {
  position: absolute;
  inset: -6px;
  width: calc(100% + 12px);
  height: calc(100% + 12px);
  overflow: visible;
  pointer-events: none;
}

/* ── Step tabs ────────────────────────────────────────────────────────── */

.tabs { display: flex; gap: 3px; margin: 0; padding: 0; list-style: none; }
.tabs li {
  flex: 1;
  min-width: 0;
  padding: 8px 2px;
  border: 1.5px solid var(--ink);
  border-bottom: 0;
  color: var(--grey);
  font: 600 12px/1 var(--display);
  letter-spacing: .06em;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}
.tabs li.done { text-decoration: line-through 1.5px var(--ink); }
.tabs li[aria-current] { background: var(--stock); color: var(--ink); }

/* ── Coupon ───────────────────────────────────────────────────────────── */

.coupon {
  position: relative;
  padding: 12px;
  border: 1.5px solid var(--ink);
  background: var(--stock);
  /* The ink edge carries the coupon; a short offset lift says "current" without a wide halo. */
  box-shadow: 0 5px 8px -5px rgba(22, 22, 22, .4);
}

.ch { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 12px; }
.ch > div { min-width: 0; }
.ch h2 { margin: 0; font: 700 22px/1.05 var(--display); text-transform: uppercase; text-wrap: balance; }
.ch h2:focus { outline: none; }
.ch h2:focus-visible { outline: 2px solid var(--carbon); outline-offset: 3px; }
.ch .sub { margin: 5px 0 0; font: 500 12px/1.4 var(--mono); color: var(--grey); overflow-wrap: anywhere; }
.ch .sub .mine { color: var(--carbon); font-weight: 600; }
.ch .no { flex: none; margin: 0; font: 600 12px/1.2 var(--mono); text-align: right; text-transform: uppercase; }
.ch .no b { display: block; margin-top: 3px; font: 700 21px/1 var(--hand); color: var(--carbon); font-variant-numeric: tabular-nums; }
.ch .no.issued b { color: var(--ink); }

/* The perforation, with the two half-circle notches bitten out of the coupon's edges. */
.perf { position: relative; margin: 0 -12px 10px; border-top: 2px dashed var(--hair); }
.perf::before, .perf::after {
  content: "";
  position: absolute;
  top: -8px;
  width: 14px; height: 14px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: var(--news);
}
.perf::before { left: -8px; clip-path: inset(0 0 0 50%); }
.perf::after { right: -8px; clip-path: inset(0 50% 0 0); }

/* ── Field boxes ──────────────────────────────────────────────────────── */

.f {
  position: relative;
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr);
  gap: 0 6px;
  margin-bottom: 6px;
  padding: 6px 8px 4px;
  border: 1px solid var(--hair);
  background: var(--paper);
}
.f .code { padding-top: 2px; font: 600 12px/1.2 var(--mono); color: var(--red); }
.f > div { min-width: 0; }
.f label { display: block; font: 600 13px/1.15 var(--display); letter-spacing: .06em; text-transform: uppercase; }
/* The whole box is the tap target: a tap anywhere in it lands on the label, which focuses the input. */
.f label::after { content: ""; position: absolute; inset: 0; }
.f label i { font-style: normal; color: var(--red); }

.f input, .f select {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  min-height: 34px;
  margin: 0;
  padding: 3px 0;
  border: 0;
  border-radius: 0;
  outline: none;
  background: transparent;
  color: var(--carbon);
  caret-color: var(--carbon);
  font: 700 17px/1.25 var(--hand);
  letter-spacing: .03em;
  text-transform: uppercase;
  -webkit-appearance: none;
  appearance: none;
}
.f input::placeholder {
  color: var(--grey);
  font: 400 13px/1.6 var(--mono);
  letter-spacing: 0;
  text-transform: none;
  opacity: 1;
}
.f input:-webkit-autofill {
  -webkit-text-fill-color: var(--carbon);
  box-shadow: 0 0 0 40px var(--paper) inset;
  transition: background-color 9999s;
}
.f input[readonly] { cursor: default; }
.f input.plain { text-transform: none; font-size: 15px; letter-spacing: .01em; }
.f input.digits { font-size: 24px; letter-spacing: .32em; font-variant-numeric: tabular-nums; }
.f select {
  padding-right: 24px;
  cursor: pointer;
  text-overflow: ellipsis;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23161616' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 4px center / 12px 8px;
}
.f select:invalid, .f select .ph { color: var(--grey); }
.f select option { color: var(--ink); font: 400 15px var(--mono); }

.f:focus-within { border-color: var(--carbon); box-shadow: 0 0 0 1px var(--carbon); }
.f.bad, .f.bad:focus-within { border-color: var(--red); box-shadow: 0 0 0 1px var(--red); }

.f .hint { margin: 0 0 4px; font: 400 12px/1.4 var(--mono); color: var(--grey); }
.f .err { margin: 2px 0 4px; font: 600 13px/1.35 var(--mono); color: var(--red); }
.f .err:empty { display: none; }
.f .stamp { margin: 2px 0 6px 2px; }

/* align-items: start: an error under one box must not stretch its neighbour. */
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 0 6px; }
.two.wide-left { grid-template-columns: minmax(0, 1fr) 7.6rem; }

/* ── Stamps ───────────────────────────────────────────────────────────── */

.stamp {
  display: inline-block;
  padding: 3px 6px;
  border: 2px solid var(--red);
  color: var(--red);
  font: 700 12px/1 var(--display);
  letter-spacing: .12em;
  text-transform: uppercase;
  transform: rotate(-6deg);
}
.stamp.big { padding: 7px 14px 6px; border-width: 3px; font-size: 28px; letter-spacing: .14em; }
.stamp.press { animation: press .55s var(--ease) both; }
@keyframes press {
  from { opacity: .3; transform: rotate(-13deg) scale(1.7); filter: blur(1.5px); }
  to { opacity: 1; transform: rotate(-6deg) scale(1); filter: blur(0); }
}
.c.me.fresh::after { transform-origin: left center; animation: strike .5s .3s var(--ease) both; }
@keyframes strike { from { transform: rotate(-20deg) scaleX(0); } to { transform: rotate(-20deg) scaleX(1); } }

/* ── Messages, notes, records ─────────────────────────────────────────── */

.msg { margin: 0 0 10px; font: 500 13px/1.45 var(--mono); }
.msg.bad { padding: 8px 10px; border: 1.5px solid var(--red); background: var(--paper); color: var(--red); font-weight: 600; }
.msg.note { padding: 8px 10px; border: 1.5px solid var(--ink); background: var(--paper); }
.msg.ok { padding: 8px 10px; border: 1px solid var(--hair); background: var(--paper); }

.tip { margin: 6px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--grey); }
.tip b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.record { margin: 0 0 6px; padding: 10px; border: 1px solid var(--hair); background: var(--paper); }
.record p { margin: 0; }
.record .who { font: 700 17px/1.4 var(--hand); color: var(--carbon); letter-spacing: .02em; overflow-wrap: anywhere; }
.record .ask { margin-top: 8px; font: 600 13px/1.2 var(--display); letter-spacing: .06em; text-transform: uppercase; }

.ts { min-height: 65px; margin: 4px 0 2px; }

/* The review sheet and the received stub list the fields the way the field boxes do, read-only. */
.sheet { margin: 0; padding: 0; border: 1px solid var(--hair); background: var(--paper); }
.sheet > div { position: relative; padding: 6px 8px 7px calc(2.2rem + 14px); border-top: 1px dashed var(--hair); }
.sheet > div:first-child { border-top: 0; }
.sheet .code { position: absolute; left: 8px; top: 8px; font: 600 12px/1.2 var(--mono); color: var(--red); }
.sheet dt { font: 600 13px/1.15 var(--display); letter-spacing: .06em; text-transform: uppercase; }
.sheet dd { margin: 3px 0 0; font: 700 17px/1.35 var(--hand); color: var(--carbon); letter-spacing: .02em; overflow-wrap: anywhere; }
.sheet dd.plain { font-size: 15px; letter-spacing: .01em; }
.sheet dd.blank { font: 400 13px/1.5 var(--mono); color: var(--grey); letter-spacing: 0; }
.sheet dd .stamp { margin-left: 8px; vertical-align: 1px; }

.rx-stamp { margin: 2px 0 12px; text-align: center; }

/* ── Stub: barcode and the ink button ─────────────────────────────────── */

.stub {
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin: 10px -12px 0;
  padding: 10px 12px 0;
  border-top: 2px dashed var(--hair);
}
.bars { flex: 0 0 36%; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bars svg { display: block; flex: 1; width: 100%; min-height: 34px; fill: var(--ink); }
.bars span { overflow: hidden; font: 500 9.5px/1 var(--mono); letter-spacing: .02em; white-space: nowrap; }

.btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
  padding: 12px 14px;
  border: 0;
  border-radius: 0;
  background: var(--ink);
  color: var(--news);
  font: 700 16px/1 var(--display);
  letter-spacing: .06em;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color .15s ease-out;
}
.btn svg { flex: none; width: 24px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.btn:hover { background: #2E2E2E; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--carbon); outline-offset: 3px; }
.btn:disabled { background: rgba(22, 22, 22, .6); cursor: progress; }

.links { display: flex; flex-wrap: wrap; align-items: center; gap: 0 20px; margin-top: 4px; }
.link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: 500 13px/1.3 var(--mono);
  text-align: left;
  text-decoration: underline 1px;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link:hover { text-decoration-thickness: 2px; }
.link:focus-visible { outline: 2px solid var(--carbon); outline-offset: 2px; }
.link:disabled { color: var(--grey); cursor: progress; }

/* ── Footer ───────────────────────────────────────────────────────────── */

.foot { margin-top: 14px; font-size: 12.5px; line-height: 1.5; color: var(--grey); }
.foot p { margin: 0; }
.foot .who { margin-top: 6px; overflow-wrap: anywhere; }
.foot .link { font-size: 12.5px; color: var(--ink); }

/* ── The PG Section-only page (locked.html) ───────────────────────────── */

.locked .coupon { margin-top: 18px; }
.locked .msg { margin: 0; font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
