/* APOLLO VPN — base layer: reset, page shell, chrome, primitives */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--t-body);
  line-height: 1.62;
  color: var(--ink-2);
  background: var(--void);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

/* Ambient field: soft radial pools under everything. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(120vw 90vh at 78% -10%, oklch(0.47 0.20 298 / 0.20), transparent 62%),
    radial-gradient(100vw 80vh at 8% 18%, oklch(0.52 0.17 256 / 0.14), transparent 60%),
    radial-gradient(90vw 70vh at 50% 108%, oklch(0.47 0.20 298 / 0.10), transparent 64%);
}

/* Fine grain, applied by JS-generated noise tile (see .grain) */
.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-repeat: repeat;
  background-size: 128px 128px;
}

main, header, footer { position: relative; z-index: 2; }

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

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  margin: 0;
  line-height: 1.06;
  letter-spacing: -0.022em;
  font-weight: 800;
  text-wrap: balance;
}
h1 { font-size: var(--t-h1); }
h2 { font-size: var(--t-h2); }
h3 { font-size: var(--t-h3); line-height: 1.22; letter-spacing: -0.012em; font-weight: 700; }

p { margin: 0; max-width: 68ch; }

a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible, summary:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

::selection { background: var(--violet-a20); color: var(--ink); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--void); }
::-webkit-scrollbar-thumb {
  background: oklch(0.30 0.05 280 / 0.7);
  border-radius: var(--r-pill);
  border: 3px solid var(--void);
}
::-webkit-scrollbar-thumb:hover { background: oklch(0.42 0.09 285 / 0.8); }

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

.skip-link {
  position: absolute; top: 10px; left: 10px; z-index: 200;
  transform: translateY(-160%);
  background: var(--surface-2); color: var(--ink);
  padding: 10px 16px; border-radius: var(--r-sm); border: 1px solid var(--line-hi);
  transition: transform var(--d-menu) var(--ease-out);
}
.skip-link:focus { transform: translateY(0); }

/* ============================ Layout ============================ */

.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.wrap-narrow { max-width: var(--maxw-narrow); }

.section { padding-block: clamp(72px, 9vw, 148px); position: relative; }
.section--tight { padding-block: clamp(56px, 6vw, 96px); }

.eyebrow {
  font-family: var(--font-display);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--violet);
  margin: 0 0 var(--s-4);
  display: flex; align-items: center; gap: 10px;
}
.eyebrow::before {
  content: ""; width: 26px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--violet));
}

.lead { font-size: var(--t-lead); color: var(--ink-3); max-width: 62ch; line-height: 1.66; }

.section-head { margin-bottom: clamp(40px, 5vw, 72px); }
.section-head h2 { margin-bottom: var(--s-4); }

/* ============================ Buttons ============================ */

.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--ink);
  --btn-bd: var(--line);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--font-display);
  font-size: var(--t-sm);
  font-weight: 700;
  letter-spacing: -0.005em;
  padding: 13px 22px;
  min-height: 46px;
  border-radius: var(--r-pill);
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  cursor: pointer;
  isolation: isolate;
  overflow: hidden;
  white-space: nowrap;
  /* A silent hard clip (the default with no text-overflow set) is worse
     than an ellipsis if some future layout ever squeezes a button
     narrower than its label needs — belt-and-suspenders next to the
     actual fix (assets/css/dashboard.css's .cfg__acts .btn), which is to
     not squeeze buttons narrower than their content in the first place. */
  text-overflow: ellipsis;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--d-press) var(--ease-out),
    border-color var(--d-menu) ease,
    box-shadow var(--d-menu) ease,
    background-color var(--d-menu) ease,
    color var(--d-menu) ease,
    opacity var(--d-menu) ease;
}
.btn > * { position: relative; z-index: 1; }
.btn:active { transform: scale(0.97); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

/* Moving sheen — only on devices with a real pointer */
.btn::after {
  content: "";
  position: absolute; inset: 0; z-index: 0;
  background: linear-gradient(115deg, transparent 32%, oklch(1 0 0 / 0.16) 50%, transparent 68%);
  transform: translateX(-120%);
  transition: transform 620ms var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .btn:hover::after { transform: translateX(120%); }
}

.btn--primary {
  --btn-fg: oklch(0.99 0.005 280);
  --btn-bd: transparent;
  background: linear-gradient(118deg, var(--violet-deep), var(--violet) 46%, var(--blue) 118%);
  box-shadow: 0 10px 30px -14px oklch(0.665 0.235 296 / 0.85), inset 0 1px 0 oklch(1 0 0 / 0.22);
}
@media (hover: hover) and (pointer: fine) {
  .btn--primary:hover {
    transform: scale(1.02);
    box-shadow: 0 16px 44px -14px oklch(0.665 0.235 296 / 0.95), inset 0 1px 0 oklch(1 0 0 / 0.28);
  }
  .btn--primary:active { transform: scale(0.97); }
}

.btn--ghost { background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
@media (hover: hover) and (pointer: fine) {
  .btn--ghost:hover { border-color: var(--line-hi); background: var(--glass-hi); transform: scale(1.02); }
  .btn--ghost:active { transform: scale(0.97); }
}

.btn--quiet { background: transparent; border-color: transparent; color: var(--ink-3); padding-inline: 14px; }
@media (hover: hover) and (pointer: fine) { .btn--quiet:hover { color: var(--ink); background: var(--glass); } }

.btn--danger { color: var(--danger); border-color: oklch(0.66 0.20 22 / 0.32); background: oklch(0.66 0.20 22 / 0.08); }
@media (hover: hover) and (pointer: fine) { .btn--danger:hover { background: oklch(0.66 0.20 22 / 0.16); } }

.btn--sm { min-height: 38px; padding: 9px 16px; font-size: var(--t-xs); }
.btn--lg { min-height: 54px; padding: 16px 30px; font-size: 1rem; }
.btn--block { width: 100%; }

.btn__icon { width: 17px; height: 17px; flex: none; }

/* Busy state */
.btn[data-busy="true"] { color: transparent; pointer-events: none; }
.btn[data-busy="true"]::before {
  content: ""; position: absolute; z-index: 2;
  width: 17px; height: 17px; border-radius: 50%;
  border: 2px solid oklch(1 0 0 / 0.25); border-top-color: oklch(1 0 0 / 0.9);
  animation: spin 620ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================ Glass panel ============================ */

.panel {
  position: relative;
  background: var(--glass-lo);
  backdrop-filter: blur(20px) saturate(1.25);
  -webkit-backdrop-filter: blur(20px) saturate(1.25);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2), inset 0 1px 0 oklch(1 0 0 / 0.045);
}

/* ============================ Header ============================ */

.hdr {
  position: fixed; inset: 0 0 auto; z-index: 90;
  height: var(--header-h);
  display: flex; align-items: center;
  border-bottom: 1px solid transparent;
  transition: background-color var(--d-menu) ease, border-color var(--d-menu) ease, box-shadow var(--d-menu) ease;
}
.hdr[data-stuck="true"] {
  background: oklch(0.075 0.024 274 / 0.72);
  backdrop-filter: blur(22px) saturate(1.5);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  border-bottom-color: var(--line-soft);
  box-shadow: 0 18px 44px -32px oklch(0.665 0.235 296 / 0.7);
}
.hdr__in { display: flex; align-items: center; gap: var(--s-5); width: 100%; }

.logo { display: inline-flex; align-items: center; gap: 10px; flex: none; }
.logo__mark { width: 30px; height: 30px; flex: none; }
.logo__txt {
  font-family: var(--font-display); font-weight: 800; font-size: 1rem;
  letter-spacing: 0.1em; color: var(--ink); text-transform: uppercase;
}
.logo__txt span { color: var(--violet); }

.nav { display: flex; align-items: center; gap: 2px; margin-inline: auto; }
.nav__link {
  position: relative;
  font-size: var(--t-sm); font-weight: 500; color: var(--ink-3);
  padding: 9px 14px; border-radius: var(--r-sm);
  transition: color var(--d-menu) ease, background-color var(--d-menu) ease;
}
@media (hover: hover) and (pointer: fine) { .nav__link:hover { color: var(--ink); background: oklch(1 0 0 / 0.04); } }
.nav__link[aria-current="page"], .nav__link.is-active { color: var(--ink); }
.nav__link[aria-current="page"]::after, .nav__link.is-active::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 2px; height: 2px;
  border-radius: 2px; background: var(--violet);
  box-shadow: 0 0 10px var(--violet);
}

.hdr__actions { display: flex; align-items: center; gap: var(--s-2); flex: none; }

.hdr__burger {
  display: none; width: 42px; height: 42px; flex: none;
  align-items: center; justify-content: center;
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--glass); color: var(--ink); cursor: pointer;
  transition: transform var(--d-press) var(--ease-out), border-color var(--d-menu) ease;
}
.hdr__burger:active { transform: scale(0.94); }
.hdr__burger span { position: relative; display: block; width: 17px; height: 1.5px; background: currentColor; border-radius: 2px; }
.hdr__burger span::before, .hdr__burger span::after {
  content: ""; position: absolute; left: 0; width: 17px; height: 1.5px; background: currentColor; border-radius: 2px;
  transition: transform var(--d-menu) var(--ease-out);
}
.hdr__burger span::before { top: -6px; }
.hdr__burger span::after { top: 6px; }
.hdr__burger[aria-expanded="true"] span { background: transparent; }
.hdr__burger[aria-expanded="true"] span::before { transform: translateY(6px) rotate(45deg); }
.hdr__burger[aria-expanded="true"] span::after { transform: translateY(-6px) rotate(-45deg); }

/* Account chip */
.acct {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 5px 14px 5px 5px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--glass);
  transition: transform var(--d-press) var(--ease-out), border-color var(--d-menu) ease;
}
.acct:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .acct:hover { border-color: var(--line-hi); } }
.acct__av {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 800; font-size: var(--t-xs);
  color: oklch(0.99 0 0);
  background: linear-gradient(140deg, var(--violet), var(--blue));
}
.acct__nm { font-size: var(--t-sm); font-weight: 600; color: var(--ink); max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Mobile sheet */
.msheet {
  position: fixed; inset: 0; z-index: 95;
  display: flex; flex-direction: column;
  padding: calc(var(--header-h) + 20px) var(--gutter) 34px;
  background: oklch(0.062 0.020 276 / 0.94);
  backdrop-filter: blur(26px); -webkit-backdrop-filter: blur(26px);
  transform: translateY(-8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--d-menu) var(--ease-out), transform var(--d-menu) var(--ease-out), visibility 0s linear var(--d-menu);
}
.msheet[data-open="true"] { opacity: 1; transform: translateY(0); visibility: visible; transition-delay: 0s; }
.msheet__nav { display: flex; flex-direction: column; gap: 2px; }
.msheet__link {
  font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; color: var(--ink);
  padding: 14px 0; border-bottom: 1px solid var(--line-soft);
  opacity: 0; transform: translateY(12px);
  transition: opacity 260ms var(--ease-out), transform 260ms var(--ease-out);
}
.msheet[data-open="true"] .msheet__link { opacity: 1; transform: translateY(0); }
.msheet[data-open="true"] .msheet__link:nth-child(1) { transition-delay: 40ms; }
.msheet[data-open="true"] .msheet__link:nth-child(2) { transition-delay: 80ms; }
.msheet[data-open="true"] .msheet__link:nth-child(3) { transition-delay: 120ms; }
.msheet[data-open="true"] .msheet__link:nth-child(4) { transition-delay: 160ms; }
.msheet[data-open="true"] .msheet__link:nth-child(5) { transition-delay: 200ms; }
.msheet__foot { margin-top: auto; display: grid; gap: 10px; padding-top: var(--s-6); }

@media (max-width: 1040px) {
  .nav { display: none; }
  .hdr__burger { display: inline-flex; }
  .hdr__actions .btn--primary, .hdr__actions .btn--ghost { display: none; }
  .hdr__in { justify-content: space-between; }
  .hdr__actions { margin-left: auto; }
}
@media (min-width: 1041px) { .msheet { display: none; } }

/* On a phone the account name and the burger fight for the same strip.
   The avatar alone still identifies the session; the name does not fit. */
@media (max-width: 600px) {
  .acct__nm { display: none; }
  .acct { padding: 4px; }
}

/* ============================ Scroll progress ============================ */

.sprog {
  position: fixed; inset: 0 0 auto; z-index: 99;
  height: 2px; background: transparent; pointer-events: none;
}
.sprog__bar {
  height: 100%; width: 100%;
  transform: scaleX(0); transform-origin: 0 50%;
  background: linear-gradient(90deg, var(--blue), var(--violet));
  box-shadow: 0 0 12px oklch(0.665 0.235 296 / 0.8);
}

/* ============================ Cursor glow (desktop only) ============================ */

.cursor-glow {
  position: fixed; top: 0; left: 0; z-index: 3;
  width: 420px; height: 420px; margin: -210px 0 0 -210px;
  border-radius: 50%; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, oklch(0.665 0.235 296 / 0.14), transparent 66%);
  transition: opacity 400ms ease;
  will-change: transform;
}
@media (hover: hover) and (pointer: fine) and (min-width: 1041px) {
  .cursor-glow[data-on="true"] { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .cursor-glow { display: none; } }

/* ============================ Page transition ============================ */

.pt-veil {
  position: fixed; inset: 0; z-index: 200; pointer-events: none;
  background: var(--void);
  opacity: 0;
  transition: opacity var(--d-page) var(--ease-out);
}
body[data-leaving="true"] .pt-veil { opacity: 1; pointer-events: all; }
body[data-leaving="true"] main { filter: blur(6px); transform: scale(0.992); }

main { transition: filter var(--d-page) var(--ease-out), transform var(--d-page) var(--ease-out); }

body[data-entering="true"] main { animation: pageIn var(--d-page) var(--ease-out) both; }
@keyframes pageIn {
  from { opacity: 0; filter: blur(7px); transform: translateY(10px) scale(0.995); }
  to   { opacity: 1; filter: blur(0);  transform: none; }
}

/* ============================ Reveal on scroll ============================ */

[data-reveal] {
  opacity: 0;
  transform: translateY(28px) scale(0.985);
  transition: opacity 620ms var(--ease-out), transform 620ms var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}
[data-reveal].is-in { opacity: 1; transform: none; }

/* ============================ Footer ============================ */

.ftr {
  border-top: 1px solid var(--line-soft);
  background: linear-gradient(180deg, transparent, oklch(0.098 0.028 273 / 0.7));
  padding-block: clamp(56px, 6vw, 88px) var(--s-6);
}
.ftr__grid {
  display: grid; gap: clamp(32px, 4vw, 56px);
  grid-template-columns: 1.6fr repeat(4, 1fr);
}
.ftr__brand p { color: var(--ink-4); font-size: var(--t-sm); margin-top: var(--s-4); max-width: 30ch; }
.ftr__brand .logo { margin-bottom: 4px; }
.ftr__col h4 {
  font-size: var(--t-micro); letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-4); font-weight: 700; margin-bottom: var(--s-4);
}
.ftr__col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ftr__col a { font-size: var(--t-sm); color: var(--ink-3); transition: color var(--d-menu) ease; }
@media (hover: hover) and (pointer: fine) { .ftr__col a:hover { color: var(--ink); } }
.ftr__base {
  margin-top: clamp(40px, 5vw, 64px); padding-top: var(--s-5);
  border-top: 1px solid var(--line-soft);
  display: flex; flex-wrap: wrap; gap: var(--s-4); justify-content: space-between;
  font-size: var(--t-xs); color: var(--ink-4);
}
@media (max-width: 900px) { .ftr__grid { grid-template-columns: 1fr 1fr; } .ftr__brand { grid-column: 1 / -1; } }
@media (max-width: 520px) { .ftr__grid { grid-template-columns: 1fr; } }

/* ============================ Reduced motion ============================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 140ms !important;
    scroll-behavior: auto !important;
  }
  [data-reveal] { opacity: 1; transform: none; }
  .btn::after { display: none; }
  body[data-leaving="true"] main { filter: none; transform: none; }
}
