/* styles.css */

/* 1. VARIABLES E BASE ------------------------------------------------------- */

:root {
  --color-bg-main: #050a18;
  --color-bg-alt: #080f24;
  --color-bg-card: rgba(10, 20, 40, 0.9);
  --color-bg-code: #0b1020;
  --color-accent: #00d4ff;
  --color-accent-soft: rgba(0, 212, 255, 0.18);
  --color-text-main: #e5ecff;
  --color-text-muted: #a1b2d8;
  --color-border-soft: rgba(255, 255, 255, 0.08);
  --shadow-deep: 0 18px 45px rgba(0, 0, 0, 0.55);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --font-title: "Edu SA Hand", system-ui, -apple-system, BlinkMacSystemFont;
  --font-body: "Roboto", system-ui, -apple-system, BlinkMacSystemFont;

  --transition-fast: 0.18s ease-out;
  --transition-med: 0.28s ease-out;

  --page-width: 1080px;
}

/* Respecto a preferencia de movemento reducido */

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* Reset básico */

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: radial-gradient(circle at top left, #102459 0, #050a18 40%, #02040a 100%);
  color: var(--color-text-main);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

/* 2. LAYOUT XERAL ----------------------------------------------------------- */

.page-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  width: 100%;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

/* 3. CABECEIRA -------------------------------------------------------------- */

.main-header {
  position: relative;
  padding: 1.5rem 1.5rem 3rem;
  overflow: hidden;
}

.header-gradient {
  position: absolute;
  inset: -40%;
  background:
    radial-gradient(circle at 10% 0%, rgba(0, 212, 255, 0.28) 0, transparent 52%),
    radial-gradient(circle at 80% 0%, rgba(128, 90, 255, 0.4) 0, transparent 55%),
    radial-gradient(circle at 50% 100%, rgba(0, 0, 0, 0.9) 0, #02040a 70%);
  opacity: 0.9;
  pointer-events: none;
  filter: saturate(1.2);
}

.header-inner {
  position: relative;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 2.5rem 2rem 2.5rem;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: linear-gradient(135deg, rgba(5, 10, 24, 0.9), rgba(5, 10, 24, 0.4));
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow-deep);
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.badge-version,
.badge-mode {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.badge-version {
  background: radial-gradient(circle at 0 0, rgba(0, 212, 255, 0.35), transparent 55%);
}

.badge-mode {
  background: radial-gradient(circle at 100% 0, rgba(128, 90, 255, 0.35), transparent 55%);
}

.doc-title {
  font-family: var(--font-title);
  font-size: clamp(2.1rem, 2.8vw, 2.7rem);
  margin: 0.2rem 0 0.8rem;
  letter-spacing: 0.03em;
}

.doc-subtitle {
  margin: 0 0 1.6rem;
  color: var(--color-text-muted);
  max-width: 48rem;
}

.header-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.7fr);
  gap: 1.5rem;
  margin-bottom: 1.8rem;
}

.header-card {
  background: linear-gradient(130deg, rgba(7, 14, 35, 0.9), rgba(9, 18, 40, 0.7));
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem;
  border: 1px solid var(--color-border-soft);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.header-card h2 {
  font-family: var(--font-title);
  font-size: 1.1rem;
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.header-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  font-size: 0.92rem;
}

.header-card dt {
  font-weight: 500;
  color: var(--color-text-muted);
}

.header-card dd {
  margin: 0;
}

.header-summary p {
  margin-top: 0.1rem;
  margin-bottom: 0.75rem;
}

.note-structure {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  border-left: 2px solid var(--color-accent);
  padding-left: 0.7rem;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

/* 4. BOTÓNS ----------------------------------------------------------------- */

.btn {
  border-radius: 999px;
  padding: 0.55rem 1.2rem;
  font-size: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  text-decoration: none;
  color: var(--color-text-main);
  background: transparent;
  transition: background var(--transition-med), transform var(--transition-fast), box-shadow var(--transition-med), border-color var(--transition-med);
}

.btn.primary {
  background: linear-gradient(135deg, #00d4ff, #18a0fb);
  color: #020412;
  box-shadow: 0 10px 26px rgba(0, 212, 255, 0.45);
  border-color: transparent;
}

.btn.ghost {
  background: rgba(0, 0, 0, 0.35);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7);
  border-color: rgba(255, 255, 255, 0.4);
}

.btn.primary:hover {
  box-shadow: 0 14px 40px rgba(0, 212, 255, 0.7);
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

/* 5. TÁBOA DE CONTIDOS ------------------------------------------------------ */

.toc {
  max-width: var(--page-width);
  margin: 1.75rem auto 2.5rem;
  padding: 1.4rem 1.6rem;
  border-radius: var(--radius-lg);
  background: radial-gradient(circle at 10% -20%, rgba(0, 212, 255, 0.16), transparent 60%),
    radial-gradient(circle at 100% 120%, rgba(65, 105, 225, 0.16), transparent 60%),
    linear-gradient(135deg, rgba(5, 10, 27, 0.95), rgba(5, 10, 27, 0.9));
  border: 1px solid var(--color-border-soft);
  box-shadow: var(--shadow-deep);
}

.toc-title {
  font-family: var(--font-title);
  font-size: 1.25rem;
  margin-top: 0;
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.toc-level {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.toc-level-1 > li {
  margin-bottom: 0.25rem;
}

.toc-level-1 > li > a {
  font-weight: 500;
  font-size: 0.96rem;
}

.toc-level-2 {
  margin-top: 0.15rem;
  margin-bottom: 0.25rem;
  padding-left: 1rem;
  border-left: 1px dashed rgba(255, 255, 255, 0.18);
}

.toc a {
  color: var(--color-text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.16rem 0.55rem 0.12rem;
  border-radius: 999px;
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.toc a::before {
  content: "●";
  font-size: 0.55rem;
  color: rgba(0, 212, 255, 0.8);
}

.toc a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text-main);
  transform: translateX(2px);
}

.toc a.toc-active {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

/* 6. SECCIÓNS --------------------------------------------------------------- */

.section {
  margin-bottom: 2.8rem;
}

.section-header {
  margin-bottom: 1.3rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(120deg, rgba(7, 15, 40, 0.97), rgba(4, 12, 28, 0.97)),
    radial-gradient(circle at 0 0, rgba(0, 212, 255, 0.18), transparent 60%);
  border: 1px solid rgba(0, 212, 255, 0.35);
}

.section-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.08), transparent 60%);
  pointer-events: none;
  mix-blend-mode: screen;
}

.section-header h2 {
  margin: 0;
  font-family: var(--font-title);
  font-size: clamp(1.3rem, 1.75vw, 1.6rem);
}

.section-intro {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.section-body {
  padding: 0.4rem 0.1rem 0;
}

/* Subsections */

.subsection {
  margin-bottom: 1.8rem;
}

.subsection h3 {
  font-family: var(--font-title);
  font-size: 1.1rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: linear-gradient(120deg, rgba(15, 28, 65, 0.9), rgba(4, 13, 32, 0.9));
  border: 1px solid rgba(0, 212, 255, 0.35);
  margin: 0 0 0.6rem;
}

/* 7. TEXTOS E LISTAS -------------------------------------------------------- */

p {
  margin: 0 0 0.7rem;
  line-height: 1.6;
  font-size: 0.96rem;
}

ul,
ol {
  margin-top: 0.2rem;
  margin-bottom: 0.6rem;
  padding-left: 1.1rem;
}

li {
  margin-bottom: 0.3rem;
}

.icon-list {
  list-style: none;
  padding-left: 0;
}

.icon-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.icon-dot {
  flex-shrink: 0;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 999px;
  background: var(--color-accent);
  margin-top: 0.45rem;
}

/* KBD */

kbd {
  background: rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  padding: 0.1rem 0.3rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 0.78rem;
}

/* 8. CARDS E GRELHAS -------------------------------------------------------- */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.1rem;
  margin-top: 0.5rem;
}

.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  border: 1px solid var(--color-border-soft);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top left, rgba(0, 212, 255, 0.12), transparent 50%);
  opacity: 0.9;
  pointer-events: none;
}

.card h3,
.card h4 {
  margin-top: 0;
  margin-bottom: 0.4rem;
  font-family: var(--font-title);
}

.chart-card {
  min-height: 240px;
}

.chart-caption {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.4rem;
}

/* 9. CALLOUTS / ASIDES ------------------------------------------------------ */

.callout {
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  margin: 1rem 0;
  border: 1px solid var(--color-border-soft);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
}

.callout h3 {
  margin-top: 0;
  margin-bottom: 0.45rem;
  font-family: var(--font-title);
  font-size: 1rem;
}

.callout.info {
  background: linear-gradient(120deg, rgba(0, 212, 255, 0.12), rgba(3, 10, 30, 0.95));
  border-color: rgba(0, 212, 255, 0.48);
}

.callout.tip {
  background: linear-gradient(120deg, rgba(72, 187, 120, 0.16), rgba(5, 15, 22, 0.95));
  border-color: rgba(72, 187, 120, 0.5);
}

.callout.example {
  background: linear-gradient(120deg, rgba(128, 90, 255, 0.16), rgba(5, 10, 26, 0.95));
  border-color: rgba(128, 90, 255, 0.5);
}

/* 10. TABOAS ---------------------------------------------------------------- */

.table-wrapper {
  margin: 0.8rem 0;
  border-radius: var(--radius-md);
  overflow: auto;
  border: 1px solid var(--color-border-soft);
  background: radial-gradient(circle at 0 0, rgba(0, 212, 255, 0.13), transparent 50%),
    radial-gradient(circle at 100% 100%, rgba(128, 90, 255, 0.13), transparent 50%),
    rgba(6, 12, 30, 0.96);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table caption {
  padding: 0.5rem 0.75rem;
  font-weight: 500;
  text-align: left;
  color: var(--color-text-muted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.data-table th,
.data-table td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: rgba(5, 12, 30, 0.95);
  z-index: 1;
  font-weight: 600;
}

.data-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.data-table tbody tr:hover {
  background: rgba(0, 212, 255, 0.06);
}

/* 11. STEPPER (PASOS) ------------------------------------------------------- */

.stepper {
  list-style: none;
  padding-left: 0;
  margin: 0.4rem 0 0.8rem;
  position: relative;
}

.stepper > li {
  position: relative;
  padding-left: 2.1rem;
  margin-bottom: 0.65rem;
}

.stepper > li::before {
  content: "";
  position: absolute;
  left: 0.7rem;
  top: 0.2rem;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 999px;
  border: 2px solid var(--color-accent);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.25);
  background: radial-gradient(circle, rgba(0, 212, 255, 0.9) 0, transparent 75%);
}

.stepper > li::after {
  content: "";
  position: absolute;
  left: 1.06rem;
  top: 1.2rem;
  bottom: -0.4rem;
  width: 1px;
  background: linear-gradient(to bottom, rgba(0, 212, 255, 0.4), transparent);
}

.stepper > li:last-child::after {
  display: none;
}

.stepper h4 {
  margin: 0 0 0.25rem;
  font-size: 0.96rem;
}

/* 12. BLOQUES DE CÓDIGO ----------------------------------------------------- */

.code-block {
  position: relative;
  margin: 0.8rem 0 1rem;
  background: var(--color-bg-code);
  border-radius: var(--radius-md);
  border: 1px solid rgba(0, 212, 255, 0.4);
  padding: 0.6rem 0.7rem 0.7rem;
  font-size: 0.85rem;
  overflow: auto;
}

.code-block code {
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  color: #00ff66;
  white-space: pre;
}

.code-block::before {
  content: attr(data-lang);
  position: absolute;
  top: 0.1rem;
  left: 0.6rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(0, 212, 255, 0.8);
}

.copy-btn {
  position: absolute;
  top: 0.25rem;
  right: 0.35rem;
  padding: 0.2rem 0.45rem;
  font-size: 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(4, 10, 24, 0.9);
  color: var(--color-text-main);
  cursor: pointer;
  opacity: 0.85;
  transition: opacity var(--transition-fast), transform var(--transition-fast), background var(--transition-fast);
}

.copy-btn:hover {
  opacity: 1;
  transform: translateY(-1px);
  background: rgba(0, 212, 255, 0.2);
}

.copy-btn:active {
  transform: translateY(0);
}

/* Coloreado aproximado de prompt (PS> ou $) e comentarios */

.code-block span.prompt {
  color: #00d4ff;
}

.code-block span.comment {
  color: #6b889e;
}

/* 13. ACTIVIDADES ----------------------------------------------------------- */

.activity-card {
  margin-bottom: 2rem;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius-md);
  background: radial-gradient(circle at 0 0, rgba(0, 212, 255, 0.14), transparent 50%),
    radial-gradient(circle at 100% 100%, rgba(128, 90, 255, 0.16), transparent 50%),
    rgba(6, 14, 30, 0.96);
  border: 1px solid var(--color-border-soft);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
}

.activity-card h3 {
  margin-top: 0;
  margin-bottom: 0.4rem;
  font-family: var(--font-title);
}

.activity-meta {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.activity-meta .badge {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(0, 212, 255, 0.16);
  border: 1px solid rgba(0, 212, 255, 0.55);
}

/* 14. SECCIÓNS COLAPSABLES -------------------------------------------------- */

.collapsible-section {
  border-radius: var(--radius-lg);
  padding: 0.2rem 0.75rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(135deg, rgba(8, 15, 36, 0.9), rgba(5, 10, 24, 0.85));
}

.collapsible-section .section-header {
  background: transparent;
  border: none;
  padding: 0.6rem 0.45rem 0.45rem;
}

.section-header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.collapsible-toggle {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.35);
  color: var(--color-text-main);
  font-size: 0.78rem;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.collapsible-toggle:hover {
  background: rgba(0, 212, 255, 0.16);
  transform: translateY(-1px);
}

.collapsible-section[data-collapsed="true"] .section-body {
  display: none;
}

/* 15. GLOSARIO EN PILLS ----------------------------------------------------- */

.pill-glossary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.75rem;
}

.pill {
  padding: 0.7rem 0.8rem;
  border-radius: 999px;
  background: rgba(8, 16, 40, 0.95);
  border: 1px solid rgba(0, 212, 255, 0.35);
  font-size: 0.88rem;
}

.pill h3 {
  margin: 0 0 0.2rem;
  font-size: 0.9rem;
  font-family: var(--font-title);
}

/* 16. CHECKLIST ------------------------------------------------------------- */

.checklist {
  list-style: none;
  padding-left: 0;
}

.checklist li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.4rem;
}

.checklist input[type="checkbox"] {
  accent-color: var(--color-accent);
  width: 0.9rem;
  height: 0.9rem;
}

/* 17. CHARTS ---------------------------------------------------------------- */

.chart-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr);
  gap: 1rem;
  margin-top: 0.5rem;
}

canvas {
  width: 100%;
  max-width: 100%;
  height: 220px;
}

/* 18. FOOTER ---------------------------------------------------------------- */

.main-footer {
  margin-top: auto;
  padding: 1.5rem 1.5rem 2rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  background: linear-gradient(to top, #020309, transparent);
}

.main-footer a {
  color: var(--color-accent);
  text-decoration: none;
}

.main-footer a:hover {
  text-decoration: underline;
}

/* 19. REVEAL / ANIMACIÓNS --------------------------------------------------- */

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* 20. ACCESIBILIDADE -------------------------------------------------------- */

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* 21. MODO IMPRESIÓN A4 ----------------------------------------------------- */

@page {
  size: A4;
  margin: 20mm;
}

@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .header-gradient {
    display: none !important;
  }

  .header-inner,
  .toc,
  .section,
  .card,
  .activity-card,
  .table-wrapper,
  .collapsible-section {
    background: #ffffff !important;
    box-shadow: none !important;
    border-color: #cccccc !important;
  }

  .code-block {
    background: #111111 !important;
    color: #f5f5f5 !important;
  }

  .btn,
  #print-mode-toggle,
  .copy-btn,
  .collapsible-toggle {
    display: none !important;
  }

  .section {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .section-header,
  .subsection h3 {
    background: #f2f5ff !important;
    color: #000 !important;
  }
}

/* Modo impresión activado manualmente (sen imprimir) */

body.print-mode {
  background: #f7f7fb;
  color: #111827;
}

body.print-mode .header-gradient {
  opacity: 0;
}

body.print-mode .header-inner,
body.print-mode .toc,
body.print-mode .section,
body.print-mode .card,
body.print-mode .activity-card,
body.print-mode .table-wrapper,
body.print-mode .collapsible-section {
  background: #ffffff !important;
  border-color: #d1d5db !important;
  box-shadow: none !important;
}

body.print-mode .code-block {
  background: #111827 !important;
}

/* 22. RESPONSIVE ------------------------------------------------------------ */

@media (max-width: 900px) {
  .header-inner {
    padding: 1.6rem 1.4rem;
  }

  .header-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  main {
    padding: 0 1rem 3rem;
  }

  .toc {
    padding: 1rem 1.1rem;
  }
}

@media (max-width: 600px) {
  .section-header {
    padding: 0.7rem 0.7rem;
  }

  .section-header-main {
    flex-direction: column;
    align-items: flex-start;
  }

  .collapsible-toggle {
    align-self: flex-start;
  }

  .stepper > li {
    padding-left: 1.7rem;
  }

  .stepper > li::before {
    left: 0.4rem;
  }

  .stepper > li::after {
    left: 0.78rem;
  }
}