/* =========================================================
   Aplicaciones Web Progresivas — sistema visual del curso
   Paleta: teal "en línea" + coral "notificación/instalar"
   Tipografía: Sora (display) + Literata (lectura) + JetBrains Mono (código)
   ========================================================= */

:root {
  --bg: #f1f5f4;
  --surface: #ffffff;
  --surface-2: #e8f0ed;
  --surface-3: #dcebe6;
  --ink: #142523;
  --ink-soft: #3f5450;
  --ink-faint: #6b7f7a;
  --primary: #0e6b5c;
  --primary-strong: #0a4f45;
  --accent: #ff7a45;
  --accent-strong: #e8622f;
  --accent-ink: #7a2c0f;
  --line: #d7e0dc;
  --line-strong: #b9c8c2;
  --good: #1f8a5f;
  --warn: #b9790a;
  --glow-primary: rgba(14, 107, 92, 0.16);
  --glow-accent: rgba(255, 122, 69, 0.14);
  --shadow-sm: 0 1px 2px rgba(20, 37, 35, 0.05), 0 2px 6px rgba(20, 37, 35, 0.04);
  --shadow: 0 2px 6px rgba(20, 37, 35, 0.05), 0 12px 32px rgba(20, 37, 35, 0.08);
  --shadow-lg: 0 8px 20px rgba(20, 37, 35, 0.08), 0 28px 64px rgba(20, 37, 35, 0.14);
  --radius-sm: 9px;
  --radius: 14px;
  --radius-lg: 22px;
  --maxw: 72ch;
  --brand-gradient: linear-gradient(135deg, var(--primary) 0%, var(--primary) 35%, var(--accent) 100%);
  --font-display: "Sora", "Segoe UI", system-ui, sans-serif;
  --font-body: "Literata", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", "Consolas", monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1312;
    --surface: #11201d;
    --surface-2: #172723;
    --surface-3: #1e332d;
    --ink: #e9f1ed;
    --ink-soft: #a9beb8;
    --ink-faint: #7d938c;
    --primary: #52dcbb;
    --primary-strong: #8aefd6;
    --accent: #ff9d6f;
    --accent-strong: #ffb489;
    --accent-ink: #ffd9c4;
    --line: #223934;
    --line-strong: #2c4a42;
    --good: #5fd6a0;
    --warn: #f0b350;
    --glow-primary: rgba(82, 220, 187, 0.14);
    --glow-accent: rgba(255, 157, 111, 0.12);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 10px rgba(0, 0, 0, 0.35), 0 16px 40px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.4), 0 32px 72px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  --bg: #0a1312;
  --surface: #11201d;
  --surface-2: #172723;
  --surface-3: #1e332d;
  --ink: #e9f1ed;
  --ink-soft: #a9beb8;
  --ink-faint: #7d938c;
  --primary: #52dcbb;
  --primary-strong: #8aefd6;
  --accent: #ff9d6f;
  --accent-strong: #ffb489;
  --accent-ink: #ffd9c4;
  --line: #223934;
  --line-strong: #2c4a42;
  --good: #5fd6a0;
  --warn: #f0b350;
  --glow-primary: rgba(82, 220, 187, 0.14);
  --glow-accent: rgba(255, 157, 111, 0.12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 10px rgba(0, 0, 0, 0.35), 0 16px 40px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.4), 0 32px 72px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

/* Grano sutil sobre toda la página: le quita planitud al fondo sin distraer. */
html::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  opacity: .035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 140px 140px;
}

body {
  margin: 0;
  background:
    radial-gradient(1100px 480px at 12% -8%, var(--glow-primary), transparent 60%),
    radial-gradient(900px 420px at 100% 0%, var(--glow-accent), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.06rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  color: var(--ink);
  text-wrap: balance;
  line-height: 1.15;
  margin: 0;
}

h1 { font-size: clamp(1.9rem, 1.35rem + 2.4vw, 3.1rem); font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: clamp(1.35rem, 1.15rem + 0.9vw, 1.8rem); font-weight: 700; letter-spacing: -0.01em; margin-bottom: .7rem; }
h3 { font-size: 1.06rem; font-weight: 600; letter-spacing: .01em; }

.grad {
  background: var(--brand-gradient);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
@media (prefers-reduced-motion: no-preference) {
  .grad, .appbar::before { animation: sheen 7s ease-in-out infinite alternate; }
}
@keyframes sheen {
  from { background-position: 0% 50%; }
  to { background-position: 100% 50%; }
}

p { max-width: var(--maxw); }

a { color: var(--primary-strong); text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

code, .mono { font-family: var(--font-mono); font-size: .88em; }
code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .1em .4em;
}

@media (prefers-reduced-motion: no-preference) {
  a, button, .card, .session, .step, .checklist li, .appbar__tabs a, .theme-toggle, tbody tr {
    transition: background-color .2s var(--ease), border-color .2s var(--ease),
      color .2s var(--ease), box-shadow .25s var(--ease), transform .25s var(--ease);
  }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------- App bar (nav) ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1.1rem;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
.appbar::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--brand-gradient);
  background-size: 200% auto;
}

.appbar__brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.appbar__dot {
  width: 14px; height: 14px;
  border-radius: 5px;
  background: var(--brand-gradient);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
  flex: none;
}

.appbar__tabs {
  display: flex;
  gap: .25rem;
  margin-left: .5rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.appbar__tabs::-webkit-scrollbar { display: none; }

.appbar__tabs a {
  text-decoration: none;
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: .88rem;
  font-weight: 600;
  padding: .5rem .8rem;
  border-radius: 999px;
  white-space: nowrap;
}
.appbar__tabs a:hover { background: var(--surface-2); color: var(--ink); transform: translateY(-1px); }
.appbar__tabs a[aria-current="page"] {
  background: var(--primary);
  color: var(--bg);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 45%, transparent);
}

.appbar__spacer { flex: 1; }

.theme-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  width: 2.2rem; height: 2.2rem;
  display: grid; place-items: center;
  cursor: pointer;
  font-size: 1rem;
  flex: none;
}
.theme-toggle:hover { border-color: var(--line-strong); transform: rotate(-12deg) scale(1.06); box-shadow: var(--shadow-sm); }

/* ---------- Layout ---------- */
main {
  position: relative;
  max-width: 1040px;
  margin: 0 auto;
  padding: 2.6rem 1.25rem 5rem;
}

.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-bottom: 2.2rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2.4rem;
  isolation: isolate;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--font-display);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--primary-strong);
}
.eyebrow::before {
  content: "";
  width: 1.4em; height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.lede { max-width: var(--maxw); color: var(--ink-soft); font-size: 1.14rem; }

.badge-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .3rem; }
.badge {
  font-family: var(--font-display);
  font-size: .78rem;
  font-weight: 600;
  padding: .32rem .7rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
}
.badge--accent {
  border-color: transparent;
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
  color: var(--primary-strong);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 22%, transparent);
}

section { margin-bottom: 3.2rem; }
section > h2 { display: flex; align-items: baseline; gap: .6rem; }
.section-hours {
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* ---------- Cards ---------- */
.grid {
  display: grid;
  gap: 1.1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  box-shadow: var(--shadow-sm);
}
.card:hover {
  border-color: color-mix(in srgb, var(--primary) 30%, var(--line));
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}

.card h3 { margin-bottom: .4rem; }
.card p { margin: 0; color: var(--ink-soft); font-size: .97rem; }

/* Session / step cards: connected like stops on a route, since they ARE a
   literal sequence of class sessions — the line encodes that order. */
.session, .step {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: .9rem;
  box-shadow: var(--shadow-sm);
}
.session:hover, .step:hover { border-color: color-mix(in srgb, var(--primary) 26%, var(--line)); box-shadow: var(--shadow); }

.session {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0 1.1rem;
  align-items: start;
}

.session__num, .step__num {
  position: relative;
  z-index: 1;
  font-family: var(--font-mono);
  font-weight: 700;
  border-radius: 8px;
  width: 2.4rem; height: 2.4rem;
  display: grid; place-items: center;
  font-size: .95rem;
  flex: none;
}
.session__num { color: var(--primary-strong); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.step__num { color: var(--bg); background: var(--brand-gradient); }

.session:not(:last-child) > .session__num::after,
.step:not(:last-child) > .step__num::after {
  content: "";
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: .95rem;
  background: linear-gradient(var(--line-strong), transparent);
}

.session__body h3, .step__body h3 { margin-bottom: .3rem; }
.session__body p { margin: 0 0 .4rem; color: var(--ink-soft); font-size: .95rem; }
.session__meta {
  display: flex; flex-wrap: wrap; gap: .4rem;
  font-family: var(--font-mono); font-size: .74rem; color: var(--ink-faint);
}
.session__meta span {
  background: var(--surface-2);
  border-radius: 6px;
  padding: .15rem .45rem;
}

.session__hours {
  font-family: var(--font-mono);
  font-size: .82rem;
  color: var(--ink-faint);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.session__hours strong { display: block; color: var(--ink); font-size: 1rem; }

@media (max-width: 640px) {
  .session { grid-template-columns: auto 1fr; }
  .session__hours { grid-column: 1 / -1; text-align: left; display: flex; gap: .5rem; }
  .session__hours strong { display: inline; }
}

/* ---------- Checklist ---------- */
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.checklist li {
  display: flex; gap: .65rem; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: .65rem .85rem; font-size: .96rem;
}
.checklist li:hover { border-color: color-mix(in srgb, var(--primary) 26%, var(--line)); box-shadow: var(--shadow-sm); }
.checklist li::before {
  content: "";
  width: 1.05rem; height: 1.05rem;
  margin-top: .15rem;
  flex: none;
  border-radius: 5px;
  border: 2px solid var(--primary);
  background: transparent;
}

/* ---------- Evidence / rubric table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
table { border-collapse: collapse; width: 100%; min-width: 640px; font-size: .93rem; }
th, td { text-align: left; padding: .75rem .95rem; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th {
  font-family: var(--font-display);
  background: var(--surface-2);
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-soft);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

.grade-pill {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .74rem;
  padding: .16rem .58rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 14%, var(--surface-2));
  color: var(--primary-strong);
}

/* ---------- Callouts ---------- */
.callout {
  position: relative;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.callout::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--accent);
}
.callout h3 { color: var(--accent-ink); margin-bottom: .3rem; }
.callout p, .callout li { color: var(--ink-soft); }
.callout--good::before { background: var(--good); }

/* ---------- Footer ---------- */
footer {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.6rem 1.25rem 3rem;
  color: var(--ink-faint);
  font-size: .85rem;
  border-top: 1px solid var(--line);
}

/* ---------- Reveal al hacer scroll (solo si JS y sin prefers-reduced-motion) ---------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .7s var(--ease), transform .7s var(--ease);
}
.reveal.is-visible { opacity: 1; transform: none; }

/* ---------- Hero de portada: texto + maqueta de teléfono ---------- */
.hero--split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.2rem;
}
@media (min-width: 880px) {
  .hero--split { grid-template-columns: 1.15fr auto; align-items: center; }
}
.hero__visual { display: flex; justify-content: center; }

.stats { display: flex; gap: 1.6rem; margin: .4rem 0 .1rem; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat:not(:first-child) { padding-left: 1.6rem; border-left: 1px solid var(--line); }
.stat strong {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat span {
  margin-top: .3rem;
  font-family: var(--font-display);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-faint);
}

.phone-mock {
  position: relative;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 32px;
  padding: 14px;
  box-shadow: var(--shadow-lg);
}
@media (prefers-reduced-motion: no-preference) {
  .phone-mock { animation: float 6s ease-in-out infinite; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.phone-mock__notch {
  width: 64px; height: 14px;
  background: var(--ink);
  opacity: .14;
  border-radius: 0 0 10px 10px;
  margin: 0 auto 10px;
}
.phone-mock__bar {
  background: var(--brand-gradient);
  color: var(--bg);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .72rem;
  border-radius: 10px;
  padding: .55rem .65rem;
  margin-bottom: .6rem;
}
.phone-mock__row {
  display: flex;
  align-items: center;
  gap: .45rem;
  background: var(--surface-2);
  border-radius: 8px;
  padding: .45rem .5rem;
  margin-bottom: .4rem;
}
.phone-mock__dot {
  width: 18px; height: 18px;
  border-radius: 5px;
  background: var(--surface-3);
  flex: none;
}
.phone-mock__line { flex: 1; height: 6px; border-radius: 3px; background: var(--line-strong); }
.phone-mock__price {
  font-family: var(--font-mono);
  font-size: .66rem;
  font-weight: 700;
  color: var(--accent-strong);
}
.phone-mock__install {
  margin-top: .5rem;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .68rem;
  color: var(--primary-strong);
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
  border: 1px dashed color-mix(in srgb, var(--primary) 55%, var(--line));
  border-radius: 10px;
  padding: .5rem;
}

/* ---------- Guías paso a paso ---------- */
.step {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 1.1rem;
}
.step__body > :first-child { margin-top: 0; }
.step__body p { color: var(--ink-soft); margin: 0 0 .6rem; }
.step__body ol, .step__body ul { margin: 0 0 .6rem; padding-left: 1.2rem; }
.step__body li { margin-bottom: .3rem; }

@media (max-width: 560px) {
  .step { grid-template-columns: 1fr; }
  .step__num { margin-bottom: .5rem; }
  .step:not(:last-child) > .step__num::after { display: none; }
}

.file-label {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-family: var(--font-mono);
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: .55rem .8rem;
}
.file-label::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #ff5f56;
  box-shadow: 13px 0 0 #ffbd2e, 26px 0 0 #27c93f;
  margin-right: 24px;
  opacity: .7;
  flex: none;
}

.codeblock {
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius-sm);
  padding: 1.05rem 1.25rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: .82rem;
  line-height: 1.7;
  margin: 0 0 1.1rem;
  white-space: pre;
  box-shadow: var(--shadow-sm);
}
.file-label + .codeblock { border-radius: 0 0 var(--radius-sm) var(--radius-sm); margin-top: 0; }
.codeblock .cm { opacity: .6; } /* comentarios dentro del bloque de código */

/* El selector genérico "code" de más arriba (fondo claro, borde, padding) se
   colaba dentro de .codeblock y dejaba texto claro sobre fondo claro (o
   oscuro sobre oscuro): por eso el código se veía "en blanco". Aquí se anula
   ese estilo para que el <code> dentro de .codeblock solo herede del <pre>. */
.codeblock code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: 1em;
}

.cmd {
  display: block;
  font-family: var(--font-mono);
  font-size: .85rem;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius-sm);
  padding: .65rem .95rem;
  margin: .5rem 0;
  overflow-x: auto;
  white-space: pre;
  box-shadow: var(--shadow-sm);
}
.cmd::before { content: "PS> "; opacity: .55; color: var(--accent); }

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--primary); color: var(--bg);
  padding: .5rem 1rem; border-radius: 0 0 8px 0;
  z-index: 100;
  font-family: var(--font-display); font-weight: 600;
}
.skip-link:focus { left: 0; }
