/* ============================================================
   THE SIGNAL PATH — base.css
   Monakai Audio redesign · shell + base design system
   Owned by CORE_SHELL.
   Requires tokens.css loaded BEFORE this file.
   Page-specific styles must use .pg-<pagename>- prefixes.
   ============================================================ */

/* ---------- reset ---------- */

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

html, body, h1, h2, h3, h4, h5, h6, p, ul, ol, li, figure,
blockquote, fieldset, legend, pre, hr { margin: 0; padding: 0; }

ul, ol { list-style: none; }

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

button, input, select, textarea { font: inherit; color: inherit; }

a { color: inherit; }

/* ---------- base ---------- */

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-display), system-ui, -apple-system, sans-serif;
  font-weight: 300;
  font-size: 16px;
  line-height: 1.5;
  padding-top: var(--nav-h);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 { font-weight: 500; line-height: 1.12; letter-spacing: -0.01em; }

a { text-decoration: none; }

::selection { background: var(--orange); color: var(--bg); }

:focus-visible { outline: 1px solid var(--orange); outline-offset: 2px; }

html { scrollbar-color: var(--line) var(--bg); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ---------- layout helpers (optional, documented in MANIFEST) ---------- */

.wrap { width: min(var(--wrap), calc(100vw - 2.5rem)); margin-inline: auto; }

.section-label {
  font-family: var(--font-mono), ui-monospace, monospace;
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- background oscilloscope canvas ---------- */

#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

main, #page-root { position: relative; z-index: 1; }

/* ---------- custom cursor ---------- */

#cursor-dot, #cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9990;
  pointer-events: none;
  border-radius: 50%;
  display: none;
}

html.has-cursor #cursor-dot, html.has-cursor #cursor-ring { display: block; }

html.has-cursor, html.has-cursor * { cursor: none !important; }

#cursor-dot { width: 6px; height: 6px; background: var(--orange); }

#cursor-ring {
  width: 30px;
  height: 30px;
  border: 1px solid var(--muted);
  opacity: 0.8;
  transition: width 0.25s var(--ease), height 0.25s var(--ease),
              border-color 0.25s var(--ease), opacity 0.25s var(--ease);
}

#cursor-ring.is-hover { width: 48px; height: 48px; border-color: var(--orange); opacity: 1; }
#cursor-ring.is-down { width: 20px; height: 20px; border-color: var(--orange); }

/* ---------- waveform wipe (page transitions) ---------- */

#wipe {
  position: fixed;
  inset: 0;
  z-index: 9400;
  pointer-events: none;
  visibility: hidden;
}

#wipe.is-on { visibility: visible; }

#wipe-svg { width: 100%; height: 100%; }

#wipe-path {
  fill: var(--bg-2);
  stroke: var(--orange);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

/* ---------- entry gate ---------- */

#gate {
  position: fixed;
  inset: 0;
  z-index: 9800;
  background: var(--bg);
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.6s var(--ease);
}

#gate.is-on { display: flex; }

#gate.is-off { opacity: 0; pointer-events: none; }

.gate-inner { position: relative; text-align: center; padding: 3rem 2rem; }

.gate-mark { font-size: clamp(2.6rem, 9vw, 6.5rem); color: var(--orange); line-height: 1; }

.gate-sub {
  font-family: var(--font-mono), ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 1.75rem;
  animation: gate-blink 1.7s steps(2, start) infinite;
}

.gate-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(320px, 70vw);
  height: min(320px, 70vw);
  border: 1px solid var(--orange);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  animation: gate-pulse 2.4s var(--ease) infinite;
}

@keyframes gate-pulse {
  0%   { transform: translate(-50%, -50%) scale(0.55); opacity: 0.55; }
  100% { transform: translate(-50%, -50%) scale(1.15); opacity: 0; }
}

@keyframes gate-blink { 50% { opacity: 0.35; } }

/* ---------- nav ---------- */

#nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 2.25rem);
  padding: 0 clamp(1rem, 4vw, 2.5rem);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.nav-brand { font-size: 1.3rem; color: var(--orange); white-space: nowrap; }

.nav-links { display: flex; align-items: center; gap: clamp(0.9rem, 2.2vw, 1.75rem); }

.nav-links a,
.nav-right a {
  font-family: var(--font-mono), ui-monospace, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.35rem 0;
  border-bottom: 1px solid transparent;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}

.nav-links a:hover, .nav-right a:hover { color: var(--ink); }

.nav-links a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--orange); }

.nav-right { margin-left: auto; display: flex; align-items: center; gap: 1.1rem; }

.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-family: var(--font-mono), ui-monospace, monospace;
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}

.nav-toggle:hover { color: var(--ink); border-color: var(--muted); }

#nav-menu { display: none; font-size: 0.95rem; line-height: 1; padding: 0.4rem 0.7rem; }

@media (max-width: 920px) {
  #nav-menu { display: inline-flex; }
  .nav-links {
    display: none;
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    z-index: 8999;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    padding: 0.75rem clamp(1rem, 4vw, 2.5rem) 1.5rem;
  }
  #nav.nav-open .nav-links { display: flex; }
  .nav-links a {
    display: block;
    width: 100%;
    font-size: 0.95rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--line);
  }
  .nav-links a[aria-current="page"] { border-bottom-color: var(--line); color: var(--orange); }
}

/* auth visibility — boot.js toggles html.auth-in / html.auth-out
   after GET /api/auth/me. Default (unchecked): "out" state shown. */

[data-auth="in"] { display: none; }
html.auth-in [data-auth="in"] { display: revert; }
html.auth-in [data-auth="out"] { display: none; }

/* ---------- footer ---------- */

#foot {
  position: relative;
  z-index: 1;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  margin-top: clamp(4rem, 10vw, 7rem);
  padding: clamp(2.5rem, 6vw, 4rem) clamp(1rem, 4vw, 2.5rem) 2rem;
}

.foot-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: clamp(1.75rem, 4vw, 3rem);
  max-width: var(--wrap);
  margin: 0 auto clamp(2rem, 5vw, 3rem);
}

.foot-label {
  display: block;
  font-family: var(--font-mono), ui-monospace, monospace;
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.1rem;
}

#foot p { color: var(--muted); font-size: 0.85rem; line-height: 1.65; max-width: 36ch; }

.foot-grid a {
  display: block;
  width: fit-content;
  font-family: var(--font-mono), ui-monospace, monospace;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  color: var(--ink);
  padding: 0.28rem 0;
  transition: color 0.2s var(--ease);
}

.foot-grid a:hover { color: var(--orange); }

.foot-line {
  max-width: var(--wrap);
  margin: 0 auto;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono), ui-monospace, monospace;
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.foot-concept { color: var(--orange); }

@media (max-width: 920px) { .foot-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 540px) { .foot-grid { grid-template-columns: 1fr; } }

/* ---------- dotmatrix (LED dot text; tint via CSS `color`) ---------- */

.dotmatrix {
  font-family: var(--font-display), system-ui, sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background-image: radial-gradient(circle, currentColor 1.05px, transparent 1.4px);
  background-size: 4px 4px;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---------- led status dot ---------- */

.led {
  display: inline-block;
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px rgba(0, 200, 83, 0.55);
}

.led.is-off { background: #3a3936; box-shadow: none; }
.led--orange { background: var(--orange); box-shadow: 0 0 6px rgba(255, 107, 53, 0.55); }
.led--blue   { background: var(--blue);   box-shadow: 0 0 6px rgba(41, 121, 255, 0.55); }
.led--yellow { background: var(--yellow); box-shadow: 0 0 6px rgba(247, 232, 76, 0.55); }
.led--orange.is-off, .led--blue.is-off, .led--yellow.is-off { background: #3a3936; box-shadow: none; }

/* ---------- entrance utilities (boot.js drives .is-in) ---------- */

.m-in {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.85s var(--ease), transform 0.85s var(--ease);
}

.m-in.is-in { opacity: 1; transform: none; }

.m-stagger > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
  transition-delay: calc(var(--i, 0) * 75ms);
}

.m-stagger.is-in > * { opacity: 1; transform: none; }

/* ---------- readable content / article typography ---------- */

.pg-content {
  max-width: 46rem;
  margin-inline: auto;
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 300;
  line-height: 1.75;
}

.pg-content > * + * { margin-top: 1.3rem; }

.pg-content h1, .pg-content h2, .pg-content h3, .pg-content h4 {
  font-weight: 500;
  line-height: 1.15;
  margin-top: 2.75rem;
}
.pg-content h1 { font-size: clamp(2rem, 5vw, 2.9rem); }
.pg-content h2 { font-size: clamp(1.5rem, 3.5vw, 1.9rem); }
.pg-content h3 { font-size: 1.3rem; }
.pg-content h4 { font-size: 1.05rem; font-family: var(--font-mono), ui-monospace, monospace; letter-spacing: 0.08em; text-transform: uppercase; }
.pg-content > h1:first-child, .pg-content > h2:first-child, .pg-content > h3:first-child { margin-top: 0; }

.pg-content a {
  color: var(--orange);
  text-decoration: underline;
  text-underline-offset: 0.22em;
  text-decoration-color: rgba(255, 107, 53, 0.35);
  transition: text-decoration-color 0.2s var(--ease);
}
.pg-content a:hover { text-decoration-color: var(--orange); }

.pg-content ul, .pg-content ol { padding-left: 1.4rem; }
.pg-content ul { list-style: none; }
.pg-content ul li::before { content: "■ "; color: var(--orange); font-size: 0.6em; vertical-align: 0.28em; margin-right: 0.55rem; }
.pg-content ol { list-style: decimal; }
.pg-content ol li::marker { color: var(--orange); font-family: var(--font-mono), ui-monospace, monospace; }
.pg-content li + li { margin-top: 0.45rem; }

.pg-content blockquote {
  border-left: 2px solid var(--orange);
  padding: 0.2rem 0 0.2rem 1.25rem;
  color: var(--muted);
}

.pg-content code {
  font-family: var(--font-mono), ui-monospace, monospace;
  font-size: 0.85em;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.1em 0.4em;
}

.pg-content pre {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  line-height: 1.6;
}
.pg-content pre code { background: none; border: none; padding: 0; font-size: 0.82rem; }

.pg-content hr { border: none; border-top: 1px solid var(--line); margin: 2.75rem 0; }

.pg-content img, .pg-content video { max-width: 100%; height: auto; border: 1px solid var(--line); }

.pg-content table { width: 100%; border-collapse: collapse; font-family: var(--font-mono), ui-monospace, monospace; font-size: 0.8rem; }
.pg-content th, .pg-content td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); }
.pg-content th { color: var(--muted); font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 400; }

.pg-content strong { font-weight: 600; }
.pg-content small { font-size: 0.8rem; color: var(--muted); }

/* ---------- forms & controls (dark theme) ---------- */

label {
  display: block;
  font-family: var(--font-mono), ui-monospace, monospace;
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="search"], input[type="url"],
input[type="tel"], input[type="date"], input[type="time"],
input:not([type]), textarea, select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--font-mono), ui-monospace, monospace;
  font-size: 0.85rem;
  padding: 0.7rem 0.85rem;
  transition: border-color 0.2s var(--ease);
}

input:focus, textarea:focus, select:focus { outline: none; border-color: var(--orange); }

input::placeholder, textarea::placeholder { color: #55534e; }

input:disabled, textarea:disabled, select:disabled { opacity: 0.45; cursor: not-allowed; }

textarea { min-height: 8rem; resize: vertical; line-height: 1.6; }

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.4rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238f8c85' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
}

input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--orange); }
input[type="range"] { accent-color: var(--orange); padding-left: 0; padding-right: 0; background: transparent; border-color: transparent; }

fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; }
legend {
  font-family: var(--font-mono), ui-monospace, monospace;
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 0.5rem;
}

/* buttons */

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: transparent;
  border: 1px solid var(--muted);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--font-mono), ui-monospace, monospace;
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 0.8rem 1.6rem;
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease),
              background-color 0.2s var(--ease);
}

button:hover, .btn:hover { border-color: var(--orange); color: var(--orange); }
button:disabled, .btn:disabled { opacity: 0.4; cursor: not-allowed; border-color: var(--line); color: var(--muted); }

.btn--solid { background: var(--orange); border-color: var(--orange); color: var(--bg); }
.btn--solid:hover { background: #ff8252; border-color: #ff8252; color: var(--bg); }

.btn--small { padding: 0.5rem 1rem; font-size: 0.66rem; }

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .m-in, .m-stagger > * { opacity: 1 !important; transform: none !important; }
  #cursor-dot, #cursor-ring { display: none !important; }
}
