/* tero site — OpenTUI virtualization.
   Tokens match tui/src/theme.ts and site/assets/tui/frames/theme.json.
   Photocopied / hyperrealistic paper is ONLY for pages tero created
   (#archivo .hoja-frame). The window chrome never swaps. */

:root {
  --bg: #0b0d10;
  --panel: #12151a;
  --panel-alt: #161a20;
  --border: #4c566a;
  --border-focus: #6cb6ff;
  --border-soft: #3d4450;
  --text: #d8dee9;
  --muted: #7a8490;
  --faint: #4b5563;
  --accent: #82aaff;
  --accent-soft: #3d5a80;
  --ok: #9ece6a;
  --warn: #c9a227;
  --err: #e06c75;
  --chip: #1a2330;
  --chip-fg: #c8d6f0;
  --input-bg: #0e1116;
  --cursor: #82aaff;
  --overlay: #0f141c;
  --brand: #9aa4b2;
  --tui-bg: #0b0d10;
  --tui-panel: #12151a;
  --tui-text: #d8dee9;
  --tui-muted: #7a8490;
  --tui-accent: #82aaff;
  --tui-ok: #9ece6a;
  --tui-warn: #c9a227;
  --tui-err: #e06c75;
  --paper: #f3ead4;
  --paper-edge: #e6d8b8;
  --ink: #1c1712;
  --font: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
}

body {
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.2;
  background: var(--tui-bg);
  padding: 12px;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--panel);
  color: var(--accent);
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
}

.skip:focus {
  left: 0.5rem;
  top: 0.5rem;
  z-index: 50;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Session ledgers stay out of the window. Never a second column. */
#consulta,
#gate-note,
#fuentes,
#derivados,
#help-copy {
  display: none !important;
}

.window {
  max-width: calc(100vw - 24px);
  margin: 0;
  background: var(--tui-bg);
  border: 0;
  border-radius: 0;
  overflow: hidden;
  min-height: 0;
  width: max-content;
  display: flex;
  flex-direction: column;
}

.window-chrome {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  font-size: 0.78rem;
  color: var(--muted);
  flex: 0 0 auto;
}

.traffic {
  display: flex;
  gap: 0.38rem;
}

.traffic i {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  display: block;
}

.traffic i:nth-child(1) {
  background: #ff5f57;
}

.traffic i:nth-child(2) {
  background: #febc2e;
}

.traffic i:nth-child(3) {
  background: #28c840;
}

.window-title {
  color: var(--text);
  justify-self: center;
}

.window-path {
  justify-self: end;
}

.window-chrome.sr-only {
  /* Beat .window-chrome padding/border so the PNG is the only window. */
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  display: block;
  flex: none;
  background: transparent;
}

.tui-host {
  position: relative;
  flex: 0 0 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  background: var(--tui-bg);
}

.tui-stage {
  position: relative;
  flex: 0 0 auto;
  background: var(--tui-bg);
}

.tui-shot-src {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.tui-shot {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  image-rendering: pixelated;
  position: relative;
  z-index: 0;
}

.tui-shot[hidden] {
  display: none;
}

.tui-grid {
  flex: 0 0 auto;
  font: 13px/1.2 var(--font);
  letter-spacing: 0;
  white-space: pre;
  background: var(--tui-bg);
  overflow: hidden;
  user-select: none;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
  width: max-content;
  display: grid;
  grid-template-columns: repeat(var(--tui-cols, 140), var(--cell-w, 1ch));
}

.tui-grid.is-shot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  background: transparent;
  display: block;
  z-index: 1;
}

.tui-cell {
  width: var(--cell-w, 1ch);
  height: var(--cell-h, 1.2em);
  overflow: hidden;
  text-align: center;
  white-space: pre;
  line-height: var(--cell-h, 1.2em);
}

.tui-row {
  height: var(--cell-h, 1.2em);
  display: block;
  white-space: pre;
  overflow: hidden;
  width: max-content;
}

.tui-row span {
  font: inherit;
  letter-spacing: 0;
}

.tui-prompt {
  position: absolute;
  z-index: 3;
  margin: 0;
  padding: 0 4px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font: 13px/1.2 var(--font);
  caret-color: var(--cursor);
  opacity: 1;
}

.tui-prompt::placeholder {
  color: var(--faint);
  opacity: 0.8;
}

.tui-prompt:not(.is-typing) {
  caret-color: var(--cursor);
}

.tui-prompt:focus {
  background: var(--input-bg);
}

.actions-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.6rem;
  background: var(--panel);
  border-top: 1px solid var(--border-soft);
  font-size: 0.75rem;
  color: var(--muted);
  z-index: 5;
}

.actions-hint {
  color: var(--faint);
  margin-right: 0.2rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.action-btn {
  background: var(--chip);
  color: var(--chip-fg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.22rem 0.5rem;
  font: inherit;
  font-size: 0.73rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  transition: all 0.15s ease;
}

.action-btn:hover {
  border-color: var(--accent);
  color: #fff;
  background: #202b3c;
}

.action-btn-alt {
  background: transparent;
  border-color: var(--border-soft);
  color: var(--muted);
}

.action-btn-alt:hover {
  border-color: var(--border);
  color: var(--text);
}

/* Photocopied hoja — only created pages, not the chrome.
   Inset one outer cell so ╭─ tero / carpeta stay the same window. */
.archivo {
  position: absolute;
  z-index: 4;
  left: var(--cell-w, 10px);
  right: var(--cell-w, 10px);
  top: var(--cell-h, 24px);
  bottom: var(--cell-h, 24px);
  overflow: auto;
  padding: 0.35rem 0.45rem 0.5rem;
  background: var(--overlay);
  border: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
}

.archivo[hidden] {
  display: none !important;
}

.archivo-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.hoja-close-btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--chip);
  color: var(--accent);
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  border-radius: 2px;
}

.hoja-close-btn:hover {
  border-color: var(--accent);
  color: #fff;
}

.archivo-lead {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ok);
}

.hoja-frame {
  position: relative;
  margin: 0;
  background: var(--paper);
  border: 1px solid #2a1a10;
  box-shadow:
    0 1px 0 #fff8,
    8px 14px 28px #00000066;
  transform: rotate(-0.35deg);
  background-image:
    radial-gradient(circle at 12% 18%, #00000014 0.6px, transparent 1.1px),
    radial-gradient(circle at 80% 70%, #00000010 0.5px, transparent 1px),
    repeating-linear-gradient(180deg, transparent 0 27px, #00000008 28px);
}

.hoja-frame img {
  display: block;
  width: 100%;
  min-height: 42vh;
  height: auto;
  background: var(--paper);
  mix-blend-mode: normal;
}

.hoja-frame figcaption {
  margin: 0;
  padding: 0.35rem 0.55rem 0.45rem;
  font-family: "Iowan Old Style", Palatino, "Times New Roman", serif;
  font-size: 0.78rem;
  color: #5c5348;
}

.hoja-nav {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  margin: 0.45rem 0 0;
  font-size: 0.82rem;
}

.hoja-nav button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--chip);
  color: var(--chip-fg);
  padding: 0.32rem 0.5rem;
}

.hoja-nav button:hover {
  border-color: var(--border-soft);
  color: var(--text);
}

kbd {
  font-family: inherit;
  font-weight: 700;
  padding: 0 0.2rem;
  color: var(--accent);
}

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

.err-code {
  color: var(--err);
  margin: 0 0 0.6rem;
}

/* El sello REVISAR vive sobre la fotocopia: la hoja que el host escribió
   sigue pasando por el criterio del docente. */
.stamp-label {
  position: absolute;
  right: 0.9rem;
  bottom: 2.2rem;
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  color: #a3312a;
  border: 2px solid #a3312a;
  border-radius: 2px;
  padding: 0.1rem 0.45rem;
  transform: rotate(-7deg);
  opacity: 0.72;
  pointer-events: none;
}

@media (max-width: 960px) {
  body {
    padding: 0.4rem;
  }

  .hoja-frame {
    transform: none;
  }
}

@media print {
  body {
    background: #fff;
    color: #111;
    padding: 0;
  }

  .skip,
  .window-chrome,
  .tui-grid,
  .tui-prompt,
  .sr-only,
  .hoja-nav {
    display: none !important;
  }

  .archivo {
    display: block !important;
    position: static;
    background: #fff;
    border: none;
    box-shadow: none;
  }

  .hoja-frame {
    transform: none;
    box-shadow: none;
  }
}

/* English legend for hackathon judges: the terminal stays Spanish (it is the
   product); this strip explains what they are looking at. Fixed at the bottom so
   it never reflows the TUI; tui-grid.js reserves its height in viewportBudget(). */
.judge-legend {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 6px;
  z-index: 20;
  margin: 0;
  padding: 7px 12px 8px;
  background: #0f1319;
  border: 1px solid var(--border-soft);
  border-radius: 3px;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--muted);
  box-shadow: 0 -8px 18px rgba(0, 0, 0, 0.45);
}

.judge-legend p {
  margin: 0;
}

.judge-legend-title {
  color: var(--text);
  font-size: 12px;
}

.judge-legend-title strong {
  color: var(--accent);
  letter-spacing: 0.04em;
}

.judge-legend-motto {
  color: var(--accent);
  font-size: 11px;
  margin-left: 6px;
  opacity: 0.75;
}

.judge-legend-stack {
  color: var(--faint);
  font-size: 11px;
  margin-left: 6px;
}

.judge-legend-body {
  color: var(--muted);
}

.judge-legend-body b {
  color: var(--chip-fg);
}

.judge-legend-note {
  color: var(--faint);
  font-size: 11px;
}

.judge-legend a {
  color: var(--accent);
}

.judge-legend kbd {
  background: var(--chip);
  border: 1px solid var(--border-soft);
  border-radius: 2px;
  padding: 0 4px;
  color: var(--chip-fg);
  font: inherit;
}

@media (max-width: 720px) {
  .judge-legend-stack,
  .judge-legend-note {
    display: none;
  }
}

/* ── Video Modal Overlay ── */
.video-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 10, 14, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: videoFadeIn 0.15s ease-out;
}

.video-overlay[hidden] {
  display: none !important;
}

.video-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.04);
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: videoScaleIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.video-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--panel-alt);
  border-bottom: 1px solid var(--border-soft);
  gap: 12px;
}

.video-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.video-badge {
  background: var(--chip);
  color: var(--accent);
  border: 1px solid var(--border-soft);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.05em;
}

.video-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font);
}

.video-lang-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  padding: 3px;
  border-radius: 4px;
  border: 1px solid var(--border-soft);
}

.video-lang-btn {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-family: var(--font);
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.video-lang-btn:hover {
  color: var(--text);
}

.video-lang-btn.active {
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

.video-close-btn {
  background: transparent;
  border: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.video-close-btn:hover {
  background: var(--chip);
  color: var(--text);
  border-color: var(--border);
}

.video-player-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-player-frame video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  outline: none;
}

.video-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--panel);
  border-top: 1px solid var(--border-soft);
  font-size: 11px;
  color: var(--faint);
  flex-wrap: wrap;
  gap: 8px;
}

.video-meta {
  margin: 0;
}

.video-direct-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.video-direct-links a {
  color: var(--accent);
  text-decoration: none;
}

.video-direct-links a:hover {
  text-decoration: underline;
}

.action-btn-video {
  background: var(--chip);
  border-color: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.action-btn-video:hover {
  background: var(--accent-soft);
  color: #ffffff;
  border-color: var(--accent);
}

@keyframes videoFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes videoScaleIn {
  from { transform: scale(0.97); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
