/* ============================================================
   APEX FORGE — styles.css
   Tailwind (CDN) handles layout utilities; this file owns the
   design tokens, effects and component styling.
   ============================================================ */

:root {
  --charcoal: #0B0C10;
  --black: #050608;
  --neon: #00E5FF;
  --alert: #FF0055;
  --line: rgba(255, 255, 255, 0.08);
}

html { scroll-behavior: auto; }
body { background: var(--charcoal); overflow-x: hidden; }
::selection { background: var(--neon); color: var(--black); }

.shadow-neon { box-shadow: 0 0 12px var(--neon), 0 0 32px rgba(0, 229, 255, 0.35); }

/* ---------- Loader ---------- */
#loader { transition: opacity .6s ease, visibility .6s ease; }
#loader.is-done { opacity: 0; visibility: hidden; }

/* ---------- Header ---------- */
#site-header { transition: background .4s ease, backdrop-filter .4s ease, border-color .4s ease; border-bottom: 1px solid transparent; }
#site-header.is-solid { background: rgba(11, 12, 16, 0.72); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-color: var(--line); }
.nav-link { position: relative; transition: color .25s; }
.nav-link::after { content: ""; position: absolute; left: 0; bottom: -6px; height: 1px; width: 0; background: var(--neon); transition: width .3s; }
.nav-link:hover { color: #fff; }
.nav-link:hover::after { width: 100%; }

/* ---------- Buttons ---------- */
.btn-neon {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  padding: .7rem 1.2rem; color: var(--neon); border: 1px solid rgba(0, 229, 255, .55);
  background: rgba(0, 229, 255, .04); overflow: hidden; isolation: isolate;
  transition: color .3s, box-shadow .3s, border-color .3s;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}
.btn-neon::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: var(--neon);
  transform: translateX(-101%); transition: transform .35s cubic-bezier(.7, 0, .2, 1);
}
.btn-neon:hover, .btn-neon:focus-visible { color: var(--black); border-color: var(--neon); box-shadow: 0 0 24px rgba(0, 229, 255, .45); outline: none; }
.btn-neon:hover::before, .btn-neon:focus-visible::before { transform: translateX(0); }
.btn-lg { padding: 1.05rem 2rem; }

/* ---------- Typography helpers ---------- */
.eyebrow { font-family: "JetBrains Mono", monospace; font-size: 11px; letter-spacing: .3em; color: var(--neon); margin-bottom: 1rem; }
.section-title { font-family: Anton, Impact, sans-serif; font-size: clamp(2.6rem, 7vw, 6.5rem); line-height: .92; color: #fff; letter-spacing: .01em; }
.text-stroke { color: transparent; -webkit-text-stroke: 1.5px rgba(255, 255, 255, .85); }

/* ---------- Ambient textures ---------- */
/* Blueprint grid, faded out with a mask on a pseudo-element so content stays unmasked */
.grid-bg { position: relative; }
.grid-bg > * { position: relative; }
.grid-bg::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse at 50% 20%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 20%, #000 20%, transparent 75%);
}

.scanlines {
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, .025) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}
.hero-vignette {
  background:
    radial-gradient(ellipse at center, transparent 45%, rgba(5, 6, 8, .75) 100%),
    linear-gradient(to bottom, rgba(5, 6, 8, .55) 0%, transparent 18%, transparent 70%, rgba(11, 12, 16, 1) 100%);
}

/* Pinned sections: sized here (not via Tailwind CDN classes, which are injected
   asynchronously and could be missing when ScrollTrigger first measures). */
#hero, #metamorphosis { position: relative; width: 100%; height: 100vh; height: 100svh; overflow: hidden; }
#hero-canvas, #repair-canvas, #hero-poster, #repair-poster { position: absolute; inset: 0; width: 100%; height: 100%; }
#hero-poster { object-fit: cover; }

/* ---------- Hero ---------- */
#hero-canvas { opacity: 0; transition: opacity .6s ease; }
#hero-canvas.is-ready { opacity: 1; }

.hero-words { position: relative; width: 100%; height: 1em; font-size: clamp(4.5rem, 17vw, 17rem); text-align: center; }
.hero-word {
  position: absolute; inset: 0; display: block;
  text-shadow: 0 0 40px rgba(0, 0, 0, .55);
  will-change: transform, opacity, filter;
}
.hero-word:not([data-i="0"]) { opacity: 0; }

.scroll-cue { width: 1px; height: 38px; background: linear-gradient(var(--neon), transparent); animation: cue 1.8s ease-in-out infinite; transform-origin: top; }
@keyframes cue { 0% { transform: scaleY(0); } 50% { transform: scaleY(1); } 100% { transform: scaleY(1); opacity: 0; } }

/* ---------- Bento ---------- */
.bento { perspective: 1400px; }
.bento-card {
  --mx: 50%; --my: 50%;
  position: relative; overflow: hidden; border-radius: 4px;
  background: linear-gradient(160deg, #14161d, #0c0d12);
  border: 1px solid var(--line);
  transform-style: preserve-3d;
  transition: border-color .35s, box-shadow .35s, transform .5s cubic-bezier(.2, .8, .2, 1);
}
.bento-card::after {        /* cursor-follow neon glow */
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(500px circle at var(--mx) var(--my), rgba(0, 229, 255, .16), transparent 45%);
  opacity: 0; transition: opacity .35s;
}
.bento-card::before {       /* animated neon edge */
  content: ""; position: absolute; inset: -1px; z-index: 3; pointer-events: none; border-radius: inherit; padding: 1px;
  background: conic-gradient(from var(--ang, 0deg), transparent 0 70%, var(--neon) 85%, var(--alert) 92%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity .35s;
}
.bento-card:hover { border-color: rgba(0, 229, 255, .35); box-shadow: 0 30px 80px -30px rgba(0, 229, 255, .35); }
.bento-card:hover::after, .bento-card:hover::before { opacity: 1; }
.bento-card:hover::before { animation: spin-edge 2.4s linear infinite; }
@property --ang { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes spin-edge { to { --ang: 360deg; } }

.bento-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scale(1.04); filter: saturate(.85) brightness(.8); transition: transform 1.2s cubic-bezier(.2, .8, .2, 1), filter .6s; }
.bento-card:hover .bento-img { transform: scale(1.12); filter: saturate(1.15) brightness(.95); }
.bento-shade { position: absolute; inset: 0; z-index: 1; background: linear-gradient(to top, rgba(8, 9, 12, .95) 8%, rgba(8, 9, 12, .35) 55%, rgba(8, 9, 12, .55)); }
.bento-title { font-family: Anton, Impact, sans-serif; font-size: clamp(2rem, 4.4vw, 4rem); line-height: .95; color: #fff; }
.chip { padding: .35rem .6rem; border: 1px solid rgba(0, 229, 255, .3); color: var(--neon); background: rgba(0, 229, 255, .05); }

/* Glitch on hover (RGB split) */
.glitch { position: relative; display: inline-block; }
.glitch::before, .glitch::after { content: attr(data-text); position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.glitch::before { color: var(--neon); }
.glitch::after { color: var(--alert); }
.bento-card:hover .glitch::before { opacity: .85; animation: glitch-a .9s steps(2, end) infinite; }
.bento-card:hover .glitch::after { opacity: .85; animation: glitch-b .9s steps(2, end) infinite; }
@keyframes glitch-a {
  0% { clip-path: inset(10% 0 70% 0); transform: translate(-3px, -1px); }
  25% { clip-path: inset(55% 0 20% 0); transform: translate(3px, 1px); }
  50% { clip-path: inset(30% 0 45% 0); transform: translate(-2px, 0); }
  75% { clip-path: inset(80% 0 5% 0); transform: translate(2px, -1px); }
  100% { clip-path: inset(0 0 90% 0); transform: translate(0); }
}
@keyframes glitch-b {
  0% { clip-path: inset(65% 0 15% 0); transform: translate(3px, 1px); }
  25% { clip-path: inset(5% 0 75% 0); transform: translate(-3px, -1px); }
  50% { clip-path: inset(40% 0 35% 0); transform: translate(2px, 0); }
  75% { clip-path: inset(15% 0 60% 0); transform: translate(-2px, 1px); }
  100% { clip-path: inset(85% 0 0 0); transform: translate(0); }
}

/* ---------- Metamorphosis ---------- */
#repair-poster { object-fit: cover; }
#repair-canvas { opacity: 0; transition: opacity .6s ease; }
#repair-canvas.is-ready { opacity: 1; }
.meta-shade { background: linear-gradient(to bottom, rgba(5, 6, 8, .7) 0%, transparent 30%, transparent 80%, rgba(5, 6, 8, .5) 100%); }

/* ---------- Language switch ---------- */
.lang-switch { display: flex; align-items: center; gap: .35rem; color: #52525b; }
.lang-switch button { padding: .35rem .15rem; color: #71717a; transition: color .25s, text-shadow .25s; }
.lang-switch button:hover { color: #fff; }
.lang-switch button[aria-pressed="true"] { color: var(--neon); text-shadow: 0 0 10px rgba(0, 229, 255, .6); }
.lang-switch button:focus-visible { outline: 1px solid var(--neon); outline-offset: 2px; }

/* ---------- Mission Control form ---------- */
.dash { position: relative; border: 1px solid rgba(0, 229, 255, .22); background: linear-gradient(180deg, rgba(18, 20, 26, .9), rgba(8, 9, 12, .9)); box-shadow: inset 0 0 60px rgba(0, 229, 255, .04); }
.dash::before, .dash::after { content: ""; position: absolute; width: 18px; height: 18px; border-color: var(--neon); border-style: solid; }
.dash::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.dash::after { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }
.dash-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.25rem; border-bottom: 1px solid var(--line); font-family: "JetBrains Mono", monospace; font-size: 11px; letter-spacing: .25em; color: #71717a; }
.dash-head i { display: block; width: 8px; height: 8px; border: 1px solid #3f3f46; }
.dash-head i:first-child { background: var(--alert); border-color: var(--alert); }

.field { display: flex; flex-direction: column; gap: .5rem; }
.field-label { font-family: "JetBrains Mono", monospace; font-size: 10px; letter-spacing: .25em; color: #71717a; transition: color .25s; }
.field input, .field select, .field textarea {
  width: 100%; background: rgba(5, 6, 8, .7); color: #fff; border: 1px solid #2A2E39; border-radius: 0;
  padding: .9rem 1rem; font-family: "JetBrains Mono", monospace; font-size: 14px; outline: none; appearance: none;
  transition: border-color .25s, box-shadow .25s, background .25s;
}
.field select { background-image: linear-gradient(45deg, transparent 50%, var(--neon) 50%), linear-gradient(135deg, var(--neon) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.field select option { background: #0B0C10; }
.field textarea { resize: vertical; min-height: 110px; }
.field ::placeholder { color: #52525b; }
.field:focus-within .field-label { color: var(--neon); }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--neon); background: rgba(0, 229, 255, .04);
  box-shadow: 0 0 0 1px var(--neon), 0 0 24px rgba(0, 229, 255, .25), inset 0 0 18px rgba(0, 229, 255, .08);
}
.field.is-invalid input, .field.is-invalid select { border-color: var(--alert); box-shadow: 0 0 0 1px var(--alert), 0 0 18px rgba(255, 0, 85, .25); }
.field.is-invalid .field-label { color: var(--alert); }

.pulse-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--neon); margin-right: 4px; box-shadow: 0 0 8px var(--neon); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- Reveal (JS adds .is-in) ---------- */
.reveal { opacity: 0; transform: translateY(30px); }
.reveal.is-in { opacity: 1; transform: none; transition: opacity .9s ease, transform .9s cubic-bezier(.2, .8, .2, 1); }

/* ---------- Mobile tuning ---------- */
@media (max-width: 767px) {
  #repair-poster { object-position: 10% 50%; }
  .hero-words { font-size: 22vw; }
}

/* ============================================================
   REDUCED MOTION — static, calm fallback
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
  #hero-canvas, #repair-canvas { display: none !important; }
  .hero-word { opacity: 0 !important; }
  .hero-word[data-i="2"] { opacity: 1 !important; }
  .reveal { opacity: 1; transform: none; }
  .bento-card:hover .bento-img { transform: scale(1.04); }
  .glitch::before, .glitch::after { display: none; }
}
