/* ============================================================
   Protolabs Global — single-view shell
   Brushed-metal header + dark cosmic magazine body.
   Cyan accents only — no amber/gold anywhere.
   ============================================================ */

:root {
  --bg: #020617;
  --panel: #0b1120;
  --panel-border: #1e293b;
  --panel-border-hover: #334155;
  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, 0.15);
  --cyan-glow: rgba(34, 211, 238, 0.25);
  --text: #f8fafc;
  /* Was dim grey (#94a3b8 / #64748b) — brightened to near-white per
     request, so all small print/taglines pop against the dark backdrop
     instead of receding into it. */
  --text-dim: #f0f4f8;
  --text-faint: #f0f4f8;
  --radius: 14px;

  /* Default cover scene palette — overridden per-scene by script.js's
     COVER_SCENES / applyCoverScene(), never hand-edited per deploy. */
  --nebula-a: #22d3ee;
  --nebula-b: #6366f1;
  --nebula-c: #0ea5e9;

  --metal-light: #e4e6eb;
  --metal-mid: #b8bcc4;
  --metal-dark: #8b909c;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  overflow: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ---------- shell layout ---------- */

.shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  /* Metallic outer bezel framing the whole viewport, same brushed-metal
     language as the top nav. */
  border: 10px solid var(--metal-mid);
  border-image: linear-gradient(135deg, var(--metal-light), var(--metal-dark) 40%, var(--metal-light) 60%, var(--metal-dark)) 1;
  box-sizing: border-box;
}

/* ---------- top nav — brushed metal ---------- */

.topnav {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 24px;
  border-bottom: 1px solid #52525b;
  background:
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0px, rgba(255, 255, 255, 0.04) 1px, transparent 1px, transparent 3px),
    linear-gradient(180deg, var(--metal-light) 0%, var(--metal-mid) 45%, var(--metal-dark) 100%);
  color: #1e2430;
}

/* Decorative folded-corner detail, top-right of the header — matches the
   reference mockup's page-curl. Pure CSS triangle, no image asset. */
.page-curl {
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 34px 34px 0;
  border-color: transparent #f8fafc transparent transparent;
  filter: drop-shadow(-2px 2px 3px rgba(0, 0, 0, 0.25));
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Metallic gold emblem — same construction/gradient stops as the real
   Ai One app's own header logo (see index.html comment). Sized to the
   38px footprint the old .brand-mark SVG used, so nothing else in the
   header layout shifts. */
.logo-container {
  position: relative;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chrome-ring {
  position: absolute;
  inset: 0;
  z-index: 1;
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.45));
}

.gold-pyramid-icon {
  position: relative;
  z-index: 2;
  width: 21px;
  height: 21px;
  perspective: 220px;
  /* Warmer than the chrome ring's own white glow — this is the one
     place the gold treatment gets its own "crisp and glowing" halo
     instead of borrowing the ring's neutral one. */
  filter: drop-shadow(0px 0px 6px rgba(245, 213, 118, 0.55));
}

.gold-pyramid {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.gold-pyramid-face {
  display: block;
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  /* Same stops as the real app's .metallic-gold-text/.ptlg-face — the
     dark-gold -> amber -> bright -> champagne-highlight -> bright ->
     amber -> dark-gold symmetry is what reads as a reflective metallic
     sheen rather than a flat gold fill. */
  background: linear-gradient(
    135deg,
    #7a5c2e 0%,
    #caa43d 20%,
    #f5d576 40%,
    #fdf6e3 52%,
    #f5d576 64%,
    #caa43d 80%,
    #7a5c2e 100%
  );
  transform-origin: 50% 100%;
  backface-visibility: hidden;
}

.gold-pyramid-face:nth-child(1) { transform: rotateY(0deg) translateZ(5.7px) rotateX(24deg); }
.gold-pyramid-face:nth-child(2) { transform: rotateY(90deg) translateZ(5.7px) rotateX(24deg); }
.gold-pyramid-face:nth-child(3) { transform: rotateY(180deg) translateZ(5.7px) rotateX(24deg); }
.gold-pyramid-face:nth-child(4) { transform: rotateY(270deg) translateZ(5.7px) rotateX(24deg); }

.brand-word {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.15;
  color: #1e2430;
}

.brand-word span {
  color: #4a5568;
  font-weight: 600;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 1;
  justify-content: center;
}

.nav-link {
  background: none;
  border: none;
  color: #3f4652;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 6px 4px;
  transition: color 0.15s ease;
}

.nav-link:hover {
  color: #0f172a;
}

.view-controls {
  display: flex;
  gap: 4px;
  border: 1px solid rgba(30, 36, 48, 0.25);
  border-radius: 8px;
  padding: 2px;
}

.view-btn {
  background: none;
  border: none;
  color: #4a5568;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 12px;
  transition: background 0.15s ease, color 0.15s ease;
}

.view-btn:hover {
  background: rgba(30, 36, 48, 0.1);
  color: #0f172a;
}

.auth-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  appearance: none;
  background: none;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 16px;
  border-radius: 999px;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  border: 1px solid rgba(30, 36, 48, 0.3);
}

.btn-ghost {
  color: #1e2430;
}

.btn-ghost:hover {
  border-color: rgba(30, 36, 48, 0.6);
}

.btn-solid {
  background: #0f172a;
  color: #f8fafc;
  border-color: #0f172a;
  font-weight: 700;
}

.btn-solid:hover {
  opacity: 0.85;
}

/* ---------- main grid: canvas + radio panel ---------- */

.main-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  padding: 16px 24px;
  min-height: 0;
}

/* ---------- primary visual magazine canvas ---------- */

.canvas {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  min-height: 0;
}

/* Modular background layer — one element, swapped wholesale by
   applyCoverScene() in script.js. Everything text-related lives in
   .canvas-overlay instead, so a scene swap never touches the overlay. */
.cover-scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-color: #030a1a;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.starfield {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.star {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  /* Two independent animations: twinkle (opacity pulse, unchanged) plus
     drift — a slow parallax-style wander whose distance/duration are
     randomized per-star in script.js (--drift-x/--drift-y/--drift-dur)
     so stars don't all move in lockstep, giving real cinematic depth
     instead of a flat field of fixed, merely-blinking dots. */
  animation: twinkle linear infinite, drift linear infinite alternate;
  animation-duration: var(--twinkle-dur, 3s), var(--drift-dur, 18s);
  animation-delay: var(--twinkle-delay, 0s), 0s;
  will-change: transform, opacity;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 0.9; }
}

@keyframes drift {
  from { transform: translate(0, 0); }
  to { transform: translate(var(--drift-x, 12px), var(--drift-y, 8px)); }
}

/* Slow-drifting nebula blobs — procedural CSS, not a photo. Colors come
   from --nebula-a/b/c, set per-scene so this whole layer is swappable
   without touching markup. */
.nebula-layer {
  position: absolute;
  inset: -10%;
  pointer-events: none;
  background:
    radial-gradient(circle at 22% 28%, color-mix(in srgb, var(--nebula-a) 75%, transparent), transparent 45%),
    radial-gradient(circle at 78% 18%, color-mix(in srgb, var(--nebula-b) 65%, transparent), transparent 50%),
    radial-gradient(circle at 55% 70%, color-mix(in srgb, var(--nebula-c) 60%, transparent), transparent 55%);
  filter: blur(45px);
  opacity: 0.8;
  mix-blend-mode: screen;
  animation: nebula-drift 26s ease-in-out infinite alternate;
}

@keyframes nebula-drift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-3%, 2%) scale(1.06); }
}

.horizon-glow {
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: -30%;
  height: 55%;
  background: radial-gradient(ellipse at center, var(--cyan-glow), transparent 70%);
  filter: blur(30px);
  pointer-events: none;
  animation: horizon-pulse 6s ease-in-out infinite;
}

@keyframes horizon-pulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.04); }
}

/* Canvas particle/orbit layer — see heroStarCanvas() in script.js. Sits in
   the same stacking level as .cover-scene (z-index: 0) but after it in DOM
   order, so it paints on top of the background/starfield/glow while still
   staying behind .canvas-overlay's text (z-index: 1). */
#hero-star-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.canvas-overlay {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  /* Text sits in the top half, over the real photo's dark sky region. */
  justify-content: flex-start;
  padding: 48px 36px 32px;
}

/* Subtle, localized wash behind the text column only — fades out well
   before the right edge, so most of the image stays completely
   untouched. Not a full-canvas scrim. */
.canvas-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  max-width: 640px;
  background: linear-gradient(90deg, rgba(2, 6, 23, 0.55) 0%, rgba(2, 6, 23, 0.3) 55%, transparent 100%);
}

.edition-tag {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--cyan);
  margin: 0 0 24px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.95), 0 4px 16px rgba(0, 0, 0, 0.7);
}

.coverline-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.cover-hero {
  margin-bottom: 22px;
}

.cover-hero-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0 4px 16px;
  border-left: 3px solid transparent;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.cover-hero-link:hover {
  border-left-color: var(--cyan);
  transform: translateX(4px);
}

.coverline a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0;
  border-left: 3px solid transparent;
  padding-left: 16px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.coverline a:hover {
  border-left-color: var(--cyan);
  transform: translateX(4px);
}

.coverline-title {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", sans-serif;
  font-size: clamp(32px, 5vw, 58px);
  font-weight: 300;
  letter-spacing: 0.005em;
  line-height: 1.05;
  color: var(--text);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.95), 0 6px 24px rgba(0, 0, 0, 0.75);
}

.coverline-sub {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-dim);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.95), 0 3px 12px rgba(0, 0, 0, 0.8);
}

/* ---------- daily history (renders as this coverline's own hero content) ---------- */
/* No panel/box background here on purpose — this sits directly on the
   cover photo the same way STAR TRACKER's own title/sub do, not inside a
   card. Icon controls float beside the text rather than a boxed layout. */

.daily-history {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.daily-history-text {
  flex: 1 1 320px;
  min-width: 0;
}

.daily-history-headline {
  margin: 0 0 8px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", sans-serif;
  font-size: clamp(28px, 4.4vw, 50px);
  font-weight: 300;
  letter-spacing: 0.005em;
  line-height: 1.08;
  color: var(--text);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.95), 0 6px 24px rgba(0, 0, 0, 0.75);
}

.daily-history-blurb {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--text-dim);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.95), 0 3px 12px rgba(0, 0, 0, 0.8);
}

.daily-history-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.daily-history-play {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--cyan);
  background: var(--cyan-soft);
  color: var(--cyan);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.daily-history-headphone {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.55), 0 6px 16px rgba(0, 0, 0, 0.4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: box-shadow 0.2s ease;
}

.daily-history-headphone.playing {
  animation: headphone-pulse 1.4s ease-in-out infinite;
}

/* Disabled while fetchHistoryDailyFeed() hasn't resolved a real episode
   audio URL yet — see renderDailyHistoryCard() in script.js. */
.daily-history-play:disabled,
.daily-history-headphone:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@keyframes headphone-pulse {
  0%, 100% { box-shadow: 0 0 24px rgba(56, 189, 248, 0.55), 0 6px 16px rgba(0, 0, 0, 0.4); }
  50% { box-shadow: 0 0 40px rgba(56, 189, 248, 0.9), 0 6px 16px rgba(0, 0, 0, 0.4); }
}

/* ---------- radio central side panel ---------- */

.radio-panel {
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  background: var(--panel);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

/* Brief highlight when a coverline click jumps focus here — makes the
   scroll read as a real activation, not just a page shift. */
.radio-panel.panel-pulse {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan), 0 0 40px rgba(34, 211, 238, 0.35);
}

.radio-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.radio-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.radio-title {
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--text-dim);
}

.radio-live {
  margin-left: auto;
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--cyan);
  border: 1px solid var(--cyan);
  border-radius: 999px;
  padding: 2px 8px;
}

.radio-station-name {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 4px;
}

.radio-station-sub {
  font-size: 10px;
  color: var(--text-faint);
  margin: 0;
}

.radio-spectrum {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 50px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.3);
}

.spectrum-bar {
  flex: 1;
  height: 100%;
  background: var(--cyan);
  opacity: 0.6;
  border-radius: 2px;
  transform-origin: bottom;
  animation: bounce 1.2s ease-in-out infinite;
}

/* transform, not a % height — percentage heights on a flex item's cross
   axis don't reliably resolve against the container here (Safari/Chrome
   both collapsed these to 0px in testing); scaleY sidesteps that. */
@keyframes bounce {
  0%, 100% { transform: scaleY(0.15); }
  50% { transform: scaleY(0.8); }
}

/* Shared "something's playing" cue — toggled by setDailyHistoryPlaying,
   same bars, just brighter/faster while any real (or, honestly, visual-
   only demo) playback state is active. */
.spectrum-bar.boosted {
  opacity: 1;
  animation-duration: 0.5s;
}

.radio-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.radio-play {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--cyan);
  background: var(--cyan-soft);
  color: var(--cyan);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.radio-volume {
  flex: 1;
  accent-color: var(--cyan);
}

.channel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--panel-border);
  padding-top: 12px;
}

.channel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
}

.channel-row-placeholder {
  opacity: 0.5;
}

.channel-tag {
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--cyan);
}

.radio-expand {
  margin-top: auto;
  background: none;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 10px;
  font-size: 11px;
  letter-spacing: 0.05em;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.radio-expand:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

/* ---------- footer metadata bar ---------- */

.footer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  border-top: 1px solid var(--panel-border);
  font-size: 10px;
  color: var(--text-faint);
  background: rgba(2, 6, 23, 0.85);
}

.footer-domain {
  color: var(--text-dim);
}

.footer-bar a:hover {
  color: var(--cyan);
}

.footer-sep {
  opacity: 0.4;
}

.footer-social {
  margin-left: auto;
  display: flex;
  gap: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---------- demo overlay ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.overlay.open {
  display: flex;
}

/* Dark glassmorphism card — translucent + blurred, with a faint metallic
   edge highlight echoing the header/bezel language rather than a flat
   panel color. */
.overlay-card {
  position: relative;
  width: min(440px, 90vw);
  background: linear-gradient(160deg, rgba(20, 28, 46, 0.65), rgba(8, 13, 24, 0.75));
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border: 1px solid rgba(228, 230, 235, 0.18);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 0 60px rgba(34, 211, 238, 0.12), 0 20px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.overlay-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 14px;
}

.overlay-close:hover {
  color: var(--text);
}

.overlay-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--cyan);
  border: 1px solid rgba(34, 211, 238, 0.5);
  background: var(--cyan-soft);
  border-radius: 999px;
  padding: 4px 10px;
  margin: 0 0 14px;
}

.overlay-card h2 {
  font-size: 19px;
  margin: 0 0 10px;
}

.overlay-card p {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
  margin: 0;
}

.overlay-cta {
  display: block;
  text-align: center;
  margin-top: 18px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: opacity 0.15s ease;
}

.overlay-cta:hover {
  opacity: 0.85;
}

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

@media (max-width: 860px) {
  body {
    overflow-y: auto;
  }

  .shell {
    height: auto;
    min-height: 100vh;
  }

  .main-grid {
    grid-template-columns: 1fr;
  }

  .nav-links {
    display: none;
  }

  .footer-bar {
    flex-wrap: wrap;
  }
}
