:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #131722;
  --muted: #4a5263;
  --border: #d9dde5;
  --accent: #006d7a;
  --accent-contrast: #ffffff;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f17;
    --surface: #121826;
    --text: #e6e9ef;
    --muted: #a3acbd;
    --border: #273044;
    --accent: #3fd0e0;
    --accent-contrast: #06232a;
    --code-bg: #060a12;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    16px/1.55 system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
}

.wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 16px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  padding: 8px 12px;
  background: var(--accent);
  color: var(--accent-contrast);
  z-index: 100;
}
.skip-link:focus {
  left: 8px;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.site-header .wrap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-top: 14px;
  padding-bottom: 14px;
}
.env-banner {
  margin: 0;
  padding: 8px 16px;
  background: #fde68a;
  color: #422006;
  font-weight: 600;
  text-align: center;
}

.brand {
  margin: 0;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}
.brand span {
  color: var(--accent);
}
.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.hero {
  padding: 40px 0 16px;
  max-width: 760px;
}
.hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  line-height: 1.15;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}
.hero p {
  color: var(--muted);
  font-size: 1.1rem;
  margin: 0;
}

h2 {
  font-size: 1.35rem;
  margin: 40px 0 16px;
}
h3 {
  font-size: 1rem;
  margin: 0 0 8px;
}

.demo-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
}
@media (max-width: 860px) {
  .demo-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.viewer-frame {
  height: min(70vh, 560px);
  min-height: 360px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.viewer-frame contrast-vehicle-viewer {
  display: block;
  width: 100%;
  height: 100%;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.model-picker {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
}
.model-picker[hidden] {
  display: none;
}
.model-picker label {
  font-weight: 600;
}
.model-picker select {
  font: inherit;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.model-picker select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.model-picker .hint {
  margin: 0;
}
.explode-control {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
}
.explode-control label {
  font-weight: 600;
}
.explode-control input {
  accent-color: var(--accent);
  width: 100%;
}
.explode-control input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
button {
  font: inherit;
  font-size: 0.9rem;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
button[aria-pressed='true'] {
  background: var(--accent);
  color: var(--accent-contrast);
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 16px;
}
kbd {
  font:
    0.8rem ui-monospace,
    monospace;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
}

.event-log {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
}
.event-log li {
  padding: 6px 0;
  border-top: 1px solid var(--border);
}
.event-log code {
  font:
    0.8rem ui-monospace,
    monospace;
  color: var(--accent);
}

pre {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: 12px;
  padding: 16px;
  overflow-x: auto;
  font:
    0.85rem/1.5 ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
}

.features ul {
  padding-left: 1.2rem;
}
.features li {
  margin-bottom: 8px;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}
.site-header nav a,
.site-footer a {
  color: var(--accent);
  font-weight: 600;
}

/* Workshop demo (spec 019). */
.damage-list {
  margin: 0 0 16px;
  padding-left: 1.2rem;
  font-size: 0.9rem;
}
.damage-list li {
  margin-bottom: 10px;
}
.damage-list .hint {
  margin: 0;
}
.damage-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.damage-photos img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.tariff {
  width: 100%;
  margin: 0 0 16px;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.tariff th,
.tariff td {
  padding: 4px 0;
  border-top: 1px solid var(--border);
  text-align: left;
  font-weight: normal;
}
.tariff td {
  text-align: right;
}
button[hidden] {
  display: none;
}

/* Inspector demo (spec 036, next-viewer-first-layout): the viewer fills the whole window; the page's own controls
   (model, file, links) sit in a menu that stays closed until asked for. */
.inspect-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.inspect-main {
  position: relative;
  flex: 1;
  min-height: 0;
}
.inspect-frame {
  position: absolute;
  inset: 0;
}
.inspect-frame contrast-viewer {
  display: block;
  width: 100%;
  height: 100%;
  /* The page's menu button is in the top right corner: the right panel opens below it. */
  --cvf-right-top: 58px;
}
/* Until the profile is applied and the first model is shown, the viewer stays invisible over a quiet frame, so
   the default look never appears before the profile one (spec next-boot-skeleton). */
.inspect-frame contrast-viewer {
  transition: opacity 0.18s ease-out;
}
.inspect-frame[data-booting] contrast-viewer {
  opacity: 0;
}
.inspect-frame[data-booting]::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: inspect-boot-spin 0.8s linear infinite;
}
@keyframes inspect-boot-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .inspect-frame[data-booting]::after {
    animation: none;
  }
  .inspect-frame contrast-viewer {
    transition: none;
  }
}
.inspect-frame contrast-viewer.dropping {
  outline: 3px dashed var(--accent);
  outline-offset: -3px;
}
.inspect-menu {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-width: calc(100% - 20px);
}
.inspect-menu-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}
.inspect-menu-btn[aria-expanded='true'] {
  border-color: var(--accent);
  color: var(--accent);
}
.inspect-menu-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.inspect-menu-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, 100%);
  box-sizing: border-box;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 28px #0007;
}
.inspect-menu-card[hidden] {
  display: none;
}
.inspect-menu-card nav {
  display: flex;
  gap: 14px;
}
.inspect-title {
  margin: 0;
  font-size: 1.1rem;
}
.inspect-menu-card .model-picker,
.inspect-menu-card .hint {
  margin: 0;
}
/* The long model names and the file control wrap, never widen the card. */
.inspect-menu-card select,
.inspect-menu-card input {
  min-width: 0;
  max-width: 100%;
}
.file-picker {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}
/* The status is read aloud always; it is drawn only when something went wrong, or while a CAD file is being converted
   (the kernel reports no progress, and the viewer's own overlay would read "100 %" for the whole wait). */
.inspect-status {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 20;
  max-width: calc(100% - 40px);
  margin: 0;
  padding: 8px 14px;
  transform: translateX(-50%);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}
.inspect-status:not(.is-alert):not(.is-busy) {
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

/* Until the element is defined its fallback paragraph is plain page text; it would flash on the first paint. */
.inspect-frame contrast-viewer:not(:defined) [slot='fallback'] {
  visibility: hidden;
  /* ... but only for a moment: when the viewer never gets defined, the message must show. */
  animation: show-fallback 0s 4s forwards;
}
@keyframes show-fallback {
  to {
    visibility: visible;
  }
}

/* Environment notice of the inspector (spec next-inspector-chrome): it floats above the viewer, so it never resizes it,
   and hides itself after 3 s (the script adds the close button and the fade-out class). */
.inspect-page {
  position: relative;
}
.inspect-page .env-banner {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  /* The page menu button is in the top right corner: the notice leaves it free. */
  width: max-content;
  max-width: calc(100% - 104px);
  padding: 4px 6px 4px 14px;
  transform: translateX(-50%);
  border-radius: 0 0 10px 10px;
  font-size: 0.9rem;
  text-align: left;
  transition: opacity 0.3s;
}
.inspect-page .env-banner[hidden] {
  display: none;
}
.inspect-page .env-banner.is-leaving {
  opacity: 0;
}
.env-banner-close {
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.env-banner-close:hover {
  background: #422006;
  color: #fde68a;
}
.env-banner-close:focus-visible {
  outline: 2px solid #422006;
  outline-offset: 1px;
}

/* The eye that hides the whole interface sits beside the menu button (spec next-clean-interface); Captura and Copiar
   enlace are in the menu card once the viewer has them. */
.inspect-menu-row {
  display: flex;
  gap: 6px;
}
.inspect-menu-btn:hover,
.inspect-menu-action:hover {
  border-color: var(--accent);
}
.inspect-menu-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.inspect-menu-actions:not(:has(:not([hidden]))) {
  display: none;
}
.inspect-menu-action {
  flex: 1;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.inspect-menu-action[hidden] {
  display: none;
}
.inspect-menu-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* The way back from the model-only view: an eye in the corner of the menu button, nearly invisible until it is looked
   for (hover or keyboard focus). The hit target stays 44 px wide and high. */
.inspect-ui-show {
  position: absolute;
  top: 8px;
  /* Where the eye was: beside the menu button's place (40 px button, 6 px gap, 10 px margin). */
  right: 54px;
  z-index: 20;
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  color: var(--text);
  opacity: 0.14;
  cursor: pointer;
  transition: opacity 0.2s;
}
.inspect-ui-show[hidden] {
  display: none;
}
.inspect-ui-show:hover,
.inspect-ui-show:focus-visible {
  opacity: 1;
  border-color: var(--border);
}
.inspect-ui-show:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* Model only: the page's own controls go with the viewer's. The status stays for screen readers (it is not drawn). */
.ui-hidden .inspect-menu,
.ui-hidden .env-banner {
  display: none;
}
@media (prefers-reduced-motion: reduce) {
  .inspect-page .env-banner,
  .inspect-ui-show {
    transition: none;
  }
}

.site-footer {
  margin-top: 48px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}
