:root {
  --bg: #0a0a0a;
  --fg: #ffffff;
  --fg-dim: #8a8a8a;
  --fg-mute: #4a4a4a;
  --stroke: #2a2a2a;
  --accent: #A8A6F7; /* lavender, discrete signature */
  --wheel-height: 62vh;
  --wheel-transition: 260ms cubic-bezier(0.4, 0.0, 0.2, 1);
  --font-display: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

@media (max-width: 640px) {
  :root { --wheel-height: 50vh; }
}

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

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-display);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

body.collapsed {
  --wheel-height: 60px;
}

/* ---- WHEEL ZONE ---- */
.wheel-zone {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--wheel-height);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: height var(--wheel-transition);
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  padding: 20px;
  cursor: default;
}

body.collapsed .wheel-zone {
  cursor: pointer;
  padding: 10px;
}

.wheel-container {
  position: relative;
  width: min(60vh, 90vw);
  aspect-ratio: 1;
  max-width: 520px;
  transition: transform var(--wheel-transition), width var(--wheel-transition);
}

body.collapsed .wheel-container {
  width: 44px;
  max-width: 44px;
  height: 44px;
}

.wheel-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  display: block;
}

.wheel-ring {
  fill: none;
  stroke: var(--stroke);
  stroke-width: 0.4;
}

.wheel-ring-outer {
  fill: none;
  stroke: var(--stroke);
  stroke-width: 0.3;
}

.wheel-indicator {
  fill: none;
  stroke: var(--accent);
  stroke-width: 0.5;
  opacity: 0.7;
}

body.collapsed .wheel-indicator { opacity: 0; }

/* wheel-rotator and ribbon are animated via requestAnimationFrame (SVG attribute
   transforms don't participate in CSS transitions reliably, and we need per-frame
   counter-rotation of icons to keep them upright while the group rotates) */

.icon-group {
  cursor: pointer;
  transition: opacity 200ms ease;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

/* Remove the mobile tap-highlight rectangle everywhere it could appear on
   interactive elements (icons, buttons, links, cards). */
.icon-group,
.icon-group *,
button,
a,
.item-card,
.wheel-zone,
.sound-toggle {
  -webkit-tap-highlight-color: transparent;
}

/* Show a focus ring only for keyboard users (not on touch/mouse), so tapping
   an icon on a phone doesn't leave a square outline behind. */
.icon-group:focus:not(:focus-visible) {
  outline: none;
}

.icon-group:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 50%;
}

.icon-group circle.icon-bg {
  fill: none;
  stroke: var(--fg);
  stroke-width: 0.4;
  transition: stroke 200ms ease, fill 200ms ease;
  pointer-events: none;
}

/* Invisible full-disc hit area so the whole inside of the ring is clickable,
   not just the white strokes of the glyph. */
.icon-group circle.icon-hit {
  fill: transparent;
  stroke: none;
}

.icon-group:hover circle.icon-bg,
.icon-group.selected circle.icon-bg {
  stroke: var(--accent);
}

.icon-shape {
  fill: none;
  stroke: var(--fg);
  stroke-width: 0.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 200ms ease;
}

.icon-group:hover .icon-shape,
.icon-group.selected .icon-shape {
  stroke: var(--accent);
}

/* Vectorized glyph icons (traced from hand-drawn artwork) — filled shapes
   rather than stroked lines, so they use fill transitions instead. */
.icon-glyph {
  fill: var(--fg);
  transition: fill 200ms ease;
  pointer-events: none;
}

.icon-group:hover .icon-glyph,
.icon-group.selected .icon-glyph {
  fill: var(--accent);
}

body.collapsed .icon-group,
body.collapsed .wheel-ring,
body.collapsed .wheel-ring-outer {
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.wheel-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: transform var(--wheel-transition);
}

/* Logo image inside circle C. The inner circle has r=45 in a 200-unit viewBox.
   The logo is already a clean circular disc, so we size it to sit just inside
   circle C: diameter ≈ 2*45/200 = 45% of the container width. */
.logo-img {
  display: block;
  width: 45%;
  height: auto;
  object-fit: contain;
  border-radius: 50%;
}

.logo-img-mini {
  display: none;
}

/* Collapsed state: swap to the miniature logo, sized to fit the small button */
body.collapsed .logo-img-full {
  display: none;
}

body.collapsed .logo-img-mini {
  display: block;
  width: 34px;
  height: auto;
  border-radius: 50%;
  transition: transform 180ms ease;
}

/* Hover feedback on the collapsed logo button: a subtle grow to signal it's clickable.
   pointer-events must be enabled here because .wheel-center is otherwise click-through. */
body.collapsed .wheel-center {
  pointer-events: auto;
}

body.collapsed .wheel-zone:hover .logo-img-mini {
  transform: scale(1.12);
}

/* ---- RIBBON ---- */
.ribbon-viewport {
  position: fixed;
  top: var(--wheel-height);
  left: 0; right: 0; bottom: 0;
  overflow: hidden;
  transition: top var(--wheel-transition);
}

.ribbon {
  display: flex;
  flex-direction: row;
  height: 100%;
  /* width is set dynamically by JS after tripling the panels (21 × 100vw) */
}

.section-panel {
  width: 100vw;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 30px min(6vw, 60px) 80px;
  scroll-behavior: smooth;
}

.section-panel::-webkit-scrollbar { width: 6px; }
.section-panel::-webkit-scrollbar-track { background: transparent; }
.section-panel::-webkit-scrollbar-thumb { background: var(--fg-mute); border-radius: 3px; }

.section-panel h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(22px, 3vw, 32px);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.section-panel .section-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--fg-mute);
  text-transform: uppercase;
  margin-bottom: 40px;
}

/* Subnav / filters */
.subnav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 30px;
}

.subnav button {
  background: transparent;
  color: var(--fg-dim);
  border: 1px solid var(--stroke);
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 200ms ease;
}

.subnav button:hover {
  color: var(--fg);
  border-color: var(--fg-dim);
}

.subnav button.active {
  color: var(--accent);
  border-color: var(--accent);
}

/* Item grid */
.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

/* When a grid holds only the empty state, drop the grid layout so the
   "Coming soon" block centers exactly like the Video Games section. */
.item-grid.is-empty {
  display: block;
}

.item-card {
  border: 1px solid var(--stroke);
  padding: 24px;
  cursor: pointer;
  transition: border-color 200ms ease, transform 200ms ease;
}

.item-card:hover {
  border-color: var(--fg-dim);
  transform: translateY(-2px);
}

.item-card h3 {
  font-weight: 500;
  font-size: 16px;
  margin-bottom: 6px;
}

.item-card .card-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-mute);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.item-card .tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  text-transform: uppercase;
  padding: 2px 6px;
  border: 1px solid var(--stroke);
}

/* Video cards (Audio Post-Production): YouTube thumbnail on top, info below */
.item-card.video-card {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.item-card.video-card .video-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}

/* Play badge: a translucent circle with a triangle, centered on the thumbnail */
.item-card.video-card .video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 300ms ease;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.item-card.video-card:hover .video-thumb img {
  transform: scale(1.04);
}

.item-card.video-card .play-badge {
  position: absolute;
  top: 50%; left: 50%;
  width: 46px; height: 46px;
  transform: translate(-50%, -50%) translateZ(0);
  border-radius: 50%;
  background: rgba(10, 10, 10, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.6);
  transition: background 200ms ease, border-color 200ms ease;
  backface-visibility: hidden;
  /* Own compositing layer so it doesn't repaint/flicker while the thumbnail
     behind it scales on hover. */
  will-change: background, border-color;
}

.item-card.video-card .play-badge::after {
  content: "";
  position: absolute;
  top: 50%; left: 54%;
  transform: translate(-50%, -50%);
  border-style: solid;
  border-width: 8px 0 8px 13px;
  border-color: transparent transparent transparent #ffffff;
}

.item-card.video-card:hover .play-badge {
  background: rgba(168, 166, 247, 0.35);
  border-color: var(--accent);
}

.item-card.video-card .video-card-info {
  padding: 16px 18px 20px;
}

.item-card.video-card .video-card-info .card-meta {
  margin-bottom: 8px;
}

.item-card.video-card .video-card-info h3 {
  margin-bottom: 0;
}

.item-card.image-card {
  padding: 0;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  position: relative;
}

/* Staggered fade-in: each card appears just after the previous one, fast.
   The delay is driven by --i (the card's index), capped via a modulo-like
   wrap in JS-free CSS by keeping the multiplier small so 79 cards still finish
   quickly (~18ms apart → last card ≈ 1.4s, but perceived as a rapid cascade). */
@keyframes cardStaggerIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.item-card.image-card.stagger-in {
  opacity: 0;
  animation: cardStaggerIn 260ms ease both;
  animation-delay: calc(var(--i, 0) * 18ms);
}

/* Respect users who prefer reduced motion: show everything at once. */
@media (prefers-reduced-motion: reduce) {
  .item-card.image-card.stagger-in {
    opacity: 1;
    animation: none;
  }
}

.item-card.image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 300ms ease;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.item-card.image-card:hover img {
  transform: scale(1.03);
}

.item-card.image-card .image-card-label {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 14px;
  background: linear-gradient(0deg, rgba(0,0,0,0.8), transparent);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  /* Own layer so the gradient banner doesn't flicker while the image scales. */
  transform: translateZ(0);
  backface-visibility: hidden;
}

.item-card.image-card .image-card-title {
  color: var(--fg);
}

.item-card.image-card .image-card-label .tag {
  border-color: rgba(255,255,255,0.35);
  color: var(--fg-dim);
  background: rgba(0,0,0,0.4);
}

/* Empty state (Video Games) */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 40vh;
  text-align: center;
}

.empty-state .glyph {
  font-family: var(--font-mono);
  font-size: 40px;
  color: var(--fg-mute);
  letter-spacing: 0.4em;
  margin-bottom: 20px;
}

.empty-state p {
  color: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* Laboratory articles */
.article-list { display: flex; flex-direction: column; gap: 0; }

.article {
  padding: 26px 0;
  border-bottom: 1px solid var(--stroke);
  cursor: pointer;
  transition: padding-left 200ms ease;
}

.article:hover { padding-left: 8px; }

.article .article-date {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--fg-mute);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.article h3 {
  font-weight: 500;
  font-size: 18px;
  margin-bottom: 6px;
}

.article .article-excerpt {
  color: var(--fg-dim);
  font-size: 14px;
  line-height: 1.6;
  max-width: 65ch;
}

/* Contact section */
.contact-intro {
  max-width: 60ch;
  margin-bottom: 40px;
}

.contact-intro p {
  color: var(--fg);
  font-size: 15px;
  line-height: 1.7;
}

.networks {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 60px;
  padding-bottom: 60px;
  border-bottom: 1px solid var(--stroke);
}

.networks a {
  color: var(--fg-dim);
  text-decoration: none;
  border-bottom: 1px solid var(--stroke);
  padding-bottom: 2px;
  transition: color 200ms ease, border-color 200ms ease;
}

.networks a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 600px;
}

.contact-form label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--fg-mute);
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.contact-form input,
.contact-form textarea {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--stroke);
  color: var(--fg);
  padding: 8px 0;
  font-family: var(--font-display);
  font-size: 14px;
  width: 100%;
  outline: none;
  transition: border-color 200ms ease;
}

.contact-form input:focus,
.contact-form textarea:focus {
  border-color: var(--accent);
}

.contact-form textarea {
  resize: vertical;
  min-height: 100px;
}

.contact-form button {
  background: transparent;
  border: 1px solid var(--fg);
  color: var(--fg);
  padding: 12px 24px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  align-self: flex-start;
  margin-top: 10px;
  transition: all 200ms ease;
}

.contact-form button:hover {
  background: var(--fg);
  color: var(--bg);
}

.contact-form button:disabled {
  opacity: 0.5;
  cursor: default;
}

.contact-form button:disabled:hover {
  background: transparent;
  color: var(--fg);
}

.form-status {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.05em;
  margin-top: 14px;
  min-height: 1.2em;
}

.form-status.success {
  color: #7fd0a3;
}

.form-status.error {
  color: #e88b8b;
}

/* Sound controls (bottom-right) */
.sound-controls {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 20;
  display: flex;
  gap: 6px;
}

.sound-toggle {
  background: transparent;
  border: 1px solid var(--stroke);
  color: var(--fg-dim);
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 200ms ease;
  display: inline-flex;
  align-items: center;
}

.sound-toggle:hover {
  color: var(--fg);
  border-color: var(--fg-dim);
}

/* =============================================================================
   MODAL SYSTEM
   ============================================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.86);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--bg);
  border: 1px solid var(--stroke);
  max-width: 720px;
  width: 100%;
  max-height: 86vh;
  overflow-y: auto;
  position: relative;
  padding: 40px;
}

@media (max-width: 640px) {
  .modal-box { padding: 24px; max-height: 90vh; }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--stroke);
  color: var(--fg-dim);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 200ms ease;
}

.modal-close:hover {
  color: var(--fg);
  border-color: var(--fg);
}

.modal-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--fg-mute);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.modal-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(18px, 2.4vw, 24px);
  letter-spacing: 0.02em;
  margin-bottom: 24px;
  padding-right: 30px;
}

.modal-media {
  width: 100%;
  margin-bottom: 20px;
}

.modal-media iframe {
  width: 100%;
  border: none;
  display: block;
}

.modal-media.youtube iframe { aspect-ratio: 16 / 9; height: auto; }
.modal-media.spotify iframe { height: 152px; }
.modal-media.soundcloud iframe { height: 166px; }

/* Fallback shown when the embedded player can't run (file:// with no referer):
   a clickable 16:9 block that opens the video on YouTube. */
.modal-media.youtube .yt-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  aspect-ratio: 16 / 9;
  width: 100%;
  background: #000;
  border: 1px solid var(--stroke);
  text-decoration: none;
  transition: border-color 200ms ease;
}

.modal-media.youtube .yt-fallback:hover {
  border-color: var(--accent);
}

.modal-media.youtube .yt-fallback .play-badge {
  position: relative;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: rgba(10, 10, 10, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.7);
  transition: background 200ms ease, border-color 200ms ease;
}

.modal-media.youtube .yt-fallback .play-badge::after {
  content: "";
  position: absolute;
  top: 50%; left: 54%;
  transform: translate(-50%, -50%);
  border-style: solid;
  border-width: 10px 0 10px 16px;
  border-color: transparent transparent transparent #ffffff;
}

.modal-media.youtube .yt-fallback:hover .play-badge {
  background: rgba(168, 166, 247, 0.35);
  border-color: var(--accent);
}

.modal-media.youtube .yt-fallback-text {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.modal-media.youtube .yt-fallback:hover .yt-fallback-text {
  color: var(--fg);
}

.modal-media img {
  width: 100%;
  height: auto;
  display: block;
  max-height: 60vh;
  object-fit: contain;
  background: #000;
}

.modal-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 10px 18px;
  border: 1px solid var(--stroke);
  color: var(--fg-mute);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: not-allowed;
  background: transparent;
  text-decoration: none;
}

.modal-download.ready {
  color: var(--fg);
  border-color: var(--accent);
  cursor: pointer;
  transition: all 200ms ease;
}

.modal-download.ready:hover {
  background: var(--accent);
  color: var(--bg);
}

.modal-image-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
}

.modal-image-nav button {
  background: transparent;
  border: 1px solid var(--stroke);
  color: var(--fg-dim);
  padding: 8px 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 200ms ease;
}

.modal-image-nav button:hover {
  color: var(--fg);
  border-color: var(--fg-dim);
}

.modal-image-nav button:disabled {
  opacity: 0.3;
  cursor: default;
}

.modal-article-body p {
  color: var(--fg-dim);
  font-size: 14px;
  line-height: 1.75;
  margin-bottom: 16px;
}

.modal-article-body .article-subhead {
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin: 26px 0 12px;
  font-weight: 500;
}

.modal-attachments {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--stroke);
}

.modal-attachments-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--fg-mute);
  text-transform: uppercase;
  margin-bottom: 12px;
}

.modal-attachment {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--stroke);
  text-decoration: none;
  color: var(--fg);
  font-size: 13px;
  transition: color 200ms ease;
}

.modal-attachment:hover {
  color: var(--accent);
}

.modal-attachment .attachment-size {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-mute);
  white-space: nowrap;
}

/* Focus visible */
:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }

/* Reduced motion respect */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}
