/* Endurance Clock component.
   Drop-in: include this file + js/endurance-clock.js, then add
   <div class="endurance-clock" data-endurance-clock></div>.
   Theme via the custom properties below. */

.endurance-clock {
  --ec-hull: #8f99a8;        /* module body */
  --ec-hull-dark: #3a4250;   /* module shadow / truss */
  --ec-hull-edge: #c7cfdb;   /* module outline */
  --ec-truss: #5b6473;
  --ec-window: #9fd3ff;
  --ec-accent: #ffb25c;      /* active module, hand tips */
  --ec-accent-hot: #ffe2b8;
  --ec-hand: #e6ecf5;
  --ec-second: #ffd089;
  --ec-text: #c9d2e0;
  --ec-text-dim: #6f7a8c;
  --ec-font: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  position: relative;
  display: grid;
  grid-template-rows: auto auto;
  gap: clamp(10px, 2.5vmin, 22px);
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  isolation: isolate;
  color: var(--ec-text);
  font-family: var(--ec-font);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---- Gargantua: accretion disc glow behind the ring ----
   The disc deliberately extends past the component's box. On narrow pages
   give the nearest full-width ancestor `overflow-x: clip` (the demo page
   does this on body). */

.endurance-clock__gargantua {
  position: absolute;
  z-index: 0;
  pointer-events: none;
  /* anchored on the ring (the SVG square is the first grid row) */
  left: 50%;
  top: 0;
  width: 100%;
  aspect-ratio: 1;
  transform: translateX(-50%);
}

.endurance-clock__gargantua::before,
.endurance-clock__gargantua::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
}

/* the tilted disc */
.endurance-clock__gargantua::before {
  width: 140%;
  height: 44%;
  transform: translate(-50%, -50%) rotate(-16deg);
  background: radial-gradient(
    ellipse at center,
    transparent 36%,
    rgba(255, 170, 90, 0.08) 42%,
    rgba(255, 150, 70, 0.55) 48%,
    rgba(255, 120, 50, 0.3) 54%,
    rgba(255, 90, 40, 0.08) 62%,
    transparent 70%
  );
  filter: blur(10px);
  opacity: 0.9;
}

/* the lensed halo around the shadow */
.endurance-clock__gargantua::after {
  width: 78%;
  height: 78%;
  transform: translate(-50%, -50%);
  background: radial-gradient(
    circle at center,
    rgba(4, 6, 12, 0.95) 38%,
    rgba(40, 20, 12, 0.9) 44%,
    rgba(255, 160, 80, 0.35) 49%,
    rgba(255, 130, 60, 0.12) 54%,
    transparent 62%
  );
  filter: blur(6px);
}

/* ---- Ship ---- */

.endurance-clock__svg {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.ec-truss {
  fill: none;
  stroke: var(--ec-truss);
}

.ec-truss-rail {
  fill: none;
  stroke: var(--ec-hull-dark);
}

.ec-spoke {
  fill: var(--ec-hull-dark);
  stroke: var(--ec-truss);
  stroke-width: 1.5;
}

.ec-spoke-rung {
  stroke: var(--ec-truss);
  stroke-width: 2;
}

.ec-hub {
  fill: #1b2029;
  stroke: var(--ec-hull-edge);
  stroke-width: 2.5;
}

.ec-hub-inner {
  fill: #0d1017;
  stroke: var(--ec-truss);
  stroke-width: 1.5;
}

.ec-hub-port {
  fill: var(--ec-hull-dark);
  stroke: var(--ec-hull-edge);
  stroke-width: 1.2;
}

/* Modules */

.ec-module__body {
  fill: var(--ec-hull);
  stroke: var(--ec-hull-edge);
  stroke-width: 2;
  transition: fill 0.9s ease, stroke 0.9s ease;
}

.ec-module__shade {
  fill: var(--ec-hull-dark);
  opacity: 0.55;
  transition: opacity 0.9s ease;
}

.ec-module__seam {
  stroke: var(--ec-hull-dark);
  stroke-width: 1.5;
  opacity: 0.8;
}

.ec-module__window {
  fill: var(--ec-window);
  opacity: 0.55;
  transition: fill 0.9s ease, opacity 0.9s ease;
}

.ec-module__hatch {
  fill: var(--ec-hull-dark);
  stroke: var(--ec-hull-edge);
  stroke-width: 1.2;
}

.ec-module__glow {
  fill: var(--ec-accent);
  opacity: 0;
  transition: opacity 0.9s ease;
}

.ec-module.is-active .ec-module__body {
  fill: var(--ec-accent);
  stroke: var(--ec-accent-hot);
}

.ec-module.is-active .ec-module__shade {
  opacity: 0.25;
}

.ec-module.is-active .ec-module__window {
  fill: #fff6e6;
  opacity: 1;
}

.ec-module.is-active .ec-module__glow {
  opacity: 0.85;
}

/* Hands */

.ec-hand-hour {
  fill: var(--ec-hand);
  stroke: #0a0d14;
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.ec-hand-minute {
  fill: var(--ec-hand);
  stroke: #0a0d14;
  stroke-width: 1.2;
  stroke-linejoin: round;
}

.ec-hand-tip {
  fill: var(--ec-accent);
}

.ec-hand-cap {
  fill: #0d1017;
  stroke: var(--ec-hand);
  stroke-width: 2.5;
}

/* Second indicator: a craft on approach around the outer orbit */

.ec-orbit {
  fill: none;
  stroke: var(--ec-second);
  stroke-width: 1;
  opacity: 0.12;
  stroke-dasharray: 2 10;
}

.ec-second-trail {
  fill: none;
  stroke: var(--ec-second);
  stroke-width: 2;
  stroke-linecap: round;
  opacity: 0.35;
}

.ec-second-dot {
  fill: var(--ec-second);
}

.ec-second-dot-core {
  fill: #fff;
}

/* ---- Readout ---- */

.endurance-clock__readout {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 0.35em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.endurance-clock__time {
  font-size: clamp(1.6rem, 6vmin, 3rem);
  font-weight: 500;
  line-height: 1;
  color: var(--ec-text);
  text-shadow: 0 0 18px rgba(255, 178, 92, 0.25);
}

.endurance-clock__time .ec-seconds {
  font-size: 0.55em;
  color: var(--ec-accent);
  vertical-align: 0.1em;
  margin-left: 0.25em;
}

.endurance-clock__time .ec-period {
  font-size: 0.5em;
  margin-left: 0.35em;
  color: var(--ec-text-dim);
}

.endurance-clock__meta {
  font-size: clamp(0.62rem, 1.9vmin, 0.85rem);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--ec-text-dim);
}

.endurance-clock__meta .ec-sep {
  margin: 0 0.6em;
  opacity: 0.5;
}

@media (prefers-reduced-motion: reduce) {
  .ec-module__body,
  .ec-module__shade,
  .ec-module__window,
  .ec-module__glow {
    transition: none;
  }
}
