/* ==========================================================================
   CDN Index — shared stylesheet (loaded on EVERY page)
   --------------------------------------------------------------------------
   1. Design tokens
   2. Reset & base
   3. Layout primitives (page shell, card)
   4. Shared components (buttons, badge, switch, section head, CDN logo tile)
   5. Site header (logo only)
   6. Site footer & marquee
   7. Motion (reveal on load / scroll)
   8. Utilities

   Page-only styles live in /assets/css/pages/<page>.css
   Naming: BEM — .block, .block__element, .block--modifier
   ========================================================================== */

/* 1. Design tokens
   ========================================================================== */
:root {
  /* Colors (from Figma "CDN Index - Finale") */
  --color-page: #f7f5f5;
  --color-surface: #ffffff;
  --color-surface-muted: #f5f2f3;
  --color-ink: #2a0a10;
  --color-ink-80: rgba(42, 10, 16, 0.8);
  --color-ink-75: rgba(42, 10, 16, 0.75);
  --color-ink-70: rgba(42, 10, 16, 0.7);
  --color-ink-60: rgba(42, 10, 16, 0.6);
  --color-ink-12: rgba(42, 10, 16, 0.12);
  --color-ink-10: rgba(42, 10, 16, 0.1);
  --color-ink-06: rgba(42, 10, 16, 0.06);
  --color-brand: #d2092d;
  --color-brand-dark: #bf102c;
  --color-neutral-7: #1d252f;
  --color-neutral-5: #5a697a;
  --color-neutral-2: #e1e2e2;
  --color-slate: #314158;
  --color-border-input: #b0b2be;
  --color-border-soft: #e6e6ea;
  --color-border-map: #dde6f0;

  /* Typography */
  --font-sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 32px;
  --radius-pill: 999px;

  /* Spacing — fluid values shrink on small screens */
  --page-gutter: clamp(12px, 2vw, 24px);
  --card-pad-x: clamp(20px, 5vw, 96px);
  --card-pad-y: clamp(40px, 6vw, 72px);
  /* Wide enough to use large monitors; caps only ultra-wide screens */
  --content-max: 2400px;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --duration-reveal: 900ms;
}

/* 2. Reset & base
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--color-page);
  color: var(--color-ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
p,
ul,
figure {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

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

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

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

em {
  font-style: italic;
}

:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Keyboard users can jump straight past the header */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--color-ink);
  color: #fff;
  font-weight: 600;
}

.skip-link:focus {
  top: 16px;
}

/* 3. Layout primitives
   ========================================================================== */
.page-shell {
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 3vw, 48px);
  padding: var(--page-gutter);
  /* Clip the footer marquee without creating horizontal scroll */
  overflow-x: clip;
}

main {
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 3vw, 48px);
}

.card {
  position: relative;
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-ink-06);
  border-radius: clamp(20px, 3vw, var(--radius-lg));
}

/* 4. Shared components
   ========================================================================== */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 28px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 16px;
  line-height: 1.2;
  white-space: nowrap;
  transition:
    transform 200ms var(--ease-out),
    box-shadow 200ms var(--ease-out),
    background-color 200ms;
}

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

.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px -10px rgba(42, 10, 16, 0.55);
}

.btn__icon {
  transition: transform 200ms var(--ease-out);
}

.btn:hover .btn__icon {
  transform: translateX(3px);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  transition: background-color 150ms;
}

.icon-button:hover {
  background: var(--color-surface-muted);
}

.icon-button--sm {
  width: 22px;
  height: 22px;
}

/* Badge (pill label with live dot) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--color-ink-10);
  border-radius: var(--radius-pill);
  color: var(--color-ink-75);
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
}

/* Pulsing "live" indicator */
.badge__dot {
  border-radius: 50%;
  animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(210, 9, 45, 0.45);
  }
  70%,
  100% {
    box-shadow: 0 0 0 7px rgba(210, 9, 45, 0);
  }
}

/* Toggle switch (accessible: real checkbox underneath) */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--color-neutral-7);
  font-size: 14px;
  letter-spacing: -0.02em;
  line-height: 1.4;
}

.switch__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch__track {
  position: relative;
  flex: none;
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: #a8aeb5;
  transition: background-color 200ms;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 1.35px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 220ms var(--ease-out);
}

.switch__input:checked + .switch__track {
  background: var(--color-brand);
}

.switch__input:checked + .switch__track::after {
  transform: translateX(15.3px);
}

.switch__input:focus-visible + .switch__track {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

/* Section head (serif title + lead) — reused by all content sections */
.section-head {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-head__title {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.section-head__lead {
  max-width: 720px;
  color: var(--color-ink-75);
  font-size: clamp(16px, 1.4vw, 18px);
  line-height: 1.45;
  letter-spacing: 0.03em;
}

/* CDN logo tile (32×32) — used by the performance map and CDN review pages
   Modifiers set each brand's tile background; multi-part marks are layered. */
.cdn-logo {
  flex: none;
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  overflow: hidden;
}

.cdn-logo--outlined {
  border: 1px solid var(--color-neutral-2);
  background: var(--color-surface);
}

.cdn-logo--fastly {
  background: #ff282d;
}

.cdn-logo--cloudfront {
  background: #7b48d7;
}

.cdn-logo--cloudflare {
  background: #f38020;
}

.cdn-logo--akamai {
  background: #019acd;
}

.cdn-logo--cachefly {
  background: linear-gradient(135deg, #c140ec 1%, #c140c1 28%, #9640c1 55%, #6b4096 75%, #6b1596 94%, #40156b 113%);
}

.cdn-logo--ioriver {
  border-radius: 5.65px;
  background: url("/assets/img/cdn-logos/ioriver-bg.png") center / cover no-repeat;
}

.cdn-logo__flip-y {
  transform: scaleY(-1);
}

/* CloudFront: zoomed circular crop */
.cdn-logo__round-crop {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  overflow: hidden;
}

.cdn-logo__round-crop img {
  width: 100%;
  height: 100%;
  transform: scale(1.435);
}

/* CDNetworks: cropped square from a wider image */
.cdn-logo__crop {
  position: relative;
  width: 20.8px;
  height: 20px;
  overflow: hidden;
}

.cdn-logo__crop--cdnetworks img {
  position: absolute;
  top: 0.77%;
  left: -15.83%;
  width: 133.49%;
  height: 120%;
  max-width: none;
}

/* Akamai: 3 layered parts, each mirrored vertically */
.akamai-mark {
  position: relative;
  width: 14.73px;
  height: 16px;
}

.akamai-mark__part {
  position: absolute;
  transform: scaleY(-1);
}

.akamai-mark__part--1 {
  top: 0;
  left: 0;
}

.akamai-mark__part--2 {
  top: 1.2px;
  left: 3.27px;
}

.akamai-mark__part--3 {
  top: 3.91px;
  left: 6.44px;
}

/* CacheFly: 2 layered parts */
.cachefly-mark {
  position: relative;
  width: 18.3px;
  height: 20px;
}

.cachefly-mark__part {
  position: absolute;
  left: 0;
}

.cachefly-mark__part--1 {
  top: 0;
  width: 99.8%;
  height: 65.98%;
}

.cachefly-mark__part--2 {
  top: 26.68%;
  width: 62.79%;
  height: 72.98%;
}

/* Fallback for a CDN without a logo file: coloured initial */
.cdn-logo--initial {
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}

/* Page hero (card under the header: badge, big serif title, lead)
   ========================================================================== */
.hero {
  padding-bottom: var(--card-pad-y);
  overflow: hidden;
}

.hero__content {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 48px;
  padding: clamp(24px, 4.5vw, 64px) var(--card-pad-x) 0;
}

.hero__intro {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
}

.hero__title {
  display: flex;
  flex-wrap: wrap;
  column-gap: 0.25em;
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: clamp(44px, 9vw, 112px);
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.hero__title em {
  font-weight: 300;
}

/* Each word sits in a mask and slides up into place on load */
.hero__word {
  display: inline-block;
  overflow: hidden;
  /* room for italic overhang + descenders inside the mask */
  padding: 0 0.06em 0.12em 0;
  margin-bottom: -0.12em;
}

.hero__word > * {
  display: inline-block;
  animation: word-rise 1.1s var(--ease-out) both;
}

@keyframes word-rise {
  from {
    transform: translateY(105%) skewY(6deg);
  }
  to {
    transform: none;
  }
}

/* After the intro, the italic word keeps a slow, subtle drift */
.hero__word em {
  animation:
    word-rise 1.1s var(--ease-out) 140ms both,
    word-drift 7s ease-in-out 1.4s infinite;
}

@keyframes word-drift {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(0.08em);
  }
}

.hero__lead {
  flex: 0 1 400px;
  padding-bottom: 14px;
  color: var(--color-ink-80);
  font-size: clamp(17px, 1.5vw, 19px);
  line-height: 1.45;
}

/* Compact hero for inner pages (legal, reports, reviews) */
.hero--compact .hero__title {
  font-size: clamp(40px, 6.5vw, 88px);
}

.hero__lead p + p {
  margin-top: 12px;
}

@media (max-width: 1024px) {
  .hero__content {
    flex-direction: column;
    align-items: flex-start;
    gap: 24px;
  }

  .hero__lead {
    flex-basis: auto;
    max-width: 560px;
    padding-bottom: 0;
  }
}

/* 5. Site header (logo only)
   ========================================================================== */
.site-header {
  display: flex;
  flex-direction: column; /* logo with the "Running in Beta" tag under it */
  align-items: center;
  justify-content: center; /* logo sits in the middle of the card */
  gap: 14px;
  padding: 28px clamp(20px, 3.5vw, 48px);
}

/* Site status tag under the logo (uses the shared .badge pill) */
.site-header__beta {
  font-size: 13px;
}

/* Square red logo: "CDN" over italic "Index" */
.brand-logo {
  position: relative;
  flex: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-left: 13px;
  width: 80px;
  height: 80px;
  background: linear-gradient(180deg, var(--color-brand), var(--color-brand-dark));
  box-shadow: 0 8px 20px rgba(198, 9, 39, 0.25);
  color: #fff;
  line-height: 1;
  transition: transform 250ms var(--ease-out);
}

.brand-logo:hover {
  transform: rotate(-3deg) scale(1.03);
}

.brand-logo__cdn {
  font-weight: 700;
  font-size: 26px;
}

.brand-logo__index {
  margin-left: 3.5px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 22px;
}

@media (max-width: 720px) {
  .site-header {
    padding: 16px 20px;
  }

  .brand-logo {
    width: 56px;
    height: 56px;
    padding-left: 8px;
  }

  .brand-logo__cdn {
    font-size: 18px;
  }

  .brand-logo__index {
    font-size: 16px;
    margin-left: 2px;
  }
}

/* 6. Site footer & marquee
   ========================================================================== */
.site-footer {
  display: flex;
  flex-direction: column;
  gap: 48px;
  padding: 72px clamp(20px, 5vw, 64px) 0;
  background: var(--color-surface-muted);
  overflow: hidden;
}

.site-footer__top {
  display: flex;
  justify-content: space-between;
  gap: 48px;
}

.site-footer__brand {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 360px;
}

.footer-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.footer-logo__mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--color-brand);
  color: #fff;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 18px;
}

.footer-logo__name {
  font-weight: 700;
  font-size: 22px;
}

.footer-logo__name em {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 25px;
}

.site-footer__tagline {
  color: var(--color-ink-70);
  font-size: 15px;
  line-height: 1.5;
}

.social-links {
  display: flex;
  gap: 10px;
}

.social-links__link {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-ink-12);
  border-radius: 50%;
  background: var(--color-surface);
  transition:
    transform 200ms var(--ease-out),
    border-color 200ms;
}

.social-links__link:hover {
  transform: translateY(-2px);
  border-color: var(--color-ink);
}

/* Footer menu: two groups of links to the performance pages (regions, CDNs) */
.footer-menu {
  display: flex;
  gap: clamp(32px, 6vw, 96px);
}

.footer-menu__group {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.footer-menu__title {
  color: var(--color-ink-60);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.footer-menu__list {
  display: grid;
  gap: 10px 40px;
}

/* The CDN list is long: three columns on desktop */
.footer-menu__list--columns {
  grid-template-columns: repeat(3, auto);
}

.footer-menu__list a {
  color: var(--color-ink-75);
  font-size: 15px;
  white-space: nowrap;
  transition: color 150ms;
}

.footer-menu__list a:hover {
  color: var(--color-ink);
}

@media (max-width: 960px) {
  .site-footer__top {
    flex-direction: column;
  }

  .footer-menu__list--columns {
    grid-template-columns: repeat(2, auto);
  }
}

@media (max-width: 560px) {
  .footer-menu {
    flex-direction: column;
    gap: 28px;
  }

  .footer-menu__list--columns {
    justify-content: start;
  }
}

.site-footer__legal a {
  color: var(--color-ink-75);
  font-size: 15px;
  white-space: nowrap;
  transition: color 150ms;
}

.site-footer__legal a:hover {
  color: var(--color-ink);
}

.site-footer__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 48px;
  border-top: 1px solid var(--color-ink-10);
  font-size: 14px;
}

.site-footer__copyright {
  color: var(--color-ink-60);
}

.site-footer__legal {
  display: flex;
  flex-wrap: wrap; /* three links don't fit one row on small phones */
  gap: 8px 32px;
}

.site-footer__legal a {
  font-size: 14px;
  font-weight: 500;
}

/* Giant decorative type — endless horizontal marquee.
   Two identical copies; translating the track by -50% loops seamlessly. */
.marquee {
  height: clamp(80px, 13vw, 190px);
  margin: 0 calc(clamp(20px, 5vw, 64px) * -1);
  overflow: hidden;
}

.marquee__track {
  display: flex;
  width: max-content;
  animation: marquee 40s linear infinite;
  will-change: transform;
}

.marquee:hover .marquee__track {
  animation-play-state: paused;
}

.marquee__text {
  flex: none;
  color: var(--color-ink-12);
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: clamp(88px, 14vw, 200px);
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

@keyframes marquee {
  to {
    transform: translateX(-50%);
  }
}

@media (max-width: 560px) {
  .site-footer {
    padding-top: 48px;
    gap: 36px;
  }

  .site-footer__bottom {
    flex-direction: column-reverse;
    align-items: flex-start;
    padding-top: 28px;
  }
}

/* 7. Motion — reveal on load / scroll
   --------------------------------------------------------------------------
   Add `data-reveal` to any element; optional `style="--reveal-delay: 200ms"`.
   main.js adds `.is-visible` when it enters the viewport.
   Scoped to `.js` so content is never hidden when JavaScript is off.
   ========================================================================== */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  filter: blur(6px);
  transition:
    opacity var(--duration-reveal) var(--ease-out),
    transform var(--duration-reveal) var(--ease-out),
    filter var(--duration-reveal) var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}

.js [data-reveal].is-visible {
  opacity: 1;
  transform: none;
  filter: none;
}

/* Respect the OS "reduce motion" setting: no movement, instant content */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }

  .js [data-reveal] {
    opacity: 1;
    transform: none;
    filter: none;
  }

  .marquee__track {
    animation: none;
  }
}

/* 8. Utilities
   ========================================================================== */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
