/* ============================================================
   Purple Fox — stylesheet
   Tokens → base → layout sections → fox rig & poses → motion
   ============================================================ */

:root{
  --c-bg: #0b0712;
  --c-bg-soft: #130a24;
  --c-purple: #7c3aed;
  --c-purple-light: #a855f7;
  --c-purple-deep: #4c1d95;
  --c-blue: #3b82f6;
  --c-cyan: #22d3ee;
  --c-white: #f5f3ff;
  --c-ink: #0b0712;
  --c-line: rgba(245,243,255,0.12);

  --font-display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --header-h: 104px;
  --header-h-shrunk: 64px;
  --max-w: 1180px;
  --radius: 18px;
}

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

/* Author rules for display can otherwise beat the browser's own
   [hidden]{display:none} rule. Force it to always win. */
[hidden]{ display: none !important; }

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

body{
  margin: 0;
  background: radial-gradient(120% 90% at 15% 0%, #1b0f3a 0%, var(--c-bg) 55%) fixed;
  color: var(--c-white);
  font-family: var(--font-body);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

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

a{ color: inherit; }

h1,h2,h3{
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.05;
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
}

p{ margin: 0 0 1em; color: rgba(245,243,255,0.78); }

.btn{
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  padding: 0.95em 1.7em;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.btn:focus-visible{ outline: 3px solid var(--c-cyan); outline-offset: 3px; }
.btn-primary{
  background: linear-gradient(120deg, var(--c-purple-light), var(--c-blue));
  color: var(--c-white);
  box-shadow: 0 10px 30px -10px rgba(124,58,237,0.6);
}
.btn-primary:hover{ transform: translateY(-2px); box-shadow: 0 14px 34px -8px rgba(124,58,237,0.75); }
.btn-ghost{
  background: transparent;
  border: 1px solid var(--c-line);
  color: var(--c-white);
}
.btn-ghost:hover{ border-color: var(--c-cyan); }

section{
  max-width: var(--max-w);
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 7rem) 1.5rem;
}

/* ============================================================
   LOADER
   ============================================================ */
.loader{
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: var(--c-bg);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.loader-label{
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: rgba(245,243,255,0.55);
  opacity: 0;
  animation: loader-label-in 0.6s ease forwards 0.9s;
}
body:not(.is-loading) .loader{
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
@keyframes loader-label-in{ to{ opacity: 1; } }

/* loader fox part reveal, driven by classes toggled in JS */
.loader-fox .fox-part{ opacity: 0; transform: scale(0.6); transform-box: fill-box; transform-origin: 50% 50%; transition: opacity 0.35s ease, transform 0.35s cubic-bezier(.2,1.4,.4,1); }
.loader.reveal-tail .fox-tail,
.loader.reveal-tail .fox-tail-tip{ opacity: 1; transform: scale(1); }
.loader.reveal-body .fox-body,
.loader.reveal-body .fox-belly{ opacity: 1; transform: scale(1); }
.loader.reveal-legs .fox-leg-fl,
.loader.reveal-legs .fox-leg-fr,
.loader.reveal-legs .fox-leg-bl,
.loader.reveal-legs .fox-leg-br{ opacity: 1; transform: scale(1); }
.loader.reveal-head .fox-head,
.loader.reveal-head .fox-ear,
.loader.reveal-head .fox-ear-inner{ opacity: 1; transform: scale(1); }
.loader.reveal-run .fox-part{ transition: none; }

/* ============================================================
   HEADER
   ============================================================ */
.site-header{
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(1rem, 4vw, 3rem);
  background: rgba(11,7,18,0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: height 0.35s cubic-bezier(.4,0,.2,1), background 0.35s ease, border-color 0.35s ease;
}
.site-header.is-scrolled{
  height: var(--header-h-shrunk);
  background: rgba(11,7,18,0.82);
  border-bottom-color: var(--c-line);
}

.logo{
  display: flex;
  align-items: center;
  gap: 0.35em;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.15rem, 2.6vw, 1.7rem);
  color: var(--c-white);
  white-space: nowrap;
}
.logo-word{ letter-spacing: -0.01em; }

.header-fox{
  width: clamp(46px, 6vw, 68px);
  height: auto;
  flex: none;
  transition: width 0.35s ease;
}
.site-header.is-scrolled .header-fox{ width: clamp(34px, 4vw, 46px); }

.site-nav{
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 2rem);
  font-size: 0.95rem;
}
.site-nav a{ text-decoration: none; color: rgba(245,243,255,0.8); transition: color 0.2s; white-space: nowrap; }
.site-nav a:hover{ color: var(--c-white); }
.site-nav a:focus-visible{ outline: 2px solid var(--c-cyan); outline-offset: 4px; border-radius: 4px; }
.nav-cta{
  padding: 0.5em 1.1em;
  border-radius: 999px;
  border: 1px solid var(--c-line);
  color: var(--c-white) !important;
  flex: none;
}
.nav-cta:hover{ border-color: var(--c-cyan); }

@media (max-width: 600px){
  .site-nav{ gap: 0.6rem; }
  .site-nav a:not(.nav-cta){ display: none; }
  .nav-cta{ padding: 0.5em 1em; font-size: 0.88rem; }
}

/* ============================================================
   HERO
   ============================================================ */
.hero{
  max-width: none;
  min-height: 100svh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: 2rem;
  padding-top: calc(var(--header-h) + 2rem);
  padding-inline: clamp(1.5rem, 6vw, 5rem);
}
.hero h1{
  font-size: clamp(2.6rem, 6.4vw, 5.4rem);
}
.hero-sub{
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  color: rgba(245,243,255,0.7);
  max-width: 30ch;
}
.hero-copy{ position: relative; z-index: 2; }
.hero-fox-wrap{
  display: flex;
  justify-content: center;
  align-items: center;
}
.hero-fox{
  width: min(100%, 520px);
  filter: drop-shadow(0 30px 60px rgba(124,58,237,0.35));
}

@media (max-width: 860px){
  .hero{
    grid-template-columns: 1fr;
    text-align: center;
    padding-top: calc(var(--header-h) + 1.5rem);
  }
  .hero-copy{ order: 2; }
  .hero-fox-wrap{ order: 1; }
  .hero-fox{ width: min(78%, 320px); }
  .hero-sub{ margin-inline: auto; }
}

/* ============================================================
   SERVICES
   ============================================================ */
.services h2{
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  text-align: center;
  margin-bottom: clamp(2rem, 5vw, 3.5rem);
}
.service-grid{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}
.service-card{
  background: linear-gradient(160deg, rgba(124,58,237,0.14), rgba(59,130,246,0.05));
  border: 1px solid var(--c-line);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  transition: transform 0.25s ease, border-color 0.25s ease;
}
.service-card:hover{ transform: translateY(-4px); border-color: rgba(34,211,238,0.4); }
.service-card h3{ font-size: 1.25rem; margin-bottom: 0.4em; }
.service-card p{ margin: 0; font-size: 0.95rem; }
.fox-mini{ width: 84px; margin: 0 auto 1rem; opacity: 0.9; }

@media (max-width: 780px){
  .service-grid{ grid-template-columns: 1fr; }
}

/* ============================================================
   PHILOSOPHY
   ============================================================ */
.philosophy{
  position: relative;
  text-align: center;
}
.philosophy h2{
  font-size: clamp(2.2rem, 6vw, 4.2rem);
  background: linear-gradient(120deg, var(--c-white), var(--c-cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.philosophy-text{
  max-width: 46ch;
  margin: 1rem auto 0;
  font-size: 1.05rem;
}
.philosophy-fox-peek{
  position: absolute;
  top: -18px;
  right: clamp(0px, 6vw, 6rem);
  width: 90px;
  height: 45px;
  overflow: hidden;
  pointer-events: none;
}
.fox-peek{ width: 90px; position: absolute; top: -10px; left: 0; }
@media (max-width: 700px){
  .philosophy-fox-peek{ right: 50%; transform: translateX(50%); }
}

/* ============================================================
   PRINCIPLES
   ============================================================ */
.principles{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}
.principle{
  text-align: center;
  padding: 1.5rem 1rem;
  border-top: 1px solid var(--c-line);
}
.principle h3{
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.principle p{ font-size: 0.92rem; margin: 0; }
.principle .fox-mini{ width: 64px; }

@media (max-width: 860px){
  .principles{ grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px){
  .principles{ grid-template-columns: 1fr; }
}

/* ============================================================
   CONTACT
   ============================================================ */
.contact{ text-align: center; }
.contact h2{
  font-size: clamp(2rem, 5vw, 3.4rem);
  margin-bottom: 1.5rem;
}
.contact-form{
  max-width: 480px;
  margin: 0 auto;
  display: grid;
  gap: 1.1rem;
  text-align: left;
  transition: opacity 0.4s ease, transform 0.4s ease, max-height 0.5s ease;
}
.field{ display: grid; gap: 0.4rem; }
.field label{ font-size: 0.85rem; color: rgba(245,243,255,0.65); }
.field input, .field textarea{
  background: var(--c-bg-soft);
  border: 1px solid var(--c-line);
  border-radius: 12px;
  padding: 0.8em 1em;
  color: var(--c-white);
  font: inherit;
  resize: vertical;
}
.field input:focus-visible, .field textarea:focus-visible{
  outline: 2px solid var(--c-cyan);
  outline-offset: 1px;
  border-color: var(--c-cyan);
}
.field-trap{
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.contact-form .btn{ justify-self: center; min-width: 160px; justify-content: center; position: relative; }
.btn-spinner{
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  display: none;
  animation: spin 0.7s linear infinite;
}
#submitBtn.is-sending .btn-spinner{ display: inline-block; }
#submitBtn.is-sending .btn-label{ opacity: 0.7; }
#submitBtn.is-sending{ cursor: progress; opacity: 0.9; }
@keyframes spin{ to{ transform: rotate(360deg); } }

.contact-form.is-hiding{
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  max-height: 0;
  overflow: hidden;
  pointer-events: none;
}

.form-error{
  color: #fca5a5;
  font-size: 0.9rem;
  text-align: center;
  margin: 0;
}

.form-success{
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  animation: success-in 0.6s cubic-bezier(.2,1.2,.4,1);
}
@keyframes success-in{
  from{ opacity: 0; transform: translateY(12px) scale(0.96); }
  to{ opacity: 1; transform: translateY(0) scale(1); }
}
.fox-success{ width: 140px; margin-bottom: 0.5rem; }
.success-title{ font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; margin: 0; color: var(--c-white); }
.success-sub{ margin: 0 0 0.5rem; color: rgba(245,243,255,0.7); }

.contact-footnote{
  margin-top: 2.5rem;
  font-size: 0.85rem;
  color: rgba(245,243,255,0.45);
}

.site-footer{
  text-align: center;
  padding: 2rem 1.5rem 3rem;
  font-size: 0.8rem;
  color: rgba(245,243,255,0.35);
}

/* ============================================================
   FOX RIG — shared parts + pose states
   ============================================================ */
.fox .fox-part{ transform-box: fill-box; }
.fox-eye-closed{ display: none; }

/* transform origins per part, tuned to each shape's own bounding box */
.fox-tail{ transform-origin: 100% 88%; }
.fox-leg-fl, .fox-leg-fr, .fox-leg-bl, .fox-leg-br{ transform-origin: 50% 0%; }
.fox-head{ transform-origin: 12% 95%; }
.fox-body{ transform-origin: 50% 100%; }

/* idle: gentle breathing + slow tail sway, used at rest everywhere */
.fox[data-pose="idle"] .fox-body{ animation: fox-breathe 3.4s ease-in-out infinite; }
.fox[data-pose="idle"] .fox-tail{ animation: fox-tail-sway 3.4s ease-in-out infinite; }
.fox[data-pose="idle"] .fox-head{ animation: fox-head-sway 4.2s ease-in-out infinite; }

@keyframes fox-breathe{ 0%,100%{ transform: scaleY(1); } 50%{ transform: scaleY(1.02); } }
@keyframes fox-tail-sway{ 0%,100%{ transform: rotate(0deg); } 50%{ transform: rotate(6deg); } }
@keyframes fox-head-sway{ 0%,100%{ transform: rotate(0deg); } 50%{ transform: rotate(-2deg); } }

/* running: legs alternate in a diagonal gait, body bounces, tail whips */
.fox[data-pose="running"] .fox-leg-fl,
.fox[data-pose="running"] .fox-leg-br{ animation: fox-leg-a 0.42s ease-in-out infinite; }
.fox[data-pose="running"] .fox-leg-fr,
.fox[data-pose="running"] .fox-leg-bl{ animation: fox-leg-b 0.42s ease-in-out infinite; }
.fox[data-pose="running"] .fox-body{ animation: fox-run-bounce 0.42s ease-in-out infinite; }
.fox[data-pose="running"] .fox-tail{ animation: fox-run-tail 0.42s ease-in-out infinite; }
.fox[data-pose="running"] .fox-head{ animation: fox-run-head 0.42s ease-in-out infinite; }

@keyframes fox-leg-a{ 0%,100%{ transform: rotate(34deg); } 50%{ transform: rotate(-30deg); } }
@keyframes fox-leg-b{ 0%,100%{ transform: rotate(-30deg); } 50%{ transform: rotate(34deg); } }
@keyframes fox-run-bounce{ 0%,100%{ transform: translateY(0); } 50%{ transform: translateY(-4px); } }
@keyframes fox-run-tail{ 0%,100%{ transform: rotate(-8deg); } 50%{ transform: rotate(10deg); } }
@keyframes fox-run-head{ 0%,100%{ transform: rotate(2deg); } 50%{ transform: rotate(-3deg); } }

/* sitting: haunches down, tail curled forward */
.fox[data-pose="sitting"] .fox-leg-fl,
.fox[data-pose="sitting"] .fox-leg-fr{ transform: scaleY(0.55); }
.fox[data-pose="sitting"] .fox-leg-bl,
.fox[data-pose="sitting"] .fox-leg-br{ transform: rotate(55deg) scaleY(0.6); }
.fox[data-pose="sitting"] .fox-tail{ transform: rotate(34deg); }
.fox[data-pose="sitting"] .fox-body{ transform: translateY(6px) scaleY(0.94); }

/* curious: head tilted, one ear perked */
.fox[data-pose="curious"] .fox-head{ animation: none; transform: rotate(-14deg) translateY(-2px); }
.fox[data-pose="curious"] .fox-ear-left{ transform: rotate(-18deg); transform-box: fill-box; transform-origin: 100% 100%; }
.fox[data-pose="curious"] .fox-tail{ animation: fox-tail-sway 2.2s ease-in-out infinite; }

/* sleeping: curled up, eyes closed */
.fox[data-pose="sleeping"] .fox-rig{ transform: rotate(6deg) translateY(6px); transform-box: fill-box; transform-origin: 50% 50%; }
.fox[data-pose="sleeping"] .fox-tail{ transform: rotate(46deg); }
.fox[data-pose="sleeping"] .fox-leg-fl,
.fox[data-pose="sleeping"] .fox-leg-fr,
.fox[data-pose="sleeping"] .fox-leg-bl,
.fox[data-pose="sleeping"] .fox-leg-br{ transform: rotate(70deg) scaleY(0.5); }
.fox[data-pose="sleeping"] .fox-eye{ display: none; }
.fox[data-pose="sleeping"] .fox-eye-closed{ display: block; }
.fox[data-pose="sleeping"] .fox-head{ animation: fox-sleep-breathe 3.6s ease-in-out infinite; }
@keyframes fox-sleep-breathe{ 0%,100%{ transform: scale(1); } 50%{ transform: scale(1.015); } }

/* direction mirroring, applied on the header fox wrapper based on scroll direction */
.header-fox{
  transition: none;
}

.header-fox .fox-rig{
  transform-box: fill-box;
  transform-origin: 50% 50%;
}

.header-fox.direction-left .fox-rig{
  transform: scaleX(-1);
}

@keyframes fox-run-tail{
  0%,100%{ transform: rotate(-12deg); }
  50%{ transform: rotate(14deg); }
}


@media (prefers-reduced-motion: reduce){
  .fox .fox-part,
  .fox-rig,
  .loader-fox .fox-part{ animation: none !important; transition: none !important; }
}

/* ============================================================
   FOCUS / ACCESSIBILITY
   ============================================================ */
:focus-visible{ outline: 2px solid var(--c-cyan); outline-offset: 2px; }

/* ============================================================
   Ultra-wide guard
   ============================================================ */
@media (min-width: 1700px){
  section{ max-width: 1320px; }
}
