/* ============================================================
   /learn/ explainer pages. Loaded after styles.css, so the tokens,
   buttons and fonts are the home page's own; everything here is
   prefixed ln- so it can never restyle the landing page.
   ============================================================ */

.ln-wrap { max-width: 760px; margin: 0 auto; padding: 0 24px; }

/* ---- Header ---- */
.ln-nav { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.92); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.ln-nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 68px; max-width: 1040px; }
.ln-brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.12rem; color: var(--ink); }
.ln-brand-mark { width: 34px; height: 34px; border-radius: 9px; }
.ln-nav-links { display: flex; align-items: center; gap: 20px; font-weight: 600; font-size: .98rem; color: var(--ink-2); }
.ln-nav-links a:not(.btn):hover { color: var(--brand-strong); }

/* ---- Main ---- */
.ln-main { padding-top: 28px; padding-bottom: 80px; }
.ln-crumbs { display: flex; gap: 8px; font-size: .9rem; font-weight: 600; color: var(--ink-3); margin-bottom: 26px; }
.ln-crumbs a:hover { color: var(--brand-strong); }

.ln-article h1,
.ln-index-head h1 { font-size: clamp(2.1rem, 5.4vw, 3.1rem); line-height: 1.08; color: var(--ink); }
.ln-meta { margin-top: 14px; font-size: .92rem; color: var(--ink-3); font-weight: 500; }

.ln-short { margin: 30px 0 36px; padding: 22px 24px; background: var(--brand-soft); border-left: 4px solid var(--brand); border-radius: 0 16px 16px 0; }
.ln-short-label { font-size: .8rem; font-weight: 800; color: var(--brand-deep); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.ln-short p:not(.ln-short-label) { font-size: 1.1rem; line-height: 1.65; color: var(--brand-ink); font-weight: 500; }

.ln-body { font-size: 1.07rem; line-height: 1.75; color: var(--ink-2); }
.ln-body h2 { font-size: clamp(1.45rem, 3.2vw, 1.8rem); line-height: 1.2; color: var(--ink); margin: 44px 0 14px; scroll-margin-top: 90px; }
.ln-body h3 { font-size: 1.2rem; line-height: 1.3; color: var(--ink); margin: 30px 0 10px; }
.ln-body p { margin: 0 0 18px; }
.ln-body ul,
.ln-body ol { margin: 0 0 20px; padding-left: 1.3em; }
.ln-body li { margin: 0 0 10px; padding-left: .2em; }
.ln-formula { margin: 4px 0 22px; padding: 16px 20px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; text-align: center; overflow-x: auto; }
.ln-formula code { font-family: var(--sans); font-size: 1.15rem; font-weight: 600; color: var(--ink); white-space: nowrap; }
.ln-body strong { color: var(--ink); font-weight: 700; }
.ln-body a,
.ln-short a { color: var(--brand-strong); font-weight: 600; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; text-decoration-color: rgba(124,58,237,.35); }
.ln-body a:hover,
.ln-short a:hover { text-decoration-color: currentColor; }

/* ---- App call to action ---- */
.ln-cta { margin-top: 48px; padding: 34px 30px; border-radius: var(--r-card); background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%); color: var(--on-brand); box-shadow: var(--shadow-md); }
.ln-cta h2 { font-size: clamp(1.35rem, 3vw, 1.65rem); line-height: 1.2; color: #fff; }
.ln-cta p { margin-top: 10px; font-size: 1.02rem; line-height: 1.6; color: rgba(255,255,255,.9); }
.ln-cta strong { color: #fff; }
.ln-cta-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }
.ln-cta-actions .btn { padding: 14px 22px; font-size: .98rem; }

/* ---- Related and index cards ---- */
section.ln-related { padding: 56px 0 0; }
.ln-related h2 { font-size: 1.5rem; line-height: 1.2; margin-bottom: 18px; }
.ln-cards { list-style: none; display: grid; gap: 14px; }
.ln-card { display: block; padding: 20px 22px; border: 1px solid var(--line); border-radius: 16px; background: #fff; transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
.ln-card:hover { border-color: var(--brand-soft-2); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.ln-card-q { display: block; font-weight: 800; font-size: 1.1rem; color: var(--ink); }
.ln-card-d { display: block; margin-top: 6px; font-size: .96rem; line-height: 1.55; color: var(--ink-2); }

.ln-index-head p { margin-top: 16px; font-size: 1.12rem; line-height: 1.65; color: var(--ink-2); font-weight: 500; }
.ln-cards--index { margin-top: 34px; }

/* ---- Footer ---- */
.ln-footer { border-top: 1px solid var(--line); background: var(--bg-soft); padding: 34px 0 40px; font-size: .92rem; color: var(--ink-3); }
.ln-footer-links { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-bottom: 16px; font-weight: 600; color: var(--ink-2); }
.ln-footer-links a:hover { color: var(--brand-strong); }

/* ---- Platform: the iPhone-only link is hidden everywhere else ---- */
html:not([data-os="ios"]) [data-ios-only] { display: none; }

/* ---- Wider layout for interactive tools ---- */
.ln-wrap--wide { max-width: 980px; }
.ln-wrap--wide .ln-body > :not(.ln-demo),
.ln-wrap--wide .ln-short,
.ln-wrap--wide .ln-strip { max-width: 760px; }
.ln-nav-tool { white-space: nowrap; }
.ln-tool { margin-top: 26px; }
.ln-tool .ln-demo { margin-bottom: 30px; }

/* ---- One-line app nudge under the short answer ---- */
.ln-strip { margin: -18px 0 34px; font-size: .98rem; line-height: 1.6; color: var(--ink-2); }
.ln-strip strong { color: var(--ink); }
.ln-strip a { margin-left: 4px; color: var(--brand-strong); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(124,58,237,.35); }
.ln-strip a:hover { text-decoration-color: currentColor; }

/* ---- Code and its real output ---- */
.ln-code,
.ln-output { margin: 4px 0 22px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.ln-code figcaption,
.ln-output figcaption { padding: 9px 16px; font-size: .82rem; font-weight: 700; color: var(--ink-3); background: var(--bg-soft); border-bottom: 1px solid var(--line); }
.ln-code figcaption span { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 600; color: var(--ink-2); }
.ln-code pre,
.ln-output pre { margin: 0; padding: 16px; overflow-x: auto; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88rem; line-height: 1.6; }
.ln-code pre { background: #1E1B2E; color: #EDE9F7; }
.ln-output pre { background: #fff; color: var(--ink); }
.ln-code pre:focus-visible,
.ln-output pre:focus-visible,
.ln-cite-text:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

/* ---- Tables ---- */
.ln-table { margin: 4px 0 22px; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.ln-table table { width: 100%; border-collapse: collapse; font-size: .97rem; line-height: 1.5; }
.ln-table th,
.ln-table td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.ln-table th { background: var(--bg-soft); color: var(--ink); font-weight: 700; }
.ln-table tr:last-child td { border-bottom: 0; }

/* ---- Interactive demos ---- */
.ln-demo { margin: 6px 0 28px; padding: 20px; border: 1px solid var(--line); border-radius: var(--r-card, 20px); background: #fff; box-shadow: var(--shadow-sm); }
.ln-demo .ln-demo-fallback { margin: 0; color: var(--ink-3); }
.ln-demo-canvas { display: block; max-width: 100%; margin: 0 auto; }
.ln-demo .ln-demo-status { margin: 12px 0 0; min-height: 3.2em; font-size: .97rem; line-height: 1.55; color: var(--ink-2); }
.ln-demo-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.ln-demo-bar select { padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; font: inherit; font-size: .95rem; color: var(--ink); }
.ln-btn { appearance: none; padding: 9px 16px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; font: inherit; font-size: .95rem; font-weight: 700; color: var(--ink); cursor: pointer; transition: border-color .15s ease, background .15s ease, transform .15s ease; }
.ln-btn:hover { border-color: var(--brand); }
.ln-btn:active { transform: translateY(1px); }
.ln-btn:focus-visible,
.ln-demo-bar select:focus-visible,
.ln-bloch-canvas:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.ln-btn:disabled { opacity: .45; cursor: default; }
.ln-btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.ln-btn--primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.ln-btn--ghost { background: var(--brand-soft); border-color: var(--brand-soft-2); color: var(--brand-deep); }
.ln-btn--gate { min-width: 52px; padding: 9px 10px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---- Bloch sphere simulator ---- */
.ln-bloch { display: grid; grid-template-columns: minmax(260px, 400px) 1fr; gap: 24px; align-items: start; }
.ln-bloch-stage { text-align: center; }
.ln-bloch-canvas { display: block; max-width: 100%; margin: 0 auto; cursor: grab; touch-action: none; border-radius: 12px; }
.ln-bloch-canvas:active { cursor: grabbing; }
.ln-demo .ln-bloch-hint { margin: 6px 0 0; font-size: .85rem; color: var(--ink-3); }
.ln-bloch-side { min-width: 0; }
.ln-demo .ln-bloch-h { margin: 18px 0 8px; font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.ln-demo .ln-bloch-side > .ln-bloch-h:first-child { margin-top: 0; }
.ln-bloch-read { padding: 14px 16px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; }
.ln-bloch-read p { margin: 0; }
.ln-bloch-state { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .95rem; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.ln-bloch-read .ln-bloch-prob { display: grid; grid-template-columns: 4.2em 1fr 4em; align-items: center; gap: 10px; margin-top: 8px; font-size: .9rem; color: var(--ink-2); }
.ln-bloch-prob span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.ln-bloch-pbar { display: block; height: 10px; border-radius: 6px; background: #fff; border: 1px solid var(--line); overflow: hidden; }
.ln-bloch-pfill { display: block; height: 100%; width: 0; background: var(--brand); transition: width .3s ease; }
.ln-bloch-read .ln-bloch-coords { margin-top: 10px; font-size: .85rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ln-bloch-gates,
.ln-bloch-rot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ln-bloch-lab { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; font-weight: 700; color: var(--ink-2); }
.ln-bloch-val { min-width: 3.4em; font-variant-numeric: tabular-nums; color: var(--ink); }
.ln-bloch input[type="range"] { width: 100%; accent-color: var(--brand); }
.ln-bloch-rot input[type="range"] { flex: 1 1 140px; }
.ln-bloch-set { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 6px 12px; }
.ln-demo .ln-bloch-circuit { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.ln-demo .ln-bloch-circuit li { margin: 0; padding: 4px 10px; border-radius: 8px; background: var(--brand-soft); color: var(--brand-deep); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88rem; font-weight: 700; }
.ln-demo .ln-bloch-circuit li.is-measure { background: #FFF4E5; color: #9A4A00; }
.ln-demo .ln-bloch-circuit li.ln-bloch-empty { background: none; padding-left: 0; color: var(--ink-3); font-family: inherit; font-weight: 500; }

/* ---- Cite box ---- */
.ln-cite { margin: 36px 0 8px; padding: 22px 24px; border: 1px dashed var(--line-2); border-radius: 16px; background: var(--bg-soft); }
.ln-body .ln-cite h2 { margin: 0 0 8px; font-size: 1.2rem; }
.ln-cite p { font-size: .98rem; }
.ln-body .ln-code,
.ln-body .ln-output { margin: 4px 0 22px; }
.ln-cite-text { margin: 0 0 14px; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .88rem; line-height: 1.55; }
.ln-copy { cursor: pointer; }

/* ---- Back to the hub ---- */
.ln-back { margin-top: 28px; font-weight: 700; }
.ln-back a { color: var(--brand-strong); }
.ln-back a::before { content: "\2190\00a0"; }
.ln-back a:hover { text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 820px) {
  .ln-bloch { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .ln-bloch-pfill, .ln-btn { transition: none; }
}

@media (max-width: 560px) {
  .ln-wrap { padding: 0 16px; }
  .ln-nav-inner { height: 60px; }
  .ln-nav-links { gap: 14px; font-size: .92rem; }
  .ln-short { padding: 18px 18px; }
  .ln-cta { padding: 26px 20px; }
  .ln-cta-actions .btn { width: 100%; }
  .ln-demo { padding: 14px; }
  .ln-nav-tool { display: none; }
  .ln-cite { padding: 18px; }
}

@media (max-width: 560px) {
  .ln-bloch-gates { display: grid; grid-template-columns: repeat(4, 1fr); }
  .ln-bloch-rot .ln-bloch-lab { flex: 0 0 auto; }
  .ln-bloch-rot input[type="range"] { flex: 1 1 100%; order: 0; }
  .ln-bloch-rot .ln-btn--gate { flex: 1 1 0; }
}
