/* Birth Receipt — style.css */
:root {
  --paper: #f4efe4;
  --paper-edge: #e6dfd0;
  --ink: #2b2622;
  --ink-faded: rgba(43, 38, 34, 0.84);
  --ink-bold: rgba(43, 38, 34, 0.95);
  --ink-small: rgba(43, 38, 34, 0.72);
  --counter: #1b2a26;
  --counter-glow: #26433b;
  --chrome: #ece7db;
  --chrome-dim: rgba(236, 231, 219, 0.7);
  --line: rgba(236, 231, 219, 0.22);
  --focus: #ffd66b;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* 40 columns at 0.6em per character = 24em; 72px = 2 × 16px gutters + 2 × 20px paper padding */
  --receipt-fs: clamp(11px, calc((100vw - 72px) / 24), 14px);
  --paper-pad: 20px;
}
@media (max-width: 340px) {
  /* 40 columns at the 11px floor need 264px; keep them inside a 320px screen */
  :root { --receipt-fs: 11px; --paper-pad: 12px; }
}

* { box-sizing: border-box; }
html { background: var(--counter); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.5;
  color: var(--chrome);
  background: radial-gradient(ellipse 80% 40% at 50% 28%, var(--counter-glow), transparent 72%) no-repeat, var(--counter);
  padding: max(28px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(40px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
[hidden] { display: none !important; }

.counter { max-width: 480px; margin: 0 auto; }
.register h1 { margin: 0 0 6px; font-size: 24px; font-weight: 600; line-height: 1.2; }
.tagline { margin: 0 0 22px; color: var(--chrome-dim); font-size: 14px; }

/* form */
.keypad { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--chrome-dim); }
.field--name { grid-column: 1 / -1; }
.field em { font-style: normal; opacity: 0.8; }
select, input[type="text"] {
  width: 100%;
  min-height: 46px;
  margin: 0;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px; /* keeps iOS Safari from zooming on focus */
  color: var(--chrome);
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 6px;
  appearance: none;
  -webkit-appearance: none;
}
select {
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23ece7db' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
select:invalid { color: var(--chrome-dim); }
select option { color: #111; background: #fff; }
input::placeholder { color: rgba(236, 231, 219, 0.45); }

.key {
  grid-column: 1 / -1;
  min-height: 48px;
  padding: 10px 16px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.key:active:not(:disabled) { transform: translateY(1px); }
.key:disabled { opacity: 0.45; cursor: default; }
.key--ghost { background: transparent; color: var(--chrome); border: 1px solid var(--line); font-weight: 400; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* receipt */
.slot { margin-top: 30px; }
.paper {
  width: calc(40ch + 2 * var(--paper-pad));
  max-width: 100%;
  margin: 0 auto;
  font-size: var(--receipt-fs);
  filter: drop-shadow(0 16px 28px rgba(0, 0, 0, 0.45));
}
.tear { height: 10px; background-repeat: repeat-x; background-size: 20px 10px; }
.tear-top { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='10' viewBox='0 0 20 10'%3E%3Cpath d='M0 10L10 0l10 10z' fill='%23f4efe4'/%3E%3C/svg%3E"); }
.tear-bottom { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='10' viewBox='0 0 20 10'%3E%3Cpath d='M0 0h20L10 10z' fill='%23f4efe4'/%3E%3C/svg%3E"); }
.receipt {
  min-height: 3em;
  padding: 14px var(--paper-pad) 18px;
  background: var(--paper);
  color: var(--ink-faded);
}
.ln { white-space: pre; line-height: 1.45; min-height: 1.45em; }
.ln.title { padding: 0.15em 0 0.25em; font-size: 1.6em; font-weight: 600; line-height: 1.3; text-align: center; color: var(--ink-bold); }
.ln.center, .ln.thanks, .ln.small, .ln.footer { text-align: center; }
.ln.small, .ln.footer { font-size: 0.85em; color: var(--ink-small); }
.ln.total, .ln.grand, .ln.thanks { font-weight: 600; color: var(--ink-bold); }
.ln.rule, .ln.double { color: var(--ink-small); }
.ln.barcode { padding: 0.35em 0 0.2em; }
.ln.barcode svg { display: block; width: 82%; height: 2.1em; margin: 0 auto; fill: var(--ink-bold); }
.barcode-label { padding-top: 0.25em; text-align: center; font-size: 0.85em; letter-spacing: 0.14em; color: var(--ink-small); }
.receipt[data-state="printing"] .ln { animation: ln-in 90ms ease-out; }
@keyframes ln-in { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }

/* actions */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 22px; }
.actions .key { grid-column: auto; }
.status { min-height: 1.5em; margin: 12px 0 0; text-align: center; font-size: 13px; color: var(--chrome-dim); overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) {
  .receipt[data-state="printing"] .ln { animation: none; }
  .key:active:not(:disabled) { transform: none; }
}
@media (min-width: 520px) {
  body { padding-top: 48px; }
  .register h1 { font-size: 26px; }
}
