/* ============================================================
   Enciende y Grafica — hoja de estilo
   Dirección visual: cuaderno de papel milimetrado + serigrafía
   de instrumento. Azul de trazo Y1 como único acento.
   ============================================================ */

:root {
  /* Superficies y tinta (tema claro) */
  --paper:      #FBFAF7;
  --paper-2:    #FFFFFF;
  --paper-sunk: #F2F1EC;
  --grid:       #DFE8F1;
  --line:       #E2E0D9;
  --ink:        #16202B;
  --ink-soft:   #3A4855;
  --muted:      #5C6B7A;

  /* Acento: el verde fosforito de la serigrafía del teclado.
     --acc es el fosforito puro (rellenos grandes); --plot es la
     versión legible para texto y bordes sobre papel. */
  --acc:        #A3E635;
  --acc-ink:    #1B2E05;
  --plot:       #5F8F12;
  --plot-weak:  #F2FADF;
  --plot-line:  #D3EBA4;

  /* Serigrafía de teclas: azul 2nd, verde ALPHA (detalle real del teclado) */
  --silk-2nd:   #2E6FE0;
  --silk-alpha: #2E7D4F;

  /* Semánticos */
  --warm:       #B4522E;

  /* LCD: es un objeto físico, conserva su color en ambos temas */
  --lcd:        #C9D6C4;
  --lcd-dim:    #B4C3AE;
  --lcd-ink:    #172114;
  --lcd-ghost:  #8FA189;
  --shell:      #2B3440;
  --shell-2:    #1D242D;

  /* Tipografía */
  --display: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  --body: "Source Serif 4", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Métrica */
  --col: 38rem;
  --r-s: 6px;
  --r-m: 10px;
  --r-l: 16px;
  --shadow-key: 0 1.5px 0 var(--line), 0 2px 4px rgba(22, 32, 43, .07);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:      #0E1620;
    --paper-2:    #141F2B;
    --paper-sunk: #0A121A;
    --grid:       #1B2A39;
    --line:       #22303E;
    --ink:        #E7EEF6;
    --ink-soft:   #C2CFDC;
    --muted:      #8A9BAC;
    --plot:       #6BA4FF;
    --plot-weak:  #142438;
    --plot-line:  #23436E;
    --silk-2nd:   #79AEFF;
    --silk-alpha: #64C08C;
    --warm:       #E0835F;
    --lcd:        #B9C7B4;
    --lcd-dim:    #A4B39E;
    --lcd-ink:    #141C12;
    --lcd-ghost:  #7C8E77;
    --shell:      #202932;
    --shell-2:    #151C24;
    --shadow-key: 0 1.5px 0 #0A121A, 0 2px 5px rgba(0, 0, 0, .35);
  }
}

:root[data-theme="dark"] {
  --paper:      #0E1620;
  --paper-2:    #141F2B;
  --paper-sunk: #0A121A;
  --grid:       #1B2A39;
  --line:       #22303E;
  --ink:        #E7EEF6;
  --ink-soft:   #C2CFDC;
  --muted:      #8A9BAC;
  --plot:       #6BA4FF;
  --plot-weak:  #142438;
  --plot-line:  #23436E;
  --silk-2nd:   #79AEFF;
  --silk-alpha: #64C08C;
  --warm:       #E0835F;
  --lcd:        #B9C7B4;
  --lcd-dim:    #A4B39E;
  --lcd-ink:    #141C12;
  --lcd-ghost:  #7C8E77;
  --shell:      #202932;
  --shell-2:    #151C24;
  --shadow-key: 0 1.5px 0 #0A121A, 0 2px 5px rgba(0, 0, 0, .35);
}

/* ---------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  min-height: 100%;
  background-color: var(--paper);
  /* Papel milimetrado: la rejilla de 22px es el fondo del cuaderno */
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: -1px -1px;
}

body {
  margin: 0;
  min-height: 100dvh;
  /* columna: el contenido crece y la navegación cae al fondo de la pantalla */
  display: flex;
  flex-direction: column;
  background: transparent;
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-synthesis-weight: none;
}

img, svg { max-width: 100%; }

h1, h2, h3 { font-family: var(--display); font-weight: 700; text-wrap: balance; margin: 0; letter-spacing: -.016em; }

p { margin: 0; }

a { color: var(--plot); }

:focus-visible {
  outline: 2.5px solid var(--plot);
  outline-offset: 3px;
  border-radius: 3px;
}

.is-hidden { display: none !important; }

/* ---------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  max-width: var(--col);
  margin-inline: auto;
  padding: .6rem 1rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}

.lang { display: flex; gap: 2px; background: var(--paper-sunk); border-radius: var(--r-s); padding: 2px; flex: none; }

.lang-btn {
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .06em;
  padding: .3rem .5rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 4px;
  cursor: pointer;
}
.lang-btn.is-on { background: var(--paper-2); color: var(--ink); box-shadow: 0 1px 2px rgba(22,32,43,.1); }

/* riel de progreso: un punto por paso, la secuencia es real */
.rail { flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.rail ol {
  margin: 0;
  padding: 0;
  display: flex;
  gap: .22rem;
  list-style: none;
}
.rail-dot {
  flex: none;
  width: 1.42rem; height: 1.42rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: .64rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background-color .18s, color .18s, border-color .18s;
}
.rail-dot:hover { border-color: var(--plot-line); color: var(--ink); }
.rail-dot.is-done { background: var(--plot-weak); border-color: var(--plot-line); color: var(--plot); }
.rail-dot.is-now { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); font-weight: 600; }

/* ---------------------------------------------------------- screens */

#main { width: 100%; max-width: var(--col); margin-inline: auto; padding: 1.6rem 1.15rem 2rem; flex: 1; }

.screen { display: none; }
.screen.is-on { display: block; animation: rise .32s cubic-bezier(.2,.7,.3,1) both; }

@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

.eyebrow {
  font-family: var(--mono);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .6rem;
}

.display-xl { font-size: clamp(1.85rem, 7.5vw, 2.6rem); line-height: 1.07; }
.display-l  { font-size: clamp(1.55rem, 6vw, 2.05rem); line-height: 1.12; }

.lede { color: var(--ink-soft); margin-top: .85rem; max-width: 34ch; font-size: 1.0625rem; }

/* ---------------------------------------------------------- bienvenida */

.facts {
  list-style: none;
  margin: 1.6rem 0 0;
  padding: .9rem 0;
  display: flex;
  gap: 1.9rem;
  border-block: 1px solid var(--line);
}
.facts li { display: flex; flex-direction: column; gap: .05rem; }
.fact-n {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--plot);
}
.fact-l { font-family: var(--mono); font-size: .68rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }

.cta-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.6rem; }

.btn {
  font-family: var(--display);
  font-weight: 600;
  font-size: .97rem;
  padding: .82rem 1.2rem;
  border-radius: var(--r-m);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  transition: transform .12s, background-color .18s, border-color .18s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--acc); color: var(--acc-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--acc) 88%, #000); }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--plot-line); color: var(--ink); }
.btn-quiet { background: var(--paper-2); color: var(--ink); border-color: var(--line); font-size: .92rem; padding: .7rem 1rem; }
.btn-quiet:hover { border-color: var(--plot-line); }

/* ---------------------------------------------------------- paso */

.step-title { font-size: clamp(1.6rem, 6.2vw, 2.05rem); line-height: 1.12; }
.step-body { color: var(--ink-soft); margin-top: .8rem; max-width: 36ch; }
.step-body b { font-family: var(--mono); font-weight: 600; font-size: .92em; color: var(--ink); }

/* El truco: anotación al margen, como en un cuaderno */
.tip {
  display: flex;
  gap: .85rem;
  margin-top: 2.1rem;
  padding: .1rem 0 .1rem .95rem;
  border-left: 2px solid var(--plot-line);
}
.tip-l {
  font-family: var(--mono);
  font-size: .64rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--plot);
  flex: none;
  padding-top: .3rem;
  font-weight: 500;
}
.tip-t { font-size: .95rem; color: var(--ink-soft); }

/* ---------------------------------------------------------- acciones del paso
   Los controles que hay que tocar, en orden. Sustituyen a la pantalla. */

.acts {
  display: grid;
  margin-top: 2rem;
}

/* Apuntes sobre la hoja: sin cajas, solo el reglado */
.act {
  display: grid;
  grid-template-columns: 3.6rem 1fr;
  align-items: center;
  gap: 1.2rem;
  padding: 1.25rem .2rem;
  border-top: 1px solid var(--line);
}
.act:last-child { border-bottom: 1px solid var(--line); }

.act-art { display: grid; place-items: center; }

.act-txt { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.act-ord {
  font-family: var(--mono);
  font-size: .64rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.act-lab { font-family: var(--display); font-weight: 600; font-size: 1rem; line-height: 1.25; color: var(--ink); }
.act-sub { font-size: .88rem; color: var(--muted); line-height: 1.4; }

/* Nota al pie de una acción, marcada con asterisco */
.act-note {
  display: flex;
  gap: .4rem;
  margin-top: .5rem;
  font-size: .82rem;
  line-height: 1.45;
  color: var(--plot);
}
.act-note::before { content: "*"; flex: none; font-family: var(--mono); }

/* Tecla: misma pastilla que el interruptor, puesta en vertical,
   en verde y con el nombre en blanco leyéndose de arriba abajo */
.act-key {
  width: 1.45rem;
  height: 2.7rem;
  padding: 0;
  background: var(--plot);
  color: #fff;
  border: 1px solid var(--plot);
  border-radius: 999px;
  display: grid;
  place-items: center;
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: var(--mono);
  font-weight: 500;
  font-size: .68rem;
  letter-spacing: .06em;
}

/* Interruptor lateral: pastilla alargada con el pulsador abajo, encendido */
.sw {
  width: 1.45rem;
  height: 2.7rem;
  padding: .18rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.sw i {
  display: block;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  background: var(--acc);
}

/* ---------------------------------------------------------- el aparato */

.device { margin-top: 1.4rem; }

.device-screen {
  background: linear-gradient(var(--shell), var(--shell-2));
  border-radius: var(--r-l);
  padding: .7rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 6px 18px rgba(22,32,43,.16);
}

.lcd {
  background: var(--lcd);
  border-radius: var(--r-s);
  min-height: 10.5rem;
  padding: .6rem .7rem;
  font-family: var(--mono);
  font-size: .85rem;
  line-height: 1.45;
  color: var(--lcd-ink);
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.18), inset 0 2px 7px rgba(0,0,0,.14);
  transition: background-color .25s;
}
.lcd[data-off="true"] { background: var(--lcd-dim); color: transparent; }

.lcd-line { white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.lcd-line.right { text-align: right; }
.lcd-line.ghost { color: var(--lcd-ghost); }
.lcd-line.inv { background: var(--lcd-ink); color: var(--lcd); display: inline-block; padding: 0 .2em; }

.caret {
  display: inline-block;
  width: .58em; height: 1.05em;
  background: var(--lcd-ink);
  vertical-align: -.18em;
  animation: blink 1.06s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.lcd-graph { display: block; width: 100%; height: 9.3rem; }
.lcd-status {
  position: absolute;
  left: .7rem; right: .7rem; bottom: .45rem;
  font-size: .76rem;
  letter-spacing: .01em;
  font-variant-numeric: tabular-nums;
}

.lcd-table { width: 100%; border-collapse: collapse; font-size: .82rem; font-variant-numeric: tabular-nums; }
.lcd-table th, .lcd-table td { text-align: right; padding: .07rem .4rem; }
.lcd-table th { font-weight: 500; border-bottom: 1px solid var(--lcd-ink); }
.lcd-table tr.hl td { background: var(--lcd-ink); color: var(--lcd); }

.device-caption {
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .04em;
  color: var(--muted);
  margin-top: .55rem;
  text-align: center;
}

/* secuencia de teclas */

.keys-block { margin-top: 1rem; }

.keys-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  margin-bottom: .55rem;
}
.keys-label {
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--muted);
}
.replay {
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .04em;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink-soft);
  border-radius: var(--r-s);
  padding: .28rem .55rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.replay:hover { border-color: var(--plot-line); color: var(--plot); }

.keys { display: flex; flex-wrap: wrap; align-items: stretch; gap: .38rem; }

.key {
  --key-face: var(--paper-2);
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 2.7rem;
  padding: .3rem .42rem .32rem;
  background: var(--key-face);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow-key);
  font-family: var(--mono);
  transition: transform .13s, background-color .13s, border-color .13s, box-shadow .13s;
}
.key-main { font-size: .78rem; font-weight: 500; line-height: 1.25; color: var(--ink); white-space: nowrap; }
.key-second {
  font-size: .56rem;
  line-height: 1;
  letter-spacing: .02em;
  color: var(--silk-2nd);
  margin-bottom: .16rem;
  white-space: nowrap;
}
.key[data-silk="alpha"] .key-second { color: var(--silk-alpha); }
.key-sm { min-width: 0; transform: translateY(-1px); }

.key.is-lit {
  background: var(--plot);
  border-color: var(--plot);
  box-shadow: 0 0 0 4px var(--plot-weak), 0 2px 4px rgba(31,95,214,.3);
  transform: translateY(1.5px);
}
.key.is-lit .key-main { color: #fff; }
.key.is-lit .key-second { color: color-mix(in srgb, #fff 72%, var(--plot)); }

.key.is-used { border-color: var(--plot-line); background: var(--plot-weak); }
.key.is-used .key-main { color: var(--plot); }

.key-arrow { color: var(--muted); align-self: center; font-size: .8rem; padding-inline: .05rem; }

/* ---------------------------------------------------------- cierre */

.closing-grid { display: grid; gap: .7rem; margin-top: 1.5rem; }
.closing-card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  padding: .95rem 1.05rem;
}
.closing-card h3 { font-size: 1.02rem; margin-bottom: .3rem; }
.closing-card p { font-size: .94rem; color: var(--ink-soft); }
.closing-card b { font-family: var(--mono); font-size: .9em; font-weight: 600; color: var(--ink); }
.closing-k { margin-bottom: .55rem; }

/* ---------------------------------------------------------- reseña */

.choice-row { display: grid; gap: .65rem; margin-top: 1.6rem; }

.choice {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "face title" "face sub";
  column-gap: .85rem;
  row-gap: .1rem;
  text-align: left;
  padding: 1.05rem 1.1rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  cursor: pointer;
  font-family: inherit;
  transition: border-color .18s, transform .12s, background-color .18s;
}
.choice:hover { border-color: var(--plot-line); transform: translateY(-1px); }
.choice:active { transform: none; }
.choice-face { grid-area: face; align-self: center; color: var(--plot); }
.choice-face svg { width: 2rem; height: 2rem; display: block; }
.choice-t { grid-area: title; font-family: var(--display); font-weight: 600; font-size: 1.05rem; color: var(--ink); }
.choice-s { grid-area: sub; font-size: .89rem; color: var(--muted); line-height: 1.4; }

.hint-card {
  margin-top: 1.4rem;
  padding: 1rem 1.1rem;
  background: var(--plot-weak);
  border-radius: var(--r-m);
}
.hint-title { font-family: var(--mono); font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; color: var(--plot); margin-bottom: .55rem; }
.hint-list { margin: 0; padding-left: 1.05rem; display: grid; gap: .3rem; }
.hint-list li { font-size: .95rem; color: var(--ink-soft); }

.fineprint { font-size: .82rem; color: var(--muted); margin-top: .9rem; line-height: 1.5; }

.form { display: grid; gap: .9rem; margin-top: 1.4rem; }
.field { display: grid; gap: .32rem; }
.field-l { font-family: var(--mono); font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.opt { text-transform: none; letter-spacing: 0; }
.field select, .field input, .field textarea {
  font: inherit;
  font-size: 16px;
  padding: .65rem .75rem;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--paper-2);
  color: var(--ink);
  width: 100%;
  resize: vertical;
}
.field select:focus, .field input:focus, .field textarea:focus { border-color: var(--plot); outline: none; box-shadow: 0 0 0 3px var(--plot-weak); }
.field textarea::placeholder, .field input::placeholder { color: var(--muted); opacity: .75; }

.sent-note {
  margin-top: 1rem;
  padding: .9rem 1rem;
  border-radius: var(--r-m);
  background: var(--plot-weak);
  border: 1px solid var(--plot-line);
  font-size: .95rem;
  color: var(--ink-soft);
}

.also { margin-top: 1.8rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.also p { font-size: .92rem; color: var(--muted); margin-bottom: .75rem; max-width: 36ch; }

/* ---------------------------------------------------------- nav inferior */

.stepnav {
  width: 100%;
  max-width: var(--col);
  margin: auto auto 0;              /* empujada al fondo de la pantalla */
  padding: 1.15rem 1.15rem calc(1.4rem + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .7rem;
  border-top: 1px solid var(--line);
}
.stepnav[hidden] { display: none; }

.nav-btn {
  font-family: var(--display);
  font-weight: 600;
  font-size: .95rem;
  padding: .6rem .1rem;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  transition: color .18s;
}
.nav-btn:hover:not(:disabled) { color: var(--ink); }
.nav-btn:disabled { opacity: .3; cursor: default; }

.nav-btn-primary {
  background: var(--acc);
  color: var(--acc-ink);
  padding: .7rem 1.25rem;
  border-radius: 999px;
}
.nav-btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--acc) 88%, #000); color: var(--acc-ink); }

.nav-count { font-family: var(--mono); font-size: .78rem; font-variant-numeric: tabular-nums; color: var(--muted); }
.nav-sep { opacity: .5; margin-inline: .12em; }

/* ---------------------------------------------------------- responsive */

@media (min-width: 46rem) {
  :root { --col: 44rem; }
  #main { padding-top: 2.4rem; }
  .closing-grid { grid-template-columns: repeat(3, 1fr); }
  .choice-row { grid-template-columns: 1fr 1fr; }
  .lcd { min-height: 12rem; }
  .lcd-graph { height: 10.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .caret { animation: none; }
}
