/* factiv · Skin Formula — v0.4 "formula lab"
 * White carries the page; blue marks only what matters. The one bold element
 * on each screen is a product code set like the bottle label. One orchestrated
 * motion per screen: the hero code morphs between the six formulas, the quiz
 * writes an equation, the result sheet prints, the coupon is scratched open. */
@import url("./tokens.css");
@import url("./base.css");

#app {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
}
main {
  flex: 1;
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
}
body {
  font-feature-settings: "tnum" 1, "ss01" 1, "cv11" 1;
}
.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: var(--z-toast);
  background: var(--ink);
  color: var(--white);
  padding: 10px 14px;
}
.skip-link:focus {
  top: 12px;
}

/* ---------- header ---------- */
.site-header {
  height: var(--header-h);
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
}
.brand img {
  width: 92px;
  height: auto;
}
.header-nav {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-sm);
  color: var(--ink-2);
  transition: color var(--dur-micro);
}
.nav-link .icon {
  width: 14px;
  height: 14px;
}
.nav-link:hover {
  color: var(--blue);
}
.lang {
  display: flex;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 2px;
}
.lang button {
  min-width: 38px;
  min-height: 32px;
  padding: 0 8px;
  border-radius: 2px;
  font-size: var(--text-sm);
  color: var(--muted);
  transition:
    background var(--dur-micro),
    color var(--dur-micro);
}
.lang button:hover {
  color: var(--ink);
}
.lang button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--white);
}

/* ---------- shared bits ---------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 56px;
  padding: 0 26px;
  border-radius: 3px;
  font-size: var(--text-md);
  font-weight: 500;
  white-space: nowrap;
  transition:
    background var(--dur-short) var(--ease-out),
    color var(--dur-short) var(--ease-out),
    border-color var(--dur-short) var(--ease-out);
}
.button .icon {
  width: 20px;
  height: 20px;
  transition: transform var(--dur-short) var(--ease-out);
}
.button:hover:not(:disabled) .icon {
  transform: translateX(4px);
}
.button-primary {
  background: var(--blue);
  color: var(--white);
}
.button-primary:hover:not(:disabled) {
  background: var(--blue-deep);
}
.button-line {
  border: 1px solid var(--rule-strong);
  color: var(--ink);
  background: var(--sheet);
}
.button-line:hover:not(:disabled) {
  border-color: var(--ink);
}
.text-button,
.text-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: var(--text-sm);
  color: var(--ink-2);
  transition: color var(--dur-micro);
}
.text-button .icon,
.text-link .icon {
  width: 16px;
  height: 16px;
}
.text-button:hover,
.text-link:hover {
  color: var(--blue);
}

/* The product code, set like the bottle: heavy, tight, raised percentage. */
.code {
  display: inline-flex;
  align-items: flex-start;
  font-weight: 700;
  letter-spacing: var(--tracking-code);
  line-height: 0.8;
  color: var(--ink);
  white-space: nowrap;
}
.code sup {
  font-size: 0.2em;
  line-height: 1;
  letter-spacing: 0;
  color: var(--blue);
  margin: 0.06em 0 0 0.12em;
  vertical-align: baseline;
  position: static;
}
.label-list {
  display: grid;
  gap: 2px;
  font-size: var(--text-sm);
  color: var(--ink-2);
}
.label-list div:first-child dd {
  color: var(--ink);
  font-weight: 500;
}
.label-list dd {
  margin: 0;
}

/* ---------- home: hero ---------- */
.hero {
  min-height: calc(100svh - var(--header-h));
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: auto 1fr auto;
  column-gap: var(--space-lg);
  padding-top: clamp(24px, 5vh, 64px);
}
.hero-copy {
  grid-column: 1 / span 6;
  grid-row: 1;
  position: relative;
  z-index: 2;
}
.hero-title {
  font-size: var(--text-display);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: var(--tracking-display);
}
.hero-title span {
  display: block;
}
.hero-text {
  margin-top: var(--space-lg);
  max-width: 30em;
  color: var(--ink-2);
  font-size: var(--text-lg);
  line-height: 1.6;
}
.hero-actions {
  margin-top: var(--space-xl);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-md) var(--space-lg);
}
.hero-note {
  font-size: var(--text-sm);
  color: var(--muted);
}
.hero-meta {
  grid-column: 10 / span 3;
  grid-row: 1;
  align-self: start;
  padding-top: 10px;
  border-top: 1px solid var(--ink);
  position: relative;
  z-index: 2;
}
.hero-name {
  font-size: var(--text-sm);
  font-weight: 500;
  margin-bottom: var(--space-sm);
}
.hero-meta.is-swapping {
  animation: ink-in 520ms var(--ease-out);
}
.hero-stage {
  grid-column: 1 / -1;
  grid-row: 2;
  position: relative;
  min-height: clamp(300px, 46vh, 520px);
  display: flex;
  align-items: flex-end;
}
.bottles {
  position: absolute;
  right: 6%;
  bottom: 0;
  width: clamp(220px, 28vw, 400px);
  aspect-ratio: 1;
}
.bottle {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  opacity: 0;
  transform: translateY(18px) scale(0.98);
  transition:
    opacity 600ms var(--ease-out),
    transform 900ms var(--ease-out);
}
.bottle.is-active {
  opacity: 1;
  transform: none;
}
.hero-code {
  position: relative;
  z-index: 1;
  margin-left: -0.04em;
  font-size: var(--text-code);
  line-height: 0.8;
  padding-bottom: 0.04em;
}
.hero-code .code-chars {
  min-width: 2ch;
}

/* the six codes as a measuring scale */
.scale {
  grid-column: 1 / -1;
  grid-row: 3;
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-top: var(--space-lg);
  border-top: 1px solid var(--ink);
}
.scale-ticks {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 7px;
  background: repeating-linear-gradient(
    to right,
    var(--rule-strong) 0 1px,
    transparent 1px 100%
  );
  background-size: calc(100% / 60) 100%;
  pointer-events: none;
}
.scale button {
  position: relative;
  text-align: left;
  padding: 16px 0 22px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted);
  transition: color var(--dur-short);
}
.scale button::before {
  content: "";
  position: absolute;
  left: 0;
  top: -1px;
  width: 1px;
  height: 14px;
  background: var(--ink);
}
.scale button:hover,
.scale button.is-active {
  color: var(--ink);
}
.scale-fill {
  position: absolute;
  left: 0;
  right: 12px;
  top: -2px;
  height: 3px;
  background: var(--blue);
  transform-origin: left;
  transform: scaleX(0);
}
.scale button.is-active .scale-fill {
  animation: fill 3200ms linear forwards;
}
.scale.is-paused button.is-active .scale-fill {
  animation: none;
  transform: none;
}

/* ---------- home: needs + flow ---------- */
.needs,
.flow {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--space-lg);
  padding: var(--space-3xl) 0 0;
}
.needs-head {
  grid-column: 1 / span 4;
}
.needs-head h2,
.flow h2 {
  font-size: var(--text-title);
  font-weight: 700;
  line-height: 1.12;
}
.needs-head p {
  margin-top: var(--space-md);
  color: var(--muted);
}
.needs-list {
  grid-column: 6 / -1;
  border-top: 1px solid var(--ink);
}
.need {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 26px 4px;
  border-bottom: 1px solid var(--rule);
  font-size: var(--text-xl);
  font-weight: 500;
  letter-spacing: -0.01em;
  text-align: left;
  transition: color var(--dur-short) var(--ease-out);
}
.need::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--blue);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 520ms var(--ease-out);
}
.need .icon {
  color: var(--faint);
  transition:
    transform var(--dur-short) var(--ease-out),
    color var(--dur-short);
}
.need:hover {
  color: var(--blue);
}
.need:hover::after {
  transform: scaleX(1);
}
.need:hover .icon {
  color: var(--blue);
  transform: translateX(6px);
}
.flow {
  padding-bottom: var(--space-3xl);
}
.flow h2 {
  grid-column: 1 / -1;
  margin-bottom: var(--space-xl);
}
.flow-list {
  grid-column: 1 / -1;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-lg);
}
.flow-list li {
  display: grid;
  gap: 6px;
  padding-top: var(--space-md);
  border-top: 1px solid var(--rule-strong);
}
.flow-n {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--blue);
  margin-bottom: var(--space-lg);
}
.flow-list strong {
  font-size: var(--text-lg);
  font-weight: 700;
}
.flow-list li > span:last-child {
  color: var(--muted);
  font-size: var(--text-sm);
}

/* ---------- quiz ---------- */
.quiz-view {
  display: flex;
  flex-direction: column;
  min-height: calc(100svh - var(--header-h));
  padding-bottom: 0;
}
.quiz-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-sm) 0;
}
.progress {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.progress span {
  height: 2px;
  background: var(--rule);
  position: relative;
  overflow: hidden;
}
.progress span::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: left;
}
.progress .done::after {
  transform: none;
}
.progress .now::after {
  background: var(--blue);
  transform: none;
  animation: fill 700ms var(--ease-out);
}
.step-count {
  font-size: var(--text-sm);
  color: var(--muted);
}
.quiz-body {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--space-lg);
  align-content: center;
  padding: var(--space-2xl) 0;
}
.quiz-q {
  grid-column: 1 / span 5;
}
.quiz-q h1 {
  font-size: var(--text-display);
  font-weight: 700;
  line-height: 1.1;
}
.quiz-hint {
  margin-top: var(--space-md);
  color: var(--muted);
  font-size: var(--text-sm);
}
.options {
  grid-column: 7 / -1;
  border-top: 1px solid var(--ink);
}
.option {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: 44px 1fr 28px;
  align-items: center;
  gap: var(--space-md);
  padding: 22px 12px 22px 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  isolation: isolate;
  overflow: hidden;
  animation: ink-in 520ms var(--ease-out) backwards;
  animation-delay: calc(var(--i) * 60ms + 80ms);
}
.option::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--blue-wash);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 420ms var(--ease-out);
}
.option:hover:not(:disabled)::before {
  transform: scaleX(1);
}
.option-key {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  margin-left: 8px;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  font-size: var(--text-sm);
  color: var(--muted);
  transition: all var(--dur-short) var(--ease-out);
}
.option-copy {
  display: grid;
  gap: 2px;
}
.option-copy strong {
  font-size: var(--text-xl);
  font-weight: 500;
  letter-spacing: -0.01em;
}
.option-copy span {
  font-size: var(--text-sm);
  color: var(--muted);
}
.option-mark {
  color: var(--blue);
  opacity: 0;
  transform: scale(0.6);
  transition: all var(--dur-short) var(--ease-out);
}
.option.selected .option-key {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--white);
}
.option.selected .option-mark {
  opacity: 1;
  transform: none;
}
.option.just-picked::before {
  background: var(--blue);
  transform: scaleX(1);
}
.option.just-picked {
  color: var(--white);
  transition: color 300ms 120ms;
}
.option.just-picked .option-copy span {
  color: rgba(255, 255, 255, 0.75);
}
.option.just-picked .option-key {
  background: var(--white);
  color: var(--blue);
  border-color: var(--white);
}
.option.just-picked .option-mark {
  color: var(--white);
}
.option:disabled {
  opacity: 0.4;
  cursor: default;
}
.option.just-picked:disabled {
  opacity: 1;
}
.quiz-view.is-next .quiz-q h1 {
  animation: ink-in 520ms var(--ease-out);
}

/* the running equation */
.equation {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-md);
  padding: var(--space-lg) 0 var(--space-xl);
  border-top: 1px solid var(--rule);
}
.eq-term {
  display: grid;
  gap: 2px;
  min-width: 5.5em;
}
.eq-term small {
  font-size: var(--text-xs);
  color: var(--muted);
}
.eq-term b {
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--faint);
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--rule-strong);
}
.eq-term.is-current b {
  border-bottom: 1px solid var(--blue);
}
.eq-term.is-filled b {
  color: var(--ink);
  border-bottom: 1px solid var(--ink);
  animation: ink-in 420ms var(--ease-out);
}
.eq-op {
  font-size: var(--text-xl);
  color: var(--faint);
  padding-bottom: 6px;
}
.eq-result {
  font-size: var(--text-title);
  font-weight: 700;
  line-height: 1;
  color: var(--blue);
  padding-bottom: 2px;
}

/* ---------- result: formula sheet ---------- */
.result-view {
  padding-top: var(--space-xl);
  padding-bottom: var(--space-3xl);
}
.result-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--space-lg);
  align-items: start;
}
.sheet-wrap {
  grid-column: 1 / span 7;
  position: relative;
}
.printer-slot {
  display: block;
  height: 8px;
  margin: 0 -14px;
  border-radius: 4px;
  background: var(--ink);
  opacity: 0;
  transition: opacity 400ms;
}
.sheet {
  position: relative;
  background: var(--sheet);
  padding: clamp(24px, 4vw, 48px);
  box-shadow:
    0 1px 0 var(--rule),
    0 40px 80px -40px rgba(16, 24, 32, 0.22);
}
.sheet-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-lg);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--ink);
}
.sheet-head img {
  width: 72px;
  height: auto;
}
.sheet-title {
  font-size: var(--text-sm);
  font-weight: 500;
  flex: 1;
}
.sheet-id {
  display: flex;
  gap: var(--space-lg);
  font-size: var(--text-xs);
}
.sheet-id div {
  display: flex;
  gap: 6px;
}
.sheet-id dt {
  color: var(--muted);
}
.sheet-id dd {
  margin: 0;
  font-weight: 500;
}
.sheet-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sheet-rows li {
  display: grid;
  grid-template-columns: 6.5em 1fr auto;
  align-items: baseline;
  gap: var(--space-md);
  padding: 16px 0;
  border-bottom: 1px solid var(--rule);
}
.row-k {
  font-size: var(--text-sm);
  color: var(--muted);
}
.row-v {
  font-size: var(--text-lg);
  font-weight: 500;
}
.row-edit {
  font-size: var(--text-xs);
  color: var(--muted);
  padding: 4px 0 4px 12px;
  transition: color var(--dur-micro);
}
.row-edit:hover {
  color: var(--blue);
}
.sheet-sum {
  display: grid;
  grid-template-columns: 6.5em 1fr;
  gap: var(--space-md);
  padding: var(--space-xl) 0 var(--space-lg);
}
.sheet-eq {
  font-size: var(--text-title);
  line-height: 1;
  color: var(--faint);
  padding-top: 0.15em;
}
.sheet-product {
  display: grid;
  gap: var(--space-md);
}
.sheet-code {
  font-size: clamp(4.5rem, 10.5vw, 9rem);
}
.sheet-name {
  font-size: var(--text-xl);
  font-weight: 500;
  letter-spacing: -0.01em;
}
.sheet-label {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px var(--space-lg);
  margin-left: calc(6.5em + var(--space-md));
  padding: var(--space-md) 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-size: var(--text-xs);
}
.sheet-focus {
  margin: var(--space-lg) 0 0 calc(6.5em + var(--space-md));
  padding-right: 130px;
  min-height: 72px;
  color: var(--ink-2);
  max-width: 40em;
}
.stamp {
  position: absolute;
  right: clamp(20px, 5%, 48px);
  bottom: clamp(20px, 4%, 40px);
  width: 116px;
  height: 116px;
  border-radius: 50%;
  border: 2px solid var(--blue);
  box-shadow: inset 0 0 0 5px var(--sheet), inset 0 0 0 6px var(--blue);
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--blue);
  transform: rotate(-12deg);
  mix-blend-mode: multiply;
  pointer-events: none;
}
.stamp span {
  font-size: var(--text-xs);
  font-weight: 500;
}
.stamp b {
  font-size: 1.375rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.print-status {
  min-height: 1.5em;
  margin-top: var(--space-sm);
  font-size: var(--text-xs);
  color: var(--muted);
}

.result-side {
  grid-column: 9 / -1;
  display: grid;
  gap: var(--space-lg);
  padding-top: var(--space-sm);
}
.result-bottle img {
  width: auto;
  max-width: 100%;
  height: clamp(180px, 20vw, 260px);
  object-fit: contain;
  object-position: left bottom;
}
.result-desc {
  font-size: var(--text-lg);
  line-height: 1.55;
}
.claim {
  width: 100%;
  justify-content: space-between;
}
.why {
  padding-top: var(--space-lg);
  border-top: 1px solid var(--rule);
}
.why h2,
.facts dt {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}
.why p {
  margin-top: var(--space-xs);
  color: var(--ink-2);
}
.facts {
  display: grid;
  border-top: 1px solid var(--rule);
}
.facts div {
  display: grid;
  grid-template-columns: 7em 1fr;
  gap: var(--space-md);
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
  font-size: var(--text-sm);
}
.facts dd {
  margin: 0;
}
.result-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-sm);
}

/* printing sequence (first visit only) */
.is-printing .sheet-wrap {
  clip-path: inset(0 -60px -120px -60px);
}
.is-printing .printer-slot {
  opacity: 1;
  position: relative;
  z-index: 3;
}
.is-printing .sheet {
  animation: feed 1700ms cubic-bezier(0.45, 0, 0.15, 1) both;
}
.is-printing .sheet-head,
.is-printing .sheet-rows li,
.is-printing .sheet-eq,
.is-printing .sheet-name,
.is-printing .sheet-label,
.is-printing .sheet-focus {
  animation: ink-in 500ms var(--ease-out) both;
}
.is-printing .sheet-head {
  animation-delay: 250ms;
}
.is-printing .sheet-rows li {
  animation-delay: calc(450ms + var(--row) * 160ms);
}
.is-printing .sheet-eq {
  animation-delay: 950ms;
}
.is-printing .sheet-name {
  animation-delay: 1500ms;
}
.is-printing .sheet-label {
  animation-delay: 1650ms;
}
.is-printing .sheet-focus {
  animation-delay: 1800ms;
}
.is-printing .stamp {
  opacity: 0;
}
.is-printed .stamp {
  animation: stamp 420ms cubic-bezier(0.3, 1.6, 0.5, 1) both;
}
.is-printed .printer-slot {
  opacity: 0;
}
.is-printing .result-side {
  animation: ink-in 700ms var(--ease-out) 1900ms both;
}

/* ---------- coupon ---------- */
.card-view {
  padding-top: var(--space-lg);
  padding-bottom: var(--space-3xl);
}
.card-layout {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  grid-template-areas:
    "head ticket"
    "actions ticket";
  grid-template-rows: auto 1fr;
  column-gap: clamp(32px, 7vw, 120px);
  align-items: start;
}
.card-head {
  grid-area: head;
  padding-top: var(--space-xl);
}
.card-head h1 {
  margin-top: var(--space-xl);
  font-size: var(--text-display);
  font-weight: 700;
  line-height: 1.08;
}
.card-head p {
  margin-top: var(--space-md);
  color: var(--ink-2);
}
.card-actions {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm) var(--space-md);
  margin-top: var(--space-xl);
}
.ticket {
  grid-area: ticket;
  position: relative;
  width: 100%;
  max-width: 540px;
  justify-self: end;
  background: var(--sheet);
  padding: clamp(22px, 3.5vw, 36px);
  box-shadow:
    0 1px 0 var(--rule),
    0 40px 80px -40px rgba(16, 24, 32, 0.22);
}
.ticket-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--ink);
  font-size: var(--text-sm);
  color: var(--ink-2);
}
.ticket-logo {
  width: 72px;
  height: auto;
}
.ticket-product {
  display: grid;
  grid-template-columns: 1fr 42%;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg) 0 var(--space-md);
}
.ticket-id {
  display: grid;
  gap: 6px;
}
.ticket-code {
  font-size: clamp(3.5rem, 8vw, 5.5rem);
  margin-bottom: var(--space-sm);
}
.ticket-name {
  font-weight: 500;
}
.ticket-active {
  font-size: var(--text-xs);
  color: var(--muted);
}
.ticket-bottle {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  object-position: center bottom;
}
.ticket-cut {
  position: relative;
  height: 0;
  margin: var(--space-sm) calc(clamp(22px, 3.5vw, 36px) * -1);
  border-top: 2px dashed var(--rule);
}
.ticket-cut::before,
.ticket-cut::after {
  content: "";
  position: absolute;
  top: -15px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--paper);
}
.ticket-cut::before {
  left: -14px;
}
.ticket-cut::after {
  right: -14px;
}
.ticket-prize {
  position: relative;
  min-height: 176px;
  margin: var(--space-lg) 0 var(--space-md);
  display: grid;
  align-items: center;
}
.prize {
  display: grid;
  gap: var(--space-sm);
}
.prize-value {
  font-size: clamp(3.75rem, 8vw, 5.75rem);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: var(--tracking-code);
  color: var(--blue);
}
.prize-code {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
}
.prize-code small {
  font-size: var(--text-xs);
  color: var(--muted);
}
.prize-code b {
  font-size: var(--text-xl);
  letter-spacing: 0.02em;
}
.scratch {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 2px;
  cursor: crosshair;
  touch-action: none;
  transition: opacity 500ms var(--ease-out);
}
.ticket.is-revealed .scratch {
  opacity: 0;
  pointer-events: none;
}
.scratch-alt {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  padding: 6px 10px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.85);
  font-size: var(--text-xs);
  color: var(--ink-2);
}
.scratch-alt:hover {
  color: var(--blue);
}
.just-revealed .prize-value {
  animation: stamp 520ms cubic-bezier(0.3, 1.6, 0.5, 1) 120ms both;
}
.ticket-terms {
  margin: 0;
  padding: var(--space-md) 0 0;
  border-top: 1px solid var(--rule);
  list-style: none;
  display: grid;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--ink-2);
}
.ticket-terms li {
  padding-left: 14px;
  position: relative;
}
.ticket-terms li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.7em;
  width: 6px;
  height: 1px;
  background: var(--muted);
}
.ticket-note {
  margin-top: var(--space-md);
  font-size: var(--text-xs);
  color: var(--sale);
}

/* ---------- footer & toast ---------- */
.site-footer {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-lg);
  padding: var(--space-lg) var(--gutter);
  font-size: var(--text-xs);
  color: var(--muted);
}
.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.footer-link:hover {
  color: var(--blue);
}
.footer-link .icon {
  width: 14px;
  height: 14px;
}
body[data-view="quiz"] .site-footer {
  display: none;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: var(--z-toast);
  transform: translate(-50%, calc(100% + 48px));
  visibility: hidden;
  padding: 12px 20px;
  border-radius: 3px;
  background: var(--ink);
  color: var(--white);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: transform var(--dur-short) var(--ease-out);
  pointer-events: none;
}
.toast.is-visible {
  visibility: visible;
  transform: translate(-50%, 0);
}

/* ---------- motion ---------- */
@keyframes ink-in {
  from {
    opacity: 0;
    filter: blur(3px);
    transform: translateY(6px);
  }
}
@keyframes fill {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}
@keyframes feed {
  from {
    transform: translateY(-101%);
  }
}
@keyframes stamp {
  from {
    opacity: 0;
    transform: rotate(-4deg) scale(1.9);
  }
}
.home-view .hero-copy,
.home-view .hero-meta,
.home-view .scale {
  animation: ink-in 800ms var(--ease-out) both;
}
.home-view .hero-meta {
  animation-delay: 150ms;
}
.home-view .hero-stage {
  animation: rise-code 1100ms var(--ease-out) 120ms both;
}
.home-view .scale {
  animation-delay: 380ms;
}
@keyframes rise-code {
  from {
    opacity: 0;
    clip-path: inset(100% 0 0 0);
    transform: translateY(40px);
  }
  to {
    clip-path: inset(-20% -10% -20% -10%);
  }
}

/* ---------- responsive ---------- */
@media (max-width: 1040px) {
  .hero-copy {
    grid-column: 1 / span 8;
  }
  .hero-meta {
    grid-column: 9 / -1;
  }
  .sheet-wrap {
    grid-column: 1 / span 7;
  }
  .result-side {
    grid-column: 8 / -1;
  }
}
@media (max-width: 860px) {
  :root {
    --header-h: 60px;
    --space-3xl: 88px;
  }
  .nav-link {
    display: none;
  }
  .hero {
    min-height: 0;
    grid-template-rows: auto;
    row-gap: var(--space-xl);
    padding-top: var(--space-lg);
  }
  .hero-copy,
  .hero-meta,
  .hero-stage,
  .scale {
    grid-column: 1 / -1;
    grid-row: auto;
  }
  .hero-meta {
    order: 3;
  }
  .hero-stage {
    order: 2;
    min-height: 0;
    padding-top: 50vw;
  }
  .scale {
    order: 4;
    margin-top: 0;
  }
  .bottles {
    right: 4%;
    top: 0;
    bottom: auto;
    width: 58vw;
  }
  .hero-code {
    font-size: clamp(5.5rem, 27vw, 9rem);
  }
  .scale {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .scale-ticks {
    display: none;
  }
  .scale button {
    padding: 12px 0 14px;
    border-top: 1px solid var(--rule);
  }
  .needs-head,
  .needs-list,
  .quiz-q,
  .options,
  .sheet-wrap,
  .result-side {
    grid-column: 1 / -1;
  }
  .needs-list {
    margin-top: var(--space-xl);
  }
  .flow-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: var(--space-xl);
  }
  .quiz-body {
    align-content: start;
    padding: var(--space-xl) 0;
    row-gap: var(--space-xl);
  }
  .equation {
    position: sticky;
    bottom: 0;
    background: var(--paper);
    padding: var(--space-md) 0 var(--space-lg);
    gap: 6px 10px;
  }
  .eq-term {
    min-width: 0;
  }
  .eq-term b {
    font-size: var(--text-sm);
  }
  .eq-op {
    font-size: var(--text-md);
  }
  .eq-result {
    font-size: var(--text-xl);
  }
  .result-view {
    padding-top: var(--space-md);
  }
  .result-side {
    margin-top: var(--space-xl);
  }
  .result-bottle {
    display: none;
  }
  .claim {
    position: sticky;
    bottom: 12px;
    z-index: 5;
    box-shadow: 0 10px 30px -10px rgba(15, 79, 130, 0.6);
  }
  .card-layout {
    grid-template-columns: 1fr;
    grid-template-areas: "head" "ticket" "actions";
  }
  .card-head {
    padding-top: 0;
    margin-bottom: var(--space-xl);
  }
  .card-head h1 {
    margin-top: var(--space-lg);
  }
  .ticket {
    justify-self: center;
  }
}
@media (max-width: 560px) {
  .sheet-rows li {
    grid-template-columns: 4.5em 1fr auto;
  }
  .sheet-sum {
    grid-template-columns: 1fr;
    gap: var(--space-xs);
  }
  .sheet-eq {
    font-size: var(--text-xl);
  }
  .sheet-label,
  .sheet-focus {
    margin-left: 0;
  }
  .stamp {
    width: 92px;
    height: 92px;
  }
  .sheet-focus {
    padding-right: 100px;
  }
  .stamp b {
    font-size: 1.05rem;
  }
  .sheet-id {
    width: 100%;
    justify-content: space-between;
  }
  .card-actions .button {
    flex: 1 1 100%;
  }
  .flow-list {
    grid-template-columns: 1fr;
  }
  .hero-actions .button {
    width: 100%;
    justify-content: space-between;
  }
}
@media (prefers-reduced-motion: reduce) {
  .is-printing .sheet,
  .home-view .hero-stage {
    animation: none;
  }
}
