/* ============================================================================
   apple.css — the product-page chrome for /meal-tracker/v2.

   Modelled on apple.com/iphone-17-pro: a sticky product sub-nav with a pill CTA,
   chapters alternating #000 and #f5f5f7, one-line typographic statements set very
   large and very tight, a snap-scrolling highlights rail, collapsible FAQ, and
   superscript footnotes.

   The canvas is Apple's. The accent is NOT: it's #007AFF, the app's real
   appThemeHex (Theme/AppTheme.swift), so the page is coloured by the product it
   is selling rather than by Apple.

   Standalone on purpose -- this file does not load base.css, so v2 cannot
   regress v1 through a shared token.
   ========================================================================== */

:root {
  --ink:      #1d1d1f;   /* Apple's near-black text */
  --ink-dim:  #6e6e73;   /* Apple's secondary grey */
  --paper:    #f5f5f7;   /* Apple's light chapter */
  --white:    #ffffff;
  --black:    #000000;
  --on-black:     #f5f5f7;
  --on-black-dim: #86868b;

  --accent:   #007AFF;   /* the app's own */
  --hairline: #d2d2d7;

  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  --text:    -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --mono:    ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--white);
  color: var(--ink);
  font-family: var(--text);
  font-size: 17px;
  line-height: 1.47;
  -webkit-font-smoothing: antialiased;
}

.ap-wrap {
  max-width: 68rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}
.ap-narrow { max-width: 50rem; margin: 0 auto; }

/* ------------------------------------------------------------- sub-nav */
/* Apple keeps this a constant pale glass regardless of the chapter behind it. */

.ap-nav {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(250, 250, 252, .82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, .08);
}
.ap-nav-inner {
  max-width: 68rem;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.ap-nav-title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.ap-nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-left: auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.ap-nav-links::-webkit-scrollbar { display: none; }
.ap-nav-links a {
  font-size: .75rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  opacity: .85;
}
.ap-nav-links a:hover { opacity: 1; }

/* Apple's pill. 980px is their literal radius. */
.ap-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 980px;
  padding: .5rem 1.1rem;
  font-family: var(--text);
  font-size: .8125rem;
  font-weight: 400;
  white-space: nowrap;
  text-decoration: none;
  cursor: default;
}
.ap-btn--lg { padding: .8rem 1.6rem; font-size: 1.0625rem; }
.ap-btn--ghost {
  background: transparent;
  color: var(--accent);
  padding-left: 0;
  padding-right: 0;
}
.ap-btn--ghost:hover { text-decoration: underline; }

/* ----------------------------------------------------------- chapters */

.ap-ch {
  padding: 7.5rem 0;
  background: var(--white);
  color: var(--ink);
}
.ap-ch--paper { background: var(--paper); }
.ap-ch--black {
  background: var(--black);
  color: var(--on-black);
}
.ap-ch--black .ap-lede,
.ap-ch--black .ap-body { color: var(--on-black-dim); }
.ap-ch--tight { padding: 5rem 0; }

/* --------------------------------------------------------------- type */

.ap-eyebrow {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--accent);
  margin: 0 0 .5rem;
}

.ap-h1 {
  font-family: var(--display);
  font-size: clamp(2.75rem, 7vw, 5.5rem);
  line-height: 1.05;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0;
}

/* The statement: one line, set as large as it will go. Apple's whole page is
   punctuated by these, and they are the reason it feels like Apple. */
.ap-h2 {
  font-family: var(--display);
  font-size: clamp(2rem, 5vw, 3.75rem);
  line-height: 1.07;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 1.5rem;
  max-width: 20ch;
}
.ap-h2--center { max-width: 22ch; margin-left: auto; margin-right: auto; text-align: center; }

.ap-h3 {
  font-family: var(--display);
  font-size: clamp(1.375rem, 2.4vw, 1.75rem);
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 .625rem;
}

.ap-lede {
  font-size: clamp(1.125rem, 1.9vw, 1.4375rem);
  line-height: 1.4;
  font-weight: 400;
  color: var(--ink-dim);
  margin: 0;
  max-width: 40ch;
}
.ap-lede--center { margin-left: auto; margin-right: auto; text-align: center; }

.ap-body {
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--ink-dim);
  margin: 0 0 1rem;
  max-width: 42ch;
}

.ap-center { text-align: center; }

/* Footnote markers. Apple's are superscript links to the notes at the foot. */
sup.fn {
  font-size: .6em;
  vertical-align: super;
  line-height: 0;
}
sup.fn a {
  color: inherit;
  opacity: .55;
  text-decoration: none;
}
sup.fn a:hover { opacity: 1; text-decoration: underline; }

/* ----------------------------------------------------------- hero scrub */

.hero { padding-top: 4.5rem; }
.hero-copy { text-align: center; margin-bottom: 3rem; }

/* The phone stays put while the day fills in beside it. */
.scrub {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: start;
}
.scrub-phone {
  position: sticky;
  top: 5.5rem;
  display: flex;
  justify-content: center;
  padding-bottom: 2rem;
}
/* Sized so the last meal is ticked off just as the final caption reaches the
   middle of the screen -- any more tail than this and the reader scrolls
   through dead space with a finished phone. */
.scrub-steps { padding: 5rem 0 4rem; }
.scrub-step {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 32ch;
  opacity: .35;
  transition: opacity .4s ease;
}
.scrub-step.is-current { opacity: 1; }
.scrub-step .num {
  font-family: var(--mono);
  font-size: .75rem;
  letter-spacing: .1em;
  color: var(--accent);
  margin: 0 0 1rem;
}

/* ---------------------------------------------------- highlights rail */

.rail {
  display: flex;
  gap: 1.25rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  /* Bleed to the window edge like Apple's, but keep the first card aligned to
     the text column. */
  padding: .5rem max(1.5rem, calc((100vw - 68rem) / 2 + 1.5rem)) 2rem;
  margin: 0 calc(50% - 50vw);
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.rail::-webkit-scrollbar { display: none; }

.hcard {
  scroll-snap-align: center;
  flex: 0 0 auto;
  width: min(20rem, 78vw);
  min-height: 30rem;
  border-radius: 28px;
  background: var(--black);
  color: var(--on-black);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.hcard h3 {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin: 0;
}
.hcard h3 b { font-weight: 600; color: var(--accent); }
.hcard p {
  margin: .75rem 0 0;
  font-size: .9375rem;
  color: var(--on-black-dim);
}
.hcard .art {
  margin-top: auto;
  padding-top: 2rem;
  display: flex;
  justify-content: center;
}
.hcard .stat {
  font-family: var(--display);
  font-size: 3rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.rail-hint {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8125rem;
  color: var(--ink-dim);
  margin-top: .5rem;
}

/* ------------------------------------------------- palette configurator */

.cfg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
}
.cfg-phone { display: flex; justify-content: center; }

.swatches {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}

/* Each option is painted in its OWN scheme -- exactly how the app's picker
   does it (Features/Settings/ColorSchemeSettingsView.swift). */
.swatch {
  display: flex;
  align-items: center;
  gap: .75rem;
  text-align: left;
  padding: .75rem;
  border-radius: 18px;
  border: 1px solid var(--sw-border);
  background: var(--sw-ground);
  color: var(--sw-text1);
  font-family: var(--text);
  cursor: pointer;
  transition: border-color .2s ease, transform .2s ease;
}
.swatch:hover { transform: translateY(-1px); }
.swatch[aria-pressed="true"] {
  border-color: var(--accent);
  border-width: 1.5px;
  padding: calc(.75rem - .5px);
}
.swatch .mini {
  width: 46px; height: 46px;
  flex: none;
  border-radius: 9px;
  background: var(--sw-tile);
  border: 1px solid var(--sw-border);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
}
.swatch .mini .chip {
  width: 30px; height: 10px;
  border-radius: 3px;
  background: var(--sw-inner);
}
.swatch .mini .ln { height: 3px; border-radius: 999px; }
.swatch .mini .l1 { width: 22px; background: var(--sw-text1); }
.swatch .mini .l2 { width: 17px; background: var(--sw-text2); }
.swatch .mini .l3 { width: 12px; background: var(--sw-text3); }
.swatch .nm { font-size: .9375rem; font-weight: 600; letter-spacing: -0.01em; }
.swatch .sub {
  display: block;
  margin-top: .15rem;
  font-size: .75rem;
  color: var(--sw-text3);
}

/* --------------------------------------------------- macro configurator */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: center;
  margin-bottom: 3rem;
}
.chip-btn {
  border: 1px solid var(--hairline);
  background: transparent;
  color: var(--ink);
  border-radius: 980px;
  padding: .5rem 1rem;
  font-family: var(--text);
  font-size: .875rem;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.chip-btn:hover { border-color: var(--ink-dim); }
.chip-btn[aria-selected="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

/* The tile, lifted out of the phone and enlarged -- Apple's "here is the
   detail" move. */
.tile-stage {
  display: flex;
  justify-content: center;
  min-height: 15rem;
  align-items: center;
}
.tile-zoom {
  transform: scale(1.55);
  transform-origin: center;
}
.tile-zoom .tile { width: 330px; }

.style-name {
  margin-top: 4.5rem;
  text-align: center;
  font-size: .875rem;
  color: var(--ink-dim);
}
.style-name b { color: var(--ink); font-weight: 600; }

/* ------------------------------------------------------------ big number */

.count {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 4rem;
  align-items: center;
}
.numeral {
  font-family: var(--display);
  font-size: clamp(3.25rem, 9vw, 7rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.numeral-sub {
  margin: 1rem 0 2rem;
  font-family: var(--display);
  font-size: clamp(1.25rem, 2.4vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -0.015em;
}

/* The scan result, drawn as the app draws it. */
.scan {
  background: #171A1F;
  border: 1px solid #23262C;
  border-radius: 22px;
  padding: 1.25rem;
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  color: #F2F3F5;
  font-variant-numeric: tabular-nums;
  max-width: 22rem;
  margin-left: auto;
  box-shadow: 0 30px 60px -30px rgba(0,0,0,.8);
}
.scan .barcode { display: flex; align-items: flex-end; gap: 2px; height: 46px; margin-bottom: .875rem; }
.scan .barcode i {
  display: block; width: var(--w, 2px); height: 100%;
  background: #F2F3F5; border-radius: 1px; opacity: .9;
}
.scan .upc {
  font-family: var(--mono);
  font-size: .6875rem; letter-spacing: .12em;
  color: #7C828C; margin: 0 0 1rem;
}
.scan .brand {
  font-size: .625rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: #7C828C; margin: 0 0 .25rem;
}
.scan .food {
  font-size: 1.0625rem; font-weight: 800;
  letter-spacing: -0.02em; line-height: 1.2;
  margin: 0 0 .25rem;
}
.scan .serving { font-size: .75rem; color: #7C828C; margin: 0 0 1rem; }
.scan .nutrients {
  display: flex; justify-content: space-between;
  padding-top: 1rem; border-top: 1px solid #23262C;
}
.scan .n { text-align: center; }
.scan .n b { display: block; font-size: 1.0625rem; font-weight: 800; letter-spacing: -0.02em; }
.scan .n span {
  display: block; margin-top: .2rem;
  font-size: .5625rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: #7C828C;
}
.scan .offline {
  margin-top: 1rem;
  display: inline-flex; align-items: center; gap: .375rem;
  font-size: .6875rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  color: #5BD273;
  background: rgba(52,178,74,.16);
  border-radius: 999px;
  padding: .3rem .625rem;
}

/* ---------------------------------------------------------------- decks */

.deck {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.25rem;
}
.dcard {
  background: var(--white);
  border-radius: 28px;
  padding: 2rem;
}
.ap-ch--paper .dcard { background: var(--white); }
.ap-ch--black .dcard { background: #1d1d1f; }
.dcard .ic {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  margin-bottom: 1.25rem;
}
.dcard h3 {
  font-family: var(--display);
  font-size: 1.1875rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 .4rem;
}
.dcard p { margin: 0; font-size: .9375rem; line-height: 1.5; color: var(--ink-dim); }
.ap-ch--black .dcard p { color: var(--on-black-dim); }
.dcard .said {
  margin-top: .75rem;
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--ink-dim);
  border-left: 2px solid var(--hairline);
  padding-left: .625rem;
}

/* -------------------------------------------------------------- split */

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
}
.split.flip .split-art { order: -1; }
.split-art { display: flex; justify-content: center; }
.frag { transform: scale(1.25); transform-origin: center; }
.frag .tile { width: 330px; }
.fitlist { width: 330px; }

/* --------------------------------------------------------- home screen */

.homescreen {
  background:
    radial-gradient(120% 90% at 20% 0%, #2b3a4f 0%, transparent 60%),
    radial-gradient(100% 80% at 90% 30%, #3b2f4a 0%, transparent 55%),
    linear-gradient(170deg, #10151c, #05070a);
  border-radius: 34px;
  padding: 4rem 3rem;
  display: flex;
  justify-content: center;
  border: 1px solid #222930;
}

/* --------------------------------------------------------------- specs */

.specs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0;
  border-top: 1px solid var(--hairline);
}
.specs div {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--hairline);
  border-right: 1px solid var(--hairline);
}
.specs div:last-child { border-right: 0; }
.specs dt {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-dim);
  margin-bottom: .35rem;
}
.specs dd {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ----------------------------------------------------------------- faq */

.faq { border-top: 1px solid var(--hairline); }
.faq details { border-bottom: 1px solid var(--hairline); }
.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 0;
  cursor: pointer;
  font-family: var(--display);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "";
  width: 12px; height: 12px;
  flex: none;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(45deg);
  transition: transform .25s ease;
}
.faq details[open] summary::after { transform: rotate(-135deg); }
.faq .a {
  padding: 0 0 1.5rem;
  margin: 0;
  color: var(--ink-dim);
  max-width: 60ch;
}

/* --------------------------------------------------------- keep exploring */

.explore {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1.25rem;
}
.ecard {
  background: var(--white);
  border-radius: 28px;
  padding: 2rem;
  text-align: center;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.ecard .ic {
  width: 52px; height: 52px;
  border-radius: 13px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  margin-bottom: 1rem;
}
.ecard h3 {
  font-family: var(--display);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 .3rem;
}
.ecard p { margin: 0 0 1rem; font-size: .875rem; color: var(--ink-dim); }
.ecard .go { margin-top: auto; font-size: .875rem; color: var(--accent); }

/* --------------------------------------------------------------- notes */

.notes {
  background: var(--paper);
  padding: 2.5rem 0 4rem;
  font-size: .75rem;
  line-height: 1.5;
  color: var(--ink-dim);
}
.notes ol { margin: 0; padding-left: 1.1rem; }
.notes li { margin-bottom: .5rem; }
.notes li:target { color: var(--ink); font-weight: 600; }
.notes .foot {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
}
.notes .foot a { color: var(--ink-dim); }
.notes .foot .sp { margin-left: auto; }

/* ---------------------------------------------------- compare pill (TEMP) */
/* REVIEW ONLY -- lets Alex flip between the two designs. Delete before deploy. */

.compare {
  position: fixed;
  right: 1rem; bottom: 1rem;
  z-index: 70;
  display: flex;
  align-items: center;
  gap: .5rem;
  background: rgba(29,29,31,.9);
  backdrop-filter: blur(12px);
  color: #fff;
  border-radius: 980px;
  padding: .45rem .5rem .45rem .9rem;
  font-size: .75rem;
  box-shadow: 0 8px 24px -8px rgba(0,0,0,.5);
}
.compare a {
  color: #fff;
  background: rgba(255,255,255,.16);
  border-radius: 980px;
  padding: .25rem .7rem;
  text-decoration: none;
}
.compare a:hover { background: var(--accent); }

/* --------------------------------------------------------------- reveal */

@media (prefers-reduced-motion: no-preference) {
  .js-reveal [data-reveal] {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity .8s cubic-bezier(.2,.7,.3,1), transform .8s cubic-bezier(.2,.7,.3,1);
  }
  .js-reveal [data-reveal].is-in { opacity: 1; transform: none; }
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ----------------------------------------------------------- responsive */

@media (max-width: 62rem) {
  .ap-ch { padding: 4.5rem 0; }

  .scrub { grid-template-columns: 1fr; gap: 0; }
  .scrub-phone { position: static; }
  .scrub-steps { padding: 2rem 0 0; }
  .scrub-step { min-height: 0; padding: 2rem 0; max-width: none; opacity: 1; }

  .cfg { grid-template-columns: 1fr; gap: 2.5rem; }
  .count { grid-template-columns: 1fr; gap: 2.5rem; }
  .scan { margin: 0; }
  .split { grid-template-columns: 1fr; gap: 2.5rem; }
  .split.flip .split-art { order: 0; }

  .frag, .tile-zoom { transform: none; }
  .frag .tile, .fitlist, .tile-zoom .tile { width: min(330px, 100%); }
  .style-name { margin-top: 2rem; }

  .homescreen { padding: 2rem 1rem; border-radius: 24px; }
  .specs div { border-right: 0; }
}

@media (max-width: 40rem) {
  .swatches { grid-template-columns: 1fr; }
  .ap-nav-title { font-size: 1rem; }
}
