@layer reset, tokens, base, layout, components, motion;

@layer tokens {
  :root {
    color-scheme: light dark;

    --ink: oklch(0.22 0.03 255);
    --muted: oklch(0.48 0.03 250);
    --line: oklch(0.88 0.015 250);
    --paper: oklch(0.995 0.005 250);
    --wash: oklch(0.96 0.01 250);
    --ops: oklch(0.17 0.025 255);
    --ops-2: oklch(0.22 0.03 255);
    --ops-ink: oklch(0.95 0.01 250);
    --ops-muted: oklch(0.72 0.02 250);
    --ember: oklch(0.55 0.22 25);
    --ember-deep: oklch(0.45 0.2 25);
    --signal: oklch(0.58 0.18 250);
    --fire: oklch(0.62 0.22 35);
    --police: oklch(0.58 0.16 255);
    --ems: oklch(0.62 0.17 150);
    --coastal: oklch(0.68 0.12 220);
    --ok: oklch(0.62 0.15 155);
    --warn: oklch(0.75 0.14 75);
    --shell: 100%;
    --shell-pad: 2rem;
    --narrow: 42rem;
    --radius: 6px;
    --font: "Source Sans 3", system-ui, sans-serif;
    --display: "Manrope", system-ui, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, monospace;
    --header-h: 4.5rem;
    --rail-h: 2.15rem;
  }
}

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

  html {
    scroll-behavior: smooth;
    width: 100%;
  }

  body {
    margin: 0;
    width: 100%;
    min-width: 100%;
  }

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

  a {
    color: inherit;
  }

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

@layer base {
  body {
    font-family: var(--font);
    color: var(--ink);
    background: var(--paper);
    line-height: 1.6;
    font-size: 1.05rem;
    overflow-x: clip;
  }

  body.nav-open {
    overflow: hidden;
  }

  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }

  .skip-link {
    position: absolute;
    left: 1rem;
    top: -3rem;
    z-index: 100;
    padding: 0.6rem 0.9rem;
    background: var(--ember);
    color: #fff;
    text-decoration: none;
    border-radius: var(--radius);
  }

  .skip-link:focus {
    top: 1rem;
  }
}

@layer layout {
  .shell {
    width: 100%;
    max-width: none;
    margin-inline: 0;
    padding-inline: var(--shell-pad);
  }

  .shell.narrow,
  .narrow {
    width: 100%;
    max-width: var(--narrow);
    margin-inline: auto;
    padding-inline: var(--shell-pad);
  }

  .band {
    width: 100%;
    padding: clamp(4rem, 8vw, 6.5rem) 0;
    background: var(--paper);
  }

  .band-soft {
    background: var(--wash);
  }

  .band-dark {
    background:
      radial-gradient(900px 420px at 10% 0%, oklch(0.35 0.12 25 / 0.28), transparent 60%),
      radial-gradient(700px 380px at 90% 20%, oklch(0.4 0.12 250 / 0.22), transparent 55%),
      linear-gradient(180deg, var(--ops), var(--ops-2));
    color: var(--ops-ink);
  }

  .band-dark .lede,
  .band-dark .ops-item p {
    color: var(--ops-muted);
  }

  .band-request {
    background:
      linear-gradient(180deg, var(--wash), var(--paper));
  }

  .section-head {
    max-width: 40rem;
    margin-bottom: clamp(2rem, 4vw, 3rem);
  }

  .section-head.narrow,
  .shell.narrow .section-head {
    margin-inline: auto;
  }
}

@layer components {
  .status-rail {
    position: sticky;
    top: 0;
    z-index: 40;
    width: 100%;
    height: var(--rail-h);
    background: #070b12;
    color: #d7e0ec;
    border-bottom: 1px solid oklch(1 0 0 / 0.08);
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
  }

  .status-rail-inner {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    overflow: auto;
    white-space: nowrap;
    padding-inline: var(--shell-pad);
  }

  .status-label {
    font-weight: 600;
    color: #fff;
  }

  .status-sep {
    width: 1px;
    height: 0.9rem;
    background: oklch(1 0 0 / 0.18);
  }

  .ops-clock {
    color: oklch(0.78 0.05 220);
  }

  .status-chip {
    padding: 0.15rem 0.45rem;
    border: 1px solid oklch(1 0 0 / 0.16);
    border-radius: 999px;
    color: oklch(0.82 0.02 250);
  }

  .pulse-dot {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 0 oklch(0.62 0.15 155 / 0.7);
    animation: pulse 1.8s ease-out infinite;
  }

  .site-header {
    position: sticky;
    top: var(--rail-h);
    z-index: 35;
    width: 100%;
    background: oklch(1 0 0 / 0.86);
    backdrop-filter: blur(14px) saturate(1.2);
    border-bottom: 1px solid var(--line);
  }

  .header-inner {
    min-height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-inline: var(--shell-pad);
  }

  .brand {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
  }

  .brand img {
    width: 40px;
    height: 40px;
    object-fit: contain;
  }

  .brand strong {
    display: block;
    font-family: var(--display);
    font-size: 0.98rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
  }

  .brand small {
    display: block;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 500;
  }

  .nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.2rem 1.15rem;
    font-size: 0.94rem;
    font-weight: 600;
  }

  .nav a {
    text-decoration: none;
    color: var(--muted);
  }

  .nav a:hover,
  .nav a:focus-visible {
    color: var(--ink);
  }

  .nav-cta {
    color: #fff !important;
    background: var(--ember);
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius);
  }

  .nav-cta:hover,
  .nav-cta:focus-visible {
    background: var(--ember-deep);
  }

  .nav-toggle {
    display: none;
    width: 2.6rem;
    height: 2.6rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    cursor: pointer;
    place-items: center;
    gap: 0.35rem;
  }

  .nav-toggle span:not(.sr-only) {
    display: block;
    width: 1.1rem;
    height: 2px;
    background: var(--ink);
  }

  .hero {
    position: relative;
    width: 100%;
    min-height: min(92vh, 820px);
    display: grid;
    align-items: end;
    overflow: hidden;
    color: #f5f8fc;
  }

  .hero-media {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: url("../assets/mcd_hero.png?v=control-room-3") center 35% / cover no-repeat;
  }

  .hero-shade {
    position: absolute;
    inset: 0;
    background:
      linear-gradient(
        105deg,
        oklch(0.12 0.03 255 / 0.72) 0%,
        oklch(0.12 0.03 255 / 0.42) 34%,
        oklch(0.12 0.03 255 / 0.12) 58%,
        oklch(0.12 0.03 255 / 0.05) 100%
      ),
      linear-gradient(180deg, oklch(0.12 0.03 255 / 0.18) 0%, transparent 35%, oklch(0.1 0.03 255 / 0.55) 100%);
  }

  .hero-scan {
    display: none;
  }

  .hero-content {
    position: relative;
    z-index: 1;
    max-width: none;
    width: 100%;
    padding-block: 6.5rem 4.25rem;
    padding-inline: var(--shell-pad);
  }

  .hero-content > * {
    max-width: 40rem;
  }

  .hero-brand {
    margin: 0 0 0.9rem;
    font-family: var(--display);
    font-size: clamp(2.5rem, 7vw, 4.2rem);
    font-weight: 800;
    line-height: 0.96;
    letter-spacing: -0.035em;
    text-wrap: balance;
    text-shadow: 0 2px 28px oklch(0 0 0 / 0.55);
  }

  .hero h1 {
    margin: 0 0 0.95rem;
    max-width: 18ch;
    font-family: var(--display);
    font-size: clamp(1.2rem, 2.5vw, 1.55rem);
    font-weight: 650;
    line-height: 1.3;
    color: oklch(0.95 0.01 250);
    text-shadow: 0 2px 18px oklch(0 0 0 / 0.5);
  }

  .hero-lead {
    margin: 0 0 1.7rem;
    max-width: 38ch;
    color: oklch(0.9 0.015 250);
    text-shadow: 0 1px 14px oklch(0 0 0 / 0.45);
  }

  .hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 2rem;
  }

  .hero-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin: 0;
    padding-top: 1.25rem;
    border-top: 1px solid oklch(1 0 0 / 0.16);
    max-width: 28rem;
  }

  .hero-metrics dt {
    font-family: var(--display);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.03em;
  }

  .hero-metrics dd {
    margin: 0.1rem 0 0;
    color: oklch(0.78 0.02 250);
    font-size: 0.88rem;
  }

  .btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.9rem;
    padding: 0.7rem 1.2rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  }

  .btn:hover,
  .btn:focus-visible {
    transform: translateY(-1px);
  }

  .btn-primary {
    background: var(--ember);
    color: #fff;
  }

  .btn-primary:hover,
  .btn-primary:focus-visible {
    background: var(--ember-deep);
  }

  .btn-ghost {
    background: transparent;
    border-color: oklch(1 0 0 / 0.4);
    color: #fff;
  }

  .btn-ghost:hover,
  .btn-ghost:focus-visible {
    border-color: #fff;
  }

  .btn-secondary {
    background: transparent;
    border-color: var(--line);
    color: var(--ink);
  }

  .eyebrow {
    margin: 0 0 0.55rem;
    font-family: var(--mono);
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ember);
  }

  .band-dark .eyebrow {
    color: oklch(0.78 0.12 25);
  }

  h2 {
    margin: 0 0 0.8rem;
    font-family: var(--display);
    font-size: clamp(1.9rem, 3.6vw, 2.55rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.12;
    text-wrap: balance;
  }

  .lede {
    margin: 0;
    color: var(--muted);
    font-size: 1.08rem;
    max-width: 46ch;
  }

  .split {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: clamp(1.5rem, 4vw, 3rem);
    align-items: start;
  }

  .split-copy > p {
    margin: 0 0 1.5rem;
    max-width: 48ch;
  }

  .detail-list {
    margin: 0;
    padding: 0;
  }

  .detail-list > div {
    padding: 1rem 0;
    border-top: 1px solid var(--line);
  }

  .detail-list > div:last-child {
    border-bottom: 1px solid var(--line);
  }

  .detail-list dt {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ember);
    margin-bottom: 0.25rem;
  }

  .detail-list dd {
    margin: 0;
  }

  .ops-panel {
    border: 1px solid oklch(0.3 0.03 255);
    border-radius: var(--radius);
    background:
      linear-gradient(180deg, oklch(0.2 0.03 255), oklch(0.16 0.025 255));
    color: var(--ops-ink);
    overflow: hidden;
  }

  .ops-panel header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid oklch(1 0 0 / 0.08);
    font-family: var(--mono);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
  }

  .panel-tag {
    color: oklch(0.78 0.12 25);
  }

  .ops-panel ul {
    list-style: none;
    margin: 0;
    padding: 0.35rem 0;
  }

  .ops-panel li {
    display: grid;
    grid-template-columns: 4.2rem 1fr auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.85rem 1rem;
    border-top: 1px solid oklch(1 0 0 / 0.05);
    font-size: 0.92rem;
  }

  .svc {
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
  }

  .svc.fire {
    color: var(--fire);
  }
  .svc.police {
    color: var(--police);
  }
  .svc.ems {
    color: var(--ems);
  }
  .svc.coastal {
    color: var(--coastal);
  }

  .state {
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .state.online {
    color: var(--ok);
  }

  .ops-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 1.5rem;
  }

  .ops-item {
    padding: 1.35rem 0;
    border-top: 1px solid oklch(1 0 0 / 0.12);
  }

  .ops-item h3 {
    margin: 0 0 0.45rem;
    font-family: var(--display);
    font-size: 1.15rem;
    font-weight: 750;
  }

  .ops-item p {
    margin: 0;
    max-width: 36ch;
  }

  .world-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
  }

  .world-tile {
    padding: 1.25rem 1.15rem 1.15rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    transition: border-color 0.15s ease, transform 0.15s ease;
  }

  .world-tile:hover,
  .world-tile:focus-within {
    border-color: oklch(0.7 0.05 25);
    transform: translateY(-2px);
  }

  .world-tile.is-selected {
    border-color: var(--ember);
    box-shadow: inset 0 0 0 1px var(--ember);
  }

  .world-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
  }

  .world-code {
    font-family: var(--display);
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--ember);
    letter-spacing: 0.04em;
  }

  .live {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--mono);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .world-tile h3 {
    margin: 0 0 0.2rem;
    font-family: var(--display);
    font-size: 1.15rem;
  }

  .world-domain {
    margin: 0 0 1.2rem;
    color: var(--muted);
    font-size: 0.92rem;
  }

  .world-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
  }

  .world-actions a,
  .world-actions button {
    appearance: none;
    border: 1px solid var(--line);
    background: var(--wash);
    color: var(--ink);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    font-weight: 650;
    font-size: 0.88rem;
    text-decoration: none;
    cursor: pointer;
  }

  .world-actions button,
  .world-actions a:last-child {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
  }

  .page-request {
    min-height: calc(100vh - var(--rail-h) - 4rem);
    padding-block: clamp(2.5rem, 6vw, 4.5rem);
  }

  .page-request h1 {
    margin: 0 0 0.65rem;
    font-family: var(--display);
    font-size: clamp(1.85rem, 3.5vw, 2.6rem);
    line-height: 1.15;
  }

  .form-back {
    margin: 1.75rem 0 0;
    text-align: center;
  }

  .form-back a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.95rem;
  }

  .form-back a:hover {
    color: var(--ink);
  }

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

  .join-steps li {
    display: grid;
    grid-template-columns: 3.2rem 1fr;
    gap: 1rem;
    padding: 1.2rem 0;
    border-top: 1px solid var(--line);
  }

  .join-steps li:last-child {
    border-bottom: 1px solid var(--line);
  }

  .step-num {
    font-family: var(--mono);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ember);
    padding-top: 0.2rem;
  }

  .join-steps h3 {
    margin: 0 0 0.3rem;
    font-family: var(--display);
    font-size: 1.1rem;
  }

  .join-steps p {
    margin: 0;
    color: var(--muted);
  }

  .join-steps a {
    color: var(--ember);
    font-weight: 650;
  }

  .form {
    display: grid;
    gap: 1.1rem;
  }

  .field {
    display: grid;
    gap: 0.4rem;
  }

  .field label {
    font-weight: 650;
    font-size: 0.95rem;
  }

  .field abbr {
    text-decoration: none;
    color: var(--ember);
  }

  .field input,
  .field select,
  .field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
    padding: 0.8rem 0.9rem;
  }

  .field input:focus,
  .field select:focus,
  .field textarea:focus {
    outline: 2px solid oklch(0.55 0.22 25 / 0.28);
    outline-offset: 1px;
    border-color: oklch(0.72 0.08 25);
  }

  .field textarea {
    resize: vertical;
    min-height: 5.5rem;
  }

  .form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .form-status {
    margin: 0;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 0.95rem;
  }

  .form-status[data-tone="ok"] {
    border-color: oklch(0.8 0.08 155);
    color: oklch(0.4 0.1 155);
    background: oklch(0.97 0.02 155);
  }

  .form-status[data-tone="error"] {
    border-color: oklch(0.8 0.08 25);
    color: oklch(0.45 0.16 25);
    background: oklch(0.97 0.02 25);
  }

  .form-status[data-tone="warn"] {
    border-color: oklch(0.84 0.08 85);
    color: oklch(0.48 0.1 75);
    background: oklch(0.98 0.02 90);
  }

  .site-footer {
    width: 100%;
    background: #070b12;
    color: oklch(0.78 0.02 250);
    border-top: 1px solid oklch(1 0 0 / 0.08);
  }

  .footer-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr auto;
    gap: 1.5rem;
    align-items: end;
    padding-block: 2.25rem;
    padding-inline: var(--shell-pad);
  }

  .footer-brand {
    margin: 0 0 0.25rem;
    font-family: var(--display);
    font-weight: 800;
    color: #fff;
  }

  .footer-note,
  .footer-copy {
    margin: 0;
    font-size: 0.9rem;
  }

  .footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem 1.25rem;
  }

  .footer-links a {
    color: #fff;
    text-decoration: none;
    font-weight: 650;
  }

  .footer-links a:hover,
  .footer-links a:focus-visible {
    color: oklch(0.78 0.12 25);
  }
}

@layer motion {
  .reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 0.7s ease, transform 0.7s ease;
  }

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

  @keyframes pulse {
    0% {
      box-shadow: 0 0 0 0 oklch(0.62 0.15 155 / 0.55);
    }
    70% {
      box-shadow: 0 0 0 0.55rem oklch(0.62 0.15 155 / 0);
    }
    100% {
      box-shadow: 0 0 0 0 oklch(0.62 0.15 155 / 0);
    }
  }

  @keyframes drift {
    from {
      transform: scale(1.04) translate3d(0, 0, 0);
    }
    to {
      transform: scale(1.08) translate3d(-1.1%, -0.7%, 0);
    }
  }

  @keyframes scan {
    from {
      transform: translateY(0);
    }
    to {
      transform: translateY(4px);
    }
  }
}

@media (max-width: 900px) {
  .split,
  .ops-grid,
  .world-grid,
  .footer-grid {
    grid-template-columns: 1fr;
  }

  .nav-toggle {
    display: grid;
  }

  .nav {
    position: fixed;
    inset: calc(var(--rail-h) + var(--header-h)) 0 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 1rem 1.25rem 2rem;
    background: #fff;
    border-top: 1px solid var(--line);
    overflow: auto;
  }

  .nav.is-open {
    display: flex;
  }

  .nav a {
    padding: 0.95rem 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-cta {
    margin-top: 0.75rem;
    text-align: center;
  }

  .hero-metrics {
    grid-template-columns: 1fr;
    max-width: 14rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .hero-media,
  .hero-scan,
  .pulse-dot,
  .btn {
    animation: none;
    transition: none;
  }
}
