/* Kudaro — Phase 4 loyalty tap prototype.
   Direction B (the punch card as a paper object) carrying Direction A's
   left-aligned typographic discipline and restrained rules.
   Every value below is a UI-SPEC token or a value from the 4px spacing scale. */

/* Alexandria, latin subset, variable 300–900. Self-hosted inside this flow as a
   standalone stand-in for the build-time next/font pipeline. */
@font-face {
  font-family: 'Alexandria';
  font-style: normal;
  font-weight: 300 900;
  font-display: block;
  src: url('fonts/alexandria-latin-var.woff2') format('woff2-variations');
}

:root {
  /* Surfaces */
  --warm-white: #faf8f5;
  --paper: #ffffff;
  --sand: #f3efe9;
  --ink: #111111;

  /* Text */
  --text-body: var(--ink);
  --gray-1: #5c5750;              /* 6.75:1 on warm white */
  --text-muted: var(--gray-1);
  --text-on-ink: var(--warm-white);

  /* Accent — exactly one non-text element per screen */
  --terracotta: #c05f3c;

  /* Error */
  --clay: #9e3b2b;

  /* Lines. Linen and stone are decorative only; anything that bounds a control
     uses an existing high-contrast token rather than a new low-contrast one. */
  --line-hairline: #ebe5dc;       /* linen */
  --line-stone: #d9d2c7;          /* stone */
  --border-control: var(--gray-1);
  --line-focus: var(--ink);
  --focus-halo: 0 0 0 var(--space-1) rgba(192, 95, 60, 0.30);

  /* Type */
  --font-sans: Alexandria, sans-serif;
  --text-hero: 44px;
  --text-display: 34px;
  --text-title: 26px;
  --text-subhead: 17px;
  --text-body-lg: 17px;
  --text-body-md: 15px;
  --text-body-sm: 13px;
  --text-caption: 12px;

  /* Spacing — the 4px scale */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-9: 40px;
  --space-10: 48px;
  --space-12: 64px;
  --space-20: 80px;

  --gutter: var(--space-5);
  --stack-tight: var(--space-3);
  --stack: var(--space-5);
  --stack-loose: var(--space-8);
  --section: var(--space-9);
  --tap-min: var(--space-10);
  --tap-primary: 60px;

  /* Shape */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --shadow-xs: 0 1px 2px rgba(17, 17, 17, 0.05);

  /* Motion */
  --dur-instant: 90ms;
  --dur-fast: 150ms;
  --dur-slow: 360ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.3, 1);
  --ease-settle: cubic-bezier(0.16, 1, 0.3, 1);
  --press-scale: 0.985;

  --screen-max: 430px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

/* No capture-only width override exists any more. The 500px-minimum-window
   workaround this rule used to serve was a headed-Chrome constraint that does
   not apply to headless Chrome; captures now set the real CSS viewport, so the
   layout under test is governed by the viewport alone. */

body {
  margin: 0;
  background: var(--warm-white);
  color: var(--text-body);
  font-family: var(--font-sans);
  font-size: var(--text-body-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, p, fieldset { margin: 0; padding: 0; }
fieldset { border: 0; min-width: 0; }

/* D-022: titles are fixed interface typography, not selectable content. Scope
   this narrowly so useful copy and every form/control retain native selection,
   focus, editing, and touch behavior. */
.screen h1,
.screen h2,
.screen .biz {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.screen {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  width: 100%;
  max-width: var(--screen-max);
  margin: 0 auto;
  padding: 0 var(--gutter) var(--space-12);
}
.screen[hidden] { display: none; }

/* Merchant identity stays at the top. The founder-supplied product wordmark is
   a quiet footer signature on every state, using the canonical shipping SVG. */
.top {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding-top: var(--space-8);
}
.biz {
  font-size: var(--text-body-sm);
  font-weight: 500;
  color: var(--text-muted);
}
.wordmark {
  position: absolute;
  left: 50%;
  bottom: var(--space-5);
  width: 74px;
  height: 14px;
  overflow: hidden;
  transform: translateX(-50%);
  background-image: url('../../../assets/brand/kudaro-wordmark.min.svg');
  background-repeat: no-repeat;
  background-position: center 48%;
  background-size: 84px auto;
  mix-blend-mode: multiply;
  opacity: 0.56;
  color: transparent;
  font-size: 0;
  line-height: 0;
  pointer-events: none;
}

.flow { padding-top: var(--space-4); }

/* Short states are composed rather than clustered at the top: the result group
   is dropped to an optical resting position using scale values, not ornament. */
.screen--short .flow { padding-top: var(--space-20); }

/* Reward redemption is a page takeover, not a modal. The customer hands this
   same screen to an employee before the irreversible button is pressed. */
.screen--takeover {
  position: relative;
  overflow: hidden;
}
.takeover {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: var(--space-8);
  padding-bottom: var(--space-8);
}
.takeover--center { min-height: 70dvh; }
.redeem-summary {
  background: var(--paper);
  border: 1px solid var(--line-stone);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  margin-top: var(--space-8);
  padding: var(--space-5);
}
.redeem-summary__label {
  color: var(--text-muted);
  font-size: var(--text-body-sm);
}
.redeem-summary__reward {
  font-size: var(--text-title);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: var(--space-1) 0;
}
.redeem-warning {
  color: var(--clay);
  font-size: var(--text-body-sm);
  font-weight: 500;
  margin-top: var(--space-5);
}
.redeemed-result {
  position: relative;
  z-index: 3;
}
.redeemed-result [role="status"] {
  animation: celebration-rise 620ms var(--ease-settle) both;
}

/* D-016's narrow celebration exception: finite, decorative and pointer-inert. */
.confetti {
  position: absolute;
  top: var(--space-20);
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  width: 100%;
  height: auto;
  pointer-events: none;
}

@keyframes celebration-rise {
  from { transform: translateY(14px) scale(0.96); opacity: 1; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.vh {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --- Type roles --------------------------------------------------------- */

.hero {
  font-size: var(--text-hero);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -0.025em;
}
.hero--stamp { font-size: 38px; }
.display {
  font-size: var(--text-display);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.02em;
}
.lede {
  font-size: var(--text-body-md);
  color: var(--ink);
  margin-top: var(--space-3);
  max-width: 34ch;
}
.step {
  font-size: var(--text-body-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.rule { height: 1px; background: var(--line-hairline); border: 0; margin: 0; }

/* --- The punch card: rendered only where loyalty exists ----------------- */

.card {
  background: var(--paper);
  border: 1px solid var(--line-stone);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: var(--space-4);
  margin-top: var(--space-5);
}
.card__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
}
.card__grid .mark {
  aspect-ratio: 1;
  width: 100%;
  max-width: 54px;
  justify-self: center;
  border-radius: var(--radius-pill);
}
.card__count {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.card__n {
  font-size: var(--text-title);
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.card__reward {
  font-size: var(--text-body-sm);
  color: var(--text-muted);
  text-align: right;
}

/* Compact earned proof for task, recovery, and review-handoff screens */
.punchline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  margin-top: var(--space-4);
}
.punchline__row { display: flex; gap: var(--space-1); }
.punchline__row .mark {
  width: 11px;
  height: 11px;
  border-radius: var(--radius-pill);
}
.punchline__txt { font-size: var(--text-body-sm); color: var(--text-muted); }
.punchline__txt strong { font-weight: 600; color: var(--ink); }

.mark {
  display: block;
  border: 1.5px solid var(--border-control);
  background: transparent;
}
.mark--on {
  background: color-mix(in srgb, var(--terracotta) 78%, var(--paper));
  border-color: color-mix(in srgb, var(--terracotta) 78%, var(--paper));
}
.mark--today {
  background: var(--terracotta);
  border-color: var(--terracotta);
  animation: kudaro-punch-pop var(--dur-slow) var(--ease-settle) var(--dur-fast) both;
}

@keyframes kudaro-punch-pop {
  from { transform: scale(0.72); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

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

.btn {
  font-family: var(--font-sans);
  font-size: var(--text-body-lg);
  font-weight: 500;
  line-height: 1;
  border-radius: var(--radius-md);
  border: 1.5px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  padding: 0 var(--space-5);
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    transform var(--dur-instant) var(--ease-out);
}
.btn:active { transform: scale(var(--press-scale)); }

.btn--primary {
  background: var(--ink);
  color: var(--text-on-ink);
  min-height: var(--tap-primary);
  width: 100%;
  margin-top: var(--space-3);
}
/* A primary that follows the statement directly needs room to breathe. */
.hero + .btn--primary,
.display + .btn--primary,
.card + .btn--primary { margin-top: var(--space-8); }

.btn--secondary {
  background: var(--paper);
  border-color: var(--border-control);
  color: var(--ink);
  font-size: var(--text-body-md);
}
.btn--secondary:hover { border-color: var(--ink); }

.btn--quiet {
  background: transparent;
  border-color: transparent;
  color: var(--ink);
  font-size: var(--text-body-md);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0 var(--space-2);
}
.btn--quiet:active { transform: none; }

/* Pending keeps the ink pairing (17.81:1). Greying the fill dropped the label to
   3.31:1, and the changed label plus aria-busy already carry the state. */
.btn[disabled],
.btn[aria-busy="true"] {
  cursor: default;
  background: var(--ink);
  color: var(--text-on-ink);
}
.btn[disabled]:active { transform: none; }

:focus-visible {
  outline: 2px solid var(--line-focus);
  outline-offset: 2px;
  box-shadow: var(--focus-halo);
}

.quiet-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-3);
  margin-left: calc(-1 * var(--space-2));
}

/* --- Fields ------------------------------------------------------------- */

.field { margin-top: var(--space-5); }
.field__label {
  display: block;
  font-size: var(--text-body-sm);
  font-weight: 500;
  color: var(--ink);
  margin-bottom: var(--space-2);
}
.field__input {
  width: 100%;
  min-height: var(--tap-primary);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-control);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-body-lg);
  padding: 0 var(--space-4);
}
.field__input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}
.field__input:focus::placeholder { color: transparent; }
.field__input:hover { border-color: var(--ink); }
.field__input[aria-invalid="true"] { border-color: var(--clay); border-width: 2px; }

.field__error {
  display: block;
  font-size: var(--text-body-sm);
  color: var(--clay);
  margin-top: var(--space-2);
}

/* Consent — never prechecked. The whole row is the label, so the target is the
   full 48px+ row rather than the 24px box alone. */
.consent {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-top: var(--space-5);
  min-height: var(--tap-min);
  padding: var(--space-1) 0;
  font-size: var(--text-body-md);
  color: var(--ink);
  cursor: pointer;
}
.consent input {
  flex: none;
  width: 24px;
  height: 24px;
  margin: var(--space-1) 0 0;
  accent-color: var(--ink);
}

/* --- Status messages ---------------------------------------------------- */

.status {
  font-size: var(--text-body-md);
  margin-top: var(--space-3);
}
.status--error { color: var(--clay); }
.status--note { color: var(--text-muted); }
.status:empty { display: none; }

/* --- Association and task groups ---------------------------------------- */

.assoc { margin-top: var(--space-8); }
.assoc .lede { margin-top: 0; }

.task { margin-top: var(--space-8); }
.punchline + .rule { margin-top: var(--space-4); }

/* --- Optional Google review, structurally separate ---------------------- */

.review { margin-top: var(--section); }
.review .rule { margin-bottom: var(--space-4); }
.review__h {
  font-size: var(--text-subhead);
  font-weight: 500;
  line-height: 1.35;
}
.review__note {
  font-size: var(--text-body-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}
.review__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

/* --- Loading ------------------------------------------------------------ */

.skeleton {
  background: var(--sand);
  border-radius: var(--radius-lg);
  animation: kudaro-skeleton var(--dur-slow) var(--ease-out) infinite;
}
.skeleton--card { height: 168px; margin-top: var(--space-5); }

@keyframes kudaro-skeleton {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* --- Prototype state navigation (never product UI, never captured) ------ */

.proto-toggle {
  position: fixed;
  right: var(--space-3);
  bottom: var(--space-3);
  z-index: 40;
  min-height: var(--tap-min);
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: var(--text-on-ink);
  font-family: var(--font-sans);
  font-size: var(--text-body-sm);
  font-weight: 500;
  padding: 0 var(--space-4);
  cursor: pointer;
}
.proto-panel {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 41;
  max-height: 72dvh;
  overflow: auto;
  background: var(--paper);
  border-top: 1px solid var(--border-control);
  padding: var(--space-4) var(--gutter) var(--space-20);
}
.proto-panel[hidden] { display: none; }
.proto-key {
  margin: 0 0 var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-body-sm);
}
.proto-key span {
  color: var(--accent);
  font-size: 1.2rem;
  font-weight: 600;
}
.proto-panel h2 {
  font-size: var(--text-body-sm);
  font-weight: 600;
  color: var(--text-muted);
  margin-top: var(--space-4);
}
.proto-panel a {
  display: flex;
  align-items: center;
  min-height: var(--tap-min);
  color: var(--ink);
  font-size: var(--text-body-md);
  text-decoration: none;
  border-bottom: 1px solid var(--line-hairline);
}
.proto-panel a[aria-current="page"] { font-weight: 600; }
.proto-panel a.proto-prune { color: var(--text-muted); }
.proto-prune__mark {
  flex: 0 0 auto;
  width: 1.25rem;
  color: var(--accent);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1;
}

@media (prefers-reduced-motion: reduce) {
  .confetti { display: none; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
