/* ==========================================================================
   Shell — shared by every page: tokens, CRT screen, nav, cursor, channel switch
   ========================================================================== */

:root {
  --screen: #e8e5df;
  --paper: #f3f0ea;
  --ink: #1c1b19;
  --ink-soft: #5b5750;
  --ink-faint: rgba(28, 27, 25, 0.16);
  --bezel: #0a0a09;
  --about: #e5432d;
  --services: #2a47d8;
  --amber: #f1b65c;
  --osd: #7dff8c;

  --font-display: "Anton", Impact, "Arial Narrow", sans-serif;
  --font-ui: "Space Grotesk", system-ui, sans-serif;
  --font-osd: "VT323", ui-monospace, monospace;

  /* Distance from the viewport edge to the corners of the curved glass */
  --bezel-corner: 36px;
  --bezel-mid: 9px;
  --gutter: calc(var(--bezel-corner) + 28px);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (max-width: 768px) {
  :root {
    --bezel-corner: 12px;
    --bezel-mid: 4px;
    --gutter: 28px;
  }
}

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

html {
  background: var(--bezel);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  background: var(--screen);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

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

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:focus-visible {
  outline: 2px solid var(--services);
  outline-offset: 4px;
}

/* No widows: even out headings, and keep paragraphs from ending on one lonely
   word (shell.js also ties the last two words together for older browsers). */
h1,
h2,
h3,
.display {
  text-wrap: balance;
}

p,
li,
dd,
figcaption,
blockquote,
summary {
  text-wrap: pretty;
}

/* ---------- CRT glass: scanlines, grain, rolling bars, vignette, bezel ---------- */

.crt {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

.crt > * {
  position: absolute;
  inset: 0;
}

.crt__scan {
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.06) 0 1px,
    transparent 1px 3px
  );
}

.crt__grain {
  opacity: 0.16;
  mix-blend-mode: overlay;
  background-size: 192px 192px;
}

.crt__roll span {
  position: absolute;
  left: 0;
  right: 0;
  top: -25vh;
  height: 22vh;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(255, 255, 255, 0.07) 45%,
    rgba(0, 0, 0, 0.03) 55%,
    transparent
  );
  animation: crt-roll var(--dur, 11s) linear infinite;
  animation-delay: var(--delay, 0s);
}

@keyframes crt-roll {
  to {
    transform: translateY(150vh);
  }
}

.crt__vignette {
  background:
    radial-gradient(120% 95% at 50% 50%, transparent 58%, rgba(0, 0, 0, 0.2) 100%),
    radial-gradient(60% 40% at 50% 0%, rgba(255, 255, 255, 0.08), transparent 70%);
}

.crt__bezel {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.crt__bezel .frame {
  fill: var(--bezel);
}

.crt__bezel .glass-edge {
  fill: none;
  stroke: rgba(255, 255, 255, 0.5);
  stroke-width: 1.2;
  filter: blur(0.6px);
}

.crt__bezel .glass-shade {
  fill: none;
  stroke: rgba(0, 0, 0, 0.55);
  stroke-width: 26;
  filter: blur(14px);
}

/* ---------- Nav ---------- */

.nav {
  position: fixed;
  z-index: 40;
  top: calc(var(--bezel-corner) + 18px);
  left: var(--gutter);
  right: var(--gutter);
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 18px;
  border: 1px solid var(--ink-faint);
  border-radius: 12px;
  background: rgba(243, 240, 234, 0.32);
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.nav__brand {
  white-space: nowrap;
}

.nav__links {
  display: flex;
  gap: 22px;
}

.nav__links a {
  position: relative;
  padding: 6px 0;
  color: var(--ink-soft);
  transition: color 0.3s;
}

.nav__links a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1px;
  height: 1.5px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.45s var(--ease-out);
}

.nav__links a:hover,
.nav__links a[aria-current="page"] {
  color: var(--ink);
}

.nav__links a:hover::after,
.nav__links a[aria-current="page"]::after {
  transform: scaleX(1);
  transform-origin: left;
}

.nav__menu {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}

.nav__menu i {
  position: relative;
  width: 18px;
  height: 8px;
}

.nav__menu i::before,
.nav__menu i::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 1.5px;
  background: currentColor;
  transition: transform 0.4s var(--ease-out), top 0.4s var(--ease-out);
}

.nav__menu i::before { top: 0; }
.nav__menu i::after { top: 6.5px; }

html.menu-open .nav__menu i::before { top: 3.25px; transform: rotate(45deg); }
html.menu-open .nav__menu i::after { top: 3.25px; transform: rotate(-45deg); }

@media (max-width: 920px) {
  .nav__links {
    display: none;
  }
  .nav__menu {
    display: inline-flex;
  }
}

@media (max-width: 480px) {
  .nav {
    padding: 0 14px;
    font-size: 10px;
    letter-spacing: 0.12em;
  }
}

/* ---------- Menu overlay (narrow screens) ---------- */

.menu {
  position: fixed;
  inset: 0;
  z-index: 39;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(var(--bezel-corner) + 90px) var(--gutter) calc(var(--bezel-corner) + 40px);
  background: #121110;
  color: var(--paper);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s, visibility 0s 0.35s;
}

html.menu-open .menu {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s;
}

html.menu-open body {
  overflow: hidden;
}

html.menu-open .nav {
  color: var(--paper);
  border-color: rgba(243, 240, 234, 0.2);
  background: transparent;
}

.menu a {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(243, 240, 234, 0.12);
  font-family: var(--font-display);
  font-size: clamp(34px, 10vw, 64px);
  line-height: 1;
  text-transform: uppercase;
  transform: translateY(14px);
  opacity: 0;
  transition: transform 0.6s var(--ease-out), opacity 0.6s var(--ease-out), color 0.3s;
}

html.menu-open .menu a {
  transform: none;
  opacity: 1;
}

.menu a[aria-current="page"] {
  color: var(--amber);
}

.menu small {
  font-family: var(--font-osd);
  font-size: 20px;
  color: var(--osd);
}

/* ---------- Cursor (fine pointers only) ---------- */

.cursor {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  html.has-cursor,
  html.has-cursor a,
  html.has-cursor button {
    cursor: none;
  }

  .cursor {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 70;
    pointer-events: none;
  }

  .cursor__dot,
  .cursor__ring {
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 50%;
    will-change: transform;
  }

  .cursor__dot {
    width: 6px;
    height: 6px;
    margin: -3px 0 0 -3px;
    background: var(--ink);
  }

  .cursor__ring {
    width: 34px;
    height: 34px;
    margin: -17px 0 0 -17px;
    border: 1.5px solid var(--ink);
    transition: width 0.35s var(--ease-out), height 0.35s var(--ease-out),
      margin 0.35s var(--ease-out), border-color 0.3s, background-color 0.3s;
  }

  .cursor.is-hover .cursor__ring {
    width: 64px;
    height: 64px;
    margin: -32px 0 0 -32px;
    background: rgba(28, 27, 25, 0.06);
  }

  .cursor.is-dark .cursor__dot {
    background: var(--paper);
  }

  .cursor.is-dark .cursor__ring {
    border-color: var(--paper);
  }

  .cursor.is-hidden {
    opacity: 0;
  }
}

/* ---------- Channel switch (page transition) ---------- */

.channel {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: none;
  background: #111;
  pointer-events: none;
}

.channel.is-on {
  display: block;
  pointer-events: all;
}

.channel__static {
  position: absolute;
  inset: 0;
  background-size: 160px 160px;
  opacity: 0.85;
  filter: contrast(1.6) brightness(0.9);
}

.channel__osd {
  position: absolute;
  top: calc(var(--bezel-corner) + 36px);
  right: calc(var(--gutter) + 8px);
  text-align: right;
  font-family: var(--font-osd);
  color: var(--osd);
  text-shadow: 0 0 10px rgba(125, 255, 140, 0.65), 2px 0 0 rgba(255, 0, 80, 0.35);
  line-height: 0.9;
}

.channel__nr {
  display: block;
  font-size: clamp(56px, 9vw, 120px);
}

.channel__name {
  display: block;
  font-size: clamp(22px, 2.6vw, 34px);
  letter-spacing: 0.08em;
}

.channel.is-leaving {
  animation: channel-out 0.45s steps(6) forwards;
}

@keyframes channel-out {
  0% {
    opacity: 1;
  }
  60% {
    opacity: 0.85;
    transform: scaleY(0.6);
  }
  100% {
    opacity: 0;
    transform: scaleY(0.02);
  }
}

/* ---------- Footer (inner pages) ---------- */

.foot {
  padding: 0 var(--gutter) calc(var(--bezel-corner) + 28px);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

@media (prefers-reduced-motion: reduce) {
  .crt__roll span {
    animation: none;
    display: none;
  }
}
