/* Learning page sections under the hero: the train, the ask section, the ending. */
.learn, .ask, .join { position: relative; z-index: 1; overflow: hidden; background: var(--orbs), var(--black); }

/* ---- Learn with Vaibhav + the train ---- */
.learn { background-size: calc(100% * (1 + 0.3 * var(--depth, 0))) calc(100% * (1 + 0.3 * var(--depth, 0))), auto; background-position: center, center;
  min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; padding-bottom: var(--space-6); }
.learn__head { display: grid; justify-items: center; gap: var(--space-4); text-align: center; padding: calc(var(--nav-height) + var(--space-6)) var(--gutter) var(--space-5); }
.learn__head h2 { font-size: var(--text-title); }
.learn__subscribe { font-family: var(--font-title); font-weight: var(--weight-title); font-size: var(--text-label); letter-spacing: var(--tracking-label); text-transform: uppercase;
  text-decoration: none; padding: var(--space-3) var(--space-5); border-radius: 999px; border: 1.5px solid color-mix(in srgb, var(--ink) 55%, transparent); transition: background var(--dur-fast), border-color var(--dur-fast); }
.learn__subscribe:hover { background: color-mix(in srgb, var(--ink) 12%, transparent); border-color: var(--ink); }

/* The train: cards ride along a curve. JS sets each card's position, tilt and size. */
.train { --card-w: clamp(200px, 21vw, 300px); position: relative; flex: 1; min-height: calc(var(--card-w) * 2.2 + 3rem); overflow: hidden; }
.train__track { position: absolute; inset: 0; }
.train .card--poster { position: absolute; left: 0; top: 0; width: var(--card-w); will-change: transform, opacity; transition: none; }
.train__status { text-align: center; opacity: 0.7; margin: 0; padding-top: var(--space-6); }
@media (max-width: 600px) { .train { --card-w: 58vw; } }

/* Reduced motion: no ride, no scatter. A plain row you can swipe. */
.train--static { overflow-x: auto; scroll-snap-type: x mandatory; display: flex; align-items: center; }
.train--static .train__track { position: static; display: flex; gap: var(--space-4); padding: 0 var(--gutter); }
.train--static .card--poster { position: relative; flex: none; scroll-snap-align: center; transform: none !important; opacity: 1 !important; }

/* ---- Ask section: three columns on desktop (toggle + its text + question box | portrait with the mission | flip card) ---- */
.ask { padding: var(--space-7) var(--gutter); }
.ask__grid { width: min(100%, 1280px); margin: 0 auto; display: grid; align-items: center; gap: var(--space-6);
  grid-template-columns: minmax(0, 1fr) minmax(0, 2.1fr) minmax(0, 1.3fr); }
.ask__side { grid-column: 1; grid-row: 1; display: grid; gap: var(--space-5); justify-items: start; }
.ask__figure { grid-column: 2; grid-row: 1; position: relative; margin: 0; }
.flip { grid-column: 3; grid-row: 1; }

/* The photo is almost white, so its edges are faded into the dark section (no hard rectangle). */
.ask__figure img { width: 100%; height: auto; display: block; max-height: 86vh; object-fit: contain;
  -webkit-mask-image: linear-gradient(to right, transparent 0, rgba(0,0,0,.4) 11%, #000 24%, #000 76%, rgba(0,0,0,.4) 89%, transparent 100%), linear-gradient(to bottom, transparent 0, #000 7%, #000 62%, rgba(0,0,0,.45) 82%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent 0, rgba(0,0,0,.4) 11%, #000 24%, #000 76%, rgba(0,0,0,.4) 89%, transparent 100%), linear-gradient(to bottom, transparent 0, #000 7%, #000 62%, rgba(0,0,0,.45) 82%, transparent 100%);
  mask-composite: intersect; }

/* The mission sits in the light area of the photo, dark and a touch soft, blended in (multiply) so it feels printed on it.
   Same font, weight, colour, blur and position as the old question line. "Why share here?" keeps the old size;
   the sentence under it is one size smaller so the block stays above the head. */
body[data-chapter="learning"] .ask__figure .mission { position: absolute; left: 50%; top: 8%; width: 66%; transform: translateX(-50%); margin: 0; text-align: center;
  font-family: var(--font-title); font-weight: 500; line-height: 1.18; letter-spacing: 0; text-transform: none;
  color: var(--black); mix-blend-mode: multiply; filter: blur(0.5px); opacity: 0.9;
  text-shadow: 0 0 14px color-mix(in srgb, var(--white) 70%, transparent); }
body[data-chapter="learning"] .ask__figure .mission__label,
body[data-chapter="learning"] .ask__figure .mission__line { margin: 0; font: inherit; letter-spacing: 0; text-transform: none; }
body[data-chapter="learning"] .ask__figure .mission__label { font-size: clamp(1.2rem, 2.3vw, 2.2rem); }
body[data-chapter="learning"] .ask__figure .mission__line { margin-top: 0.4em; font-size: clamp(0.9rem, 1.45vw, 1.4rem); }

.ask__toggle { display: inline-flex; padding: 4px; border-radius: 999px; background: var(--glass-bg); border: 1px solid var(--glass-border); backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur)); }
.ask__toggle label { position: relative; cursor: pointer; }
.ask__toggle input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.ask__toggle span { display: block; padding: var(--space-2) var(--space-5); border-radius: 999px; font-family: var(--font-title); font-weight: var(--weight-title); font-size: var(--text-label); letter-spacing: var(--tracking-label); text-transform: uppercase; transition: background var(--dur-med) var(--ease), color var(--dur-med) var(--ease); }
.ask__toggle input:checked + span { background: var(--white); color: var(--black); }
.ask__toggle input:focus-visible + span { outline: 2px solid var(--glow); outline-offset: 2px; }

/* Toggle text: small, thin, wide uppercase lines with thin dividers. Both notes share one grid cell,
   so switching never moves the layout; the inactive one fades out, the active one fades in. */
.ask__notes { display: grid; width: 100%; }
.note { grid-area: 1 / 1; display: grid; gap: var(--space-3); align-content: start;
  transition: opacity var(--dur-med) var(--ease), transform var(--dur-med) var(--ease), visibility 0s; }
.ask__grid[data-visibility="Personal"] .note:not([data-note="Personal"]),
.ask__grid[data-visibility="Public"] .note:not([data-note="Public"]) { opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity var(--dur-med) var(--ease), transform var(--dur-med) var(--ease), visibility 0s linear var(--dur-med); }
.note p { margin: 0; font-family: var(--font-body); font-weight: 300; text-transform: uppercase; text-align: left; }
.note__head { padding-top: var(--space-3); border-top: 1px solid color-mix(in srgb, var(--ink) 35%, transparent); font-size: 0.8rem; letter-spacing: 0.24em; line-height: 1.5; }
.note__line { font-size: 0.74rem; letter-spacing: 0.02em; line-height: 1.6; opacity: 0.85; }
.note__fact { padding-top: var(--space-3); border-top: 1px solid color-mix(in srgb, var(--ink) 18%, transparent); font-size: 0.66rem; letter-spacing: 0.02em; line-height: 1.6; color: color-mix(in srgb, var(--ink) 65%, transparent); border-top-color: color-mix(in srgb, var(--ink) 12%, transparent); }
.note__fact a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; white-space: nowrap; transition: opacity var(--dur-fast); }
.note__fact a:hover { opacity: 0.75; }

/* Highlighter (Personal fact line): a marker swipe behind the words. Slanted, slightly uneven ends and a
   lighter streak along the top and bottom edges, with a soft yellow glow. Text on top stays dark.
   ask.js adds .hl-pending, then removes it the first time the line is on screen, so the swipe draws in
   left to right once. Without JS, or with reduce motion, it is simply there. */
.hl { --hl: color-mix(in srgb, var(--marker) 85%, transparent); --hl-soft: color-mix(in srgb, var(--marker) 55%, transparent);
  color: var(--navy); padding: 0.1em 0.3em; margin-inline: -0.12em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  border-radius: 0.4em 0.15em 0.45em 0.2em / 0.7em 0.35em 0.6em 0.3em;
  background-color: transparent; background-repeat: no-repeat;
  background-image: linear-gradient(97deg, transparent 0 0.12em, var(--hl) 0.3em calc(100% - 0.25em), transparent calc(100% - 0.05em)),
                    linear-gradient(var(--hl-soft), var(--hl-soft)),
                    linear-gradient(var(--hl-soft), var(--hl-soft));
  background-size: 100% 76%, 94% 16%, 88% 14%;
  background-position: 0 55%, 0.2em 4%, 0.35em 98%;
  box-shadow: 0 0 0.75em 0.05em color-mix(in srgb, var(--marker) 35%, transparent); }
/* First reveal: swipe, then the glow. The link draws after the first highlight. */
.note__fact .hl { transition: background-size 0.9s var(--ease) 0.25s, color 0.9s var(--ease) 0.25s, box-shadow 0.5s ease 0.9s; }
.note__fact .hl--link { transition-delay: 0.75s, 0.75s, 1.4s; }
/* Before the swipe, the words keep the line's normal colour (dark text would vanish on the dark page). */
.hl-pending .hl { background-size: 0% 76%, 0% 16%, 0% 14%; box-shadow: 0 0 0 0 transparent; color: inherit; }
/* After that (ask.js adds .hl-done), only the hover glow moves, and quickly. */
.hl-done .hl { transition: box-shadow var(--dur-med) ease; }
.note__fact a.hl:hover, .note__fact a.hl:focus-visible { opacity: 1; box-shadow: 0 0 1.1em 0.2em color-mix(in srgb, var(--marker) 60%, transparent); }


/* Question box: one line to start, grows as they type. ask.js sets the height, CSS animates it. */
.ask__box { position: relative; width: 100%; }
.ask__text { display: block; width: 100%; min-height: 3rem; max-height: 16rem; resize: none; overflow-y: auto;
  padding: 0.8rem 3.4rem 0.8rem 1.1rem; border-radius: 1.5rem; color: var(--ink); font: inherit; font-size: var(--text-sm); line-height: 1.5;
  background: color-mix(in srgb, var(--cobalt-deep) 55%, transparent); border: 1px solid color-mix(in srgb, var(--cobalt) 70%, transparent);
  box-shadow: inset 0 0 28px 0 color-mix(in srgb, var(--cobalt) 25%, transparent); transition: height var(--dur-med) var(--ease), border-color var(--dur-fast); }
.ask__text:focus-visible { outline: 2px solid var(--glow); outline-offset: 2px; border-color: var(--cobalt); }
.ask__text--twin { position: absolute; left: 0; top: 0; z-index: -1; height: 0 !important; min-height: 0; max-height: none; visibility: hidden; pointer-events: none; transition: none; }
.ask__send { position: absolute; right: 0.4rem; bottom: 0.4rem; width: 2.2rem; height: 2.2rem; display: grid; place-items: center; border-radius: 50%; background: var(--white); color: var(--black); transition: transform var(--dur-fast); }
.ask__send:hover { transform: scale(1.08); }
.ask__send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- Flip card (Figma frame 09, 1050 x 600). --u is one Figma pixel, so the card scales as one piece. ---- */
.flip { --u: calc(100cqw / 1050); --flip-r: max(12px, calc(22 * var(--u)));
  appearance: none; -webkit-appearance: none; display: block; width: 100%; aspect-ratio: 7 / 4; padding: 0; margin: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
  border-radius: var(--flip-r); container-type: inline-size; perspective: 1600px; align-self: center; -webkit-tap-highlight-color: transparent; }
.flip__inner { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.9s var(--ease); }
@media (hover: hover) { .flip:hover .flip__inner { transform: rotateY(180deg); } }
.flip.is-flipped .flip__inner { transform: rotateY(180deg); }
.flip__face { position: absolute; inset: 0; display: block; overflow: hidden; border-radius: var(--flip-r); isolation: isolate;
  -webkit-backface-visibility: hidden; backface-visibility: hidden; box-shadow: 0 28px 60px -24px color-mix(in srgb, var(--black) 85%, transparent); }
/* Film grain over the whole face (a real file: the CSP in vercel.json blocks data: images). */
.flip__face::after { content: ""; position: absolute; inset: 0; z-index: 10; pointer-events: none; background: url("../assets/img/grain.svg"); background-size: 200px; mix-blend-mode: overlay; opacity: 0.4; }
.flip__face > * { position: absolute; }

/* Front */
.flip__face--front { background: linear-gradient(to bottom right, var(--pale) 0%, color-mix(in srgb, var(--pale) 82%, var(--flip-cobalt)) 34%, var(--flip-cobalt) 60%, var(--flip-deep) 92%); color: var(--navy); }
.flip__photo { left: calc(600 * var(--u)); top: calc(10 * var(--u)); width: calc(240 * var(--u)); height: auto; max-width: none; z-index: 2; }
.flip__ast { fill: currentColor; }
.flip__ast--big { left: calc(690 * var(--u)); top: calc(90 * var(--u)); width: calc(170 * var(--u)); color: var(--flip-cobalt); z-index: 1; }
.flip__ast--small { left: calc(570 * var(--u)); top: calc(250 * var(--u)); width: calc(46 * var(--u)); color: var(--navy); z-index: 3; }
.flip__ast--mid { left: calc(880 * var(--u)); top: calc(330 * var(--u)); width: calc(64 * var(--u)); color: var(--pale); z-index: 3; }
.flip__ast--tiny { left: calc(860 * var(--u)); top: calc(200 * var(--u)); width: calc(22 * var(--u)); color: var(--pale); z-index: 3; }
.flip__spark { left: calc(830 * var(--u)); top: calc(470 * var(--u)); width: calc(90 * var(--u)); fill: var(--pale); z-index: 3; }
.flip__grid { left: calc(520 * var(--u)); top: calc(420 * var(--u)); width: calc(120 * var(--u)); height: calc(100 * var(--u)); z-index: 3;
  border: 1px solid color-mix(in srgb, var(--pale) 75%, transparent);
  background: linear-gradient(color-mix(in srgb, var(--pale) 75%, transparent), color-mix(in srgb, var(--pale) 75%, transparent)) center / 1px 100% no-repeat,
              linear-gradient(color-mix(in srgb, var(--pale) 75%, transparent), color-mix(in srgb, var(--pale) 75%, transparent)) center / 100% 1px no-repeat; }
.flip__vc { font-family: var(--font-title); font-weight: 700; line-height: 1; letter-spacing: 0.01em; }
.flip__face--front .flip__vc { left: calc(56 * var(--u)); top: calc(46 * var(--u)); font-size: max(12px, calc(36 * var(--u))); z-index: 4; }
.flip__label { font-family: var(--font-body); font-weight: 400; font-size: max(7px, calc(12 * var(--u))); letter-spacing: 0.38em; line-height: 1; color: var(--pale); }
.flip__face--front .flip__label { right: calc(54 * var(--u)); top: calc(52 * var(--u)); z-index: 4; }
.flip__hook { left: calc(56 * var(--u)); top: calc(200 * var(--u)); z-index: 4;
  font-family: var(--font-body); font-weight: 300; font-size: max(14px, calc(50 * var(--u))); letter-spacing: 0.06em; line-height: 1.08; }
.flip__hint { left: calc(56 * var(--u)); top: calc(500 * var(--u)); width: calc(380 * var(--u)); padding-top: calc(18 * var(--u)); z-index: 4;
  border-top: 1px solid color-mix(in srgb, var(--navy) 45%, transparent);
  font-family: var(--font-mono); font-size: max(7.5px, calc(14 * var(--u))); letter-spacing: 0.2em; line-height: 1; }
.flip__hook > span { display: block; }
.flip__hint span { margin-left: 0.8em; }

/* Back */
.flip__face--back { transform: rotateY(180deg); color: var(--pale); display: flex; flex-direction: column;
  padding: calc(50 * var(--u)) calc(56 * var(--u)) calc(46 * var(--u));
  background: radial-gradient(ellipse 30% 44% at 12% 93%, color-mix(in srgb, var(--flip-glow-pink) 75%, transparent), transparent 100%),
              radial-gradient(ellipse 42% 60% at 8% 100%, color-mix(in srgb, var(--flip-glow-violet) 80%, transparent), transparent 100%),
              radial-gradient(ellipse 22% 34% at 94% 0%, color-mix(in srgb, var(--flip-cobalt) 55%, transparent), transparent 100%),
              var(--navy); }
.flip__face--back > * { position: relative; }
.flip__face--back .flip__label { padding-bottom: calc(22 * var(--u)); border-bottom: 1px solid color-mix(in srgb, var(--pale) 28%, transparent); }
.flip__brief { display: grid; gap: 0.45em; align-content: start; flex: 1; margin-top: calc(40 * var(--u));
  font-family: var(--font-mono); font-size: max(9.5px, calc(19 * var(--u))); line-height: 1.5; letter-spacing: 0.02em; }
.flip__brief span { display: block; }
.flip__foot { display: flex; justify-content: space-between; align-items: center; padding-top: calc(22 * var(--u)); border-top: 1px solid color-mix(in srgb, var(--pale) 28%, transparent); }
.flip__site { font-family: var(--font-body); font-weight: 400; font-size: max(8px, calc(15 * var(--u))); letter-spacing: 0.02em; opacity: 0.9; }
.flip__face--back .flip__vc { font-size: max(14px, calc(46 * var(--u))); }

/* Reduced motion: no 3D turn. The back simply appears in place. */
@media (prefers-reduced-motion: reduce) {
  .flip__inner, .flip.is-flipped .flip__inner { transform: none !important; transition: none; }
  .flip__face--back { transform: none; opacity: 0; }
  .flip.is-flipped .flip__face--back { opacity: 1; }
  .note { transform: none !important; }
}
@media (prefers-reduced-motion: reduce) and (hover: hover) { .flip:hover .flip__face--back { opacity: 1; } }


/* Small laptops and tablets: toggle + text | portrait, then the card under them. */
@media (max-width: 1100px) and (min-width: 861px) {
  .ask__grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); }
  .flip { grid-column: 1 / -1; grid-row: 2; justify-self: center; width: min(100%, 480px); }
}

/* Phones: portrait with the question, then the toggle and its text, then the card. */
@media (max-width: 860px) {
  .ask__grid { grid-template-columns: minmax(0, 1fr); gap: var(--space-5); }
  .ask__figure, .ask__side, .flip { grid-column: 1; }
  .ask__figure { grid-row: 1; }
  .ask__side { grid-row: 2; justify-items: center; }
  .ask__box { width: min(100%, 460px); }
  .flip { grid-row: 3; justify-self: center; width: min(100%, 460px); margin-top: var(--space-4); }
  .ask__figure img { max-height: none; }
  body[data-chapter="learning"] .ask__figure .mission { top: 7%; width: 72%; }
  body[data-chapter="learning"] .ask__figure .mission__label { font-size: clamp(1.1rem, 5vw, 1.6rem); }
  body[data-chapter="learning"] .ask__figure .mission__line { font-size: clamp(0.85rem, 3.6vw, 1.1rem); }
}

/* ---- Ending ---- */
.join { display: grid; justify-items: center; align-content: center; gap: var(--space-6); text-align: center; min-height: 70vh; min-height: 70svh; padding: var(--space-7) var(--gutter); }
.join h2 { font-size: var(--text-title); max-width: 16ch; }
.join__btn { font-family: var(--font-title); font-weight: var(--weight-title); font-size: var(--text-sm); letter-spacing: var(--tracking-label); text-transform: uppercase; text-decoration: none;
  padding: var(--space-4) var(--space-6); border-radius: 999px; background: var(--white); color: var(--black); box-shadow: 0 0 40px -6px color-mix(in srgb, var(--cobalt) 80%, transparent); transition: transform var(--dur-fast); }
.join__btn:hover { transform: translateY(-3px); }
