/* EstudIA course platform.
   Brand colours from the program template (Assets/templates/...profile.md): black ink,
   orange / magenta / green as the signature stripe. Orange is a fill colour only; it is
   never small text on white (contrast). One memorable element: the three-colour stripe,
   which doubles as the quiz progress bar and the reveal. Everything else stays quiet. */

:root {
  --ink: #000000;
  --text: #2b2b2b;
  --muted: #5b6170;
  --paper: #ffffff;
  --wash: #f3f4f6;
  --line: #d9dbe0;
  --orange: #ff7c1a;
  --magenta: #cb318e;
  --magenta-text: #a3226f;   /* 6.4:1 on white, for links and small text */
  --green: #7fc200;
  --green-text: #3f6b00;
  --danger: #b42318;
  --good: #0ca30c;           /* status palette (dataviz): feasibility = state */
  --warning: #fab219;
  --critical: #d03b3b;
  --radius-s: 6px;
  --radius-m: 12px;
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: 2.2rem;
  --step-4: 3rem;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font: 400 var(--step-0)/1.55 var(--body);
}
img { max-width: 100%; }
[hidden] { display: none !important; }

a { color: var(--magenta-text); text-underline-offset: 0.18em; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--magenta); outline-offset: 2px; border-radius: 3px; }

h1, h2, h3 { font-family: var(--display); color: var(--ink); line-height: 1.12; margin: 0 0 0.5em; }
h1 { font-size: var(--step-3); font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: var(--step-2); font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: var(--step-1); font-weight: 700; }
p { margin: 0 0 1em; max-width: 68ch; }
.lede { font-size: var(--step-1); color: var(--muted); max-width: 52ch; }
.muted { color: var(--muted); }
.small { font-size: var(--step--1); }

/* ---- signature stripe ---- */
.stripe { display: flex; height: 6px; }
.stripe span { flex: 1; }
.stripe span:nth-child(3n+1) { background: var(--orange); }
.stripe span:nth-child(3n+2) { background: var(--magenta); }
.stripe span:nth-child(3n) { background: var(--green); }

/* ---- page frame ---- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.9rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 0.6rem; text-decoration: none; color: var(--ink); }
.brand b { font: 800 1.35rem/1 var(--display); letter-spacing: -0.03em; }
.brand span { font-size: var(--step--1); color: var(--muted); }
.top nav { display: flex; align-items: center; gap: 1rem; font-size: var(--step--1); }
.top nav form { margin: 0; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--magenta-text); cursor: pointer; text-decoration: underline; text-underline-offset: 0.18em; }

main { padding: clamp(1.5rem, 5vw, 3rem) clamp(1rem, 4vw, 2.5rem) 4rem; }
.narrow { max-width: 30rem; }
.column { max-width: 46rem; }
.wide { max-width: 78rem; }

/* ---- forms ---- */
label { display: block; font-weight: 700; color: var(--ink); margin: 0 0 0.35rem; }
.field { margin: 0 0 1.25rem; }
.hint { display: block; font-weight: 400; font-size: var(--step--1); color: var(--muted); margin-top: 0.15rem; }
input[type=text], input[type=password], input[type=url], input[type=number], textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--paper);
  border: 1.5px solid var(--line); border-radius: var(--radius-s); padding: 0.65rem 0.75rem;
}
textarea { resize: vertical; min-height: 4.5rem; }
input:focus, textarea:focus, select:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(203, 49, 142, 0.25); }
.err { color: var(--danger); font-size: var(--step--1); margin-top: 0.3rem; }
.field.bad input, .field.bad textarea { border-color: var(--danger); }
.check { display: flex; gap: 0.6rem; align-items: flex-start; font-weight: 400; color: var(--text); margin: 0 0 0.8rem; }
.check input { width: 1.15rem; height: 1.15rem; margin-top: 0.2rem; accent-color: var(--ink); flex: none; }
fieldset { border: 0; padding: 0; margin: 0 0 1.4rem; }
legend { font-weight: 700; color: var(--ink); margin-bottom: 0.45rem; padding: 0; }
.choices { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.choices label {
  display: inline-flex; align-items: center; gap: 0.45rem; font-weight: 400; color: var(--text);
  border: 1.5px solid var(--line); border-radius: 999px; padding: 0.4rem 0.85rem; cursor: pointer; margin: 0;
}
.choices input { accent-color: var(--ink); margin: 0; }
.choices label:has(input:checked) { border-color: var(--ink); background: var(--wash); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font: 700 var(--step-0)/1 var(--body); text-decoration: none; cursor: pointer;
  background: var(--ink); color: var(--paper); border: 2px solid var(--ink);
  border-radius: var(--radius-s); padding: 0.8rem 1.25rem; min-height: 2.9rem;
}
.btn:hover { background: #222; color: var(--paper); }
.btn.secondary { background: var(--paper); color: var(--ink); }
.btn.secondary:hover { background: var(--wash); }
.btn.danger { background: var(--paper); color: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.small { font-size: var(--step--1); padding: 0.45rem 0.8rem; min-height: 2.2rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-top: 1.5rem; }

.notice { border-left: 4px solid var(--ink); background: var(--wash); padding: 0.85rem 1rem; margin: 0 0 1.5rem; border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.notice.warn { border-color: var(--orange); }
.notice.bad { border-color: var(--danger); }
.notice.ok { border-color: var(--green); }

/* ---- home: session agenda ---- */
.session-head { display: flex; align-items: baseline; gap: 1rem; margin: 2.5rem 0 0.75rem; }
.session-head .num { font: 800 var(--step-4)/0.9 var(--display); color: var(--ink); letter-spacing: -0.04em; }
.agenda { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--ink); }
.agenda li { border-bottom: 1px solid var(--line); }
.agenda a {
  display: grid; grid-template-columns: 1fr auto; gap: 0.25rem 1rem; align-items: center;
  padding: 1.1rem 0.25rem; text-decoration: none; color: var(--text);
}
.agenda a:hover { background: var(--wash); }
.agenda strong { font: 700 var(--step-1)/1.2 var(--display); color: var(--ink); }
.agenda .state { font-size: var(--step--1); color: var(--muted); }
.agenda .go { grid-row: span 2; font-size: 1.5rem; color: var(--ink); }
.empty { padding: 2rem 0; color: var(--muted); }

/* ---- quiz (student) ---- */
.quiz-progress { display: flex; gap: 6px; margin: 0 0 2rem; }
.quiz-progress span { flex: 1; height: 8px; border-radius: 4px; background: var(--wash); transition: background 0.3s; }
.quiz-progress span.done:nth-child(3n+1), .quiz-progress span.now:nth-child(3n+1) { background: var(--orange); }
.quiz-progress span.done:nth-child(3n+2), .quiz-progress span.now:nth-child(3n+2) { background: var(--magenta); }
.quiz-progress span.done:nth-child(3n), .quiz-progress span.now:nth-child(3n) { background: var(--green); }
.quiz-progress span.now { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }
.q-text { font: 700 clamp(1.35rem, 3.2vw, 2rem)/1.25 var(--display); color: var(--ink); margin: 0 0 1.5rem; max-width: 34ch; }
.options { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.65rem; }
.opt {
  width: 100%; display: grid; grid-template-columns: 2.4rem 1fr; gap: 0.8rem; align-items: center; text-align: left;
  font: 400 var(--step-0)/1.4 var(--body); color: var(--text); background: var(--paper);
  border: 2px solid var(--line); border-radius: var(--radius-m); padding: 0.85rem 1rem; cursor: pointer; position: relative; overflow: hidden;
}
.opt:hover:not(:disabled) { border-color: var(--ink); }
.opt .key { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 2px solid var(--ink); font: 800 1rem/1 var(--display); color: var(--ink); }
.opt.mine { border-color: var(--ink); background: var(--wash); }
.opt.mine .key { background: var(--ink); color: var(--paper); }
.opt:disabled { cursor: default; }
.opt .bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--wash); z-index: 0; transition: width 0.9s cubic-bezier(.2,.8,.2,1); }
.opt > *:not(.bar) { position: relative; z-index: 1; }
.opt .pct { justify-self: end; font: 700 var(--step-0)/1 var(--display); color: var(--ink); grid-column: 2; }
.opt.correct { border-color: var(--green-text); }
.opt.correct .bar { background: rgba(127, 194, 0, 0.28); }
.opt.correct .key { background: var(--green); border-color: var(--green-text); color: var(--ink); }
.opt.revealed { grid-template-columns: 2.4rem 1fr auto; }
.opt.revealed .pct { grid-column: 3; }
.waiting { display: grid; gap: 1rem; padding: 3rem 0; }
.waiting .dots { display: flex; gap: 8px; }
.waiting .dots span { width: 14px; height: 14px; border-radius: 50%; animation: bob 1.2s ease-in-out infinite; }
.waiting .dots span:nth-child(1) { background: var(--orange); }
.waiting .dots span:nth-child(2) { background: var(--magenta); animation-delay: 0.15s; }
.waiting .dots span:nth-child(3) { background: var(--green); animation-delay: 0.3s; }
@keyframes bob { 50% { transform: translateY(-8px); } }
.verdict { margin-top: 1.25rem; font-weight: 700; }

/* ---- ideas ---- */
.idea-block { border-top: 1.5px solid var(--ink); padding-top: 1.25rem; margin-top: 2rem; }
.counter { float: right; font-weight: 400; font-size: var(--step--1); color: var(--muted); }
.feedback { border-top: 1.5px solid var(--ink); padding: 1.25rem 0; margin-top: 2rem; }
.feedback h3 { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.feedback dl { margin: 0; display: grid; gap: 0.9rem; }
.feedback dt { font-weight: 700; color: var(--ink); }
.feedback dd { margin: 0.15rem 0 0; max-width: 68ch; }
.feedback ol { margin: 0.25rem 0 0; padding-left: 1.2rem; }
.pill { display: inline-flex; align-items: center; gap: 0.35rem; font: 700 var(--step--1)/1 var(--body); padding: 0.35rem 0.65rem; border-radius: 999px; border: 1.5px solid currentColor; }
.pill.alta { color: var(--green-text); }
.pill.media { color: #8a5a00; }
.pill.baja { color: var(--danger); }
.pill .mark { width: 0.6rem; height: 0.6rem; display: inline-block; }
.pill.alta .mark { background: var(--good); border-radius: 50%; }
.pill.media .mark { background: var(--warning); transform: rotate(45deg); }
.pill.baja .mark { width: 0; height: 0; border-left: 0.36rem solid transparent; border-right: 0.36rem solid transparent; border-bottom: 0.62rem solid var(--critical); }
.spinner { width: 1rem; height: 1rem; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- privacy text ---- */
.legal h2 { font-size: var(--step-1); margin-top: 2rem; }
.legal li { margin-bottom: 0.4rem; max-width: 68ch; }
details.policy { border: 1.5px solid var(--line); border-radius: var(--radius-s); padding: 0.75rem 1rem; margin: 0 0 1rem; }
details.policy summary { cursor: pointer; font-weight: 700; color: var(--ink); }
details.policy .legal { max-height: 22rem; overflow: auto; margin-top: 0.75rem; padding-right: 0.5rem; }

/* ---- admin ---- */
.admin-nav { display: flex; flex-wrap: wrap; gap: 0.25rem; border-bottom: 1px solid var(--line); padding: 0 clamp(1rem, 4vw, 2.5rem); }
.admin-nav a { padding: 0.7rem 0.9rem; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 700; font-size: var(--step--1); }
.admin-nav a[aria-current=page] { color: var(--ink); border-color: var(--ink); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: 2rem 3rem; }
.stat { font: 800 var(--step-4)/1 var(--display); color: var(--ink); letter-spacing: -0.03em; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.85rem 0; border-bottom: 1px solid var(--line); }
.toggle-row:first-child { border-top: 1.5px solid var(--ink); }
.switch { position: relative; width: 3.1rem; height: 1.75rem; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background 0.2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: calc(1.75rem - 6px); height: calc(1.75rem - 6px); border-radius: 50%; background: var(--paper); transition: transform 0.2s; }
.switch input:checked + span { background: var(--ink); }
.switch input:checked + span::after { transform: translateX(1.35rem); }
.switch input:focus-visible + span { outline: 3px solid var(--magenta); outline-offset: 2px; }
.join-code { font: 800 clamp(2.5rem, 7vw, 4.5rem)/1 var(--display); letter-spacing: 0.08em; color: var(--ink); }
table { border-collapse: collapse; width: 100%; font-size: var(--step--1); }
th, td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink); border-bottom: 1.5px solid var(--ink); font-weight: 700; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* quiz stage (projected) */
.stage { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 2.5rem; align-items: start; }
@media (max-width: 960px) { .stage { grid-template-columns: 1fr; } }
.stage .q-text { font-size: clamp(1.6rem, 3vw, 2.4rem); max-width: 30ch; }
.stage .opt { font-size: var(--step-1); cursor: default; }
.control { border-left: 1.5px solid var(--ink); padding-left: 1.5rem; display: grid; gap: 0.75rem; position: sticky; top: 1rem; }
.control .count { font: 800 var(--step-3)/1 var(--display); color: var(--ink); }
.explain { margin-top: 1.5rem; border-top: 1.5px solid var(--ink); padding-top: 1rem; }
.explain li { margin-bottom: 0.5rem; max-width: 70ch; }

/* charts */
.hbars { display: grid; gap: 0.45rem; margin: 0 0 1.75rem; }
.hbar { display: grid; grid-template-columns: minmax(8rem, 15rem) 1fr 2.5rem; gap: 0.75rem; align-items: center; font-size: var(--step--1); }
.hbar .track { height: 14px; border-radius: 0 4px 4px 0; background: transparent; position: relative; }
.hbar .fill { height: 100%; background: var(--ink); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 700; }

.map-wrap { position: relative; border: 1px solid var(--line); border-radius: var(--radius-m); background: #fcfcfb; }
.map-wrap svg { display: block; width: 100%; height: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 1.25rem; margin: 0.75rem 0 0; font-size: var(--step--1); color: var(--text); }
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.tooltip { position: absolute; pointer-events: none; background: var(--ink); color: var(--paper); font-size: var(--step--1); padding: 0.45rem 0.6rem; border-radius: var(--radius-s); max-width: 18rem; transform: translate(-50%, calc(-100% - 12px)); }

.show-card { border-top: 6px solid var(--ink); padding: 1.5rem 0; }
.show-card.alta { border-color: var(--green); }
.show-card.media { border-color: var(--orange); }
.show-card.baja { border-color: var(--magenta); }
.show-card h2 { font-size: clamp(1.8rem, 3.5vw, 2.8rem); }
.show-card dl { display: grid; grid-template-columns: minmax(8rem, 12rem) 1fr; gap: 0.75rem 1.5rem; font-size: var(--step-1); }
.show-card dt { font-weight: 700; color: var(--ink); }
.show-card dd { margin: 0; }
.why { font-size: var(--step-1); background: var(--wash); padding: 1rem 1.25rem; border-radius: var(--radius-s); margin-top: 1.25rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 560px) {
  .hbar { grid-template-columns: 1fr 2.5rem; }
  .hbar .track { grid-column: 1 / -1; grid-row: 2; }
  .show-card dl { grid-template-columns: 1fr; }
}
