@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Space+Mono:wght@400;700&display=swap');

:root {
  color-scheme: dark;
  --bg: #03040a;
  --ink: #dde4f0;
  --muted: #5a6880;
  --muted-bright: #8898b8;
  --line: rgba(100, 140, 220, 0.12);
  --line-bright: rgba(100, 140, 220, 0.2);
  --panel: rgba(5, 8, 20, 0.78);
  --accent: #4fc3f7;
  --accent-2: #b57bee;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', ui-sans-serif, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }

.stage {
  position: relative;
  min-height: 100vh;
}

.stage::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 82% 82% at 50% 50%, transparent 30%, rgba(3,4,10,0.72) 100%);
  pointer-events: none;
  z-index: 1;
}

#quake-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

/* ── Control panel ── */
.control-panel {
  position: absolute;
  z-index: 10;
  left: 50%;
  transform: translateX(-50%);
  bottom: clamp(1.2rem, 3vw, 2rem);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.45rem;
  border-radius: 12px;
  border: 1px solid var(--line-bright);
  background: var(--panel);
  backdrop-filter: blur(32px);
  box-shadow:
    0 0 0 1px rgba(79, 195, 247, 0.04),
    0 24px 64px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  white-space: nowrap;
}

.panel-divider {
  width: 1px;
  height: 1.6rem;
  background: var(--line-bright);
  flex-shrink: 0;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2rem;
  padding: 0 0.9rem;
  border: 1px solid rgba(79, 195, 247, 0.3);
  border-radius: 7px;
  background: rgba(79, 195, 247, 0.08);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.primary-button:hover {
  background: rgba(79, 195, 247, 0.16);
  border-color: rgba(79, 195, 247, 0.55);
  box-shadow: 0 0 14px rgba(79, 195, 247, 0.18);
  transform: translateY(-1px);
}

.primary-button.is-playing {
  background: rgba(79, 195, 247, 0.15);
  border-color: var(--accent);
}



.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.control-label {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
}

select {
  min-height: 1.55rem;
  padding: 0 0.45rem;
  border: 1px solid var(--line-bright);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  font-size: 0.74rem;
  cursor: pointer;
  max-width: 9.5rem;
}

select:focus { outline: none; border-color: rgba(79, 195, 247, 0.45); }

input[type="range"] {
  width: 6.5rem;
  accent-color: var(--accent-2);
  cursor: pointer;
}

.status-pill {
  font-size: 0.68rem;
  font-family: 'Space Mono', monospace;
  color: var(--muted);
  padding: 0 0.2rem;
}

/* ── Quake readout ── */
.quake-readout {
  position: absolute;
  z-index: 10;
  left: clamp(1.4rem, 3vw, 2.4rem);
  bottom: clamp(5.5rem, 9vw, 7rem);
  width: min(32rem, calc(100vw - 2.8rem));
  transition: opacity 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  opacity: 1;
  transform: translateY(0);
}

.quake-readout.is-empty { display: none; }

.quake-readout h2 {
  margin: 0 0 0.35rem;
  font-size: clamp(1rem, 1.8vw, 1.4rem);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: var(--ink);
}

.quake-meta {
  margin: 0;
  font-family: 'Space Mono', monospace;
  font-size: 0.72rem;
  color: var(--muted-bright);
  line-height: 1.6;
}

.mag-bar {
  margin-top: 0.55rem;
  height: 1.5px;
  border-radius: 999px;
  transform-origin: left;
  animation: mag-expand 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes mag-expand {
  from { transform: scaleX(0); opacity: 0; }
  to   { transform: scaleX(1); opacity: 1; }
}

.fullscreen-button, #settings-toggle-button, #play-button {
  width: 2rem;
  padding: 0;
  font-size: 0.95rem;
  justify-content: center;
}

.fullscreen-button.is-active, #settings-toggle-button.is-active {
  background: rgba(79, 195, 247, 0.2);
  border-color: var(--accent);
}

.text-toggle-button {
  width: 2rem;
  padding: 0;
  font-size: 0.95rem;
  justify-content: center;
}

.text-toggle-button.is-active {
  background: rgba(79, 195, 247, 0.2);
  border-color: var(--accent);
  color: var(--accent);
}

.quake-readout.info-hidden {
  display: none !important;
}

.ui-hotzone {
  display: none;
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 20vh;
  z-index: 9;
}

body.fullscreen-active .ui-hotzone {
  display: block;
}

body.fullscreen-active .control-panel {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 24px);
  transition: opacity 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

body.fullscreen-active:has(.ui-hotzone:hover, .control-panel:hover, .quake-readout:hover) .control-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── Cosmic Panel ── */
.cosmic-panel {
  position: absolute;
  top: clamp(1.2rem, 3vw, 2rem);
  right: clamp(1.4rem, 3vw, 2.4rem);
  width: min(20rem, calc(100vw - 2.8rem));
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line-bright);
  background: var(--panel);
  backdrop-filter: blur(24px);
  box-shadow:
    0 0 0 1px rgba(79, 195, 247, 0.04),
    0 12px 32px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: opacity 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.cosmic-panel[hidden] {
  display: none !important;
}

.cosmic-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cosmic-icon {
  font-size: 1.15rem;
  color: var(--accent);
  text-shadow: 0 0 8px rgba(79, 195, 247, 0.4);
  width: 1.5rem;
  text-align: center;
}

.cosmic-info {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  flex-grow: 1;
}

.cosmic-label {
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
}

.cosmic-value {
  font-family: 'Space Mono', monospace;
  font-size: 0.76rem;
  color: var(--ink);
}

.cosmic-badge {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  background: rgba(79, 195, 247, 0.15);
  border: 1px solid rgba(79, 195, 247, 0.3);
  color: var(--accent);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.cosmic-badge.storm {
  background: rgba(244, 104, 92, 0.15);
  border-color: rgba(244, 104, 92, 0.4);
  color: #f4685c;
  text-shadow: 0 0 6px rgba(244, 104, 92, 0.3);
}

.cosmic-divider {
  height: 1px;
  background: var(--line);
}

.cosmic-tide-bar {
  width: 4rem;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
}

.cosmic-tide-fill {
  height: 100%;
  width: 50%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 99px;
  transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

body.fullscreen-active .cosmic-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-12px);
}

body.fullscreen-active:has(.ui-hotzone:hover, .control-panel:hover, .quake-readout:hover) .cosmic-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* ── Settings Side-Drawer ── */
.settings-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: min(23rem, 100vw);
  height: 100vh;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: rgba(5, 8, 20, 0.9);
  border-right: 1px solid var(--line-bright);
  backdrop-filter: blur(36px);
  box-shadow: 10px 0 40px rgba(0, 0, 0, 0.8);
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  transform: translateX(0);
}

.settings-drawer[hidden] {
  transform: translateX(-100%);
  display: flex !important; /* Force layout so transitions work cleanly */
  pointer-events: none;
}

.settings-drawer #observer-location {
  max-width: none;
  width: 100%;
  height: 2.2rem;
  border-radius: 7px;
  background: rgba(5, 8, 20, 0.4);
  border: 1px solid var(--line-bright);
  color: var(--ink);
  margin-top: 0.25rem;
  outline: none;
}

.settings-drawer #observer-location:focus {
  border-color: rgba(79, 195, 247, 0.5);
}

/* ── Tabs Navigation ── */
.drawer-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  padding: 0 1.5rem;
  gap: 0.5rem;
}

.tab-button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted-bright);
  padding: 0.65rem 0.5rem;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  outline: none;
}

.tab-button:hover {
  color: var(--ink);
}

.tab-button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-shadow: 0 0 8px rgba(79, 195, 247, 0.3);
}

/* ── Tab Content ── */
.tab-content {
  display: none !important;
}

.tab-content.active {
  display: block !important;
}

/* ── Earthquake History List ── */
.event-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.55rem;
}

.event-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
  outline: none;
}

.event-item:hover {
  background: rgba(79, 195, 247, 0.06);
  border-color: rgba(79, 195, 247, 0.3);
  box-shadow: 0 0 10px rgba(79, 195, 247, 0.08);
  transform: translateY(-1px);
}

.event-item.is-active {
  background: rgba(79, 195, 247, 0.1);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(79, 195, 247, 0.15);
}

.event-mag {
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  margin-right: 0.85rem;
  min-width: 2rem;
}

.event-place {
  display: block;
  font-size: 0.74rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 13rem;
}

.event-meta {
  display: block;
  font-family: 'Space Mono', monospace;
  font-size: 0.62rem;
  color: var(--muted-bright);
  margin-top: 0.15rem;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--line-bright);
}

.drawer-header h3 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(79, 195, 247, 0.35);
}

.test-sound-btn {
  height: 1.85rem;
  padding: 0 0.85rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  border-radius: 6px;
  background: rgba(79, 195, 247, 0.1);
  border: 1px solid rgba(79, 195, 247, 0.4);
  color: var(--accent);
  box-shadow: 0 0 10px rgba(79, 195, 247, 0.15);
  transition: all 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.test-sound-btn:hover {
  background: rgba(79, 195, 247, 0.22);
  border-color: var(--accent);
  color: var(--ink);
  box-shadow: 0 0 14px rgba(79, 195, 247, 0.35);
}

.close-drawer {
  background: none;
  border: none;
  color: var(--muted-bright);
  font-size: 1.6rem;
  font-weight: 300;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.15s ease;
}

.close-drawer:hover {
  color: var(--ink);
}

.drawer-body {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Custom Scrollbar for Drawer */
.drawer-body::-webkit-scrollbar {
  width: 4px;
}
.drawer-body::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.1);
}
.drawer-body::-webkit-scrollbar-thumb {
  background: var(--line-bright);
  border-radius: 99px;
}

.designer-section {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.preset-row, .save-row {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.preset-row select {
  flex-grow: 1;
  max-width: none;
  height: 2.2rem;
}

.save-row input {
  flex-grow: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line-bright);
  border-radius: 7px;
  padding: 0 0.75rem;
  color: var(--ink);
  font-size: 0.8rem;
}
.save-row input:focus {
  outline: none;
  border-color: rgba(79, 195, 247, 0.5);
}

.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid rgba(244, 104, 92, 0.3);
  border-radius: 7px;
  background: rgba(244, 104, 92, 0.08);
  color: #f4685c;
  cursor: pointer;
  transition: all 0.15s ease;
}

.danger-button:hover:not(:disabled) {
  background: rgba(244, 104, 92, 0.18);
  border-color: rgba(244, 104, 92, 0.6);
  box-shadow: 0 0 10px rgba(244, 104, 92, 0.2);
}

.danger-button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  border-color: var(--line);
  color: var(--muted);
}

.designer-divider {
  height: 1px;
  background: var(--line);
  margin: 0.25rem 0;
}

.designer-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.designer-group h4 {
  margin: 0 0 0.15rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--muted-bright);
  text-transform: uppercase;
}

.designer-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  font-size: 0.76rem;
}

.designer-item.flex-col {
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
}

.designer-item label {
  color: var(--ink);
  font-weight: 400;
}

.designer-item select {
  height: 1.85rem;
  max-width: 9rem;
}

.label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
}

.label-row span {
  font-family: 'Space Mono', monospace;
  color: var(--accent);
}

.slider-styled {
  width: 100% !important;
  accent-color: var(--accent);
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 99px;
  outline: none;
}

/* ── Mixer Deck and Faders ── */
.mixer-deck {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: clamp(4.4rem, 6.8vw, 5.2rem);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--line-bright);
  background: var(--panel);
  backdrop-filter: blur(32px);
  box-shadow:
    0 0 0 1px rgba(79, 195, 247, 0.04),
    0 20px 48px rgba(0, 0, 0, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  z-index: 10;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.mixer-fader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  width: 4.8rem;
}

.fader-label {
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-bright);
}

.fader-styled {
  width: 100% !important;
  accent-color: var(--accent);
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 99px;
  outline: none;
  cursor: pointer;
}

.fader-styled::-webkit-slider-runnable-track {
  height: 3px;
}

.fader-val {
  font-family: 'Space Mono', monospace;
  font-size: 0.58rem;
  color: var(--accent);
}

body.fullscreen-active .mixer-deck {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 24px);
}

body.fullscreen-active:has(.ui-hotzone:hover, .control-panel:hover, .mixer-deck:hover, .quake-readout:hover) .mixer-deck {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

/* Adjust Readout Position slightly higher due to Mixer Deck */
.quake-readout {
  bottom: clamp(7.4rem, 11vw, 9rem) !important;
}

/* Tides Ocean Swell bar adjustments */
.cosmic-tide-bar {
  width: 3.5rem !important;
  background: rgba(255,255,255,0.06) !important;
}

.cosmic-tide-fill {
  background: linear-gradient(90deg, var(--accent), #5c6bc0) !important;
}

/* ──────────────────────────────────────────────
   TEMP DEV HUD — placeholder visualization of the
   7 audio layers' live state. Final design TBD.
   ────────────────────────────────────────────── */
/* ── Telemetry tab content ── */
#dev-hud {
  font-family: 'Space Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  line-height: 1.45;
}

.telemetry-header {
  margin-bottom: 0.75rem;
}

.telemetry-header h3 {
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  font-weight: 700;
  color: var(--accent);
}

.telemetry-header h3 .hud-pulse {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 0.45rem;
  box-shadow: 0 0 8px var(--accent);
  animation: hud-pulse 2.4s ease-in-out infinite;
}

@keyframes hud-pulse {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 1; }
}

.hud-layer {
  margin-bottom: 0.55rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.hud-layer:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.hud-layer h4 {
  margin: 0 0 0.25rem;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--muted-bright);
  text-transform: uppercase;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.7rem;
}

.hud-row > :first-child {
  color: var(--muted);
}

.hud-row > :last-child {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.hud-bar {
  margin-top: 0.3rem;
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 99px;
  overflow: hidden;
}

.hud-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #5c6bc0);
  transition: width 1.2s ease-out;
}

.session-log-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.log-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.72rem;
  line-height: 1.4;
}

.log-time {
  font-family: 'Space Mono', monospace;
  color: var(--muted-bright);
  font-size: 0.64rem;
  white-space: nowrap;
  margin-top: 0.05rem;
}

.log-badge {
  font-family: 'Space Mono', monospace;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* Badge specific styling */
.log-system .log-badge { background: rgba(255, 255, 255, 0.06); color: var(--ink); border: 1px solid rgba(255, 255, 255, 0.12); }
.log-location .log-badge { background: rgba(79, 195, 247, 0.08); color: var(--accent); border: 1px solid rgba(79, 195, 247, 0.2); }
.log-quake .log-badge { background: rgba(255, 179, 71, 0.08); color: #ffb347; border: 1px solid rgba(255, 179, 71, 0.2); }
.log-quake-severe .log-badge { background: rgba(244, 104, 92, 0.08); color: #f4685c; border: 1px solid rgba(244, 104, 92, 0.2); }
.log-asteroid .log-badge { background: rgba(181, 123, 238, 0.08); color: var(--accent-2); border: 1px solid rgba(181, 123, 238, 0.2); }
.log-telemetry .log-badge { background: rgba(79, 195, 247, 0.04); color: var(--muted-bright); border: 1px solid var(--line); }

.log-message {
  color: var(--ink);
  word-break: break-word;
}

/* Fullscreen rules for Quake Readout */
body.fullscreen-active .quake-readout {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
}

body.fullscreen-active:has(.ui-hotzone:hover, .control-panel:hover, .mixer-deck:hover, .quake-readout:hover) .quake-readout {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
