/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.95rem 1.75rem;
  border-radius: var(--radius-pill);
  font-weight: 500;
  font-size: var(--fs-16);
  letter-spacing: 0.01em;
  transition: all var(--dur-base) var(--ease-out);
  position: relative;
  white-space: nowrap;
  will-change: transform;
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
}
.btn-primary:hover { background: var(--btn-primary-bg-hover); transform: translateY(-2px); }

.btn-secondary {
  background: transparent;
  color: var(--btn-secondary-fg);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover {
  background: var(--btn-secondary-bg-hover);
  color: var(--btn-secondary-fg-hover);
  border-color: var(--btn-secondary-bg-hover);
}

.btn-ghost { padding: 0.5rem 0; color: var(--fg-muted); }
.btn-ghost:hover { color: var(--fg); }

.btn-arrow::after {
  content: '→';
  transition: transform var(--dur-base) var(--ease-out);
}
.btn-arrow:hover::after { transform: translateX(4px); }

/* ============ Navigation ============ */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  padding: 1.25rem 0;
  transition: background var(--dur-base) var(--ease-out), backdrop-filter var(--dur-base);
}
.nav.scrolled {
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 clamp(1.5rem, 4vw, 5rem);
}
.nav-logo { margin-right: auto; }

.nav-logo {
  display: inline-flex;
  align-items: center;
  color: var(--fg);
  transition: transform var(--dur-base) var(--ease-out);
}
.nav-logo:hover { transform: translateY(-1px); }

.thomax-logo {
  height: 28px;
  width: auto;
  display: block;
  color: var(--fg);
}
.thomax-logo--lg { height: 56px; }
.thomax-logo .thomax-spark { fill: var(--accent); transition: fill var(--dur-base); }
.nav-logo:hover .thomax-spark { filter: drop-shadow(0 0 6px var(--accent)); }
.thomax-logo .thomax-frame { stroke: currentColor; }
.thomax-logo .thomax-word,
.thomax-logo .thomax-tag { fill: currentColor; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.nav-link {
  font-size: var(--fs-14);
  color: var(--fg-muted);
  transition: color var(--dur-fast);
}
.nav-link:hover, .nav-link.active { color: var(--fg); }

.theme-toggle {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  color: var(--fg);
  transition: border-color var(--dur-base), color var(--dur-base), transform var(--dur-base) var(--ease-out);
  position: relative;
  z-index: 110;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); transform: rotate(20deg); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* Burger button — refined circular pill */
.nav-burger {
  display: none;
  width: 36px; height: 36px;
  position: relative;
  z-index: 110;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: transparent;
  cursor: pointer;
  transition:
    background 0.45s var(--ease-out),
    border-color 0.45s var(--ease-out),
    box-shadow 0.45s var(--ease-out);
}
.nav-burger:hover { border-color: var(--accent); }
.nav-burger.open {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 60%, transparent);
}
.nav-burger span {
  position: absolute;
  left: 9px; right: 9px;
  height: 1.5px;
  background: var(--fg);
  border-radius: 2px;
  transition:
    transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
    top 0.5s cubic-bezier(0.16, 1, 0.3, 1),
    background 0.4s var(--ease-out);
}
.nav-burger span:nth-child(1) { top: 14px; }
.nav-burger span:nth-child(2) { top: 20px; }
.nav-burger.open span { background: #0a0a0a; }
.nav-burger.open span:nth-child(1) { transform: rotate(45deg); top: 17px; }
.nav-burger.open span:nth-child(2) { transform: rotate(-45deg); top: 17px; }

@media (max-width: 768px) {
  .nav-burger { display: block; }

  /* Mobile fullscreen overlay */
  .nav-links {
    position: fixed;
    inset: 0;
    z-index: 105;
    background: var(--bg);
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    gap: 0;
    transform: translateX(100%);
    transition: transform 0.6s cubic-bezier(0.85, 0, 0.15, 1);
    padding: 6rem 0 3rem;
    overflow-y: auto;
    overflow-x: hidden;
    isolation: isolate;
  }
  .nav-links.open { transform: translateX(0); }

  /* Gold radial glow background */
  .nav-links::before {
    content: '';
    position: absolute;
    top: 30%; left: 50%;
    width: 110vw; height: 70vw;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, var(--accent-glow), transparent 65%);
    filter: blur(80px);
    opacity: 0.7;
    pointer-events: none;
    z-index: -1;
  }

  /* Decorative giant THOMAX wordmark fading at bottom */
  .nav-links::after {
    content: 'THOMAX';
    position: absolute;
    bottom: -2rem;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-italic);
    font-style: italic;
    font-size: 32vw;
    line-height: 0.85;
    letter-spacing: -0.025em;
    background: linear-gradient(180deg,
      color-mix(in srgb, var(--fg) 14%, transparent) 0%,
      transparent 80%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    pointer-events: none;
    z-index: -1;
    user-select: none;
    white-space: nowrap;
    font-weight: 400;
  }

  /* Stagger each child */
  .nav-links > * {
    opacity: 0;
    transform: translateX(40px);
    transition:
      opacity 0.55s cubic-bezier(0.16, 1, 0.3, 1) calc(var(--i, 0) * 70ms + 200ms),
      transform 0.6s cubic-bezier(0.16, 1, 0.3, 1) calc(var(--i, 0) * 70ms + 200ms);
  }
  .nav-links.open > * { opacity: 1; transform: translateX(0); }
  .nav-links > :nth-child(1) { --i: 0; }
  .nav-links > :nth-child(2) { --i: 1; }
  .nav-links > :nth-child(3) { --i: 2; }
  .nav-links > :nth-child(4) { --i: 3; }

  /* Big italic links — list-style with bottom borders */
  .nav-links .nav-link {
    font-family: var(--font-italic);
    font-style: italic;
    font-size: clamp(2.5rem, 9vw, 3.75rem);
    color: var(--fg);
    padding: 1rem clamp(1.5rem, 5vw, 3rem);
    margin: 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    letter-spacing: -0.02em;
    line-height: 1;
    transition:
      color 0.35s var(--ease-out),
      padding-left 0.45s var(--ease-out),
      background 0.35s var(--ease-out);
    width: 100%;
    text-align: left;
  }
  .nav-links .nav-link:first-of-type { border-top: 1px solid var(--border); }
  .nav-links .nav-link::after {
    content: '→';
    font-family: var(--font-body);
    font-style: normal;
    font-size: 0.45em;
    color: var(--fg-subtle);
    transition: transform 0.35s var(--ease-out), color 0.35s;
    flex-shrink: 0;
    margin-left: 1rem;
  }
  .nav-links .nav-link:hover {
    color: var(--accent);
    padding-left: clamp(2rem, 7vw, 4rem);
    background: color-mix(in srgb, var(--accent) 5%, transparent);
  }
  .nav-links .nav-link:hover::after {
    transform: translateX(8px);
    color: var(--accent);
  }
  .nav-links .nav-link.active { color: var(--accent); }
  .nav-links .nav-link.active::after {
    content: '';
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
  }

  /* CTA button at bottom of overlay — full width */
  .nav-links .btn {
    margin: 2.5rem clamp(1.5rem, 5vw, 3rem) 0;
    padding: 1.125rem 1.75rem;
    font-size: 1rem;
    border-radius: var(--radius-pill);
    align-self: stretch;
    justify-content: center;
    width: auto;
  }

  /* Reduced motion */
  @media (prefers-reduced-motion: reduce) {
    .nav-links { transition: opacity 0.2s linear; }
    .nav-links > * { transition: opacity 0.2s linear !important; transform: none !important; }
  }
}

/* ============ Footer (enhanced) ============ */
.footer {
  position: relative;
  background: var(--bg);
  border-top: 1px solid var(--border);
  overflow: hidden;
  isolation: isolate;
}
.footer::before {
  content: '';
  position: absolute;
  top: -10%; left: 50%;
  width: 80vw; height: 60%;
  max-width: 1200px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center top, var(--accent-glow), transparent 60%);
  filter: blur(80px);
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
}
.footer > * { position: relative; z-index: 1; }

/* Top CTA block */
.footer-cta {
  border-bottom: 1px solid var(--border);
  padding: clamp(3rem, 6vw, 5rem) 0;
}
.footer-cta-inner {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2.5rem;
  align-items: end;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 clamp(1.5rem, 4vw, 5rem);
}
@media (max-width: 800px) {
  .footer-cta-inner { grid-template-columns: 1fr; align-items: start; }
}
.footer-cta-content { display: flex; flex-direction: column; gap: 0.875rem; }
.footer-cta-content .eyebrow { gap: 0.625rem; }
.footer-cta-content .eyebrow::before { display: none; }
.footer-cta-title {
  font-size: clamp(2rem, 4.5vw, 3.5rem);
  margin: 0.5rem 0 0.25rem;
}
.footer-cta-mail {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  font-family: var(--font-italic);
  font-style: italic;
  font-size: clamp(1.125rem, 2vw, 1.375rem);
  color: var(--accent);
  margin-top: 0.5rem;
  align-self: flex-start;
  transition: gap var(--dur-base) var(--ease-out);
}
.footer-cta-mail:hover { gap: 1rem; }
.footer-status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  background: #34d399;
  border-radius: 50%;
  box-shadow: 0 0 8px #34d399;
  animation: pulse 2.4s ease-in-out infinite;
  flex-shrink: 0;
}

/* Main grid (4 columns) */
.footer-main {
  padding-top: clamp(3rem, 6vw, 5rem);
  padding-bottom: clamp(3rem, 6vw, 5rem);
}
.footer-grid {
  display: grid;
  grid-template-columns: 2.2fr 1fr 1fr 1.4fr;
  gap: clamp(2rem, 4vw, 4rem);
}
@media (max-width: 1024px) { .footer-grid { grid-template-columns: 1.5fr 1fr 1fr; } .footer-grid > :last-child { grid-column: 1 / -1; } }
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-grid > :first-child { grid-column: 1 / -1; } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; gap: 2rem; } }

.footer-brand .thomax-logo { margin-bottom: 1.5rem; }
.footer-tagline {
  font-family: var(--font-italic);
  font-style: italic;
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  color: var(--fg);
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
  line-height: 1;
}
.footer-brand p { max-width: 36ch; font-size: var(--fs-14); }
.footer-col { display: flex; flex-direction: column; }
.footer-col-title {
  font-size: var(--fs-12);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--fg-subtle);
  margin-bottom: 1.25rem;
  font-weight: 500;
}
.footer-list li { margin-bottom: 0.75rem; }
.footer-list a, .footer-list span {
  color: var(--fg-muted);
  font-size: var(--fs-14);
  transition: color var(--dur-fast);
  position: relative;
  display: inline-block;
}
.footer-list a::after {
  content: '';
  position: absolute;
  bottom: -2px; left: 0;
  width: 100%; height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s var(--ease-out);
}
.footer-list a:hover { color: var(--fg); }
.footer-list a:hover::after { transform: scaleX(1); }

.footer-socials {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.75rem;
}
.footer-socials a {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  color: var(--fg-muted);
  transition:
    border-color var(--dur-base),
    color var(--dur-base),
    transform var(--dur-base) var(--ease-out),
    background var(--dur-base);
}
.footer-socials a:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

/* Big decorative wordmark */
.footer-wordmark {
  text-align: center;
  margin: clamp(1.5rem, 3vw, 2.5rem) 0 0;
  pointer-events: none;
  user-select: none;
  overflow: hidden;
  padding: 0 1rem;
}
.footer-wordmark span {
  font-family: var(--font-italic);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(4rem, 18vw, 16rem);
  line-height: 0.9;
  letter-spacing: -0.025em;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--fg) 22%, transparent) 0%,
    transparent 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-block;
  white-space: nowrap;
}

/* Bottom strip */
.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 2rem;
  padding-bottom: 2rem;
  margin-top: clamp(1rem, 2vw, 2rem);
  border-top: 1px solid var(--border);
  font-size: var(--fs-12);
  color: var(--fg-subtle);
  flex-wrap: wrap;
  gap: 1.5rem;
}
.footer-bottom-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
}

/* Copyright — italic editorial, separated by a thin vertical rule */
.footer-copy {
  font-family: var(--font-italic);
  font-style: italic;
  font-size: var(--fs-14);
  color: var(--fg-muted);
  letter-spacing: 0.01em;
  padding-right: 1.25rem;
  margin-right: 1.25rem;
  border-right: 1px solid var(--border);
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.footer-copy::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--accent);
}

/* Legal links list with subtle bullet separators */
.footer-legal-links {
  display: flex;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0;
}
.footer-legal-links li { display: flex; align-items: center; }
.footer-legal-links li:not(:last-child)::after {
  content: '·';
  margin: 0 0.875rem;
  color: var(--fg-subtle);
  opacity: 0.55;
}
.footer-legal-links a {
  color: var(--fg-subtle);
  letter-spacing: 0.02em;
  position: relative;
  transition: color 0.35s var(--ease-out);
  padding: 0.15rem 0;
}
.footer-legal-links a::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.45s var(--ease-out);
}
.footer-legal-links a:hover { color: var(--fg); }
.footer-legal-links a:hover::after { transform: scaleX(1); }

/* Legacy class kept for compat */
.footer-link-discreet { color: var(--fg-subtle); transition: color var(--dur-fast); }
.footer-link-discreet:hover { color: var(--fg); }

/* Back-to-top — pill with "Haut" label + arrow */
.footer-top-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.55rem 1rem 0.55rem 1.1rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--fg-muted);
  font-size: 0.6875rem;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    border-color var(--dur-base) var(--ease-out),
    color var(--dur-base) var(--ease-out),
    background var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out);
}
.footer-top-btn svg {
  width: 12px; height: 12px;
  transition: transform 0.45s var(--ease-out);
}
.footer-top-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  transform: translateY(-2px);
}
.footer-top-btn:hover svg { transform: translateY(-3px); }

@media (max-width: 700px) {
  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.25rem;
  }
  .footer-copy {
    border-right: none;
    padding-right: 0;
    margin-right: 0;
  }
  .footer-bottom-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
}

/* ============ Card de service ============ */
.service-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(1.5rem, 3vw, 2.5rem);
  transition: transform var(--dur-base) var(--ease-out),
              border-color var(--dur-base),
              box-shadow var(--dur-base);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.service-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(600px circle at var(--mx, 50%) var(--my, 50%), var(--accent-dim), transparent 40%);
  opacity: 0;
  transition: opacity var(--dur-base);
  pointer-events: none;
}
.service-card:hover {
  transform: translateY(-6px);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  box-shadow: var(--shadow-card-hover);
}
.service-card:hover::before { opacity: 1; }

.service-card-icon {
  width: 56px; height: 56px;
  border-radius: var(--radius-md);
  background: var(--accent-dim);
  border: 1px solid rgba(212, 175, 55, 0.25);
  display: grid;
  place-items: center;
  margin-bottom: 1.5rem;
  color: var(--accent);
}
.service-card h3 { margin-bottom: 0.75rem; font-size: clamp(1.25rem, 2vw, 1.625rem); }
.service-card p { font-size: var(--fs-16); }
.service-card-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  color: var(--accent);
  font-size: var(--fs-14);
  font-weight: 500;
}

/* ============ Custom cursor ============ */
.cursor-dot, .cursor-ring {
  position: fixed;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 9999;
  mix-blend-mode: difference;
  will-change: transform;
}
.cursor-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--fg);
}
.cursor-ring {
  width: 36px; height: 36px;
  border: 1px solid var(--fg);
  border-radius: 50%;
  transition: width var(--dur-fast), height var(--dur-fast), background var(--dur-fast);
}
.cursor-ring.hover {
  width: 56px; height: 56px;
  background: rgba(255, 255, 255, 0.08);
}
@media (max-width: 1024px) {
  .cursor-dot, .cursor-ring { display: none; }
}

/* ============ Page loader (initial load) ============ */
.page-loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  display: grid;
  place-items: center;
  transform: translateY(0);
  transition: transform 0.85s cubic-bezier(0.85, 0, 0.15, 1);
  pointer-events: all;
  overflow: hidden;
}
.page-loader::before {
  content: '';
  position: absolute;
  top: 30%;
  left: 50%;
  width: 60vw; height: 60vw;
  max-width: 700px; max-height: 700px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, var(--accent-glow), transparent 65%);
  filter: blur(60px);
  opacity: 0.7;
  pointer-events: none;
}
.page-loader::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
  pointer-events: none;
  opacity: 0.6;
}
.page-loader.is-done {
  transform: translateY(-100%);
  pointer-events: none;
}
.page-loader.is-done .page-loader-inner { opacity: 0; }
.page-loader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  position: relative;
  z-index: 1;
  opacity: 0;
  transform: translateY(8px);
  animation: loader-intro 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.05s forwards;
  transition: opacity 0.4s var(--ease-out);
}
@keyframes loader-intro {
  to { opacity: 1; transform: translateY(0); }
}
.page-loader .thomax-logo {
  height: 64px;
}
.page-loader .loader-spark {
  transform-origin: 20px 18px;
  animation: loader-spark-pulse 1.4s cubic-bezier(0.4, 0, 0.6, 1) 0.4s infinite;
}
@keyframes loader-spark-pulse {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 0 0 transparent);
  }
  50% {
    transform: scale(1.18);
    filter: drop-shadow(0 0 8px var(--accent));
  }
}
.page-loader-bar {
  width: 240px;
  height: 1px;
  background: var(--border);
  position: relative;
  overflow: hidden;
}
.page-loader-fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 0;
  background: linear-gradient(to right, var(--accent), var(--accent-soft));
  box-shadow: 0 0 10px var(--accent);
  animation: loader-fill 1.5s cubic-bezier(0.45, 0, 0.55, 1) 0.3s forwards;
}
@keyframes loader-fill {
  0%   { width: 0; }
  18%  { width: 22%; }
  42%  { width: 48%; }
  68%  { width: 74%; }
  100% { width: 100%; }
}
.page-loader-tag {
  font-family: var(--font-italic);
  font-style: italic;
  font-size: 0.875rem;
  color: var(--accent);
  letter-spacing: 0;
  margin-top: 0.25rem;
  animation: loader-tag-pulse 1.8s ease-in-out 0.5s infinite;
}
@keyframes loader-tag-pulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .page-loader-inner { animation: none; opacity: 1; transform: none; }
  .page-loader-fill { width: 100%; animation: none; }
  .page-loader .loader-spark { animation: none; }
  .page-loader-tag { animation: none; opacity: 0.7; }
  .page-loader { transition: opacity 0.3s; }
  .page-loader.is-done { opacity: 0; transform: none; }
}

/* ============ Page transition overlay ============ */
.page-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9000;
  pointer-events: none;
  transform: translateY(100%);
}

/* ============ Word rotator (cycling pill, grid-stack version) ============ */
.word-rotator {
  display: inline-grid;
  vertical-align: 0.06em;
  position: relative;
  padding: 0.1em 1em 0.15em;
  margin: 0 0.4em;
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  outline: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 4px;
  font-family: var(--font-display);
  font-style: normal;
  font-size: 0.76em;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.005em;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  transform: rotate(-2deg);
  isolation: isolate;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent) 20%, transparent),
    0 6px 20px -8px color-mix(in srgb, var(--accent) 35%, transparent);
  transition:
    box-shadow var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out);
}
.word-rotator.is-flipping {
  animation: rotator-breath 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes rotator-breath {
  0%, 100% {
    box-shadow:
      0 0 0 1px color-mix(in srgb, var(--accent) 20%, transparent),
      0 6px 20px -8px color-mix(in srgb, var(--accent) 35%, transparent);
    border-color: var(--accent);
  }
  50% {
    box-shadow:
      0 0 0 2px var(--accent),
      0 14px 32px -10px color-mix(in srgb, var(--accent) 65%, transparent);
    border-color: var(--accent-soft);
  }
}
@media (prefers-reduced-motion: reduce) {
  .word-rotator.is-flipping { animation: none; }
}
.word-rotator::before,
.word-rotator::after {
  content: '';
  position: absolute;
  width: 6px; height: 6px;
  background: var(--accent);
  top: 50%;
  z-index: 3;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(45deg);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 70%, transparent);
}
.word-rotator::before { left: 0; }
.word-rotator::after { left: auto; right: 0; transform: translate(50%, -50%) rotate(45deg); }

.word-rotator-track {
  display: inline-grid;
  grid-template-areas: 'stack';
  align-items: center;
  justify-items: center;
  line-height: 1.1;
}
.word-rotator-item {
  grid-area: stack;
  white-space: nowrap;
  pointer-events: none;
  display: inline-flex;
}
.word-rotator-item .char {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.55em) rotate(var(--r-in, 0deg)) scale(0.85);
  transition:
    opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1) calc(var(--i, 0) * 28ms),
    transform 0.5s cubic-bezier(0.16, 1, 0.3, 1) calc(var(--i, 0) * 28ms);
  will-change: transform, opacity;
}
.word-rotator-item.is-active .char {
  opacity: 1;
  transform: translateY(0) rotate(0deg) scale(1);
}
.word-rotator-item.is-leaving .char {
  opacity: 0;
  transform: translateY(-0.55em) rotate(var(--r-out, 0deg)) scale(0.85);
  transition:
    opacity 0.32s cubic-bezier(0.4, 0, 1, 1) calc(var(--i, 0) * 22ms),
    transform 0.42s cubic-bezier(0.4, 0, 1, 1) calc(var(--i, 0) * 22ms);
}
@media (prefers-reduced-motion: reduce) {
  .word-rotator-item .char { transition: opacity 0.2s linear; }
  .word-rotator-item.is-active .char,
  .word-rotator-item.is-leaving .char { transform: none; }
}

/* ============ Stamp word reveal (post-it style) ============ */
.stamp-word {
  display: inline-block;
  overflow: visible;
  white-space: nowrap;
}
.stamp-word-inner {
  display: inline-block;
  transform-origin: 50% 80%;
  will-change: transform, opacity;
}

/* ============ Theme transition (explosion) ============ */
.theme-particle {
  position: fixed;
  border-radius: 50%;
  background: var(--accent);
  box-shadow:
    0 0 12px var(--accent),
    0 0 24px color-mix(in srgb, var(--accent) 60%, transparent);
  pointer-events: none;
  z-index: 10000;
  transform: translate(-50%, -50%);
  animation: theme-particle-burst 0.85s var(--delay, 0ms) cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes theme-particle-burst {
  0% {
    transform: translate(-50%, -50%) scale(0.4);
    opacity: 0;
  }
  15% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0);
    opacity: 0;
  }
}

/* ============ View Transition ripple ============ */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-old(root) {
  z-index: 1;
}
::view-transition-new(root) {
  z-index: 9999;
  animation: theme-ripple 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes theme-ripple {
  from {
    clip-path: circle(0 at var(--ripple-x, 50%) var(--ripple-y, 50%));
  }
  to {
    clip-path: circle(var(--ripple-r, 150vmax) at var(--ripple-x, 50%) var(--ripple-y, 50%));
  }
}

/* Pulse the toggle button itself during transition */
.is-theme-transitioning .theme-toggle {
  animation: theme-toggle-pulse 0.5s ease-out;
}
@keyframes theme-toggle-pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 var(--accent); }
  40% { transform: scale(1.18); box-shadow: 0 0 0 14px transparent; }
  100% { transform: scale(1); box-shadow: 0 0 0 0 transparent; }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) { animation: none; }
}
