/* Molde batería TGM — réplica 3D · Hormitec (estilo cisterna / Inter) */
:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a0a;
  --bg-elev: #111;
  --bg-card: #161616;
  --text: #f5f5f5;
  --text-strong: #fff;
  --text-muted: rgba(245,245,245,.68);
  --accent: #D2222A;
  --accent-soft: rgba(210,34,42,.14);
  --amber: #F5A524;
  --line: rgba(255,255,255,.12);
  --nav-border: rgba(255,255,255,.35);
  --nav-solid: rgba(10,10,10,.94);
  --nav-grad: linear-gradient(to bottom, rgba(0,0,0,.55), transparent);
  --hero-bg: radial-gradient(120% 80% at 50% 0%, #1c1c1c 0%, #0a0a0a 60%);
  --logo-filter: none;
  --hud-bg: rgba(10,10,10,.78);
  --canvas-veil: #0e0e0e;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, sans-serif;
  --nav-h: 56px;
  --measure: 1080px;
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #F7F7F7;
  --bg-elev: #fff;
  --bg-card: #fff;
  --text: #1a1a1a;
  --text-strong: #0a0a0a;
  --text-muted: rgba(26,26,26,.62);
  --accent: #D2222A;
  --accent-soft: rgba(210,34,42,.10);
  --amber: #C47A00;
  --line: rgba(0,0,0,.10);
  --nav-border: rgba(0,0,0,.22);
  --nav-solid: rgba(247,247,247,.94);
  --nav-grad: linear-gradient(to bottom, rgba(247,247,247,.85), transparent);
  --hero-bg: radial-gradient(120% 80% at 50% 0%, #ffffff 0%, #F7F7F7 60%);
  --logo-filter: brightness(0);
  --hud-bg: rgba(255,255,255,.88);
  --canvas-veil: #eae8e4;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 1rem); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-weight: 400;
  color: var(--text); background: var(--bg);
  font-size: 17px; line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; }
b, strong { color: var(--text-strong); font-weight: 600; }
.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em; padding: .1em .35em; border-radius: 4px;
  background: var(--accent-soft);
}
.skip-link { position: absolute; left: -9999px; top: 0; background: #fff; color: #000; padding: .75rem 1rem; z-index: 1000; }
.skip-link:focus { left: 1rem; top: 1rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* NAV */
.nav {
  position: fixed; inset: 0 0 auto 0;
  height: calc(var(--nav-h) + env(safe-area-inset-top, 0px));
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: env(safe-area-inset-top, 0px) 1rem 0;
  z-index: 50; background: var(--nav-grad);
  transition: background .25s, backdrop-filter .25s, border-color .25s;
}
.nav.is-solid {
  background: var(--nav-solid); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav-brand { display: flex; align-items: center; text-decoration: none; }
.nav-logo { height: 22px; width: auto; filter: var(--logo-filter); }
.nav-actions { display: flex; gap: .45rem; align-items: center; }
.nav-link {
  text-decoration: none; font-size: .8125rem; font-weight: 500;
  border: 1px solid var(--nav-border); border-radius: 999px;
  padding: .4rem .9rem; color: var(--text);
}
.nav-link:hover { border-color: var(--accent); background: var(--accent); color: #fff; }
.theme-toggle {
  appearance: none; background: var(--accent-soft); color: var(--text-strong);
  border: 1px solid var(--accent); border-radius: 999px;
  padding: .4rem .85rem; font-size: .8125rem; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: .35rem;
}
.theme-toggle .theme-icons { position: relative; width: 1rem; height: 1rem; }
.theme-toggle svg { position: absolute; inset: 0; width: 1rem; height: 1rem; }
.theme-toggle .icon-moon { opacity: 0; }
[data-theme="light"] .theme-toggle .icon-sun { opacity: 0; }
[data-theme="light"] .theme-toggle .icon-moon { opacity: 1; }
.theme-toggle:hover { background: var(--accent); color: #fff; }
.theme-toggle:hover svg { stroke: #fff; }
@media (max-width: 640px) {
  .nav-link { display: none; }
  .theme-toggle { width: 2.4rem; height: 2.4rem; padding: 0; }
  .theme-toggle .theme-label { display: none; }
  .nav-logo { height: 18px; }
}

/* HERO */
.hero {
  position: relative; min-height: 72vh;
  display: flex; align-items: flex-end;
  padding: calc(var(--nav-h) + 3rem) 1.5rem 3.5rem;
  background: var(--hero-bg);
}
.hero-gradient {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(60% 50% at 80% 20%, rgba(30,90,180,.18), transparent 70%);
}
.hero-content { position: relative; max-width: var(--measure); margin: 0 auto; width: 100%; }
.eyebrow {
  font-size: .75rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-muted); margin: 0 0 .75rem;
}
.hero h1 {
  font-size: clamp(1.85rem, 4.5vw, 3rem); font-weight: 600; letter-spacing: -.02em;
  line-height: 1.15; margin: 0 0 .85rem; color: var(--text-strong);
}
.hero-sub { margin: 0 0 1.25rem; max-width: 40rem; color: var(--text-muted); font-size: 1.05rem; }
.hero-tags { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 2rem; }
.hero-tag {
  margin: 0; font-size: .8rem; font-weight: 500;
  padding: .35rem .75rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg-card);
}
.hero-tag.acc { border-color: var(--accent); background: var(--accent-soft); color: var(--text-strong); }
.scroll-cue {
  display: inline-flex; align-items: center; gap: .35rem;
  text-decoration: none; font-size: .9rem; font-weight: 500; color: var(--text-muted);
}
.scroll-cue:hover { color: var(--accent); }

/* CHAPTERS */
.chapter { padding: 3.5rem 1.5rem; }
.chapter.alt { background: var(--bg-elev); }
.chapter-head, .prose { max-width: var(--measure); margin-left: auto; margin-right: auto; }
.chapter-head { margin-bottom: 1.75rem; }
.chapter-head h2 {
  font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 600; letter-spacing: -.02em;
  margin: 0 0 .5rem; color: var(--text-strong);
}
.lede { margin: 0; color: var(--text-muted); max-width: 40rem; }

/* 3D MODEL */
.model-wrap {
  position: relative;
  max-width: 1200px; margin: 0 auto;
  height: min(72vh, 640px);
  border-radius: 16px; overflow: hidden;
  border: 1px solid var(--line);
  background: var(--canvas-veil);
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
#molde-3d-canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.model-hud {
  position: absolute; left: .75rem; right: .75rem; top: .75rem;
  display: flex; flex-wrap: wrap; gap: .6rem .85rem; align-items: flex-end;
  padding: .65rem .75rem; border-radius: 12px;
  background: var(--hud-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); z-index: 2;
}
.hud-block { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.hud-label {
  font-size: .68rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted); width: 100%; margin-bottom: .1rem;
}
.hud-unit { font-size: .75rem; color: var(--text-muted); margin-left: .15rem; }
.seg {
  display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden;
  background: var(--bg-card);
}
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--text);
  padding: .35rem .7rem; font-size: .8rem; font-weight: 500; cursor: pointer;
  border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: 0; }
.seg button.is-active, .seg button[aria-pressed="true"] {
  background: var(--accent); color: #fff;
}
.hud-toggles { gap: .65rem; }
.chk {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .8rem; font-weight: 500; cursor: pointer; user-select: none;
}
.chk input { accent-color: var(--accent); width: 0.95rem; height: 0.95rem; }
.model-legend {
  position: absolute; left: .75rem; bottom: .75rem;
  display: flex; flex-wrap: wrap; gap: .55rem .9rem;
  padding: .45rem .7rem; border-radius: 999px;
  background: var(--hud-bg); border: 1px solid var(--line);
  font-size: .72rem; font-weight: 500; z-index: 2;
}
.swatch {
  display: inline-block; width: .65rem; height: .65rem; border-radius: 2px;
  margin-right: .3rem; vertical-align: -1px;
}
.swatch.blue { background: #1e5aaf; }
.swatch.yellow { background: #F5C518; }
.swatch.grey { background: #9a968c; }
.swatch.cyan { background: #3aa0d8; }
.disclaimer {
  max-width: var(--measure); margin: 1.25rem auto 0;
  font-size: .88rem; color: var(--text-muted); line-height: 1.55;
  padding: .9rem 1rem; border-left: 3px solid var(--amber); background: var(--bg-card); border-radius: 0 8px 8px 0;
}

/* KPIs / TABLE */
.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .75rem; margin: 0 0 1.75rem;
}
.kpi {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 12px;
  padding: 1rem 1.1rem;
}
.kpi .v { font-size: 1.45rem; font-weight: 600; letter-spacing: -.02em; color: var(--text-strong); line-height: 1.2; }
.kpi .v small { font-size: .7em; font-weight: 500; color: var(--text-muted); }
.kpi .l { font-size: .78rem; color: var(--text-muted); margin-top: .25rem; }
.kpi.acc { border-color: rgba(210,34,42,.45); background: linear-gradient(180deg, var(--accent-soft), transparent), var(--bg-card); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 1.75rem; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--line); }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); background: var(--bg-card); }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(127,127,127,.04); }

.parts-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .85rem;
}
.part-card {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 12px;
  padding: 1.1rem 1.15rem;
}
.part-card h3 { margin: 0 0 .4rem; font-size: 1rem; color: var(--text-strong); }
.part-card p { margin: 0; font-size: .9rem; color: var(--text-muted); }

.gallery {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem; margin-bottom: 1.25rem;
}
.gallery figure {
  margin: 0; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line); background: #111;
}
.gallery img { width: 100%; height: 200px; object-fit: cover; }
.gallery figcaption {
  padding: .55rem .75rem; font-size: .78rem; color: var(--text-muted);
  background: var(--bg-card);
}
.note { font-size: .88rem; color: var(--text-muted); }
.dl-list { margin: 0; padding-left: 1.2rem; }
.dl-list a { color: var(--accent); font-weight: 500; }
.muted { color: var(--text-muted); font-size: .85em; }

.foot {
  border-top: 1px solid var(--line); padding: 2rem 1.5rem 3rem;
}
.foot-inner { max-width: var(--measure); margin: 0 auto; display: flex; flex-direction: column; gap: .6rem; }
.foot-logo { height: 17px; width: auto; filter: var(--logo-filter); opacity: .85; }
.foot p { margin: 0; font-size: .85rem; color: var(--text-muted); }

@media (max-width: 720px) {
  .model-wrap { height: min(68vh, 520px); border-radius: 12px; }
  .model-hud { flex-direction: column; align-items: stretch; gap: .55rem; }
  .hud-label { width: auto; margin-right: .4rem; }
  .hud-block { align-items: center; }
  .model-legend { font-size: .65rem; left: .5rem; right: .5rem; bottom: .5rem; border-radius: 10px; }
}
