/* ============================================================
   Dos instrumentos en un mismo panel oscuro:
   izquierda — cuenta atrás sobre la molécula de tadalafilo
   derecha   — El Amortiguador Costal (simulador mecánico)
   ============================================================ */

:root {
  --bg:        #0a0d12;
  --bg-2:      #121721;
  --ink:       #f2f5fa;
  --ink-dim:   #8d97a8;
  --molecule:  #c9d1de;
  --seam:      #232a36;
  --rivet:     #3a4454;

  --font-sans: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

/* El atributo hidden debe ganar a los display de .unit / .sep */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------------------- Estructura de dos paneles ---------------------- */

.rig {
  display: flex;
  align-items: stretch;
  min-height: 100svh;
  width: 100%;
}

.panel {
  position: relative;
  flex: 1 1 50%;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.panel-count { overflow: hidden; }

.panel-anatomy {
  background: var(--bg);
}

.anatomy-frame {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 100svh;
  border: 0;
  display: block;
  color-scheme: dark;
}

/* Costura central: une visualmente los dos instrumentos */
.seam {
  flex: 0 0 auto;
  width: 1px;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding-block: 4vh;
  background: linear-gradient(to bottom, transparent, var(--seam) 10%, var(--seam) 90%, transparent);
}

.rivet {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--rivet);
  flex: none;
}

/* Viñeta suave para que el centro de cada panel respire */
.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%,
              rgba(10, 13, 18, 0.45) 0%,
              rgba(10, 13, 18, 0.75) 60%,
              rgba(10, 13, 18, 0.92) 100%);
}

/* ---------------------- Molécula de fondo ---------------------- */

.molecule {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* preserveAspectRatio="meet": la molécula siempre cabe entera,
   se adapte como se adapte el panel. */
.molecule svg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 6vmin);
  height: calc(100% - 6vmin);
  opacity: 0.5;
}

.molecule .bonds line {
  stroke: var(--molecule);
  stroke-width: 2.6;
  stroke-linecap: round;
  fill: none;
}

.molecule .atoms text {
  fill: var(--molecule);
  font-family: var(--font-sans);
  font-size: 19px;
  font-weight: 500;
  text-anchor: middle;
  dominant-baseline: middle;
}

.molecule .atoms text.small { font-size: 15px; }

/* ---------------------- Contador centrado ---------------------- */

.stage {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(0.75rem, 2.5vh, 2rem);
  padding: 4vh clamp(0.75rem, 4vw, 3rem);
  text-align: center;
}

.title {
  margin: 0;
  font-size: clamp(1rem, 3.2vw, 1.75rem);
  font-weight: 400;
  letter-spacing: 0.05em;
  color: var(--ink-dim);
}

.clock {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(0.35rem, 1.8vw, 1.5rem);
  width: 100%;          /* imprescindible para que pueda envolver */
  max-width: 100%;
}

.unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.2rem, 1vh, 0.6rem);
  flex: 0 1 auto;
  min-width: 0;
}

.value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-size: clamp(2.2rem, 9.5vw, 8.5rem);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: var(--ink);
  text-shadow: 0 0 40px rgba(201, 209, 222, 0.28);
}

.label {
  font-family: var(--font-sans);
  font-size: clamp(0.68rem, 1.9vw, 0.95rem);
  letter-spacing: 0.01em;
  color: var(--ink-dim);
  white-space: nowrap;
}

.sep {
  font-family: var(--font-mono);
  font-size: clamp(2rem, 11vw, 6rem);
  line-height: 0.95;
  color: var(--ink-dim);
  opacity: 0.45;
  transform: translateY(-0.04em);
}

.finished {
  margin: 0;
  font-size: clamp(0.95rem, 3.4vw, 1.6rem);
  color: var(--ink-dim);
}

.panel-caption {
  position: relative;
  z-index: 2;
  margin: 0;
  padding: 0 clamp(0.75rem, 4vw, 3rem) max(0.9rem, env(safe-area-inset-bottom));
  text-align: center;
  font-size: clamp(0.72rem, 1.6vw, 0.82rem);
  color: var(--ink-dim);
  opacity: 0.6;
}

.panel-caption sub { font-size: 0.78em; }

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

/* ---------------------- Ajustes responsive ---------------------- */

/* Debajo de este ancho, los dos instrumentos se apilan: el contador
   arriba, el simulador mecánico debajo, separados por una costura
   horizontal. */
@media (max-width: 880px) {
  .rig { flex-direction: column; min-height: 0; }
  .panel { flex: none; width: 100%; }
  .panel-count { min-height: 100svh; }
  .panel-anatomy { min-height: 100svh; }
  .seam {
    width: 100%;
    height: 1px;
    flex-direction: row;
    padding-block: 0;
    padding-inline: 4vh;
    background: linear-gradient(to right, transparent, var(--seam) 10%, var(--seam) 90%, transparent);
  }
}

@media (max-width: 620px) {
  .clock { row-gap: clamp(0.5rem, 3vh, 1.5rem); }
  .sep { display: none; }
  .value { font-size: clamp(1.9rem, 10.5vw, 4.5rem); }
  .label { font-size: clamp(0.6rem, 2.4vw, 0.85rem); }
  .molecule svg {
    width: calc(100% - 3vmin);
    height: calc(100% - 3vmin);
    opacity: 0.6;
  }
}

/* Pantallas muy bajas (móvil en horizontal) */
@media (max-height: 420px) {
  .value { font-size: clamp(2rem, 15vh, 5.5rem); }
  .label { font-size: clamp(0.6rem, 2.6vh, 0.85rem); }
  .stage { padding-block: 2vh; }
  .panel-caption { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .molecule svg { transition: opacity 1.2s ease; }
}
