/* ============================================
   Protocolo IA-Socrático — USACH
   Estética Claude/Anthropic
   ============================================ */

/* 1. DESIGN TOKENS */
:root {
  --bg-cream: #F4F3EE;
  --bg-white: #FFFFFF;
  --accent: #da7756;
  --accent-hover: #c4654a;
  --accent-light: #f0d4c8;
  --text-primary: #141413;
  --text-secondary: #4a4a48;
  --gray-warm: #B1ADA1;
  --border-light: #e8e6dc;
  --link-color: #da7756;
  --link-hover: #c4654a;
  --code-bg: #1e1e1e;
  --code-text: #f8f8f2;
  --success: #788c5d;
  --font-body: ui-serif, Georgia, Cambria, "Times New Roman", serif;
  --font-heading: ui-serif, Georgia, Cambria, "Times New Roman", serif;
  --font-mono: "Cascadia Code", "Fira Code", "SF Mono", Consolas, monospace;
  --max-content: 780px;
  --sidebar-width: 280px;
  --radius: 8px;
  --shadow-sm: 0 1px 3px rgba(20, 20, 19, 0.06);
  --shadow-md: 0 4px 12px rgba(20, 20, 19, 0.08);
}

/* 2. RESET & BASE */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 17px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-cream);
  line-height: 1.7;
}

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

/* 3. LAYOUT */
.layout {
  min-height: 100vh;
}

.main {
  margin-left: var(--sidebar-width);
  padding: 2.5rem 3rem 4rem;
  max-width: calc(var(--max-content) + 6rem);
}

/* 4. SIDEBAR */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
  background: var(--bg-white);
  border-right: 1px solid var(--border-light);
  padding: 2rem 0;
  z-index: 100;
}

.sidebar::-webkit-scrollbar {
  width: 5px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background-color: var(--border-light);
  border-radius: 3px;
}

.sidebar__brand {
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 1.5rem;
}

.sidebar__title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.sidebar__subtitle {
  font-size: 0.78rem;
  color: var(--gray-warm);
  margin-top: 0.25rem;
  letter-spacing: 0.02em;
}

.sidebar__section {
  padding: 0 1.5rem;
  margin-top: 1.5rem;
}

.sidebar__section-title {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gray-warm);
  margin-bottom: 0.5rem;
}

.sidebar__link {
  display: block;
  padding: 0.4rem 1.5rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
}

.sidebar__link:hover {
  color: var(--text-primary);
  background: var(--bg-cream);
}

.sidebar__link--active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
  background: rgba(218, 119, 86, 0.05);
}

.sidebar__version {
  padding: 1.5rem;
  margin-top: 2rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.72rem;
  color: var(--gray-warm);
}

/* Mobile hamburger */
.hamburger {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  line-height: 1;
}

.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-primary);
  margin: 4px 0;
  transition: 0.2s;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 19, 0.3);
  z-index: 90;
}

.overlay--active { display: block; }

/* 5. TYPOGRAPHY */
.breadcrumb {
  font-size: 0.8rem;
  color: var(--gray-warm);
  margin-bottom: 0.75rem;
}

.breadcrumb a {
  color: var(--gray-warm);
  text-decoration: none;
}

.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { margin: 0 0.4rem; }

h1 {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.page-meta {
  font-size: 0.82rem;
  color: var(--gray-warm);
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

h2 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  padding-top: 1rem;
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

p {
  margin-bottom: 1rem;
  max-width: 65ch;
}

a {
  color: var(--link-color);
  text-decoration: none;
  transition: color 0.15s;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

strong { font-weight: 600; }

ul, ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

li { margin-bottom: 0.35rem; }

li::marker { color: var(--accent); }

blockquote {
  border-left: 4px solid var(--accent);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--bg-white);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
  color: var(--text-secondary);
}

blockquote strong {
  color: var(--text-primary);
  font-style: normal;
}

hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 2.5rem 0;
}

/* 6. TABLES */
.table-responsive {
  overflow-x: auto;
  margin: 1.25rem 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-white);
  font-size: 0.88rem;
}

thead th {
  background: var(--text-primary);
  color: var(--bg-white);
  font-weight: 600;
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

tbody td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}

tbody tr:nth-child(even) { background: var(--bg-cream); }
tbody tr:hover { background: var(--accent-light); }

tbody td:first-child {
  font-weight: 600;
  white-space: nowrap;
}

table.simple thead th {
  background: var(--bg-cream);
  color: var(--text-primary);
}

/* 7. CODE BLOCKS */
.code-block {
  margin: 1.5rem 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.code-block__label {
  background: var(--accent);
  color: var(--bg-white);
  padding: 0.5rem 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.code-block pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.65;
  margin: 0;
  border-left: 4px solid var(--accent);
}

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: rgba(218, 119, 86, 0.1);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: var(--accent-hover);
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* 8. CAUSAL CHAIN DIAGRAMS */
.causal-chain {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.5rem 0;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
}

.causal-chain pre {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
  margin: 0;
  color: var(--text-primary);
  background: none;
}

/* 9. DIMENSION BADGES */
.dim-ref {
  display: inline-block;
  background: var(--accent);
  color: var(--bg-white);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15em 0.5em;
  border-radius: 4px;
  text-decoration: none;
  letter-spacing: 0.03em;
  vertical-align: middle;
}

.dim-ref:hover {
  background: var(--accent-hover);
  color: var(--bg-white);
  text-decoration: none;
}

/* 10. GLOSSARY TERMS */
.glossary-term {
  border-bottom: 1px dotted var(--accent);
  cursor: help;
  position: relative;
}

.glossary-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  line-height: 1.5;
  width: 280px;
  box-shadow: var(--shadow-md);
  z-index: 50;
  font-style: normal;
}

.glossary-term:hover .glossary-tooltip { display: block; }

.glossary-tooltip a {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--accent);
}

/* 11. DOWNLOAD CARDS */
.download-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.download-card {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.download-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.download-card__title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.download-card__desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.download-card__file {
  display: inline-block;
  max-width: 100%;
  background: var(--accent);
  color: var(--bg-white);
  padding: 0.4rem 1rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
  margin-bottom: 0.4rem;
  margin-right: 0.4rem;
  overflow-wrap: anywhere;
  white-space: normal;
}

.download-card__file:hover {
  background: var(--accent-hover);
  color: var(--bg-white);
  text-decoration: none;
}

.download-card__file--pending {
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  cursor: default;
  font-style: italic;
}

/* 12. SIGNAL/NOISE BADGES */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2em 0.6em;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge--signal { background: #e8f0de; color: #4a6630; }
.badge--symptom { background: #fef3cd; color: #856404; }
.badge--noise { background: #e8e6dc; color: #6b6960; }

/* 13. HERO (index page) */
.hero {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 2.5rem;
  margin-bottom: 2.5rem;
  text-align: center;
}

.hero h1 {
  font-size: 2.2rem;
  margin-bottom: 0.75rem;
}

.hero__rule {
  font-size: 1.15rem;
  color: var(--accent);
  font-weight: 600;
  font-style: italic;
  margin: 1.25rem 0;
}

.hero__meta {
  font-size: 0.85rem;
  color: var(--gray-warm);
}

/* 14. INFO BOXES */
.info-box {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  font-size: 0.9rem;
}

.info-box--warning {
  border-left-color: #d4a017;
  background: #fffdf5;
}

/* 15. FOOTER */
.footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.78rem;
  color: var(--gray-warm);
  text-align: center;
}

/* 16. RESPONSIVE */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }

  .sidebar--open {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }

  .hamburger { display: block; }

  .main {
    margin-left: 0;
    padding: 3.5rem 1.25rem 3rem;
  }

  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.2rem; }

  .hero { padding: 1.5rem; }
  .hero h1 { font-size: 1.6rem; }

  .download-grid {
    grid-template-columns: 1fr;
  }

  tbody td:first-child {
    white-space: normal;
  }

  .table-responsive {
    margin-left: -0.25rem;
    margin-right: -0.25rem;
  }

  table { font-size: 0.8rem; }
  thead th, tbody td { padding: 0.5rem 0.65rem; }
}

/* 17. STORY COMPONENTS (escenarios anticipados) */
.table-wide {
  width: calc(100vw - var(--sidebar-width) - 6rem);
  max-width: none;
}

.table-wide thead th {
  white-space: normal;
}

.story-scene {
  margin: 1.5rem 0 2rem;
  padding: 1.25rem 1.5rem;
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.story-scene__title {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-warm);
  margin-bottom: 0.75rem;
}

.story-branch {
  border-left: 4px solid var(--border-light);
  padding: 0.85rem 1.25rem;
  margin: 0.75rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--bg-cream);
}

.story-branch--a { border-left-color: #788c5d; }
.story-branch--b { border-left-color: #da7756; }
.story-branch--c { border-left-color: #B1ADA1; }

.story-branch__tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.15rem 0.6rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  color: #fff;
}

.story-branch--a .story-branch__tag { background: #788c5d; }
.story-branch--b .story-branch__tag { background: #da7756; }
.story-branch--c .story-branch__tag { background: #B1ADA1; }

.story-branch__title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.story-branch p, .story-branch li {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.story-dialogue {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 0.5rem 0;
  font-size: 0.85rem;
}

.story-dialogue__speaker {
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}

.story-dialogue__speaker--bot { color: #788c5d; }
.story-dialogue__speaker--student { color: var(--text-secondary); }

.story-arrow {
  text-align: center;
  font-size: 0.82rem;
  color: var(--gray-warm);
  margin: 1.25rem 0 0.5rem;
  font-style: italic;
}

.story-dimensions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.story-dim {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}

.story-tree {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-secondary);
  overflow-x: auto;
}

/* 18. PRINT */
@media print {
  .sidebar, .hamburger, .overlay { display: none !important; }
  .layout { grid-template-columns: 1fr; }
  .main { padding: 0; max-width: 100%; }
  body { font-size: 11pt; }
  h1 { font-size: 18pt; }
  h2 { font-size: 14pt; }
  table { font-size: 9pt; }
  .code-block pre { white-space: pre-wrap; font-size: 8pt; }
  a { color: var(--text-primary); text-decoration: underline; }
  .hero { border: 1px solid #ccc; }
}
