/* Trackpad Ninja — three-template design system.
   Families: cards (rails of dark skill cards), results (compact rows), learn (stage + steps + practice).
   One accent, consistent tokens, mobile-first stacking. */

:root {
  --ink: #172536;
  --ink-soft: #2f3f52;
  --muted: #586575;
  --paper: #f6f8fa;
  --paper-2: #eef2f5;
  --line: #dce3e9;
  --line-strong: #c5ced6;
  --accent: #086b64;
  --accent-strong: #065750;
  --accent-soft: #e4f2ef;
  --accent-bright: #2f9e90;
  --card-bg: #15202b;
  --card-bg-2: #1b2836;
  --card-line: #2a3544;
  --card-line-hover: #4aa79c;
  --card-ink: #e8eef4;
  --card-ink-soft: #b7c4d0;
  --card-ink-muted: #8fa0b0;
  --header-bg: #0f1720;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow-card: 0 8px 24px #0a101880;
  --shadow-card-hover: 0 10px 28px #0a1018a0;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --measure: 880px;
}

/* ---------- Base ---------- */
body { color: var(--ink); background: #fff; }
a { text-underline-offset: 3px; color: var(--accent); }
a:hover { color: var(--accent-strong); }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid #167d94; outline-offset: 4px;
}
.skip-link { position: absolute; left: 1rem; top: -100px; z-index: 2000; background: #fff; padding: 1rem; }
.skip-link:focus { top: 1rem; }
.section-eyebrow, .tip-eyebrow {
  text-transform: uppercase; letter-spacing: .13em; font-size: .7rem; font-weight: 750; color: var(--accent); margin-bottom: .4rem;
}
kbd, .lesson-focus kbd, .lesson-action kbd, .technique-action kbd, .skill-card-action kbd {
  font-family: var(--font-mono); font-size: .85em; padding: .15rem .45rem; border: 1px solid var(--line-strong);
  border-bottom-width: 2px; border-radius: 5px; background: var(--paper); color: #243447; white-space: nowrap;
}
.skill-card kbd { background: #243447; color: #f4f7fa; border-color: #3a4a5c; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover, .btn-accent:focus { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-outline-ink { border: 1px solid var(--line-strong); color: var(--ink); background: #fff; }
.btn-outline-ink:hover { border-color: var(--ink); color: var(--ink); background: var(--paper); }

/* ---------- Site header ---------- */
.site-header { background: var(--header-bg); color: #fff; }
.site-nav { padding: .6rem 0; }
.site-nav-inner { display: flex; align-items: center; gap: .75rem 1.25rem; flex-wrap: wrap; }
.site-brand { display: flex; align-items: center; gap: .6rem; margin-right: 0; padding: 0; font-weight: 700; font-size: 1.15rem; color: #fff; }
.site-brand .ninja-logo { height: 38px; width: 38px; border-radius: 50%; }
.site-search { display: flex; flex: 1 1 260px; max-width: 520px; min-width: 0; border: 1px solid #2a3544; background: #1b2836; border-radius: 999px; overflow: hidden; }
.site-search input { flex: 1; min-width: 0; border: 0; background: transparent; color: #fff; padding: .5rem 1rem; font-size: .95rem; }
.site-search input::placeholder { color: #8fa0b0; }
.site-search input:focus { outline: none; }
.site-search button { border: 0; background: var(--accent); color: #fff; padding: .5rem 1rem; font-weight: 600; font-size: .9rem; }
.site-search button:hover { background: var(--accent-bright); }
.site-links { display: flex; gap: .15rem; margin-left: auto; }
.site-links .nav-link { color: #d6e1e8; font-weight: 500; font-size: .95rem; padding: .45rem .8rem; border-radius: 999px; }
.site-links .nav-link:hover { color: #fff; background: #ffffff14; }
.site-links .nav-link.active { color: #fff; background: #ffffff20; }
.site-nav .navbar-toggler { border-color: #2a3544; margin-left: auto; }
.studio-edit-bar a { font-weight: 600; }

/* ---------- Tip strip ---------- */
.tip-strip { background: var(--accent-soft); border-bottom: 1px solid #d9e9e2; }
.tip-strip-inner { display: flex; align-items: center; gap: 1rem; min-height: 48px; padding-top: .5rem; padding-bottom: .5rem; }
.tip-strip p { flex: 1; font-size: .85rem; margin: 0; line-height: 1.5; }
.tip-strip a { color: #224b46; }
.tip-strip [data-tip-controls] { display: flex; gap: .3rem; }
.tip-strip [hidden] { display: none !important; }
.tip-strip button, .rail-tools button { border: 1px solid var(--line); background: #fff; border-radius: 50%; min-width: 34px; min-height: 34px; color: var(--ink); line-height: 1; }
.rail-tools button:disabled { opacity: .35; }

/* ---------- Page header (cards + results) ---------- */
.page-head { padding: 2.6rem 0 1.6rem; background: linear-gradient(130deg, #f5f9f8, #f7f8fc); border-bottom: 1px solid var(--line); }
.page-head-compact { padding: 1.8rem 0 1.2rem; }
.page-head-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; align-items: center; }
.page-head.has-hero .page-head-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.page-head h1 { font-size: clamp(1.75rem, 3.6vw, 2.8rem); letter-spacing: -.04em; line-height: 1.1; max-width: 760px; margin-bottom: .5rem; }
.page-head-compact h1 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
.page-subtitle { color: var(--muted); font-size: 1.05rem; max-width: 680px; margin: 0; }
.page-search { display: flex; gap: .5rem; margin: 1.2rem 0 .4rem; max-width: 620px; }
.page-search .form-control { border-radius: 999px; padding: .6rem 1.1rem; border-color: var(--line-strong); }
.page-search .btn { border-radius: 999px; padding: .6rem 1.2rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.page-chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1rem; }
.dojo-switcher { display: flex; flex-wrap: wrap; gap: .45rem; margin: 0 0 1rem; }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .35rem .8rem; border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; color: var(--ink); font-size: .85rem; text-decoration: none; line-height: 1.3; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.page-hero-media { max-width: 330px; margin: 0 auto; }
.page-hero-media .trackpad-ninja-wrapper .container, .page-hero-media .container { box-shadow: none; background: transparent; padding: 0; }
.page-body { padding: .5rem 0 2rem; }
.page-intro { color: var(--muted); max-width: 760px; margin: 1.5rem 0 0; }
.page-footnote { color: var(--muted); font-size: .85rem; margin-top: 2rem; }
.empty-state { margin: 3rem 0; padding: 2rem; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--paper); }
.empty-state h2 { font-size: 1.3rem; }
.empty-state p { color: var(--muted); }

/* ---------- Rails + cards ---------- */
.discovery-section { margin: 1.6rem 0; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .9rem; }
.section-heading h2 { font-size: 1.4rem; letter-spacing: -.03em; margin-bottom: .25rem; }
.section-heading p { font-size: .95rem; color: var(--muted); margin: 0; }
.rail-tools { display: flex; align-items: center; gap: 1rem; white-space: nowrap; font-size: .875rem; }
.skill-rail {
  display: grid; grid-auto-flow: column; grid-auto-columns: calc((100% - 2rem) / 3); gap: 1rem;
  overflow-x: auto; scroll-snap-type: x proximity; scroll-padding: 4px; padding: 5px 4px 15px; scrollbar-width: thin;
}
.skill-card {
  display: flex; flex-direction: column; min-width: 0; scroll-snap-align: start; padding: 1.05rem 1.15rem 1rem;
  border: 1px solid var(--card-line); border-top: 3px solid #3d8f86; border-radius: var(--radius);
  background: var(--card-bg); color: var(--card-ink); box-shadow: var(--shadow-card); transition: border-color .15s, box-shadow .15s;
}
.skill-card:hover { border-color: var(--card-line-hover); box-shadow: var(--shadow-card-hover); }
.skill-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .85rem; min-height: 1rem; }
.skill-card h3 { font-size: 1.1rem; line-height: 1.4; letter-spacing: -.02em; margin-bottom: .5rem; }
.skill-card h3 a { color: #f4f7fa; text-decoration: none; }
.skill-card h3 a:hover { text-decoration: underline; }
.skill-card-action { font-size: .98rem; line-height: 1.55; overflow-wrap: anywhere; color: var(--card-ink-soft); margin-bottom: .6rem; }
.skill-card-action-soft { color: var(--card-ink-muted); font-size: .9rem; }
.skill-card-note { color: var(--card-ink-muted); margin-bottom: .4rem; }
.skill-card-meta { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 .3rem; font-size: .72rem; color: var(--card-ink-muted); }
.skill-card-meta span { border: 1px solid #314152; border-radius: 4px; padding: .1rem .4rem; }
.skill-card-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-top: auto; padding-top: .4rem; }
.skill-card-actions .btn-outline-dark, .skill-card-actions .btn-outline-secondary { border-color: #6b7c8c; color: #d7e0e8; }
.skill-card-actions .btn-outline-dark:hover, .skill-card-actions .btn-outline-secondary:hover { background: #ffffff14; color: #fff; }
.skill-card-actions .btn-dark { background: var(--accent-bright); border-color: var(--accent-bright); }
.skill-card-actions .btn-dark:hover { background: #3bb3a3; border-color: #3bb3a3; }
.skill-card-actions .small { color: #9eb0c0; margin-left: auto; }
.skill-card-mark { color: #5ecfc0; font-size: .85rem; }
.skill-card .context-label { color: var(--card-ink-muted); border-left: 0; padding-left: 0; min-width: 0; }
.skill-card-link { background: linear-gradient(150deg, var(--card-bg-2), var(--card-bg)); border-top-color: #4b6b85; }
.skill-card-sheet { border-top-color: #c9a24b; }
.context-airpods { border-top-color: #149b89; }
.context-terminal { border-top-color: #7aa85a; }
.context-mobile, .context-ipad, .context-iphone { border-top-color: #9a84c9; }
.skill-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; }

/* ---------- Results rows ---------- */
.results-page { max-width: 1060px; }
.results-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin: 1.4rem 0 .5rem; }
.results-count { color: var(--muted); font-size: .9rem; margin: 0; }
.results-filter { flex: 0 1 300px; }
.results-group { margin: 1rem 0 1.25rem; scroll-margin-top: 1rem; }
.results-group-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; border-bottom: 2px solid var(--line); padding-bottom: .5rem; margin-bottom: .25rem; }
.results-group-head h2, .results-group-collapsed summary { font-size: 1.05rem; font-weight: 650; margin: 0; }
.results-group-head a { font-size: .875rem; white-space: nowrap; }
.results-group-count { color: var(--muted); font-weight: 500; font-size: .85rem; margin-left: .25rem; }
.results-group-desc { color: var(--muted); font-size: .9rem; margin: .5rem 0 .25rem; }
.results-group-collapsed { border-top: 2px solid var(--line); padding-top: .6rem; }
.results-group-collapsed summary { cursor: pointer; padding: .3rem 0; list-style-position: outside; }
.results-no-match { color: var(--muted); margin: 1.5rem 0; }
.technique-row { display: flex; align-items: center; gap: .8rem; min-height: 50px; padding: .6rem .15rem; border-bottom: 1px solid #e5e9ed; font-size: .94rem; }
.technique-row[hidden] { display: none; }
.row-number { font-family: var(--font-mono); font-size: .8rem; color: var(--muted); min-width: 1.6rem; }
.technique-title { flex: 1; min-width: 0; color: #172b42; text-decoration: none; font-weight: 550; }
.technique-title:hover { text-decoration: underline; color: var(--accent-strong); }
.technique-action { font-family: var(--font-mono); font-size: .84rem; color: #46546a; max-width: 40%; }
.technique-note { font-size: .8rem; color: var(--muted); }
.context-label { font-size: .72rem; font-weight: 650; white-space: nowrap; border-left: 3px solid #8795a6; padding-left: .45rem; color: #526173; min-width: 75px; text-transform: uppercase; letter-spacing: .06em; }
.technique-row .context-desktop { border-color: #3174c5; }
.technique-row .context-terminal { border-color: #9371bc; }
.technique-row .context-mobile, .technique-row .context-ipad, .technique-row .context-iphone { border-color: #21816b; }
.technique-row .context-airpods { border-color: #149b89; }
.demo-link { white-space: nowrap; font-size: .83rem; padding: .35rem .6rem; border-radius: 6px; text-decoration: none; border: 1px solid var(--line-strong); color: var(--ink); }
.demo-link:hover { border-color: var(--accent); color: var(--accent); }
.pagination-links { display: flex; justify-content: center; gap: 2rem; margin: 2rem 0; }

/* ---------- Learn page ---------- */
.learn-container { max-width: var(--measure); }
.learn-head { padding: 1.15rem 0 .75rem; background: linear-gradient(130deg, #f5f9f8, #f7f8fc); border-bottom: 1px solid var(--line); }
.learn-crumbs { display: flex; flex-wrap: wrap; gap: .4rem; font-size: .85rem; color: var(--muted); margin-bottom: .8rem; }
.learn-crumbs a { color: var(--muted); text-decoration: none; }
.learn-crumbs a:hover { color: var(--accent); text-decoration: underline; }
.learn-head h1 { font-size: clamp(1.6rem, 3.4vw, 2.4rem); letter-spacing: -.04em; line-height: 1.15; margin-bottom: .9rem; }
.lesson-action { font-size: 1.15rem; background: var(--accent-soft); border-left: 3px solid var(--accent); padding: .9rem 1.1rem; border-radius: 0 10px 10px 0; margin-bottom: .8rem; }
.learn-subtitle { color: var(--muted); margin: 0; }
.learn-body { padding-top: 1.5rem; }
.learn-stage { margin: 0 0 1.5rem; }
.learn-stage .reference-player { margin: 0; padding: 0; max-width: none; }
.learn-stage .reference-stage { background: #f7f9fc; border-color: var(--line); }
.player-open { margin-left: auto; font-size: .85rem; }
.stage-note { color: var(--muted); font-size: .85rem; }
.learn-more-demos { display: flex; flex-wrap: wrap; gap: .5rem 1rem; font-size: .9rem; color: var(--muted); }
.learn-steps { margin: 1.5rem 0; }
.learn-steps h2, .learn-practice h2 { font-size: 1.2rem; letter-spacing: -.02em; margin-bottom: .75rem; }
.step-list { padding-left: 1.25rem; margin: 0; }
.step-list li { padding: .45rem 0 .45rem .25rem; border-bottom: 1px solid #eef2f5; line-height: 1.55; }
.step-list li:last-child { border-bottom: 0; }
.step-text { white-space: pre-line; }
.learn-tool { margin: 1.5rem 0; }
.learn-practice { margin: 2rem 0; scroll-margin-top: 1.5rem; }
.learn-practice-intro { color: var(--muted); }
.learn-practice-item + .learn-practice-item { margin-top: 1.5rem; }
.learn-nav { margin: 2.5rem 0 1.5rem; padding: 1rem 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.learn-nav-title { font-size: .85rem; color: var(--muted); margin-bottom: .6rem; }
.learn-nav-links { display: flex; justify-content: space-between; gap: 1rem; }
.learn-nav-links a { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); font-weight: 600; max-width: 48%; }
.learn-nav-links a small { color: var(--muted); font-weight: 500; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
.learn-nav-links a:hover { color: var(--accent-strong); }
.learn-nav-next { text-align: right; margin-left: auto; }
.learn-details details { border-top: 1px solid var(--line); padding: .9rem 0; }
.learn-details summary { font-weight: 600; cursor: pointer; }
.learn-details p, .learn-details li { color: var(--ink-soft); font-size: .95rem; }
.learn-detail-body { margin-top: .6rem; }
.learn-chips { margin: 1.5rem 0; }
.learn-related { margin-top: 1rem; max-width: var(--measure); }
.learn-related .skill-rail { grid-auto-columns: calc((100% - 1rem) / 2); }
.learn-hook { font-style: italic; color: var(--ink-soft); margin: .25rem 0 0; }
.results-more { margin-top: .4rem; }
.results-more summary { cursor: pointer; font-size: .9rem; color: var(--accent); padding: .5rem 0; font-weight: 600; }
.learn-tool .training-section h2 { font-size: 1.2rem; }
.learn-tool .training-section h3 { font-size: 1.05rem; margin-top: 1.25rem; }
.shortcut-tables table { font-size: .9rem; }
.shortcut-tables .filter-input { width: 100%; font-size: .85rem; }
.daily-dojo-form summary { cursor: pointer; font-weight: 600; }
.learn-page .practice-shell, .learn-practice-item > div { scroll-margin-top: 1rem; }
.learn-page.is-embedded .learn-body { padding: 0; }
.nm-player { max-width: 720px; }
.nm-stage-wrap { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #f8fafc; }
.nm-stage-svg { width: 100%; height: auto; display: block; }
.nm-key rect { transition: fill 80ms linear; }
.nm-key-active rect { fill: #fbbf24 !important; stroke: #b45309; stroke-width: 2; }
.nm-highlight-on > rect:first-child, .nm-highlight.nm-highlight-on #nm-trackpad-surface { stroke: #0ea5e9 !important; stroke-width: 4 !important; }
.nm-finger { fill: #38bdf8; stroke: #0f172a; stroke-width: 2; opacity: .92; }
.nm-controls { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.nm-reduced { border: 1px dashed #94a3b8; border-radius: 12px; padding: 1.25rem; background: #f1f5f9; }

/* ---------- Motion dialog ---------- */
.motion-dialog { border: 0; border-radius: 12px; padding: 1rem; width: min(920px, 95vw); max-height: 94dvh; box-shadow: 0 20px 80px #0005; }
.motion-dialog::backdrop { background: #172b4280; }
.motion-dialog header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.motion-dialog iframe { display: block; width: 100%; height: min(670px, 76dvh); border: 0; }
.motion-dialog button { padding: .5rem 1rem; }

/* ---------- Footer ---------- */
.site-footer { background: var(--header-bg); color: #d6e1e8; padding: 2.5rem 0 1.5rem; margin-top: 3rem; }
.site-footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 2rem; align-items: start; }
.site-footer-brand { display: flex; align-items: center; gap: 1rem; }
.site-footer-brand .ninja-logo { border: 2px solid #fff; }
.site-footer-tagline { font-size: 1.15rem; margin: 0; color: #fff; }
.site-footer-links { display: flex; flex-direction: column; gap: .4rem; }
.site-footer-links a { color: #b7c4d0; text-decoration: none; font-size: .95rem; }
.site-footer-links a:hover { color: #fff; text-decoration: underline; }
.site-footer-legal { margin: 2rem 0 0; font-size: .8rem; color: #8fa0b0; }
.site-footer-legal a { color: #d6e1e8; }

/* ---------- Setup form (My Apple Setup header) ---------- */
.setup-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: 1.1rem; }
.setup-form .chip { cursor: pointer; }
.setup-form input:checked + .chip, .setup-form .chip:has(input:checked) { background: var(--ink); border-color: var(--ink); color: #fff; }
.setup-form input[type=checkbox] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.setup-form .chip:has(input:focus-visible) { outline: 3px solid #167d94; outline-offset: 3px; }
.setup-form .btn { margin-left: .25rem; }

/* ---------- Responsive ---------- */
@media (max-width: 991px) {
  .skill-rail { grid-auto-columns: calc((100% - 1rem) / 2); }
  .skill-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head.has-hero .page-head-grid { grid-template-columns: 1fr; }
  .page-hero-media { max-width: 240px; }
  .tip-eyebrow { display: none; }
  .site-links { margin-left: 0; flex-direction: column; gap: .1rem; padding: .5rem 0 .25rem; }
  .site-links .nav-link { border-radius: 8px; }
  .site-footer-grid { grid-template-columns: 1fr 1fr; }
  .site-footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 575px) {
  .skill-rail { grid-auto-columns: 86%; }
  .skill-grid { grid-template-columns: 1fr; }
  .section-heading { align-items: start; }
  .section-heading p { font-size: .85rem; }
  .rail-tools { flex-direction: column; gap: .5rem; align-items: end; }
  .tip-strip-inner { gap: .5rem; flex-wrap: wrap; }
  .tip-strip p { min-width: 65%; }
  .page-head { padding: 1.6rem 0 1.2rem; }
  .page-hero-media { display: none; }
  .page-search { flex-direction: column; }
  .site-nav-inner { gap: .5rem .75rem; }
  .site-brand span { font-size: 1rem; }
  .site-search { order: 3; flex-basis: 100%; max-width: none; }
  .site-links-wrap { order: 4; }
  .technique-row { flex-wrap: wrap; gap: .4rem .6rem; }
  .technique-title { flex-basis: 60%; }
  .technique-action { max-width: none; flex: 1 1 65%; padding-left: 0; }
  .context-label { min-width: auto; }
  .demo-link { min-height: 44px; display: flex; align-items: center; }
  .learn-nav-links { flex-direction: column; }
  .learn-nav-links a { max-width: none; }
  .learn-nav-next { text-align: left; margin-left: 0; }
  .learn-related .skill-rail { grid-auto-columns: 86%; }
  .lesson-action { font-size: 1.05rem; }
  .learn-head h1 { font-size: 1.6rem; }
  .site-footer-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .skill-rail { scroll-behavior: auto; }
  .skill-card { transition: none; }
  .nm-key rect { transition: none; }
}
@media print {
  .site-header, .site-footer, .tip-strip, .studio-edit-bar, .rail-tools, .page-chips, .page-actions, .results-filter, .learn-nav, .learn-related, .motion-dialog { display: none !important; }
  .technique-row { break-inside: avoid; }
  .results-group-collapsed { display: block; }
  .results-group-collapsed[open] summary, .results-group-collapsed summary { display: block; }
}
