/* Infographic touches for items, digests and Home. */

/* at a glance tiles */
.glance { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin: 0 0 22px; }
.g-tile { display: grid; justify-items: center; gap: 2px; padding: 12px 8px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); text-align: center; }
.g-tile span { font-size: 1.3rem; }
.g-tile b { font-size: 1.35rem; line-height: 1.1; }
.g-tile small { color: var(--muted); font-size: .75rem; }

/* key points timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; inset-block: 14px; inset-inline-start: 33px; width: 2px; background: linear-gradient(var(--brand), var(--accent)); opacity: .35; }
.timeline li { position: relative; display: flex; gap: 14px; align-items: flex-start; margin-bottom: 12px; }
.ts-node { position: relative; z-index: 1; flex: none; min-width: 68px; padding: .35em .5em; border-radius: 10px; text-align: center; font: 700 .8rem/1.2 ui-monospace, "Cascadia Code", Consolas, monospace; color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2)); border: 0; box-shadow: 0 3px 10px color-mix(in srgb, var(--brand) 30%, transparent); }
button.ts-node { cursor: pointer; }
button.ts-node:hover { filter: brightness(1.1); }
.ts-node.num { font-family: inherit; font-size: .95rem; }
.timeline .prose { flex: 1; padding: 8px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.timeline .prose p { margin: 0; }

/* Academy links on item pages */
.lesson-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.lesson-link { --track: var(--brand); display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; color: var(--text); background: linear-gradient(135deg, color-mix(in srgb, var(--track) 12%, var(--surface)), var(--surface)); border: 1px solid color-mix(in srgb, var(--track) 30%, var(--line)); }
.lesson-link:hover { text-decoration: none; border-color: var(--track); }
.lesson-link .big-icon { width: 48px; height: 48px; font-size: 1.6rem; border-radius: 14px; }
.lesson-link small { display: block; color: var(--muted); font-size: .75rem; }
.lesson-link b { display: block; }

/* digest */
.digest-hero { padding: 20px; border-radius: 18px; margin-bottom: 16px; background: radial-gradient(120% 140% at 100% 0%, #22d3ee22, transparent 50%), var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.digest-hero h2 { margin-bottom: 14px; }
.digest-hero .glance { margin-bottom: 12px; }
.digest-hero .g-tile { box-shadow: none; background: var(--surface-2); border: 0; }
.digest-thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.digest-thumbs img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; display: block; }
.digest-card { --dc: var(--brand); background: var(--surface); border: 1px solid var(--line); border-inline-start: 5px solid var(--dc); border-radius: 16px; padding: 16px 20px; margin-bottom: 14px; box-shadow: var(--shadow); }
.digest-card h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-size: 1.05rem; }
.digest-card h3 span { font-size: 1.3rem; }
.digest-card .prose > :last-child { margin-bottom: 0; }
.dc-top { --dc: #f97316; }
.dc-discovered { --dc: #a855f7; }
.dc-look { --dc: #0ea5e9; }
.dc-try { --dc: #16a34a; background: linear-gradient(135deg, color-mix(in srgb, #16a34a 7%, var(--surface)), var(--surface)); }
.dc-radar { --dc: #06b6d4; }
.dc-archived { --dc: var(--line); opacity: .8; }

/* Home: daily learning habit */
.learn-strip { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; margin: -6px 0 24px; }
.learn-strip > a { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); color: var(--text); box-shadow: var(--shadow); }
.learn-strip > a:hover { text-decoration: none; border-color: var(--brand); }
.ls-streak, .ls-cards { flex-direction: column; justify-content: center; gap: 0 !important; min-width: 96px; text-align: center; }
.ls-streak b, .ls-cards b { font-size: 1.25rem; }
.learn-strip small { color: var(--muted); font-size: .75rem; }
.ls-cards.due { border-color: #fbbf24 !important; background: color-mix(in srgb, #fbbf24 10%, var(--surface)) !important; }
.ls-next { --track: var(--brand); background: linear-gradient(135deg, color-mix(in srgb, var(--track) 14%, var(--surface)), var(--surface) 75%) !important; }
.ls-icon { font-size: 1.8rem; }
.ls-text { flex: 1; min-width: 0; display: grid; }
.ls-text b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ls-go { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--track); flex: none; }


@media (max-width: 860px) {
  .learn-strip { grid-template-columns: 1fr 1fr; }
  .ls-next { grid-column: 1 / -1; order: -1; }
  .digest-thumbs { grid-template-columns: repeat(2, 1fr); }
  .timeline::before { inset-inline-start: 29px; }
  .ts-node { min-width: 58px; }
}

/* Ask your hub */
.ask-panel { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-radius: 16px; background: linear-gradient(135deg, var(--brand-soft), var(--surface)); border: 1px solid var(--line); margin-bottom: 16px; }
.ask-panel header { width: 100%; }
.ask-panel .prose { width: 100%; }
.spinner { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.dc-week { --dc: #6366f1; font-size: 1.05rem; }
.dc-progress { --dc: #f59e0b; }
.dc-learn { --dc: #0f766e; }

/* inbox triage */
.card-wrap { position: relative; display: flex; flex-direction: column; transition: opacity .25s, transform .25s; }
.card-wrap > .card { flex: 1; }
.card-actions { display: flex; gap: 6px; padding: 8px 10px; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); background: var(--surface-2); margin-top: -8px; padding-top: 14px; }
.card-wrap > .card { border-end-start-radius: var(--radius); border-end-end-radius: var(--radius); position: relative; z-index: 1; }
.card-actions .button, .card-actions button { padding: .3em .7em; font-size: .78rem; }
.leaving { opacity: 0; transform: scale(.96); }
.idea { transition: opacity .25s, transform .25s; }
.tabs small { opacity: .7; margin-inline-start: 4px; }
.radar-meta { font-weight: 700; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
label.check.disabled { opacity: .6; }
.ts-node.playing { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); }


/* phone "More" menu */
.tab-more { position: relative; flex: 1; flex-direction: column; gap: 2px; padding: 6px 4px; font-size: .68rem; border: 0; background: none; color: var(--muted); font-weight: 600; }
.badge-dot { position: absolute; top: 2px; inset-inline-end: 22%; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: #ef4444; color: #fff; font-size: .65rem; display: grid; place-items: center; }
.more-sheet { position: fixed; bottom: calc(64px + env(safe-area-inset-bottom)); inset-inline: 10px; display: grid; gap: 2px; padding: 8px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 10px 30px rgb(0 0 0 / 25%); z-index: 20; }
.more-sheet a { flex-direction: row !important; font-size: .95rem !important; padding: 12px 14px !important; justify-content: flex-start; }

/* focus mode: lessons and reviews get the whole screen */
body.focus .sidebar, body.focus .topbar, body.focus .tabbar { display: none !important; }
body.focus #shell { grid-template-columns: 1fr; }
body.focus .view { max-width: 820px; margin: 0 auto; padding-top: 20px; }

/* chips rows scroll without a visible bar */
.chips.scroll { scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }

/* phone: compact rows instead of tall cards */
@media (max-width: 600px) {
  .cards { grid-template-columns: 1fr; gap: 10px; }
  .card { flex-direction: row; align-items: stretch; }
  .card .thumb { width: 96px; min-width: 96px; aspect-ratio: auto; font-size: .7rem; }
  .card .thumb .play { width: 30px; height: 30px; }
  .card .thumb .play::after { inset-block-start: 8px; inset-inline-start: 11px; border-block-width: 7px; border-inline-start-width: 11px; }
  .card-body { padding: 10px 12px; gap: 4px; }
  .card h3 { font-size: .93rem; }
  .card .summary { -webkit-line-clamp: 2; font-size: .82rem; }
  .card-actions { margin-top: -4px; padding-top: 10px; }
}
.source-list li.failing { border-color: color-mix(in srgb, var(--err) 45%, var(--line)); background: color-mix(in srgb, var(--err) 5%, var(--surface)); }

/* Home: idea previews stay short; the Ideas page shows them in full */
.two-col .idea .how { max-height: 6.2em; overflow: hidden; mask-image: linear-gradient(#000 60%, transparent); }
.two-col .idea .seg { display: none; }

/* tool updates timeline */
.updates .tool-row { display: grid; grid-template-columns: 220px 1fr; gap: 6px 16px; padding: 12px 0; border-top: 1px dashed var(--line); }
.updates .tool-row:first-of-type { border-top: 0; }
.tool-name small { display: block; color: var(--muted); font-size: .78rem; }
.versions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ver { display: inline-grid; padding: .3em .7em; border-radius: 10px; background: var(--surface-2); color: var(--text); font: 700 .8rem/1.2 ui-monospace, "Cascadia Code", Consolas, monospace; text-align: center; }
.ver small { font: 500 .68rem/1.2 var(--font); color: var(--muted); }
.ver.latest { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.ver.latest small { color: #e0e7ff; }
.ver:hover { text-decoration: none; filter: brightness(1.05); }
.changes { grid-column: 2; margin: 4px 0 0; padding-inline-start: 1.1em; color: var(--muted); font-size: .88rem; display: grid; gap: 3px; }
.update-strip { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -10px 0 22px; font-weight: 700; font-size: .88rem; }
.update-strip .chip b { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
@media (max-width: 860px) {
  .updates .tool-row { grid-template-columns: 1fr; }
  .changes { grid-column: 1; }
}

/* Home: one compact row of numbers instead of four big tiles */
.stat-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 20px; }
.stat-chips a { display: inline-flex; align-items: center; gap: 6px; padding: .45em .9em; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: .88rem; box-shadow: var(--shadow); }
.stat-chips a b { color: var(--text); font-size: 1rem; }
.stat-chips a:hover { border-color: var(--brand); text-decoration: none; }
.brief-cta.done { background: rgb(255 255 255 / 10%); font-weight: 600; cursor: default; }

/* arrows follow the reading direction; media "play" icons never flip */
:dir(rtl) .dir-arrow { display: inline-block; transform: scaleX(-1); }

/* toasts with an action (Undo) */
#toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; }
#toast:not(.show) { pointer-events: none; }
.toast-action { padding: .25em .8em; border-radius: 8px; border: 1px solid rgb(255 255 255 / 40%); background: transparent; color: #fff; font-weight: 700; font-size: .85rem; }

/* hub offline */
#offline { position: fixed; top: 0; inset-inline: 0; z-index: 80; padding: 10px 16px; text-align: center; background: #b45309; color: #fff; font-size: .9rem; box-shadow: var(--shadow); }
#offline small { opacity: .85; margin-inline-start: 8px; }

/* copyable code chips */
code.copyable { cursor: copy; border: 1px dashed transparent; }
code.copyable:hover { border-color: var(--brand); }
code.copied { background: color-mix(in srgb, var(--ok) 25%, var(--surface)); }

/* Listen while speaking */
.speaking { animation: pulse 1s infinite alternate; border-color: var(--brand) !important; }

/* settings cards share one width; More badge clears its icon */
.settings { max-width: none; }
.badge-dot { top: 0; inset-inline-end: 14%; transform: translate(40%, -10%); }
:dir(rtl) .badge-dot { transform: translate(-40%, -10%); }

/* readable long titles everywhere */
.card h3, .brief-body h2, .item h1, .lesson-link b { overflow-wrap: anywhere; }
.brief-cta.done { font-size: .8rem; padding: .45em 1em; border-radius: 12px; }
.item .player { scroll-margin-top: 72px; }

/* video study layout: player + "now playing" beside the summary, timeline and use cases */
.item.has-video { max-width: 1240px; }
.item-side .now-playing { margin: -6px 2px 14px; }
.timeline li.now .prose { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.timeline li.now .ts-node { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); }
@media (min-width: 1200px) {
  .item.has-video { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 28px; align-items: start; }
  .item.has-video .item-side { grid-column: 2; grid-row: 1; position: sticky; top: 80px; }
  .item.has-video .item-main { grid-column: 1; grid-row: 1; min-width: 0; }
  .item.has-video .item-side .player { margin-bottom: 10px; }
}

.item.has-video .glance { grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); }
.side-points h2 { font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
@media (min-width: 1200px) {
  /* chapters beside the video: scroll inside the column, the video stays put */
  .item.has-video .side-points { max-height: calc(100vh - 80px - 300px); overflow-y: auto; padding-inline-end: 6px; scrollbar-width: thin; }
}

/* first-run checklist */
.getting-started header small { color: var(--muted); font-weight: 600; margin-inline-start: 6px; }
.gs-bar { background: var(--surface-2); margin: 0 0 14px; }
.gs-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.gs-steps a { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); color: var(--text); background: var(--surface); }
.gs-steps a:hover { border-color: var(--brand); text-decoration: none; }
.gs-steps small { display: block; color: var(--muted); font-size: .78rem; }
.gs-icon { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); font-size: 1.1rem; }
.gs-steps li.done a { opacity: .6; }
.gs-steps li.done .gs-icon { background: var(--ok); color: #fff; font-weight: 800; }

@media (max-width: 1199px) {
  .item.has-video { display: flex; flex-direction: column; }
  .item.has-video .item-side { display: contents; }
  .item.has-video .player { order: 0; }
  .item.has-video .now-playing { order: 1; }
  .item.has-video .item-main { order: 2; }
  .item.has-video .side-points { order: 3; }
}
@media (max-width: 860px) {
  /* the playing video stays reachable while scrolling the chapters */
  .item.has-video .player { position: sticky; top: 56px; z-index: 6; }
}
.ver.pre { opacity: .7; border: 1px dashed var(--line); }
.ic .code, .lab .code { display: grid; gap: 6px; }
.ic .code button, .lab .code button { position: static; justify-self: end; }
