/* GARGANTUA — mission-terminal visual system */

:root {
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --cyan: #7fdcff;
  --amber: #ffb454;
  --cyan-dim: rgba(127, 220, 255, 0.45);
  --hl: #eafaff;
  --bg: #000;
  --panel-bg: linear-gradient(145deg, rgba(4, 12, 22, 0.82), rgba(2, 8, 16, 0.72));
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--hl);
  font-family: var(--font-mono);
  -webkit-text-size-adjust: 100%;
  touch-action: none;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  user-select: none;
  -webkit-user-select: none;
}

/* Canvas — lowest layer */
#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  outline: none;
  touch-action: none;
}

/* Post FX decoration */
#fx {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.6;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.025) 0px,
      rgba(255, 255, 255, 0.025) 1px,
      transparent 1px,
      transparent 3px
    ),
    radial-gradient(
      ellipse at center,
      transparent 55%,
      rgba(0, 0, 0, 0.55) 100%
    );
}

/* ── HUD ─────────────────────────────────────────────────── */
#hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.6s ease;
  font-family: var(--font-mono);
}

#hud.hidden {
  opacity: 0;
  visibility: hidden;
}

#hud .pe {
  pointer-events: auto;
}

/* Corner brackets */
.corner {
  position: fixed;
  width: 34px;
  height: 34px;
  border-color: var(--cyan-dim);
  border-style: solid;
  border-width: 0;
  z-index: 11;
  pointer-events: none;
  animation: cornerFlicker 6s step-end infinite;
}

.corner.tl { top: 22px; left: 22px; border-top-width: 1px; border-left-width: 1px; }
.corner.tr { top: 22px; right: 22px; border-top-width: 1px; border-right-width: 1px; }
.corner.bl { bottom: 22px; left: 22px; border-bottom-width: 1px; border-left-width: 1px; }
.corner.br { bottom: 22px; right: 22px; border-bottom-width: 1px; border-right-width: 1px; }

@keyframes cornerFlicker {
  0%, 97.4% { opacity: 1; }
  97.5%, 100% { opacity: 0.35; }
}

body.reduce-motion .corner {
  animation: none;
}

/* Title block — top left */
.title-block {
  position: fixed;
  top: 30px;
  left: 42px;
  z-index: 12;
  pointer-events: none;
}

.title-block h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.42em;
  color: #fff;
  line-height: 1.15;
  text-indent: 0.42em;
  margin-left: -0.42em;
}

.title-block .sub {
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: 0.30em;
  color: var(--amber);
  text-indent: 0.30em;
  margin-left: -0.30em;
}

.title-block .meta {
  margin-top: 5px;
  font-size: 9.5px;
  letter-spacing: 0.24em;
  color: var(--cyan-dim);
  text-indent: 0.24em;
  margin-left: -0.24em;
}

/* Clock — top right */
.clock-block {
  position: fixed;
  top: 32px;
  right: 44px;
  z-index: 12;
  text-align: right;
  pointer-events: none;
}

.clock-block .label {
  font-size: 9px;
  letter-spacing: 0.3em;
  color: var(--cyan-dim);
  display: block;
  margin-bottom: 4px;
}

.clock-block .value {
  font-size: 17px;
  letter-spacing: 0.18em;
  color: var(--hl);
}

/* Telemetry — bottom left */
.telemetry {
  position: fixed;
  bottom: 34px;
  left: 42px;
  z-index: 12;
  font-size: 10.5px;
  line-height: 1.95;
  color: var(--cyan-dim);
  pointer-events: none;
}

.telemetry .row {
  display: flex;
  gap: 8px;
}

.telemetry .k {
  min-width: 190px;
  color: var(--cyan-dim);
}

.telemetry .v {
  color: var(--hl);
  letter-spacing: 0.06em;
}

/* Deck — bottom right */
.deck {
  position: fixed;
  bottom: 30px;
  right: 40px;
  width: 260px;
  z-index: 12;
  padding: 14px 14px 10px;
  border: 1px solid var(--cyan-dim);
  background: linear-gradient(160deg, rgba(3, 14, 28, 0.88), rgba(1, 6, 14, 0.78));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 0;
  pointer-events: auto;
}

.deck-title {
  font-size: 9px;
  letter-spacing: 0.28em;
  color: var(--amber);
  margin-bottom: 10px;
}

.deck .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cyan);
  background: transparent;
  border: 1px solid var(--cyan-dim);
  padding: 8px 4px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  min-height: 36px;
  border-radius: 0;
}

.deck .btn:hover {
  background: rgba(127, 220, 255, 0.08);
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(127, 220, 255, 0.15);
}

.deck .btn:focus-visible {
  outline: 1px solid var(--cyan);
  outline-offset: 2px;
}

.deck .btn.active {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(255, 180, 84, 0.15);
}

.deck .btn-cine {
  margin-bottom: 8px;
}

.deck .preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}

.deck .row-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}

.deck .btn-sound {
  margin-bottom: 8px;
}

.deck .hints {
  font-size: 8px;
  letter-spacing: 0.08em;
  color: var(--cyan-dim);
  line-height: 1.55;
  text-align: center;
  opacity: 0.85;
}

/* Bottom center tip */
#tip {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--cyan-dim);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease;
  white-space: nowrap;
  text-align: center;
  max-width: 90vw;
}

#tip.show {
  opacity: 1;
}

#manual-hint {
  position: fixed;
  bottom: 42px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--amber);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  text-align: center;
}

#manual-hint.show {
  opacity: 1;
}

/* ── Parameters panel ────────────────────────────────────── */
#params {
  position: fixed;
  top: 88px;
  right: 40px;
  width: 284px;
  z-index: 15;
  background: linear-gradient(160deg, rgba(3, 14, 28, 0.82), rgba(1, 6, 14, 0.72));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--cyan-dim);
  padding: 12px 14px 14px;
  pointer-events: auto;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 180px;
  max-height: calc(100vh - 280px);
  scrollbar-width: thin;
  scrollbar-color: var(--cyan-dim) transparent;
  border-radius: 0;
  opacity: 1;
  transition: opacity 0.3s ease, visibility 0.3s;
}

#params.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#params::-webkit-scrollbar {
  width: 5px;
}
#params::-webkit-scrollbar-thumb {
  background: var(--cyan-dim);
}
#params::-webkit-scrollbar-track {
  background: transparent;
}

.params-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(127, 220, 255, 0.15);
}

.params-header h2 {
  font-size: 11px;
  letter-spacing: 0.28em;
  color: var(--cyan);
  font-weight: 600;
}

.params-header .btn-reset {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--amber);
  background: transparent;
  border: 1px solid rgba(255, 180, 84, 0.4);
  padding: 4px 10px;
  cursor: pointer;
  min-height: 28px;
}

.params-header .btn-reset:hover {
  background: rgba(255, 180, 84, 0.12);
  border-color: var(--amber);
}

.params-header .btn-reset:focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: 2px;
}

.param-row {
  margin-bottom: 10px;
}

.param-row label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 8.5px;
  letter-spacing: 0.1em;
  color: var(--cyan-dim);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.param-row .pval {
  color: var(--hl);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.param-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: rgba(127, 220, 255, 0.2);
  outline: none;
  border-radius: 0;
  cursor: pointer;
}

.param-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(127, 220, 255, 0.7);
  cursor: pointer;
  border: none;
}

.param-row input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(127, 220, 255, 0.7);
  cursor: pointer;
  border: none;
}

.param-row input[type="range"]:focus-visible {
  outline: 1px solid var(--cyan);
  outline-offset: 4px;
}

/* ── Intro ───────────────────────────────────────────────── */
#intro {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  pointer-events: auto;
  opacity: 1;
  transition: opacity 1.6s ease;
}

#intro.fade {
  opacity: 0;
  pointer-events: none;
}

#intro.gone {
  display: none;
}

.intro-card {
  text-align: center;
  animation: introCard 5.2s ease forwards;
}

body.reduce-motion .intro-card {
  animation: introCardStatic 5.2s ease forwards;
}

@keyframes introCard {
  0%   { opacity: 0; transform: scale(1.06); filter: blur(8px); }
  25%  { opacity: 1; transform: scale(1); filter: blur(0); }
  80%  { opacity: 1; transform: scale(1); filter: blur(0); }
  100% { opacity: 0; transform: scale(0.99); filter: blur(0); }
}

@keyframes introCardStatic {
  0%   { opacity: 0; }
  25%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { opacity: 0; }
}

.intro-tag {
  font-size: 10px;
  letter-spacing: 0.5em;
  color: rgba(127, 220, 255, 0.55);
  margin-bottom: 18px;
  text-indent: 0.5em;
}

.intro-title {
  font-size: clamp(44px, 9vw, 104px);
  font-weight: 700;
  letter-spacing: 0.36em;
  color: #fff;
  text-indent: 0.36em;
  margin-left: -0.18em;
  text-shadow:
    0 0 24px rgba(127, 220, 255, 0.55),
    0 0 64px rgba(127, 220, 255, 0.25);
  line-height: 1.1;
}

.intro-quote {
  margin-top: 22px;
  font-size: 12px;
  font-style: italic;
  letter-spacing: 0.22em;
  color: rgba(255, 180, 84, 0.75);
  text-indent: 0.22em;
}

/* Error overlay — must sit above intro (z20) and accept clicks */
#error-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.92);
  padding: 24px;
  pointer-events: auto;
}

#error-overlay.show {
  display: flex;
}

.error-card {
  max-width: 480px;
  border: 1px solid var(--cyan-dim);
  padding: 28px 24px;
  background: rgba(4, 12, 22, 0.95);
  text-align: center;
}

.error-card h2 {
  font-size: 14px;
  letter-spacing: 0.28em;
  color: var(--amber);
  margin-bottom: 14px;
}

.error-card p {
  font-size: 11px;
  line-height: 1.7;
  color: var(--cyan-dim);
  margin-bottom: 18px;
  word-break: break-word;
  white-space: pre-wrap;
  text-align: left;
}

.error-card .err-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  pointer-events: auto;
}

.error-card button {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--cyan);
  background: transparent;
  border: 1px solid var(--cyan-dim);
  padding: 10px 16px;
  cursor: pointer;
  min-height: 44px;
  min-width: 120px;
  pointer-events: auto;
  position: relative;
  z-index: 51;
}

.error-card button:hover {
  border-color: var(--cyan);
  background: rgba(127, 220, 255, 0.08);
}

/* Quality toast */
#toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--amber);
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(255, 180, 84, 0.4);
  padding: 12px 20px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
}

#toast.show {
  opacity: 1;
}

/* shot mode */
body.shot #intro,
body.shot #fx {
  display: none !important;
}

/* Responsive ≤720px */
@media (max-width: 720px) {
  .title-block {
    top: 22px;
    left: 28px;
  }
  .title-block h1 {
    font-size: 22px;
    letter-spacing: 0.28em;
  }
  .title-block .sub {
    font-size: 9px;
    letter-spacing: 0.18em;
  }
  .title-block .meta {
    font-size: 8px;
    letter-spacing: 0.14em;
    max-width: 55vw;
  }
  .clock-block {
    top: 24px;
    right: 28px;
  }
  .telemetry {
    bottom: 24px;
    left: 28px;
    font-size: 9px;
  }
  .telemetry .k {
    min-width: 140px;
  }
  .deck {
    width: 210px;
    right: 20px;
    bottom: 20px;
    padding: 10px;
  }
  .corner {
    width: 24px;
    height: 24px;
  }
  .corner.tl { top: 14px; left: 14px; }
  .corner.tr { top: 14px; right: 14px; }
  .corner.bl { bottom: 14px; left: 14px; }
  .corner.br { bottom: 14px; right: 14px; }
  #params {
    right: 16px;
    left: 16px;
    width: auto;
    top: 70px;
    max-height: 50vh;
  }
  #tip {
    display: none;
  }
}

@media (max-width: 900px) {
  #tip {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .corner {
    animation: none;
  }
  .intro-card {
    animation: introCardStatic 5.2s ease forwards;
  }
}
