/* ============================================================
   ciber.cafe — hoja de estilos compartida (index + temario)
   Tema oscuro por defecto; tema claro con html[data-theme="light"].
   Layout por página con html[data-page="index" | "temario"].
   ============================================================ */

:root {
  /* superficie y texto (oscuro) */
  --espresso:   #160e08;   /* fondo */
  --bean:       #1f140c;
  --grounds:    #2a1c11;
  --surface:    #211710;   /* tarjetas, toc, pills */
  --glass:      rgba(22,14,8,0.95);
  --crema:      #f3e7d3;    /* texto principal */
  --crema-dim:  #cbb79c;    /* texto secundario */
  --mocha:      #94785b;    /* texto tenue */
  /* acentos */
  --amber:      #e3a85a;
  --amber-soft: #f0c986;
  --terra:      #c4663c;
  --line:       #3a2918;
  /* relleno de botones/pills activos y texto sobre ellos */
  --fill:       #e3a85a;
  --on-fill:    #160e08;

  --radius: 14px;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --sans: 'IBM Plex Sans', system-ui, sans-serif;
}

:root[data-theme="light"] {
  --espresso:   #f5ede1;
  --bean:       #ece2d3;
  --grounds:    #e4d6c3;
  --surface:    #ece1d0;
  --glass:      rgba(245,237,225,0.95);
  --crema:      #2a1b10;
  --crema-dim:  #5c4733;
  --mocha:      #8a7257;
  --amber:      #9c5a16;
  --amber-soft: #7e480f;
  --terra:      #b04a23;
  --line:       #dccbb1;
  --fill:       #9c5a16;
  --on-fill:    #f5ede1;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  color: var(--crema);
  background-color: var(--espresso);
  background-image:
    radial-gradient(900px 500px at 78% -8%, rgba(227,168,90,0.16), transparent 60%),
    radial-gradient(700px 480px at 8% 12%, rgba(196,102,60,0.12), transparent 60%),
    radial-gradient(1100px 700px at 50% 120%, rgba(148,120,91,0.10), transparent 65%);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color .3s ease, color .3s ease;
}
html[data-page="temario"] body { line-height: 1.72; }

/* grano de película */
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 9999; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--fill); color: var(--on-fill); }

.wrap { max-width: 880px; margin: 0 auto; padding: 0 24px; }
html[data-page="temario"] .wrap { max-width: 740px; }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  color: var(--crema); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.1rem; line-height: 1;
  transition: color .2s, border-color .2s, transform .25s;
}
.theme-toggle:hover { color: var(--amber); border-color: var(--amber); transform: rotate(20deg); }
.theme-toggle.fixed { position: fixed; top: 16px; right: 16px; z-index: 100; }

/* ============================================================
   ÍNDICE (index.html)
   ============================================================ */

/* ---------- Header ---------- */
header {
  padding: clamp(64px, 12vw, 130px) 0 clamp(44px, 7vw, 76px);
  position: relative;
}
.blink {
  width: 13px; height: clamp(2.4rem,9vw,5rem);
  background: var(--amber);
  display: inline-block;
  animation: blink 1.1s steps(1) infinite;
  transform: translateY(0.12em);
  margin-left: 8px;
}
@keyframes blink { 50% { opacity: 0; } }

h1.logo {
  font-family: var(--mono);
  font-weight: 600;
  font-size: clamp(2.9rem, 11vw, 6.4rem);
  line-height: 0.92;
  letter-spacing: -0.02em;
  color: var(--crema);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
h1.logo .slash { color: var(--terra); }
h1.logo em { font-style: normal; color: var(--amber); }
h1.logo .logo-gato { height: 1em; width: auto; margin-right: 0.25em; flex-shrink: 0; }

.tagline {
  margin-top: 28px;
  max-width: 56ch;
  font-size: clamp(1.02rem, 2.2vw, 1.22rem);
  color: var(--crema-dim);
  font-weight: 300;
}

main { padding: clamp(48px, 8vw, 88px) 0 0; }

/* ---------- Tab switch ---------- */
.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 5px;
  margin-bottom: clamp(32px, 5vw, 48px);
  border: 1px solid var(--line);
  border-radius: 100px;
  background: var(--surface);
}
.tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--crema-dim);
  font-family: var(--mono);
  font-size: clamp(0.78rem, 2.4vw, 0.9rem);
  letter-spacing: 0.01em;
  padding: 11px 22px;
  border-radius: 100px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  transition: color .2s, background .2s;
}
.tab .tnum { color: var(--terra); font-size: 0.72em; }
.tab:hover { color: var(--crema); }
.tab[aria-selected="true"] { background: var(--fill); color: var(--on-fill); font-weight: 500; }
.tab[aria-selected="true"] .tnum { color: var(--on-fill); opacity: .65; }

.panel { display: none; }
.panel.active { display: block; animation: rise .45s cubic-bezier(.2,.7,.2,1); }

/* ---------- Topic list ---------- */
.topics { list-style: none; }
.topic { border-bottom: 1px solid var(--line); }
.topic:first-child { border-top: 1px solid var(--line); }
.topic .row {
  display: flex; align-items: center; gap: 18px;
  padding: 18px 8px;
  transition: padding-left 0.25s ease, background 0.25s ease;
}
.topic:hover .row {
  padding-left: 18px;
  background: linear-gradient(90deg, rgba(227,168,90,0.06), transparent 70%);
}
.t-index {
  font-family: var(--mono); font-size: 0.82rem; color: var(--amber);
  min-width: 2.4ch; text-align: right; flex-shrink: 0;
}
.t-title {
  font-family: var(--mono); font-weight: 500;
  font-size: clamp(1rem, 2.4vw, 1.15rem);
  color: var(--crema); letter-spacing: -0.01em;
}

/* subtemas (x.y) */
.subtopics {
  list-style: none;
  margin: 4px 0 18px calc(2.4ch + 18px + 8px);
  display: grid; gap: 12px;
  border-left: 1px dashed var(--line);
  padding-left: 22px;
}
.sub { display: grid; grid-template-columns: 3.6ch 1fr; gap: 12px; align-items: baseline; }
.sub .s-idx { font-family: var(--mono); color: var(--terra); font-size: 0.8rem; }
.sub .s-text { color: var(--crema-dim); font-size: 0.98rem; font-weight: 300; }

/* ---------- CTA buttons ---------- */
.cta-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin: 3em 0;
}
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 0.92rem; letter-spacing: 0.01em;
  padding: 16px 26px; border-radius: 100px;
  text-decoration: none; border: 1px solid var(--line);
  transition: transform .2s ease, background .2s, border-color .2s, color .2s;
}
.btn-primary { background: var(--fill); color: var(--on-fill); border-color: var(--fill); font-weight: 500; }
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-2px); }
.btn-ghost { color: var(--crema); }
.btn-ghost:hover { border-color: var(--amber); color: var(--amber-soft); transform: translateY(-2px); }

/* ============================================================
   TEMARIO (temario.html)
   ============================================================ */

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 0.82rem;
}
.topbar .wrap {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 12px; padding-bottom: 12px; max-width: 980px;
}
.topbar .brand { color: var(--crema); letter-spacing: -0.01em; }
.topbar .brand .dot { color: var(--terra); }
.topbar .right { display: inline-flex; align-items: center; gap: 14px; }
.topbar a.back { color: var(--mocha); transition: color .2s; text-decoration: none; }
.topbar a.back:hover { color: var(--amber); }
.topbar .theme-toggle { width: 34px; height: 34px; font-size: 0.95rem; }

/* ---------- Masthead ---------- */
.masthead { padding: clamp(56px,10vw,110px) 0 clamp(40px,6vw,64px); border-bottom: 1px solid var(--line); }
.kicker {
  font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.3em;
  text-transform: uppercase; color: var(--mocha); margin-bottom: 26px;
  display: flex; align-items: center; gap: 12px;
}
.kicker::before { content:""; width: 28px; height: 1px; background: var(--mocha); }
.masthead h1 {
  font-family: var(--mono); font-weight: 600;
  font-size: clamp(2.1rem,6.5vw,3.6rem); line-height: 1.02;
  letter-spacing: -0.02em; color: var(--crema);
}
.masthead h1 em { font-style: normal; color: var(--amber); }
.masthead .lead {
  margin-top: 26px; font-size: clamp(1.1rem,2.4vw,1.32rem);
  color: var(--crema-dim); font-weight: 300; max-width: 60ch;
}

/* ---------- Table of contents ---------- */
.toc {
  margin: clamp(40px,7vw,72px) 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface);
  padding: clamp(22px,4vw,34px);
}
.toc h2 {
  font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.24em;
  text-transform: uppercase; color: var(--terra); margin-bottom: 20px;
}
.toc ol { list-style: none; }
.toc .toc-block { font-family: var(--mono); color: var(--amber); font-size: 0.8rem; letter-spacing: 0.1em; margin: 18px 0 8px; }
.toc li a {
  color: var(--crema-dim); text-decoration: none;
  display: flex; gap: 14px; padding: 4px 0; transition: color .2s, padding-left .2s;
}
.toc li a:hover { color: var(--crema); padding-left: 6px; }
.toc li a .n { font-family: var(--mono); color: var(--mocha); min-width: 3.2ch; font-size: 0.82rem; }

/* ---------- Article prose ---------- */
article { padding-bottom: 40px; }

.block-title {
  font-family: var(--mono); font-weight: 600;
  font-size: clamp(1.6rem,4.5vw,2.3rem); color: var(--crema);
  margin: clamp(64px,10vw,104px) 0 6px; letter-spacing: -0.01em;
  padding-top: 24px; border-top: 1px solid var(--line);
}
.block-title .tag { display:block; font-size: 0.74rem; letter-spacing: 0.3em; text-transform: uppercase; color: var(--terra); margin-bottom: 12px; font-weight: 500; }

h2.sec {
  font-family: var(--mono); font-weight: 500;
  font-size: clamp(1.35rem,3.6vw,1.85rem); color: var(--crema);
  margin: clamp(48px,7vw,72px) 0 4px; letter-spacing: -0.01em;
  scroll-margin-top: 80px;
}
h2.sec .num { color: var(--amber); margin-right: 0.5ch; }

h3.sub {
  font-family: var(--mono); font-weight: 500;
  font-size: 1.08rem; color: var(--amber-soft);
  margin: 38px 0 2px; letter-spacing: -0.005em;
  scroll-margin-top: 80px;
}
h3.sub .num { color: var(--terra); margin-right: 0.6ch; font-size: 0.86rem; }

article p { margin-top: 16px; font-weight: 300; color: var(--crema-dim); font-size: 1.04rem; }
article p strong { color: var(--crema); font-weight: 500; }
article p em { color: var(--amber-soft); font-style: italic; }
article a {
  color: var(--amber); text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: color .2s, border-color .2s;
}
article a:hover { color: var(--amber-soft); border-color: var(--amber); }

/* notas de fuente */
.sources {
  margin: 14px 0 0; padding-left: 20px;
  font-family: var(--mono); font-size: 0.74rem; color: var(--mocha);
  list-style: none;
}
.sources li { margin-top: 4px; position: relative; }
.sources li::before { content: "↳"; position: absolute; left: -18px; color: var(--terra); }
.sources a { border: none; color: var(--mocha); }
.sources a:hover { color: var(--amber); }

blockquote {
  margin: 30px 0; padding: 6px 0 6px 26px;
  border-left: 2px solid var(--terra);
  font-family: var(--sans); font-style: italic; font-weight: 300;
  color: var(--crema); font-size: 1.16rem; line-height: 1.55;
}
blockquote cite { display:block; margin-top: 10px; font-style: normal; font-family: var(--mono); font-size: 0.78rem; color: var(--mocha); }

.callout {
  margin: 28px 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: rgba(227,168,90,0.06); padding: 20px 22px;
}
.callout .label {
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--amber); margin-bottom: 8px; display:block;
}
.callout p { margin-top: 0; color: var(--crema); font-size: 0.98rem; }

article ul.dash { list-style: none; margin: 16px 0; }
article ul.dash li {
  position: relative; padding-left: 24px; margin-top: 10px;
  color: var(--crema-dim); font-weight: 300; font-size: 1.02rem;
}
article ul.dash li::before { content: "—"; position: absolute; left: 0; color: var(--terra); font-family: var(--mono); }
article ul.dash li strong { color: var(--crema); font-weight: 500; }

.term { font-family: var(--mono); font-size: 0.92em; color: var(--amber-soft); }

/* tabla de mercados */
.market-wrap { overflow-x: auto; margin: 26px 0; }
table.markets { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 560px; }
table.markets th, table.markets td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.markets thead th {
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--terra); font-weight: 500;
  border-bottom: 1px solid var(--mocha);
}
table.markets tbody th { font-family: var(--mono); font-weight: 500; color: var(--crema); white-space: nowrap; }
table.markets td { color: var(--crema-dim); font-weight: 300; }
table.markets tbody tr:hover { background: rgba(227,168,90,0.05); }
table.markets .swatch {
  display:inline-block; width: 10px; height: 10px; border-radius: 50%;
  margin-right: 9px; vertical-align: middle; border: 1px solid var(--line);
}
table.markets .yes { color: var(--amber-soft); }
table.markets .no  { color: var(--mocha); }

/* ============================================================
   Footer + animaciones (compartido)
   ============================================================ */
footer {
  margin-top: clamp(72px, 12vw, 130px);
  padding: 64px 0 80px;
  border-top: 1px solid var(--line);
  color: var(--mocha); font-family: var(--mono); font-size: 0.8rem;
}
html[data-page="temario"] footer { padding: 64px 0 90px; }
footer a { color: var(--amber); border-bottom: 1px solid var(--line); text-decoration: none; }

.fade { opacity: 0; transform: translateY(14px); animation: rise 0.7s cubic-bezier(.2,.7,.2,1) forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .fade, .blink, .panel.active { animation: none; opacity: 1; transform: none; }
  html { scroll-behavior: auto; }
}
