/* ==========================================================================
   DRELVA · NOCTURNE DESIGN SYSTEM
   Source of truth: DESIGN-SPEC.md & design-reference.png
   ========================================================================== */

/* --- TOKENS --- */
:root {
  --bg: #0A0D0F;
  --base: #0E1214;
  --panel: #141A1D;
  --panel-2: #10151A;
  --line: #232C28;
  --edge: #2E3A33;
  --lime: #B7FF3B;
  --lime-hi: #D6FF7A;
  --lime-deep: #8FC93A;
  --glow: rgba(183, 255, 59, 0.35);
  --text: #E5E7EB;
  --dim: #8A938E;
  --faint: #5A635E;

  --font-brand: 'Michroma', -apple-system, sans-serif;
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --radius-window: 16px;
  --radius-card: 10px;
  --radius-input: 8px;
  --radius-pill: 999px;

  color-scheme: dark;
}

/* --- RESET & BASE --- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}

img, svg {
  max-width: 100%;
  display: block;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
}

:focus-visible {
  outline: 2px solid var(--lime) !important;
  outline-offset: 3px !important;
}

/* --- MAIN WINDOW --- */
.drelva-window {
  width: 100%;
  max-width: 1360px;
  margin: 24px auto;
  padding: 24px;
  background: var(--base);
  border: 1px solid var(--line);
  border-radius: var(--radius-window);
  position: relative;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.95);
}

@media (max-width: 768px) {
  .drelva-window {
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    padding: 16px 14px;
  }
}

/* --- HEADER --- */
.drelva-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
  position: relative;
}

.brand-group {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-monogram {
  height: 24px;
  width: auto;
  filter: drop-shadow(0 0 10px var(--glow));
}

.brand-lettering {
  height: 14px;
  width: auto;
  opacity: 0.95;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.nav-link {
  color: var(--dim);
  padding: 4px 2px;
}

.nav-link:hover {
  color: var(--text);
}

.nav-link.active {
  color: var(--lime);
}

.nav-sep {
  color: var(--faint);
  user-select: none;
}

/* 1px rule under header breaking around a centred tick above hero */
.header-divider-wrap {
  position: relative;
  width: 100%;
  height: 14px;
  margin-bottom: 24px;
}

.header-divider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--edge);
}

.header-tick {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 14px;
  background: var(--lime);
  box-shadow: 0 0 6px var(--lime);
}

/* --- HERO SECTION --- */
.drelva-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px 16px 36px;
}

/* Centred glowing wave-orb with tick ring & brackets */
.hero-orb-container {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-orb-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hero-orb-canvas {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, #09120e 0%, #050807 70%, #020403 100%);
  border: 1px solid var(--line);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.9), 0 0 35px rgba(183, 255, 59, 0.12);
  display: block;
}

.hero-title {
  font-family: var(--font-brand);
  font-size: clamp(26px, 4.5vw, 36px);
  font-weight: 400;
  letter-spacing: 0.38em;
  line-height: 1.1;
  margin: 0 0 12px;
  color: var(--text);
  text-indent: 0.38em; /* optical balance for letter-spacing */
}

.hero-tagline {
  color: var(--dim);
  font-size: 14px;
  max-width: 54ch;
  margin: 0 0 24px;
  line-height: 1.6;
}

/* OS Switcher Pill Group */
.os-filter-group {
  display: inline-flex;
  border: 1px solid var(--edge);
  border-radius: var(--radius-pill);
  padding: 3px;
  background: var(--panel-2);
}

.os-btn {
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  transition: all 0.15s ease;
}

.os-btn:hover {
  color: var(--text);
}

.os-btn[aria-pressed="true"] {
  background: var(--lime);
  color: #0A0D0F;
  font-weight: 600;
}

/* --- PRODUCT CARDS GRID --- */
.plugins-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 580px), 1fr));
  gap: 20px;
  margin-top: 10px;
}

@media (max-width: 640px) {
  .plugins-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* Product Card (Reference Module Card Anatomy) */
.product-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 20px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 18px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.product-card:hover {
  border-color: var(--edge);
}

.product-card.selected {
  border-color: var(--edge);
}

/* Card Header: Icon + "01" + UPPERCASE NAME + Version Pill */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 4px;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.card-icon {
  width: 20px;
  height: 20px;
  stroke: var(--text);
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.card-num {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.card-name {
  font-family: var(--font-brand);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0.2em;
  margin: 0;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pills */
.pill {
  border-radius: var(--radius-pill);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--dim);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  padding: 3px 10px;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.pill.lime {
  color: var(--lime);
  border-color: rgba(183, 255, 59, 0.4);
}

/* Card Visual Row: Screenshot + Knob Component */
.card-visual-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  background: #060907;
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: 12px;
}

@media (max-width: 480px) {
  .card-visual-row {
    grid-template-columns: 1fr;
    justify-items: center;
  }
}

.card-screenshot-btn {
  display: block;
  width: 100%;
  cursor: zoom-in;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #020302;
  position: relative;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card-screenshot-btn:hover {
  border-color: var(--lime);
  box-shadow: 0 0 16px rgba(183, 255, 59, 0.2);
}

.card-screenshot-btn img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  object-position: center top;
  display: block;
}

@media (max-width: 480px) {
  .card-screenshot-btn img {
    height: 140px;
  }
}

.screenshot-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(10, 13, 15, 0.85);
  border: 1px solid var(--edge);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--dim);
  text-transform: uppercase;
  pointer-events: none;
}

/* --- KNOB COMPONENT (SPEC.md) ---
   - Body: disc, radial gradient #1A2024 -> #0B0E10, 1px --line rim, inner shadow
   - Track: 3px ring outside body, --line, sweep 270° (-135° to +135°, gap at bottom)
   - Value arc: same radius, 3px, round caps, --lime -> --lime-hi, with --glow
   - Pointer: 2px short line --text from body edge inward
   - Sizes: L 64px, M 44px, S 30px
   - States: hover, focus, disabled, modulated
   - Label under knob: 11px uppercase --dim
   - Value under label: 13px --text, tabular-nums
*/
.drelva-knob {
  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
  flex-shrink: 0;
}

.knob-widget {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drelva-knob.size-l .knob-widget { width: 64px; height: 64px; }
.drelva-knob.size-m .knob-widget { width: 44px; height: 44px; }
.drelva-knob.size-s .knob-widget { width: 30px; height: 30px; }

.knob-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Knob Track (270° ring, 3px, --line) */
.knob-track {
  stroke: var(--line);
  stroke-width: 3px;
  fill: none;
  stroke-linecap: round;
}

/* Knob Value Arc (3px, round caps, lime -> lime-hi, with glow) */
.knob-arc {
  stroke: url(#lime-gradient);
  stroke-width: 3px;
  fill: none;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px var(--glow));
  transition: stroke 0.2s ease, filter 0.2s ease;
}

/* Modulated ring: thin second arc 1px outside at 40% opacity */
.knob-mod {
  stroke: var(--lime);
  stroke-width: 1px;
  fill: none;
  stroke-linecap: round;
  opacity: 0.4;
}

/* Knob Body disc with radial gradient #1A2024 -> #0B0E10 */
.knob-disc {
  fill: url(#knob-body-gradient);
  stroke: var(--line);
  stroke-width: 1px;
  filter: drop-shadow(inset 0 2px 4px rgba(255, 255, 255, 0.05));
}

/* Knob Pointer: 2px short line --text from edge inward */
.knob-pointer {
  stroke: var(--text);
  stroke-width: 2px;
  stroke-linecap: round;
}

/* Knob Labels */
.knob-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--dim);
  margin-top: 6px;
  text-align: center;
  transition: color 0.15s ease;
}

.knob-val {
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: center;
  line-height: 1.2;
}

/* Knob Hover & Focus States */
.drelva-knob:hover .knob-arc {
  stroke: var(--lime-hi);
  filter: drop-shadow(0 0 7px var(--lime));
}

.drelva-knob:hover .knob-label {
  color: var(--text);
}

.drelva-knob.disabled .knob-arc {
  stroke: var(--faint);
  filter: none;
}

.drelva-knob:focus-visible {
  border-radius: 50%;
}

/* --- CARD CONTENT & TYPOGRAPHY --- */
.card-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-kind {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--lime);
  margin: 0;
}

.card-blurb {
  font-size: 14px;
  color: var(--text);
  margin: 0;
  line-height: 1.6;
}

/* Points list with stylized lime dashes */
.card-points {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-points li {
  position: relative;
  padding-left: 18px;
  font-size: 13px;
  color: #c9cdd2;
  line-height: 1.5;
}

.card-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  width: 8px;
  height: 1px;
  background: var(--lime);
}

/* "What's new" Section (.card-upd) */
.card-upd {
  background: radial-gradient(120% 120% at 0% 0%, rgba(183, 255, 59, 0.07), transparent 60%), var(--panel-2);
  border: 1px solid rgba(183, 255, 59, 0.35);
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 4px;
}

.upd-title {
  margin: 0 0 4px;
  font-family: var(--font-brand);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--lime);
  display: flex;
  align-items: center;
  gap: 8px;
}

.upd-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 6px var(--lime);
}

.upd-status {
  font-size: 12px;
  color: var(--dim);
  margin: 0 0 8px;
  line-height: 1.4;
}

.upd-group-title {
  margin: 8px 0 2px;
  font-family: var(--font-brand);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--lime-hi);
  text-transform: uppercase;
}

.upd-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.upd-list li {
  font-size: 12px;
  color: #c0c5cb;
  padding: 2px 0 2px 14px;
  position: relative;
  line-height: 1.4;
}

.upd-list li::before {
  content: "•";
  position: absolute;
  left: 2px;
  color: var(--dim);
}

/* Gallery for Pongo */
.card-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 6px;
}

.gallery-btn {
  all: unset;
  cursor: zoom-in;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gallery-btn img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--line);
  transition: border-color 0.15s ease;
}

.gallery-btn:hover img {
  border-color: var(--lime);
}

.gallery-btn span {
  font-size: 11px;
  color: var(--dim);
  line-height: 1.3;
}

/* Versio Firmware Section (.card-firmware) */
.card-firmware {
  padding: 14px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: var(--panel-2);
  margin-top: 6px;
}

.firmware-title {
  font-family: var(--font-brand);
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--lime);
  margin: 0 0 6px;
}

.firmware-text {
  font-size: 13px;
  color: var(--dim);
  margin: 0 0 10px;
  line-height: 1.5;
}

.firmware-note {
  font-size: 12px;
  color: var(--faint);
  margin: 10px 0 0;
  line-height: 1.4;
}

/* --- BUTTONS & DOWNLOAD ROW --- */
.download-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.btn {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 14px;
  border-radius: var(--radius-input);
  border: 1px solid var(--edge);
  background: var(--panel-2);
  color: var(--text);
  font-size: 11px;
  font-family: var(--font-sans);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 140px;
  flex: 1 1 calc(50% - 8px);
}

.btn b {
  font-family: var(--font-brand);
  font-weight: 400;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text);
}

.btn small {
  color: var(--dim);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.btn:hover {
  border-color: var(--lime);
  color: var(--lime);
  box-shadow: 0 0 18px var(--glow);
}

.btn:hover b {
  color: var(--lime);
}

/* Primary / Main active button */
.btn.main {
  border-color: var(--lime);
  background: radial-gradient(120% 140% at 50% 50%, rgba(183, 255, 59, 0.12), transparent 70%), var(--panel-2);
  box-shadow: 0 0 20px rgba(183, 255, 59, 0.18);
}

.btn.main b {
  color: var(--lime-hi);
}

/* Secondary / demo / manual buttons */
.btn.sub-btn {
  flex: 1 1 100%;
  padding: 7px 12px;
}

.empty-os-note {
  color: var(--dim);
  font-size: 12px;
  margin: 0;
  font-style: italic;
}

/* Card Meta & Release Notes Link */
.card-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--dim);
  margin-top: 4px;
}

.card-meta a {
  color: var(--lime);
  text-decoration: none;
}

.card-meta a:hover {
  text-decoration: underline;
}

/* Previous versions details */
details.old-versions {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

details.old-versions summary {
  cursor: pointer;
  color: var(--dim);
  font-family: var(--font-brand);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  user-select: none;
}

details.old-versions summary:hover {
  color: var(--text);
}

.old-versions-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}

.old-versions-list a {
  color: var(--text);
  margin-left: 4px;
}

.old-versions-list a:hover {
  color: var(--lime);
}

/* Bottom Progress Bar along card bottom (SPEC.md) */
.card-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--line);
}

.card-progress-fill {
  height: 100%;
  background: var(--lime);
  box-shadow: 0 0 6px var(--lime);
}

/* --- SYSTEM NOTICE BANNER --- */
.system-notice-box {
  margin: 36px 0 20px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--panel-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12.5px;
  color: var(--dim);
  line-height: 1.6;
}

.system-notice-box a {
  color: var(--lime);
}

.notice-title {
  font-family: var(--font-brand);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text);
}

/* --- FOOTER --- */
.drelva-footer {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--faint);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.footer-left {
  font-family: var(--font-brand);
  letter-spacing: 0.38em;
  color: var(--dim);
}

.footer-right a {
  color: var(--dim);
}

.footer-right a:hover {
  color: var(--lime);
}

/* --- LIGHTBOX DIALOG --- */
dialog#lb {
  border: 1px solid var(--edge);
  background: #020302;
  padding: 12px;
  max-width: 95vw;
  max-height: 94vh;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.95);
  color: var(--text);
}

dialog#lb::backdrop {
  background: rgba(2, 4, 3, 0.88);
  backdrop-filter: blur(4px);
}

.lb-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

dialog#lb img {
  display: block;
  max-width: calc(95vw - 24px);
  max-height: calc(94vh - 80px);
  width: auto;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--edge);
}

.lb-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lb-cap {
  font-size: 12px;
  color: var(--dim);
}

#lbclose {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--edge);
  border-radius: 6px;
  padding: 6px 14px;
  font-family: var(--font-brand);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s ease;
}

#lbclose:hover {
  border-color: var(--lime);
  color: var(--lime);
}

/* --- ACCESSIBILITY & PREFERS-REDUCED-MOTION --- */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
