/* Learn to Code (learntocode.epiccoon.com): Olympus' parchment and night blue, gold for what matters, code on dark slate. */
@font-face { font-family: "Cinzel"; src: url("/static/vendor/cinzel-latin.woff2") format("woff2"); font-weight: 400 900; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/static/vendor/inter-latin.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #f6efe0; --bg-2: #efe4cc; --card: #fffaf0; --ink: #2a1c10; --ink-2: #5b4630; --muted: #8a7558; --line: #dccaa5;
  --night: #14183a; --night-2: #232a5c; --gold: #f2b01e; --gold-2: #ffc533; --bronze: #a86b1f; --accent: #3b5bdb;
  --code-bg: #171a2b; --code-ink: #e7e9f5; --code-line: #2a2f4a;
  --ok: #2f9e44; --shadow: 0 2px 0 rgba(42, 28, 16, .12), 0 10px 30px -14px rgba(42, 28, 16, .35);
  --display: "Cinzel", Georgia, serif; --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1226; --bg-2: #161a36; --card: #1a1f40; --ink: #f2ead8; --ink-2: #cdbf9f; --muted: #9a8f78; --line: #2c3263;
    --code-bg: #0b0d1c; --code-line: #232849; --accent: #8ea6ff; --shadow: 0 10px 30px -14px rgba(0, 0, 0, .7); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1226; --bg-2: #161a36; --card: #1a1f40; --ink: #f2ead8; --ink-2: #cdbf9f; --muted: #9a8f78; --line: #2c3263;
  --code-bg: #0b0d1c; --code-line: #232849; --accent: #8ea6ff; --shadow: 0 10px 30px -14px rgba(0, 0, 0, .7); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; overflow-x: hidden; background: var(--bg); color: var(--ink); font: 16px/1.65 var(--sans); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); }
img { max-width: 100%; }
html[data-lang="es"] [lang="en"], html[data-lang="en"] [lang="es"] { display: none !important; }

/* ---------------------------------------------------------------- top bar */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px; padding: 10px max(16px, calc(50% - 600px));
  background: var(--night); color: #fff; border-bottom: 3px solid var(--gold); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand img { border-radius: 8px; }
.brand span { display: flex; flex-direction: column; line-height: 1.05; }
.brand b { font: 900 18px var(--display); letter-spacing: .03em; }
.brand small { font: 700 11px var(--display); letter-spacing: .2em; text-transform: uppercase; color: var(--gold-2); }
.topnav { display: flex; gap: 4px; margin-left: 8px; flex: 1; }
.topnav a { color: #d9dcf2; text-decoration: none; font-weight: 600; font-size: 14px; padding: 6px 10px; border-radius: 8px; }
.topnav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.tools { display: flex; gap: 6px; }
.iconbtn { border: 1px solid rgba(255, 255, 255, .25); background: transparent; color: #fff; border-radius: 8px; height: 34px; min-width: 34px;
  font: 700 13px var(--sans); cursor: pointer; }
.iconbtn:hover { background: rgba(255, 255, 255, .1); }
@media (max-width: 640px) { .topnav a:not(:first-child) { display: none; } .brand small { display: none; } .top { gap: 10px; } }

main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px 48px; }
.foot { text-align: center; color: var(--muted); font-size: 14px; padding: 22px 16px 30px; border-top: 1px solid var(--line); }
.foot a { color: var(--muted); }

/* ---------------------------------------------------------------- home */
.hero { margin: 0 calc(50% - 50vw) 28px; padding: 56px 16px 46px; text-align: center; color: #fff;
  background: radial-gradient(ellipse at 50% 120%, rgba(242, 176, 30, .35), transparent 60%), linear-gradient(180deg, var(--night), var(--night-2)); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 10px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='10'%3E%3Cpath d='M0 10h3V3h10v4H8V5H6v5h14V1H3' fill='none' stroke='%23ffc533' stroke-width='1.6' opacity='.8'/%3E%3C/svg%3E") repeat-x; }
.hero .kicker { display: inline-block; font: 900 12px var(--display); letter-spacing: .2em; text-transform: uppercase; color: var(--gold-2);
  border: 1px solid rgba(255, 197, 51, .5); border-radius: 99px; padding: 4px 14px; }
.hero h1 { font: 900 clamp(32px, 6vw, 56px)/1.05 var(--display); margin: 14px 0 10px; text-shadow: 0 3px 0 rgba(0, 0, 0, .35); }
.hero p { max-width: 640px; margin: 0 auto; color: #d9dcf2; font-size: 17px; }
.hero .code-hint { display: inline-block; margin-top: 22px; font: 14px var(--mono); background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 10px; padding: 10px 16px; color: #e7e9f5; text-align: left; }
.hero .code-hint .k { color: #ff9e64; } .hero .code-hint .s { color: #9ece6a; } .hero .code-hint .f { color: #7aa2f7; }

h2.section { font: 900 24px var(--display); margin: 8px 0 14px; }
.tracks { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.track { display: flex; flex-direction: column; background: var(--card); border: 2px solid var(--line); border-radius: 16px; overflow: hidden;
  text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.track:hover { transform: translateY(-3px); border-color: var(--c, var(--gold)); }
.track .band { height: 92px; display: grid; place-items: center; font-size: 44px;
  background: radial-gradient(ellipse at 50% 120%, color-mix(in srgb, var(--c, #f2b01e) 55%, transparent), transparent 70%), linear-gradient(180deg, var(--night), var(--night-2)); }
.track .in { padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.track h3 { font: 900 19px var(--display); margin: 0; }
.track p { margin: 0; color: var(--ink-2); font-size: 15px; flex: 1; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--bg-2); color: var(--ink-2); border: 1px solid var(--line); }
.pill.lang { background: color-mix(in srgb, var(--c, #f2b01e) 18%, var(--card)); border-color: color-mix(in srgb, var(--c, #f2b01e) 45%, var(--line)); }
.bar { height: 6px; background: var(--bg-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.why { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 30px; }
.why div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.why b { display: block; font: 900 16px var(--display); margin-bottom: 4px; }
.why span { color: var(--ink-2); font-size: 15px; }

/* ---------------------------------------------------------------- a track */
.crumbs { font-size: 14px; color: var(--muted); margin: 22px 0 6px; }
.crumbs a { color: var(--muted); text-decoration: none; } .crumbs a:hover { color: var(--accent); }
.trackhead { display: flex; gap: 18px; align-items: center; background: var(--card); border: 2px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.trackhead .big { font-size: 48px; width: 84px; height: 84px; display: grid; place-items: center; border-radius: 16px; flex: none;
  background: linear-gradient(180deg, var(--night), var(--night-2)); }
.trackhead h1 { font: 900 clamp(24px, 4vw, 34px)/1.1 var(--display); margin: 0 0 4px; }
.trackhead p { margin: 0; color: var(--ink-2); }
.lessons { list-style: none; padding: 0; margin: 20px 0 0; display: flex; flex-direction: column; gap: 10px; }
.lessons a { display: flex; gap: 14px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px;
  text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
.lessons a:hover { border-color: var(--gold); transform: translateX(3px); }
.lessons .n { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font: 900 15px var(--display);
  background: var(--night); color: var(--gold-2); }
.lessons .done .n { background: var(--ok); color: #fff; }
.lessons b { display: block; }
.lessons small { color: var(--muted); }
.lessons .grow { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- a lesson */
.lessonwrap { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 28px; margin-top: 18px; align-items: start; }
.side { position: sticky; top: 78px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; max-height: calc(100vh - 100px); overflow: auto; }
.side h4 { font: 900 14px var(--display); margin: 4px 6px 8px; }
.side a { display: flex; gap: 8px; align-items: baseline; padding: 6px 8px; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-size: 14px; }
.side a:hover { background: var(--bg-2); }
.side a.on { background: var(--night); color: #fff; }
.side a .n { font-weight: 800; color: var(--muted); min-width: 18px; }
.side a.on .n { color: var(--gold-2); }
.side a.done .n::after { content: " ✓"; color: var(--ok); }
@media (max-width: 900px) { .lessonwrap { grid-template-columns: 1fr; } .side { position: static; max-height: none; } }

article.lesson { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: clamp(18px, 4vw, 40px); box-shadow: var(--shadow); min-width: 0; }
article.lesson .lhead h1 { font: 900 clamp(26px, 4.5vw, 38px)/1.12 var(--display); margin: 4px 0 8px; }
article.lesson .lhead .sum { color: var(--ink-2); font-size: 17px; margin: 0 0 6px; }
.prose h2 { font: 900 24px/1.2 var(--display); margin: 34px 0 10px; padding-top: 6px; border-top: 1px dashed var(--line); }
.prose h3 { font: 800 19px/1.25 var(--sans); margin: 24px 0 8px; }
.prose h4 { font: 800 16px var(--sans); margin: 18px 0 6px; }
.prose p, .prose li { font-size: 16.5px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 4px 0; }
.prose :not(pre) > code { font: .9em var(--mono); background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.prose blockquote { margin: 16px 0; padding: 4px 16px; border-left: 4px solid var(--line); color: var(--ink-2); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 26px 0; }
.prose img { border-radius: 10px; border: 1px solid var(--line); }
.prose table { border-collapse: collapse; width: 100%; font-size: 15px; }
.prose .tablewrap { overflow-x: auto; margin: 14px 0; }
.prose th, .prose td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--bg-2); }
.callout { border-radius: 12px; padding: 12px 16px; margin: 16px 0; border: 1px solid; }
.callout .ct { font-weight: 800; margin-bottom: 2px; }
.callout > :last-child { margin-bottom: 0; }
.callout.tip { background: color-mix(in srgb, #2f9e44 10%, var(--card)); border-color: color-mix(in srgb, #2f9e44 40%, var(--line)); }
.callout.info, .callout.note { background: color-mix(in srgb, #3b5bdb 10%, var(--card)); border-color: color-mix(in srgb, #3b5bdb 40%, var(--line)); }
.callout.warning { background: color-mix(in srgb, #f08c00 12%, var(--card)); border-color: color-mix(in srgb, #f08c00 45%, var(--line)); }
.callout.danger { background: color-mix(in srgb, #e03131 10%, var(--card)); border-color: color-mix(in srgb, #e03131 40%, var(--line)); }

.codebox { position: relative; margin: 16px 0; border-radius: 12px; overflow: hidden; background: var(--code-bg); border: 1px solid var(--code-line); }
.codebox .cbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 14px; background: rgba(255, 255, 255, .04); border-bottom: 1px solid var(--code-line);
  font: 700 12px var(--sans); letter-spacing: .06em; text-transform: uppercase; color: #9aa3c7; }
.codebox .cbar .dots { display: flex; gap: 5px; margin-right: 4px; }
.codebox .cbar .dots i { width: 9px; height: 9px; border-radius: 50%; background: #3a4066; }
.codebox .cbar .file { text-transform: none; letter-spacing: 0; font: 12px var(--mono); color: #c7cdf0; }
.codebox .cbar .grow { flex: 1; }
.codebox .copy { border: 1px solid #3a4066; background: transparent; color: #c7cdf0; border-radius: 6px; font: 700 12px var(--sans); padding: 3px 9px; cursor: pointer; }
.codebox .copy:hover { background: #2a2f4a; }
.codebox .copy.ok { color: #9ece6a; border-color: #9ece6a; }
.codebox pre { margin: 0; padding: 14px 16px; overflow-x: auto; font: 14px/1.6 var(--mono); color: var(--code-ink); tab-size: 4; }
.tok-k { color: #ff9e64; font-weight: 600; } .tok-t { color: #2ac3de; } .tok-s { color: #9ece6a; } .tok-c { color: #6b7394; font-style: italic; }
.tok-n { color: #ff757f; } .tok-a { color: #e0af68; } .tok-f { color: #7aa2f7; } .tok-p { color: #bb9af7; }

.done-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line); }
.btn { display: inline-flex; align-items: center; gap: 8px; border: 2px solid var(--ink); background: var(--card); color: var(--ink); border-radius: 10px;
  font: 800 15px var(--sans); padding: 9px 16px; cursor: pointer; text-decoration: none; box-shadow: 0 3px 0 var(--ink); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.btn.gold { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #2a1c10; border-color: #2a1c10; box-shadow: 0 3px 0 #2a1c10; }
.btn.ok { background: var(--ok); color: #fff; border-color: #1b5e2a; box-shadow: 0 3px 0 #1b5e2a; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.pager a { display: block; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; text-decoration: none; color: inherit; }
.pager a:hover { border-color: var(--gold); }
.pager small { color: var(--muted); display: block; font-weight: 700; }
.pager .next { text-align: right; grid-column: 2; }
@media (max-width: 560px) { .pager { grid-template-columns: 1fr; } .pager .next { grid-column: 1; } }

.empty, .error { text-align: center; color: var(--muted); padding: 60px 16px; }
.loading { display: flex; justify-content: center; gap: 8px; padding: 80px 0; }
.loading span { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); animation: blink 1s infinite; }
.loading span:nth-child(2) { animation-delay: .15s; } .loading span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 50% { opacity: .2; } }
@media (prefers-reduced-motion: reduce) { .track, .lessons a { transition: none; } .loading span { animation: none; } }
