/* SalsaCoach — /learn/ and /es/ pages. Loaded after style.css; reuses its
   tokens (--bg, --surface, --timing, --gold …) and adds reading layout and
   the teaching figures. Colour meaning follows the app: celeste = the count,
   gold = clave, coral = beat-keepers, green = harmony. */

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 50; background: var(--timing); color: #08222e; padding: 8px 14px; border-radius: 8px; font-weight: 800; }
.skip-link:focus { left: 12px; }

/* language links in the header (real URLs on static pages, not a JS swap) */
.lang-links a { display: inline-block; color: var(--muted); padding: 6px 13px; font-size: 13px; font-weight: 700; letter-spacing: .5px; text-decoration: none; }
.lang-links a:hover { color: var(--text); }
.lang-links a.active { background: var(--accent); color: #17121c; }
nav a[aria-current="page"] { color: var(--text); }

/* ---------- article ---------- */
.article { max-width: 44rem; margin: 0 auto; padding: 28px 0 40px; }
.article h1 { font-size: clamp(34px, 6vw, 56px); margin: 10px 0 14px; }
.article .dek { font-size: clamp(18px, 2.3vw, 21px); color: var(--muted); line-height: 1.55; margin-bottom: 22px; }
.article h2 { font-family: var(--font-display); font-size: clamp(25px, 3.4vw, 34px); margin: 44px 0 12px; letter-spacing: .3px; line-height: 1.1; }
.article h3 { font-size: 19px; margin: 26px 0 8px; }
.article p, .article li { font-size: 17.5px; line-height: 1.72; color: #e9e1d6; }
.article p { margin: 0 0 16px; }
.article ul, .article ol { margin: 0 0 18px; padding-left: 22px; }
.article li { margin-bottom: 6px; }
.article a { color: var(--timing); text-underline-offset: 3px; }
.article a:hover { color: #8fd3f4; }
.article strong { color: var(--text); }
.article em { color: var(--text); }
.article .label { font-family: var(--font-display); letter-spacing: .6px; text-transform: uppercase; font-size: 12px; color: var(--faint); }

.crumbs { font-size: 13.5px; color: var(--faint); margin-top: 8px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }

.byline { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13.5px; color: var(--faint); margin-bottom: 26px; }
.byline a { color: var(--muted); }

.short-answer { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--timing); border-radius: 14px; padding: 18px 22px 6px; margin: 8px 0 30px; }
.short-answer .label { color: var(--timing); display: block; margin-bottom: 6px; }
.short-answer p { font-size: 18px; color: var(--text); }

.callout { background: var(--raised); border: 1px solid var(--border); border-radius: 14px; padding: 16px 20px 4px; margin: 22px 0; }
.callout.gold { border-color: rgba(255, 201, 75, .45); }
.callout .label { display: block; color: var(--gold); margin-bottom: 4px; }
.callout p { font-size: 16px; }

.steps-list { counter-reset: s; list-style: none; padding-left: 0; }
.steps-list > li { counter-increment: s; position: relative; padding-left: 44px; margin-bottom: 14px; }
.steps-list > li::before { content: counter(s); position: absolute; left: 0; top: 2px; width: 30px; height: 30px; border-radius: 50%; background: var(--raised); border: 1px solid var(--border); color: var(--timing); font-family: var(--font-display); font-weight: 700; display: grid; place-items: center; font-size: 15px; }

.try-box { display: grid; gap: 6px; background: radial-gradient(120% 90% at 0% 0%, rgba(87, 188, 236, .14), transparent 60%), var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px 24px; margin: 34px 0; }
.try-box h2 { margin: 0 0 4px; font-size: 26px; }
.try-box p { margin: 0; color: var(--muted); }
.try-box .cta { justify-self: start; margin-top: 12px; }

/* ---------- the count grid ---------- */
.count-grid, .clave-pair, .timing-scale { margin: 26px 0 30px; }
.grid-frame, .table-frame { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 10px 10px; }
.count-grid table, .clave-pair table { width: 100%; border-collapse: separate; border-spacing: 2px 5px; table-layout: fixed; }
.count-grid th, .count-grid td, .clave-pair th, .clave-pair td { padding: 0; text-align: center; font-weight: 600; }
.count-grid thead th, .clave-pair thead th { font-family: var(--font-display); font-size: 15px; color: var(--muted); padding-bottom: 4px; }
.count-grid thead th.and, .clave-pair thead th.and { font-size: 11px; color: var(--faint); }
.count-grid thead th.one, .clave-pair thead th.one { color: var(--timing); }
.count-grid .rowhead, .clave-pair tbody th { width: 76px; text-align: left; font-size: 12.5px; color: var(--text); padding-right: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clave-pair tbody th small { display: block; font-weight: 400; font-size: 10.5px; color: var(--faint); white-space: normal; line-height: 1.2; }
.clave-pair tbody th { width: 110px; }
.count-grid td, .clave-pair td { height: 26px; border-radius: 6px; background: rgba(255, 255, 255, .025); position: relative; }
.count-grid td.and, .clave-pair td.and { background: transparent; }
.count-grid td.one, .clave-pair td.one { box-shadow: inset 0 0 0 1.5px rgba(87, 188, 236, .55); background: rgba(87, 188, 236, .07); }
.count-grid td.hit::before, .clave-pair td.hit::before { content: ''; position: absolute; left: 50%; top: 50%; width: 13px; height: 13px; margin: -6.5px 0 0 -6.5px; border-radius: 50%; background: var(--inst, var(--gold)); box-shadow: 0 0 0 3px rgba(0, 0, 0, .15); }
.count-grid td.and.hit::before, .clave-pair td.and.hit::before { width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; }
.count-grid .rowhead .inst-name { display: block; overflow: hidden; text-overflow: ellipsis; }
.count-grid tr[data-inst] .rowhead .inst-name { border-left: 3px solid var(--inst); padding-left: 6px; }
.count-grid tbody.grid-feet .feet-label th { text-align: left; font-family: var(--font-display); font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); padding-top: 10px; }
.count-grid tr.step-row td.step::before, .count-grid tr.step-row td.brk::before { content: ''; position: absolute; left: 50%; top: 50%; width: 14px; height: 9px; margin: -4.5px 0 0 -7px; border-radius: 5px; background: var(--timing); opacity: .75; }
.count-grid tr.step-row td.brk::before { width: 18px; height: 12px; margin: -6px 0 0 -9px; opacity: 1; background: var(--accent); }
.count-grid tr.step-row td.hold::before { content: '·'; color: var(--faint); font-size: 18px; line-height: 26px; }
.count-grid tr[data-inst].muted { opacity: .35; }
.count-grid td.now, .count-grid th.now { outline: 2px solid var(--text); outline-offset: -2px; }
.count-grid thead th.now { color: var(--text); }
.count-grid .rowhead button { all: unset; cursor: pointer; display: block; width: 100%; }
.count-grid .rowhead button:focus-visible { outline: 2px solid var(--timing); outline-offset: 2px; border-radius: 4px; }
.count-grid .rowhead button::after { content: ' ⏻'; font-size: 10px; color: var(--faint); }
.count-grid tr.muted .rowhead button::after { content: ' ✕'; }

figcaption { margin-top: 10px; }
.grid-caption { font-size: 14.5px !important; color: var(--muted) !important; margin: 0 0 6px !important; }
.grid-summary { list-style: none; padding: 0 !important; margin: 0 !important; display: grid; gap: 2px; }
.grid-summary li { font-size: 13.5px !important; color: var(--faint) !important; line-height: 1.5 !important; margin: 0 !important; }
.grid-summary strong { color: var(--muted); }

.player { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 0 0 10px; }
.player[hidden] { display: none; }
.player-play { font: inherit; font-weight: 800; background: var(--timing); color: #08222e; border: 0; border-radius: 999px; padding: 10px 20px; cursor: pointer; min-height: 44px; }
.player-play[aria-pressed="true"] { background: var(--accent); color: #1f0c06; }
.player-tempo, .player-one { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.player-tempo input { accent-color: var(--timing); width: 140px; }
.player-tempo output { font-family: var(--font-display); color: var(--text); min-width: 2.2em; text-align: right; }
.player-one input { accent-color: var(--timing); width: 18px; height: 18px; }
.player-note { flex-basis: 100%; margin: 0 !important; font-size: 12.5px !important; color: var(--faint) !important; }

/* ---------- timing scale ---------- */
.scale { position: relative; height: 64px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.scale .band { position: absolute; top: 12px; height: 22px; border-radius: 6px; }
.scale .band.work { background: rgba(255, 201, 75, .28); }
.scale .band.good { background: rgba(87, 188, 236, .45); }
.scale .band.perfect { background: #a5e06a; }
.scale .zero { position: absolute; left: 50%; top: 6px; bottom: 22px; width: 2px; background: var(--text); }
.scale .tick { position: absolute; bottom: 4px; font-size: 11px; color: var(--faint); }
.scale .tick.l { left: 8px; } .scale .tick.c { left: 50%; transform: translateX(-50%); } .scale .tick.r { right: 8px; }
.scale-legend { list-style: none; padding: 0 !important; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 12px !important; }
.scale-legend li { font-size: 14px !important; margin: 0 !important; display: inline-flex; align-items: center; gap: 7px; }
.scale-legend li::before { content: ''; width: 12px; height: 12px; border-radius: 3px; }
.scale-legend .perfect::before { background: #a5e06a; } .scale-legend .good::before { background: rgba(87, 188, 236, .75); } .scale-legend .work::before { background: rgba(255, 201, 75, .55); }
table.windows { width: 100%; border-collapse: collapse; font-size: 14px; }
table.windows th, table.windows td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--border); }
table.windows thead th { color: var(--faint); font-weight: 700; font-size: 12.5px; text-transform: uppercase; letter-spacing: .6px; }
table.windows tbody th { color: var(--text); }
table.windows td { color: var(--muted); font-variant-numeric: tabular-nums; }
table.windows tr:last-child th, table.windows tr:last-child td { border-bottom: 0; }

/* ---------- sources, related, about ---------- */
.sources { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border); }
.sources h2 { font-size: 22px !important; margin-top: 0 !important; }
.sources li { font-size: 14.5px !important; color: var(--muted) !important; }
.sources .note { color: var(--faint); }
.related { margin-top: 34px; }
.related h2 { font-size: 22px !important; margin-top: 0 !important; }
.related ul { list-style: none; padding: 0 !important; display: grid; gap: 10px; }
.related li a { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; color: var(--text); text-decoration: none; font-weight: 700; }
.related li a span { display: block; font-weight: 400; font-size: 14px; color: var(--muted); margin-top: 2px; }
.related li a:hover { border-color: var(--timing); }
.about-page { margin-top: 30px; font-size: 14px !important; color: var(--faint) !important; border-top: 1px solid var(--border); padding-top: 16px; }

/* ---------- /learn/ hub ---------- */
.hub { padding: 30px 0 50px; }
.hub h1 { font-size: clamp(38px, 7vw, 64px); margin: 10px 0 12px; }
.hub .lead { color: var(--muted); max-width: 640px; font-size: 18px; }
.hub-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 14px; margin-top: 26px; }
.hub-card { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px 22px; text-decoration: none; color: var(--text); position: relative; overflow: hidden; }
.hub-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--card-edge, var(--timing)); }
.hub-card:hover { border-color: var(--card-edge, var(--timing)); transform: translateY(-1px); }
.hub-card .kind { font-family: var(--font-display); font-size: 12px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--card-edge, var(--timing)); }
.hub-card h3 { font-size: 20px; margin: 0; }
.hub-card p { color: var(--muted); font-size: 15px; margin: 0; }
.hub-section { margin-top: 44px; }
.hub-section h2 { font-size: clamp(26px, 3.6vw, 36px); margin-bottom: 6px; }
.hub-section > p { color: var(--muted); max-width: 640px; }
.coming { color: var(--faint); font-size: 14.5px; }

@media (max-width: 560px) {
  .article p, .article li { font-size: 16.5px; }
  .count-grid .rowhead { width: 58px; font-size: 11px; }
  .clave-pair tbody th { width: 64px; }
  .count-grid td, .clave-pair td { height: 22px; border-radius: 4px; }
  .count-grid table, .clave-pair table { border-spacing: 1px 4px; }
  .count-grid td.hit::before, .clave-pair td.hit::before { width: 10px; height: 10px; margin: -5px 0 0 -5px; }
  .count-grid td.and.hit::before, .clave-pair td.and.hit::before { width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; }
  .count-grid thead th, .clave-pair thead th { font-size: 12px; }
  .grid-frame { padding: 8px 4px 6px; }
  .player-tempo input { width: 110px; }
}
@media (prefers-reduced-motion: reduce) {
  .hub-card:hover { transform: none; }
}

/* Step-row labels ("On2 (2-3-4)") may wrap on phones rather than truncate. */
.count-grid tr.step-row .rowhead, .count-grid tr.step-row .rowhead .inst-name { white-space: normal; line-height: 1.15; overflow: visible; }

/* ---------- history visuals: timeline, network map, recordings, listen box ---------- */
[data-place="cuba"] { --place: var(--gold); }
[data-place="pr"] { --place: var(--pink); }
[data-place="ny"] { --place: var(--timing); }
[data-place="co"] { --place: var(--lime); }
[data-place="world"], [data-place="af"], [data-place="ve"] { --place: var(--accent); }

.timeline { margin: 26px 0 30px; }
.tl-list { list-style: none; padding: 0 !important; margin: 0 !important; position: relative; }
.tl-list::before { content: ''; position: absolute; left: 7px; top: 10px; bottom: 10px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-left: 34px; margin: 0 0 22px !important; }
.tl-item::before { content: ''; position: absolute; left: 1px; top: 6px; width: 14px; height: 14px; border-radius: 50%; background: var(--place, var(--timing)); box-shadow: 0 0 0 3px var(--bg); }
.tl-when { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; margin: 0 !important; }
.tl-year { font-family: var(--font-display); font-weight: 700; color: var(--text); font-size: 17px; }
.tl-place { font-size: 11.5px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--place, var(--timing)); }
.tl-title { font-size: 17px !important; margin: 2px 0 4px !important; line-height: 1.35; }
.tl-text { font-size: 15.5px !important; line-height: 1.6 !important; color: var(--muted) !important; margin: 0 !important; }
.tl-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0 !important; margin: 8px 0 0 !important; }
.tl-legend li { font-size: 13.5px !important; color: var(--muted) !important; margin: 0 !important; display: inline-flex; align-items: center; gap: 7px; }
.tl-legend li::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--place); }

.network-map { margin: 26px 0 30px; }
.nm-frame { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px; }
.nm-frame svg { display: block; width: 100%; height: auto; }
.nm-frame svg.nm-tall { display: none; max-width: 420px; margin: 0 auto; }
@media (max-width: 560px) {
  .nm-frame svg.nm-wide { display: none; }
  .nm-frame svg.nm-tall { display: block; }
}
.nm-node rect { fill: var(--raised); stroke: var(--place, var(--timing)); stroke-width: 2; }
.nm-label { fill: var(--text); font: 700 15px var(--font-display); }
.nm-sub { fill: var(--muted); font: 500 11.5px var(--font-body); }
.nm-edge { fill: none; stroke: rgba(247, 241, 232, .45); stroke-width: 1.6; }
.nm-arrowhead { fill: rgba(247, 241, 232, .6); }
.nm-edge-label { fill: var(--gold); font: 800 13px var(--font-display); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.nm-list { padding-left: 0 !important; list-style: none; margin: 12px 0 0 !important; display: grid; gap: 6px; }
.nm-list li { font-size: 14.5px !important; line-height: 1.55 !important; color: var(--muted) !important; margin: 0 !important; }
.nm-list strong { color: var(--text); }
.nm-key { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 6px; background: var(--raised); color: var(--gold); font: 800 12.5px var(--font-display); margin-right: 4px; }

.recordings { margin: 22px 0 28px; }
.recordings table { width: 100%; border-collapse: collapse; }
.recordings th, .recordings td { text-align: left; vertical-align: top; padding: 10px 10px; border-bottom: 1px solid var(--border); font-size: 15px; line-height: 1.5; }
.recordings th { font-size: 12.5px; letter-spacing: .5px; text-transform: uppercase; color: var(--faint); font-weight: 800; }
.rec-year { font-family: var(--font-display); font-weight: 700; white-space: nowrap; color: var(--gold); }
.rec-meta { font-size: 13px; color: var(--faint); }

.listen-box { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--pink); border-radius: 14px; padding: 16px 20px 8px; margin: 26px 0; }
.listen-box h2 { font-size: 20px !important; margin: 0 0 8px !important; }
.listen-box ul { margin: 0 0 8px !important; }
.listen-box p { font-size: 14.5px !important; color: var(--faint) !important; }

.editorial-note { font-size: 14.5px !important; color: var(--faint) !important; border-top: 1px solid var(--border); padding-top: 12px; margin-top: 26px !important; }

@media (max-width: 560px) {
  .recordings th:nth-child(1), .recordings td:nth-child(1) { width: 52px; }
}

/* Buttons inside articles keep their own colours (the article link colour made
   the try-box CTA blue on coral, 1.3:1). */
.article a.cta, .article a.cta:hover { color: #1f0c06; text-decoration: none; }

/* Evidence tables stack into cards on phones instead of scrolling sideways. */
@media (max-width: 560px) {
  .evidence table, .evidence thead, .evidence tbody, .evidence tr, .evidence th, .evidence td { display: block; width: 100%; }
  .evidence thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .evidence tr { border-bottom: 1px solid var(--border); padding: 12px 0; }
  .evidence th, .evidence td { border: 0; padding: 3px 0; }
  .evidence td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--faint); margin-top: 6px; }
}
