/* Shared chrome for every marketing page: atmosphere, header, navigation, footer, dialogs. */
@layer components {
  .atmosphere {
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    overflow: hidden;
  }
  /* Rain brightness lives in scripts/motion.js so the decoder lens can exceed it. */
  #data-rain {
    width: 100%;
    height: 100%;
  }
  .technical-grid {
    position: absolute;
    inset: 0;
    background:
      radial-gradient(
        ellipse 70% 55% at 78% 8%,
        rgb(34 140 255 / 16%),
        transparent 70%
      ),
      radial-gradient(
        ellipse 50% 40% at 6% 92%,
        rgb(67 216 242 / 8%),
        transparent 70%
      ),
      linear-gradient(rgb(140 200 235 / 4%) 1px, transparent 1px) 0 0 / 80px
        80px,
      linear-gradient(90deg, rgb(140 200 235 / 4%) 1px, transparent 1px) 0 0 /
        80px 80px;
    mask-image: linear-gradient(180deg, #000 0%, rgb(0 0 0 / 55%) 100%);
  }

  /* Header */
  .site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--header-h);
    background: rgb(7 12 19 / 74%);
    -webkit-backdrop-filter: blur(18px) saturate(130%);
    backdrop-filter: blur(18px) saturate(130%);
    border-bottom: 1px solid rgb(140 200 235 / 10%);
  }
  .header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    height: 100%;
  }
  .brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    text-decoration: none;
    flex: none;
  }
  .brand-mark {
    width: 44px;
    height: auto;
    filter: drop-shadow(0 0 14px rgb(67 216 242 / 25%));
  }
  .brand-word {
    font: 700 1.2rem/1 var(--display);
    letter-spacing: 0.02em;
    white-space: nowrap;
  }
  .brand-word b {
    color: var(--cyan);
  }
  .brand-word i {
    font-style: normal;
    color: var(--cyan);
  }
  .primary-nav {
    display: flex;
    align-items: center;
    gap: clamp(14px, 2vw, 30px);
  }
  .primary-nav > a,
  .nav-services-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font: 500 1rem/1 var(--display);
    color: #d7e3ee;
    text-decoration: none;
    transition: color 0.2s;
  }
  .primary-nav > a:hover,
  .nav-services-link:hover,
  .primary-nav > a[aria-current] {
    color: #fff;
  }
  .primary-nav > a[aria-current]::after,
  .nav-services-link[aria-current]::after,
  .nav-services[data-current] .nav-services-link::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 6px;
    height: 2px;
    background: var(--cyan);
    box-shadow: 0 0 10px var(--cyan);
  }
  .primary-nav > .nav-cta {
    padding: 0 18px;
    min-height: 44px;
    border: 1px solid var(--cyan);
    color: var(--cyan);
    clip-path: polygon(
      10px 0,
      100% 0,
      100% calc(100% - 10px),
      calc(100% - 10px) 100%,
      0 100%,
      0 10px
    );
    transition:
      background-color 0.2s,
      color 0.2s;
  }
  .primary-nav > .nav-cta:hover {
    background: var(--cyan);
    color: #04121a;
  }
  .primary-nav > .nav-cta::after {
    display: none;
  }

  /* Services disclosure: the link works alone; the toggle reveals the four pages. */
  .nav-services {
    position: relative;
    display: inline-flex;
    align-items: center;
  }
  .nav-services-toggle {
    display: inline-grid;
    place-items: center;
    width: 32px;
    min-height: 44px;
    color: var(--muted);
  }
  .nav-services-toggle svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    transition: transform 0.2s;
  }
  .nav-services-toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
  }
  .services-menu {
    list-style: none;
  }
  .services-menu a {
    display: grid;
    gap: 2px;
    padding: 12px 14px;
    text-decoration: none;
    border-left: 2px solid transparent;
    transition:
      background-color 0.2s,
      border-color 0.2s;
  }
  .services-menu a:hover,
  .services-menu a[aria-current] {
    background: rgb(67 216 242 / 8%);
    border-left-color: var(--cyan);
  }
  .services-menu strong {
    font: 700 1.02rem/1.25 var(--display);
    color: #fff;
  }
  .services-menu span {
    font-size: 0.88rem;
    line-height: 1.4;
    color: var(--muted);
  }
  @media (min-width: 981px) {
    .services-menu {
      position: absolute;
      top: calc(100% + 14px);
      left: -16px;
      width: 330px;
      padding: 8px;
      background: rgb(9 16 26 / 96%);
      border: 1px solid var(--line);
      box-shadow: 0 30px 60px rgb(0 0 0 / 50%);
      -webkit-backdrop-filter: blur(18px);
      backdrop-filter: blur(18px);
    }
    .js .services-menu:not([data-open]) {
      display: none;
    }
    html:not(.js) .services-menu {
      display: none;
    }
  }

  .menu-toggle {
    display: none;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 0 4px;
    font: 500 1rem/1 var(--display);
  }
  .menu-lines,
  .menu-lines::before {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--cyan);
    transition: transform 0.25s var(--ease-out);
  }
  .menu-lines {
    position: relative;
    box-shadow: 0 -7px 0 var(--cyan);
  }
  .menu-lines::before {
    content: "";
    position: absolute;
    top: 7px;
  }
  .menu-toggle[aria-expanded="true"] .menu-lines {
    box-shadow: none;
    transform: rotate(45deg);
  }
  .menu-toggle[aria-expanded="true"] .menu-lines::before {
    top: 0;
    transform: rotate(-90deg);
  }

  @media (max-width: 980px) {
    :root {
      --header-h: 68px;
    }
    .menu-toggle:not([hidden]) {
      display: inline-flex;
    }
    .brand-mark {
      width: 38px;
    }
    .brand-word {
      font-size: 1.05rem;
    }
    /* The header's backdrop-filter makes it the containing block for this fixed
       panel, so size it explicitly instead of relying on a bottom inset. */
    .js .primary-nav {
      position: fixed;
      top: var(--header-h);
      left: 0;
      right: 0;
      height: calc(100dvh - var(--header-h));
      z-index: 29;
      display: flex;
      flex-direction: column;
      align-items: stretch;
      gap: 0;
      padding: 18px var(--gutter) max(28px, env(safe-area-inset-bottom));
      overflow-y: auto;
      overscroll-behavior: contain;
      background:
        radial-gradient(
          ellipse 80% 50% at 90% 0%,
          rgb(34 140 255 / 18%),
          transparent 70%
        ),
        #05090f;
      animation: nav-in 0.3s var(--ease-out);
    }
    .js .primary-nav[hidden] {
      display: none;
    }
    .primary-nav > a,
    .nav-services-link {
      min-height: 58px;
      font-size: 1.6rem;
      border-bottom: 1px solid rgb(140 200 235 / 10%);
    }
    .primary-nav > a[aria-current]::after,
    .nav-services-link[aria-current]::after,
    .nav-services[data-current] .nav-services-link::after {
      top: 50%;
      bottom: auto;
      left: -14px;
      right: auto;
      width: 4px;
      height: 22px;
      transform: translateY(-50%);
    }
    .nav-services {
      display: block;
    }
    .nav-services-link {
      display: flex;
    }
    .nav-services-toggle {
      display: none;
    }
    .services-menu {
      display: grid;
      padding: 6px 0 14px;
      border-bottom: 1px solid rgb(140 200 235 / 10%);
    }
    .primary-nav > .nav-cta {
      justify-content: center;
      margin-top: 24px;
      min-height: 56px;
      font-size: 1.15rem;
      background: var(--cyan);
      color: #04121a;
    }
    html:not(.js) .header-inner {
      flex-wrap: wrap;
    }
    html:not(.js) .site-header {
      height: auto;
      position: relative;
    }
    html:not(.js) .primary-nav {
      flex-wrap: wrap;
      gap: 4px 18px;
      padding-bottom: 12px;
    }
    html:not(.js) .services-menu {
      display: none;
    }
  }
  body.nav-open {
    overflow: hidden;
  }
  @keyframes nav-in {
    from {
      opacity: 0;
      transform: translateY(-8px);
    }
  }

  /* Footer */
  .site-footer {
    position: relative;
    padding: 72px 0 32px;
    border-top: 1px solid var(--line);
    background: linear-gradient(180deg, rgb(4 7 12 / 40%), var(--bg-deep));
  }
  .footer-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) repeat(2, minmax(0, 1fr));
    gap: 40px;
  }
  .footer-intro p {
    max-width: 36ch;
    margin: 18px 0 14px;
    color: var(--muted);
  }
  .footer-intro .footer-email {
    font: 700 1.05rem/1.3 var(--display);
    color: var(--cyan);
    text-decoration: none;
  }
  .footer-intro .footer-email:hover {
    text-decoration: underline;
  }
  .footer-nav h2 {
    margin-bottom: 12px;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    color: var(--faint);
  }
  .footer-nav ul {
    list-style: none;
    display: grid;
    gap: 2px;
  }
  .footer-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    color: #d7e3ee;
    text-decoration: none;
  }
  .footer-nav a:hover {
    color: var(--cyan);
    text-decoration: underline;
  }
  .footer-bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    margin-top: 56px;
    padding-top: 22px;
    border-top: 1px solid rgb(140 200 235 / 10%);
    font-size: 0.9rem;
    color: var(--faint);
  }
  .footer-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 18px;
  }
  .footer-controls button,
  .footer-controls a {
    min-height: 44px;
    color: #c9d6e2;
    font-size: 0.9rem;
    text-decoration: underline;
    text-decoration-color: rgb(201 214 226 / 35%);
  }
  .footer-controls button:hover,
  .footer-controls a:hover {
    color: var(--cyan);
  }
  .footer-controls button:disabled {
    color: var(--faint);
    text-decoration: none;
  }
  .footer-controls a {
    display: inline-flex;
    align-items: center;
  }
  @media (max-width: 760px) {
    .footer-grid {
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
    .footer-intro {
      grid-column: 1 / -1;
    }
  }
  @media (max-width: 380px) {
    .footer-grid {
      grid-template-columns: minmax(0, 1fr);
    }
  }

  /* Native dialogs */
  .dialog {
    width: min(640px, calc(100% - 24px));
    max-height: min(88vh, 820px);
    padding: 0;
    border: 1px solid rgb(140 200 235 / 30%);
    background: #0a121d;
    color: var(--text);
    box-shadow: 0 40px 120px rgb(0 0 0 / 70%);
    overscroll-behavior: contain;
  }
  .dialog::backdrop {
    background: rgb(2 5 9 / 78%);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
  }
  .dialog[open] {
    animation: dialog-in 0.35s var(--ease-out);
  }
  @keyframes dialog-in {
    from {
      opacity: 0;
      transform: translateY(16px) scale(0.98);
    }
  }
  .dialog-inner {
    position: relative;
    padding: clamp(26px, 5vw, 44px);
  }
  .dialog-inner h2 {
    margin: 10px 0 18px;
    font-size: clamp(1.8rem, 5vw, 2.4rem);
  }
  .dialog-inner p {
    margin-bottom: 14px;
    color: #cfdae6;
  }
  .dialog-inner h3 {
    margin: 22px 0 6px;
    font-size: 1.1rem;
    color: var(--cyan);
  }
  .dialog-lead {
    font-size: 1.1rem;
  }
  .dialog-close {
    position: absolute;
    top: 10px;
    right: 10px;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    font-size: 1.8rem;
    line-height: 1;
    color: var(--muted);
    border: 1px solid transparent;
  }
  .dialog-close:hover {
    color: #fff;
    border-color: var(--line);
  }
  .tags {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 18px 0 26px;
  }
  .tags li {
    padding: 5px 11px;
    border: 1px solid var(--line);
    font-size: 0.88rem;
    color: #cfe9f6;
  }

  /* Glass surfaces keep the rain softly visible behind interface panels. */
  .glass {
    background: linear-gradient(
      140deg,
      rgb(232 247 255 / 9%),
      rgb(150 205 240 / 3%) 55%,
      rgb(225 244 255 / 5%)
    );
    -webkit-backdrop-filter: blur(4px) saturate(150%) brightness(112%);
    backdrop-filter: blur(4px) saturate(150%) brightness(112%);
    border: 1px solid rgb(216 241 255 / 22%);
    box-shadow:
      inset 0 1px 0 rgb(255 255 255 / 22%),
      0 24px 60px rgb(0 0 0 / 28%);
  }
  @supports not (
    (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))
  ) {
    .site-header,
    .glass {
      background: rgb(10 20 33 / 96%);
    }
  }
  @media (prefers-reduced-transparency: reduce), (forced-colors: active) {
    .site-header,
    .glass {
      background: var(--panel);
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }
  }
  /* Lite devices (scripts/perf-tier.js): re-blurring panels over the moving
     rain every frame is the costliest surface effect on weak or software
     GPUs, so they keep their tint and become near-solid instead. Capable
     devices are unaffected. */
  html[data-perf="lite"] *,
  html[data-perf="lite"] *::backdrop {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
  html[data-perf="lite"] .site-header {
    background: rgb(7 12 19 / 94%);
  }
  html[data-perf="lite"] .glass {
    background:
      linear-gradient(
        140deg,
        rgb(232 247 255 / 9%),
        rgb(150 205 240 / 3%) 55%,
        rgb(225 244 255 / 5%)
      ),
      rgb(8 16 27 / 82%);
  }
  html[data-perf="lite"] .logo-plate::before {
    animation: none;
  }
}
