/* Receipts. Built from the Claude Design file "Receipts Redesign", direction 1a (brochure),
   in the Pass & Joyce design system: paper, ink and brass.
   Token names match the system's colors_and_type.css so the two stay comparable.
   Fonts are served from this app (not Google) because it has to open with no signal. */

@font-face { font-family: 'Playfair Display'; src: url('/fonts/playfair-display.woff2') format('woff2'); font-weight: 600 700; font-display: swap; }
@font-face { font-family: 'Manrope'; src: url('/fonts/manrope.woff2') format('woff2'); font-weight: 400 800; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('/fonts/jetbrains-mono.woff2') format('woff2'); font-weight: 400 700; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('/fonts/ibm-plex-sans-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('/fonts/ibm-plex-sans-400-italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  color-scheme: light;

  --paper-50: #fdfbf8;  --paper-100: #faf7f3; --paper-200: #f8f5f2;
  --paper-300: #efe9e0; --paper-400: #e2dacd; --paper-500: #cbc1b1;
  --ink-900: #14110f;   --ink-700: #2c2722;   --ink-600: #3d362f;  --ink-500: #5a5048;
  --ink-400: #7c7167;   --ink-300: #a0958a;   --ink-200: #c9bfb4;
  --brass-200: #d8c386; --brass-300: #c2a85e; --brass-400: #b08c3f; --brass-500: #8d6f2f; --brass-600: #6b5322;
  --verdigris-300: #7fa092; --verdigris-500: #3d6b5b;
  --oxblood-100: #ecd6d2; --oxblood-500: #8a3329;

  /* Status: done, waiting, failed. The -on-ink set is for the dark viewer. */
  --status-done: var(--verdigris-500);  --status-waiting: var(--brass-600);  --status-failed: var(--oxblood-500);

  --font-display: 'Playfair Display', 'Iowan Old Style', Garamond, serif;
  --font-wordmark: 'IBM Plex Sans', -apple-system, 'Segoe UI', sans-serif;
  --font-sans: 'Manrope', -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;

  --shadow-sm: 0 1px 2px rgba(20, 17, 15, 0.06);
  --shadow-md: 0 4px 12px -2px rgba(20, 17, 15, 0.10), 0 2px 4px -1px rgba(20, 17, 15, 0.06);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  --edge: 20px;                                           /* screen side padding */
  --foot: max(14px, env(safe-area-inset-bottom));         /* clears the home bar */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper-200); color: var(--ink-900);
  font: 500 16px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
::selection { background: var(--brass-200); color: var(--ink-900); }
p, h1 { margin: 0; }
button, label, a { touch-action: manipulation; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

:is(button, input, a):focus-visible,
input.visually-hidden:focus-visible + label { outline: 2px solid var(--brass-400); outline-offset: 2px; }

/* ---- shared parts ---- */

.wordmark { font-family: var(--font-wordmark); font-weight: 600; font-size: 15px; letter-spacing: -0.005em; color: var(--ink-900); }
.wordmark em { font-weight: 400; font-style: italic; color: var(--ink-400); margin: 0 0.15em; }
.wordmark.small { font-size: 11px; color: var(--ink-500); }
.wordmark.small em { margin: 0; }

.eyebrow { font-weight: 600; font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--brass-600); }
.sunburst { width: 220px; height: 22px; color: var(--brass-400); flex: none; }
.sunburst.small { width: 160px; height: 16px; }
.quiet { color: var(--ink-500); font-size: 14px; }
.error { color: var(--oxblood-500); font-weight: 600; font-size: 14px; line-height: 1.45; }

.primary {
  width: 100%; height: 56px; border: 1px solid var(--ink-900); border-radius: 0; background: var(--ink-900); color: var(--paper-100);
  font: 600 13px var(--font-sans); letter-spacing: 0.18em; text-transform: uppercase; cursor: pointer;
}
.primary:active, .shutter:active, .library:active { transform: translateY(1px); }
.primary:disabled { opacity: 0.4; cursor: not-allowed; }

.link {
  display: inline-flex; align-items: center;          /* so a link and a button sit on the same line */
  border: 0; background: none; padding: 10px 0; min-height: 44px; cursor: pointer;
  font: 500 14px var(--font-sans); color: var(--ink-900);
  text-decoration: underline; text-decoration-color: var(--brass-400); text-decoration-thickness: 1px; text-underline-offset: 4px;
}
.link:active { text-decoration-thickness: 2px; }
.link.on-ink { color: var(--paper-100); font-size: 15px; }
.link.on-ink.danger { color: var(--oxblood-100); text-decoration-color: var(--oxblood-500); }
.link.on-ink.danger[data-armed="1"] { color: var(--paper-100); background: var(--oxblood-500); text-decoration: none; padding: 10px 12px; }

.dot { width: 8px; height: 8px; border-radius: 999px; flex: none; background: currentColor; }

/* ---- the gate: opening, login, code, confirm. Centred like the site hero. ---- */

.gate {
  min-height: 100dvh; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 28px calc(20px + var(--foot));
}
.gate-hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 18px; padding-top: 40px; }
.gate-mark { width: 44px; height: 44px; object-fit: contain; }
.gate-mark.large { width: 64px; height: 64px; }
.gate-title { font-family: var(--font-display); font-weight: 700; font-size: 38px; line-height: 1.05; letter-spacing: -0.02em; }
.gate-title.large { font-size: 48px; line-height: 1; letter-spacing: -0.025em; }
.gate-lead { font-size: 16px; line-height: 1.55; color: var(--ink-600); max-width: 32ch; font-weight: 400; overflow-wrap: anywhere; }
.gate-lead strong { color: var(--ink-900); font-weight: 700; }
.gate-hero .error { font-size: 15px; line-height: 1.5; max-width: 32ch; }

.gate-form { display: flex; flex-direction: column; gap: 8px; padding-bottom: 16px; width: 100%; max-width: 420px; margin: 0 auto; }
.gate-form input {
  width: 100%; height: 54px; padding: 0 14px; border: 1px solid var(--ink-900); border-radius: 0; background: var(--paper-50);
  font: 500 17px var(--font-sans); color: var(--ink-900); appearance: none;
}
.gate-form input::placeholder { color: var(--ink-200); }
.gate-form input[aria-invalid="true"] { border-color: var(--oxblood-500); }
.gate-form .primary { margin-top: 8px; }
#code { font-family: var(--font-mono); font-size: 26px; letter-spacing: 0.28em; text-align: center; font-variant-numeric: tabular-nums; }
.gate-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 4px; }
.gate-note { font-size: 14px; line-height: 1.5; color: var(--ink-500); text-align: center; font-weight: 400; padding-top: 6px; }
.legal { text-align: center; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-400); }

/* ---- the app: header, scrolling roll, actions ---- */

.app { height: 100dvh; display: flex; flex-direction: column; position: relative; }

.bar { display: flex; align-items: flex-end; gap: 12px; padding: calc(14px + env(safe-area-inset-top)) var(--edge) 12px; border-bottom: 1px solid var(--ink-900); flex: none; }
.bar-mark { width: 34px; height: 34px; object-fit: contain; margin-bottom: 2px; flex: none; }
.bar-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.bar h1 { font-family: var(--font-display); font-weight: 700; font-size: 24px; line-height: 1; letter-spacing: -0.02em; }
.account {
  border: 0; border-bottom: 1px solid var(--brass-400); background: none; border-radius: 0; cursor: pointer;
  min-height: 44px; padding: 10px 0 4px; display: flex; align-items: flex-end;
  font: 500 14px var(--font-sans); color: var(--ink-700);
}
.account[aria-expanded="true"] { border-bottom-width: 2px; color: var(--ink-900); }

.menu {
  position: absolute; z-index: 6; right: var(--edge); top: calc(76px + env(safe-area-inset-top)); width: min(260px, calc(100% - 2 * var(--edge)));
  background: var(--paper-50); border: 1px solid var(--ink-900); box-shadow: var(--shadow-md); padding: 6px 0;
}
.menu-email {
  padding: 10px 16px 8px; border-bottom: 1px solid var(--paper-400); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-400);
}
.menu-note { padding: 12px 16px 4px; font-size: 13px; line-height: 1.45; color: var(--brass-600); }
.menu-item { display: block; width: 100%; border: 0; background: none; text-align: left; padding: 14px 16px; cursor: pointer; font: 600 14px var(--font-sans); color: var(--ink-900); }

.notice {
  flex: none; display: flex; gap: 10px; align-items: flex-start; padding: 10px var(--edge);
  background: var(--paper-300); border-bottom: 1px solid var(--paper-400);
  font-family: var(--font-mono); font-size: 12px; line-height: 1.45; color: var(--ink-700);
}
.notice::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: var(--brass-500); flex: none; margin-top: 5px; }

.scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0 var(--edge) 22px; -webkit-overflow-scrolling: touch; }

.roll {
  position: relative; max-width: 520px; margin: 0 auto; background: var(--paper-50);
  border-left: 1px solid var(--paper-400); border-right: 1px solid var(--paper-400);
  filter: drop-shadow(0 1px 2px rgba(20, 17, 15, 0.06));   /* follows the torn edge, a box-shadow would not */
}
/* Torn edge: one downward tooth per 20 x 12 tile, as in the design. */
.roll::after {
  content: ""; position: absolute; left: -1px; right: -1px; top: calc(100% - 1px); height: 13px;
  background: conic-gradient(from -37.57deg at 50% 100%, var(--paper-50) 75.14deg, transparent 0) 0 0 / 20px 13px repeat-x;
}

.group { padding: 6px 16px 0; }
.group.on-phone { background: var(--paper-300); padding: 12px 16px 4px; border-bottom: 1px dashed var(--brass-400); }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0 6px; }
.on-phone .group-head { padding: 0 0 8px; }
.group-head .eyebrow { white-space: nowrap; }
.group-head .link { font-weight: 600; font-size: 13px; padding: 4px 0; min-height: 32px; }
.group-rule { flex: 1; min-width: 0; height: 14px; color: var(--brass-400); }

.entries { list-style: none; margin: 0; padding: 0; }
.entries > li { border-top: 1px dashed var(--paper-500); }

.entry-open {
  display: flex; gap: 14px; align-items: flex-start; width: 100%; padding: 12px 0; border: 0; background: none;
  color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.on-phone .entry-open { padding: 10px 0 12px; }
.entry-open img, .tile { width: 52px; height: 66px; flex: none; border: 1px solid var(--ink-200); display: block; }
.entry-open img { object-fit: cover; background: var(--paper-300); }
.tile {
  display: flex; align-items: center; justify-content: center; background: var(--paper-300);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; color: var(--ink-900);
}
.entry-words { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; padding-top: 2px; }
.entry-when, .entry-name { font-family: var(--font-mono); font-size: 12px; color: var(--ink-500); font-variant-numeric: tabular-nums; }
.entry-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-what { font-weight: 600; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.entry-open .dot { margin-top: 8px; }
.tone-done { color: var(--status-done); }
.tone-waiting { color: var(--status-waiting); }
.tone-failed { color: var(--status-failed); }

/* A new line feeds in. Only ever plays in answer to adding a receipt. */
@keyframes feed { from { max-height: 0; opacity: 0.3; } to { max-height: 110px; opacity: 1; } }
.entries > li.fresh { overflow: hidden; animation: feed 360ms var(--ease-out); }
@media (prefers-reduced-motion: reduce) { .entries > li.fresh { animation: none; } }

.empty { padding: 40px 24px 28px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty p { font-size: 15px; line-height: 1.5; color: var(--ink-500); max-width: 26ch; font-weight: 400; }
.more { display: flex; margin: 0 auto; padding: 12px 0 6px; }

.actions { flex: none; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px var(--edge) calc(20px + var(--foot)); background: var(--paper-200); }
.shutter, .library {
  width: 100%; max-width: 480px; display: flex; align-items: center; justify-content: center; cursor: pointer;
  font-weight: 600; text-transform: uppercase; border: 1px solid var(--ink-900);
  user-select: none; -webkit-user-select: none;
}
.shutter {
  height: 72px; gap: 14px; background: var(--ink-900); color: var(--paper-100); font-size: 14px; letter-spacing: 0.18em;
  outline: 1px solid var(--brass-400); outline-offset: -6px;          /* the deco frame set inside the ink block */
}
.shutter svg { color: var(--brass-300); }
.library { height: 52px; background: transparent; color: var(--ink-900); font-size: 13px; letter-spacing: 0.16em; }
input.visually-hidden:focus-visible + .shutter { outline: 2px solid var(--brass-400); outline-offset: 2px; }

/* ---- viewer: dark, with the site's ink-panel footer ---- */

dialog#viewer { border: 0; padding: 0; margin: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; background: var(--ink-900); color: var(--paper-100); }
dialog#viewer[open] { display: flex; flex-direction: column; }
dialog#viewer::backdrop { background: var(--ink-900); }
.viewer-top {
  flex: none; display: flex; justify-content: space-between; gap: 16px; padding: calc(16px + env(safe-area-inset-top)) var(--edge) 0;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-300);
}
#viewer-kind { flex: none; }
#viewer-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 24px; }
#viewer-img { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.5); }
.stamp {
  width: 220px; aspect-ratio: 1 / 1.3; background: var(--paper-50); border: 3px double var(--ink-900); outline: 1px solid var(--paper-50);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
}
.stamp .eyebrow { font-size: 10px; }
.stamp-ext { font-family: var(--font-mono); font-size: 32px; letter-spacing: 0.12em; color: var(--ink-900); }
.viewer-foot { flex: none; border-top: 1px solid var(--brass-400); padding: 16px var(--edge) calc(20px + var(--foot)); display: flex; flex-direction: column; gap: 12px; }
.viewer-status { display: flex; gap: 10px; align-items: baseline; font-family: var(--font-mono); font-size: 13px; line-height: 1.45; color: var(--paper-100); }
.viewer-status .dot { transform: translateY(-1px); }
.viewer-status .tone-done { color: var(--verdigris-300); }
.viewer-status .tone-waiting { color: var(--brass-200); }
.viewer-status .tone-failed { color: var(--oxblood-100); }
.viewer-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
