/* ============================================================================
   Visin — shared stylesheet for the four share-page templates
   (recipe / training plan / workout routine / interval). Consumes the design
   tokens from /assets/tokens.css (linked before this file by every template).
   Colour identity is driven by <body data-accent="…"> → var(--accent).
   ============================================================================ */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.page-bg {
  position: fixed;
  inset: 0;
  background: var(--paper);
  z-index: -1;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 22px 16px 64px;
}

/* ── Icons ──────────────────────────────────────────────────────────────── */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1em;
  height: 1em;
  /* Text glyphs used as icons (+ / − stepper) would otherwise keep the
     inherited line-height and overflow the 1em box downwards. */
  line-height: 1;
}
.icon svg { width: 100%; height: 100%; display: block; }

/* ── Page title ─────────────────────────────────────────────────────────── */
h1 {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  margin: 0;
  line-height: 1.12;
  letter-spacing: -0.015em;
  color: var(--ink);
}
/* Per-content-type display personality (the one place type varies per page).
   Recipes and plans read as editorial italics; the two workout pages stay
   upright and heavier, which suits a list you scan mid-set. */
[data-accent="recipe"] h1,
[data-accent="plan"] h1 { font-style: italic; font-weight: 600; }
[data-accent="routine"] h1,
[data-accent="interval"] h1 { font-weight: 700; letter-spacing: -0.02em; }

/* ── Language switch (server-rendered ?lang= links, see web-common.js) ──── */
.lang-switch {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin: 0 2px 10px;
}
.lang-option {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-decoration: none;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sharp);
  padding: 5px 9px;
  line-height: 1;
  transition: color .15s, border-color .15s, background .15s;
}
.lang-option:hover { color: var(--accent); border-color: var(--accent); }
.lang-option.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.lang-option.is-active:hover { color: var(--accent-ink); }

/* ── Servings stepper ───────────────────────────────────────────────────── */
.servings {
  display: flex; align-items: center; justify-content: space-between;
  background: none; border: none; border-radius: 0;
  padding: 4px 2px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 14px;
}
.servings-controls {
  display: inline-flex; align-items: stretch; gap: 0;
  border: 1px solid var(--border); border-radius: var(--r-sharp);
  overflow: hidden; background: var(--surface);
}
.servings-button {
  border: none; box-shadow: none; width: 44px; height: 44px;
  background: transparent; color: var(--accent);
  font-size: 18px; font-weight: 600; cursor: pointer;
  display: grid; place-items: center; transition: background .15s;
}
.servings-button:hover { background: var(--accent-tint); }
.servings-value {
  min-width: 44px; display: grid; place-items: center; text-align: center;
  font-family: var(--font-mono); font-weight: 600; font-size: 15px;
  border-left: 1px solid var(--border); border-right: 1px solid var(--border);
}

/* ── Ingredient amounts & thumbnails (recipe card) ──────────────────────── */
.ingredient-thumb, .ingredient-thumb-placeholder { width: 34px; height: 34px; border-radius: var(--r-sharp); flex-shrink: 0; }
.ingredient-thumb { object-fit: cover; }
.ingredient-thumb-placeholder { background: var(--surface-alt); color: var(--accent); display: grid; place-items: center; }
.ing-ph-icon { width: 15px; height: 15px; opacity: 0.7; }
.amount { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); font-size: 13px; }
.item { color: var(--ink); font-weight: 500; }

/* ── Footer helper text ─────────────────────────────────────────────────── */
.already-installed { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.already-installed .app-open-link { margin-left: 4px; }

/* ── Official-style store badges ────────────────────────────────────────── */
.store-badges { display: flex; gap: 10px; flex-wrap: wrap; }
/* One install element per platform (html class set by script.js; without JS
   both badges stay visible and the QR stays hidden — the pre-JS default). */
html.ua-ios .store-badge[data-tp-store="playstore"],
html.ua-android .store-badge[data-tp-store="appstore"],
html.ua-desktop .store-badge { display: none; }
.store-qr { display: none; }
html.ua-desktop .store-qr {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
}

/* ── Official-style store badges ────────────────────────────────────────── */
.store-qr-code {
  width: 96px;
  height: 96px;
  padding: 6px;
  background: #fff; /* scan contrast — deliberately theme-independent */
  border: 1px solid var(--border);
  border-radius: var(--r-sharp);
  flex-shrink: 0;
  box-sizing: border-box;
}
.store-qr-code img { width: 100%; height: 100%; display: block; }
.store-qr-caption {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  max-width: 24ch;
}
.store-qr-links { font-size: 12px; }
.store-qr-links a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.store-qr-links a:hover { border-color: var(--accent); }
.store-badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: #000;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 8px;
  padding: 8px 15px;
  min-height: 48px;
  text-decoration: none;
  box-sizing: border-box;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  transition: background .15s ease, transform .15s ease;
}
.store-badge:hover { background: #1a1a1a; transform: translateY(-1px); }
.store-badge .sb-logo { width: 22px; height: 22px; flex-shrink: 0; }
.store-badge .sb-text { display: flex; flex-direction: column; line-height: 1.05; }
.sb-pre { font-size: 9px; font-weight: 500; letter-spacing: .01em; opacity: .92; }
.sb-name { font-size: 17px; font-weight: 600; letter-spacing: .01em; }

/* Secondary "open in app" link under the badges */
.app-open-link {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
}
.app-open-link:hover { color: var(--accent); border-color: var(--accent); }

/* ══ Share card (all four share pages — print-like centred layout) ════════
   Shared skeleton: head, facts band, headings, leader rows, label box and
   footer. Page-specific content lives in rx-* (exercises), pc-* (plan days)
   and iv-* (interval time bar) below. Everything tokens-based so light and
   dark both resolve; the double rules deliberately use --ink (they are part
   of the typographic voice, not hairline chrome). ═══════════════════════ */
.rc {
  max-width: 712px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.rc-hero {
  align-self: center;
  width: min(560px, 100%);
  height: 360px;
  object-fit: cover;
  border-radius: 280px 280px 12px 12px;
}
.rc-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.rc-kicker {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
.rc-head h1 { font-size: clamp(28px, 6vw, 42px); }
.rc-rating { display: flex; align-items: center; gap: 8px; }
.rc-stars { display: flex; gap: 2px; align-items: center; color: var(--accent); }
.rc-stars svg { display: block; }
.rc-rating-value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  color: var(--accent);
}
.rc-rating-count { font-size: 12px; color: var(--muted); }
.rc-ornament { width: 44px; border-top: 2px solid var(--accent); margin-top: 4px; }

/* Double rule — standalone divider, or the frame of the facts band. */
.rc-dbl-top { border-top: 2px solid var(--ink); padding-top: 3px; }
.rc-dbl-top > div { border-top: 1px solid var(--ink); }
.rc-dbl-bottom { border-bottom: 2px solid var(--ink); padding-bottom: 3px; }
.rc-dbl-bottom > div { border-bottom: 1px solid var(--ink); }
.rc-band-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px 34px;
  padding: 12px 6px;
}
.rc-fact { display: flex; align-items: baseline; gap: 8px; }
.rc-fact-label {
  font-size: 9.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
}
.rc-fact-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
}
.rc-desc {
  margin: 0;
  align-self: center;
  max-width: 520px;
  text-align: center;
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--muted);
}

/* ── Ingredients & steps columns ── */
.rc-columns { display: flex; flex-direction: column; gap: 28px; }
.rc-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.rc-heading { display: flex; align-items: center; gap: 12px; }
.rc-heading h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 21px;
  color: var(--ink);
}
.rc-heading-rule { flex-grow: 1; border-top: 1px solid var(--border); }
/* Neutralise the generic .servings container inside the heading row and
   compact the (shared) stepper controls to heading height. */
.rc-servings { padding: 0; border-bottom: 0; flex-shrink: 0; }
.rc-servings .servings-button { width: 34px; height: 34px; font-size: 16px; }
.rc-servings .servings-value { min-width: 36px; font-size: 13px; }

.rc-ingredients { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 13px; }
.rc-ing { display: flex; align-items: baseline; }
.rc-ing .item { font-size: 14.5px; }
.rc-leader {
  flex-grow: 1;
  border-bottom: 1.5px dotted color-mix(in srgb, var(--muted) 45%, transparent);
  margin: 0 8px 4px;
}
.rc-ing.has-thumb { align-items: center; }
.rc-ing .ingredient-thumb,
.rc-ing .ingredient-thumb-placeholder { width: 26px; height: 26px; border-radius: 50%; margin-right: 10px; }
.rc-ing.has-thumb .rc-leader { margin-bottom: 0; }

.rc-steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 16px; }
.rc-step { display: flex; gap: 12px; }
.rc-num {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: 19px;
  line-height: 1.4;
  color: var(--accent);
  flex-shrink: 0;
}
.rc-step-text { font-size: 14.5px; line-height: 1.68; min-width: 0; }

/* ── Nutrition label box ── */
.rc-label {
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  background: var(--surface);
  padding: 16px 20px 12px;
}
.rc-label h3 {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  color: var(--ink);
  padding-bottom: 8px;
  border-bottom: 3px solid var(--ink);
}
.rc-label-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 13.5px; }
.rc-label-row + .rc-label-row { border-top: 1px solid var(--border); }
.rc-label-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 13px;
}
.rc-label-note { margin: 8px 0 0; font-size: 10.5px; color: var(--muted); }

/* ── Footer (install CTA) ── */
.rc-footer {
  border-top: 1px solid var(--border);
  padding-top: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.rc-footer h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  color: var(--ink);
}
.rc-footer .store-badges { justify-content: center; }

/* Lede under the title — states the one thing the page must get across
   (for plans: that the day list is a loop, not a schedule). */
.rc-lede {
  margin: 0;
  max-width: 46ch;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--muted);
}
.rc-section { display: flex; flex-direction: column; gap: 18px; }
/* Quiet chips under the header (routine muscle groups). */
.rc-tags { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.rc-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--r-sharp);
  padding: 5px 10px;
}

/* ── Exercise rows (routine page + plan day sections) ───────────────────── */
.rx-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 15px; }
.rx-item { display: flex; align-items: center; gap: 12px; }
.rx-thumb {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  place-items: center;
}
.rx-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rx-thumb--empty { background: color-mix(in srgb, var(--accent) 9%, transparent); color: var(--accent); }
.rx-thumb-fallback {
  width: 100%;
  height: 100%;
  place-items: center;
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  color: var(--accent);
}
.rx-thumb-icon { width: 18px; height: 18px; display: block; }
.rx-name { font-size: 14.5px; font-weight: 500; color: var(--ink); }
.rx-leader {
  flex-grow: 1;
  border-bottom: 1.5px dotted color-mix(in srgb, var(--muted) 45%, transparent);
  margin: 0 8px 4px;
}
.rx-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--accent);
  flex-shrink: 0;
}
.rx-empty { font-size: 14px; color: var(--muted); font-style: italic; }
/* Supersets are performed as one unit — the bracket says so without a legend. */
.rx-superset {
  border-left: 2px solid var(--accent);
  padding-left: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.rx-superset-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
}
.rx-superset-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }

/* ── Plan: the cycle of days ────────────────────────────────────────────── */
.pc-days { display: flex; flex-direction: column; gap: 26px; }
.pc-day { display: flex; flex-direction: column; gap: 14px; }
.pc-day-head { margin: 0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pc-day-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  flex-shrink: 0;
}
.pc-day-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  color: var(--ink);
  min-width: 0;
}
.pc-day-rule { flex-grow: 1; border-top: 1px solid var(--border); }
.pc-day-dur {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  flex-shrink: 0;
}
.pc-ex-list { display: flex; flex-direction: column; gap: 13px; }
/* A rest day is part of the plan, so it is listed — just quietly. */
.pc-day--rest .pc-day-name { font-style: italic; font-weight: 500; font-size: 16px; color: var(--muted); }
.pc-day--rest .pc-day-num { color: var(--muted); }
.pc-day-empty { margin: 0; font-size: 13.5px; font-style: italic; color: var(--muted); }
.pc-empty { margin: 0; font-size: 14px; color: var(--muted); font-style: italic; }
.pc-cycle-text {
  margin: 0;
  padding: 12px 6px;
  /* Without this the line breaks into a "… BEI / TAG 1" orphan at 390px. */
  text-wrap: balance;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}
.pc-cycle-icon { width: 15px; height: 15px; flex-shrink: 0; color: var(--accent); }
.pc-cycle-icon svg { width: 100%; height: 100%; display: block; }

/* ── Interval: the cycle as a proportional time bar ─────────────────────── */
.iv-bar { margin: 0; display: flex; flex-direction: column; gap: 9px; }
.iv-track {
  display: flex;
  height: 26px;
  border-radius: 6px;
  overflow: hidden;
  /* Transparent on purpose: the segments always fill the track, and a tinted
     track would composite under the pale rest segments so the legend swatch
     (which sits on the page background) could never match them. */
  background: transparent;
}
.iv-seg { background: var(--accent); }
/* Rest reads as absence of work — same hue, far less ink. */
.iv-seg--rest { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.iv-scale {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--muted);
}
/* The middle cell carries a duration ("4m 40s"); uppercasing it would render
   "4M 40S", so only the label part is set in caps. */
.iv-scale-label { text-transform: uppercase; }
.iv-legend { display: flex; justify-content: center; gap: 18px; }
.iv-key { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.iv-swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); flex-shrink: 0; }
.iv-swatch--rest { background: color-mix(in srgb, var(--accent) 20%, transparent); }

.iv-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 13px; }
.iv-block { display: flex; align-items: center; gap: 12px; }
.iv-block-name {
  width: 40%;
  max-width: 200px;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.iv-mini {
  flex-grow: 1;
  height: 8px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  overflow: hidden;
}
.iv-mini-fill { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.iv-block-time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--accent);
  width: 46px;
  text-align: right;
  flex-shrink: 0;
}
.iv-block--rest .iv-block-name { font-weight: 400; font-style: italic; font-size: 12.5px; color: var(--muted); }
.iv-block--rest .iv-mini-fill { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.iv-block--rest .iv-block-time { color: var(--muted); font-weight: 500; }
.iv-empty { font-size: 14px; color: var(--muted); font-style: italic; }

@media (max-width: 600px) {
  .pc-cycle-text { letter-spacing: 0.06em; }
  .iv-block-name { width: 34%; }
  .rx-thumb { width: 36px; height: 36px; }
  .pc-days { gap: 22px; }
}

@media (min-width: 700px) {
  .rc-columns {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 44px;
  }
}
@media (max-width: 600px) {
  .rc-hero { height: 280px; border-radius: 170px 170px 10px 10px; }
  .rc-band-row { gap: 10px 22px; }
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (min-width: 860px) {
  .page { padding-top: 32px; }
}
@media (max-width: 600px) {
  .rc-footer .store-badge { flex: 1 1 200px; justify-content: center; }
}

/* ── Reduced motion: honour the user's OS setting (WCAG 2.3.3 / EAA) ─────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
