/* ==========================================================================
   Spin Digital Design — site styles
   Plain CSS, no build step. Tokens first, then base, layout, components.
   ========================================================================== */

:root {
  /* Colour
     Black + white come from the "Ideas" concept. The magenta comes from the
     "Portal" concept tokens (#d81ba8) but is split into accessible variants:
       --accent-fill  #c0168f  white text on it = 5.6:1  (buttons)
       --accent-ink   #f06acb  on black = 7.6:1          (links, focus, active)
       --accent-brand #d81ba8  decorative only (favicon, spiral glow)          */
  --black: #000;
  --white: #fff;
  --grey-1: #a3a3a3;   /* secondary text, 8.3:1 on black */
  --grey-2: #262626;   /* hairlines, panels */
  --grey-3: #141414;   /* raised surfaces */
  --accent-brand: #d81ba8;
  --accent-fill: #c0168f;
  --accent-fill-hover: #a81380;
  --accent-ink: #f06acb;

  --font: "Mulish", "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  --tracking-head: 0.18em;
  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: clamp(1.125rem, 1.05rem + 0.3vw, 1.3125rem);
  --step-2: clamp(1.375rem, 1.2rem + 0.8vw, 1.875rem);
  --step-3: clamp(1.75rem, 1.4rem + 1.6vw, 2.75rem);

  /* Space + layout */
  --measure: 45rem;          /* 720px column from the Ideas file */
  --gutter: clamp(1.25rem, 4vw, 4rem);
  --section-gap: clamp(5rem, 10vw, 8rem);
  --header-h: 6rem;
  --header-h-compact: 4.25rem;
  --radius: 4px;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-h-compact);
}

body {
  margin: 0;
  background: var(--black);
  color: var(--white);
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.65;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a { color: var(--white); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 4px;
  border-radius: 2px;
}

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

h1, h2, h3 {
  margin: 0;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-head);
  line-height: 1.25;
  text-wrap: balance;
}
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); letter-spacing: 0.14em; }

.visually-hidden {
  position: absolute !important;
  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;
  left: 1rem; top: -4rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--white);
  color: var(--black);
  font-weight: 700;
  transition: top 0.2s var(--ease-out);
}
.skip-link:focus { top: 1rem; color: var(--black); }

/* ---------- Header ---------- */
.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding-inline: var(--gutter);
  background: rgba(0,0,0,.75);
  transition: height 0.35s var(--ease-out), background-color 0.35s var(--ease-out), border-color 0.35s;
  border-bottom: 1px solid transparent;
}
.site-header.is-compact {
  height: var(--header-h-compact);
  background: rgb(0 0 0 / 0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom-color: var(--grey-2);
}

.brand { display: block; flex: none; color: var(--white); }
.brand img {
  height: 4rem;
  width: auto;
  transition: height 0.35s var(--ease-out), transform 0.8s var(--ease-out);
}
.site-header.is-compact .brand img { height: 2.75rem; }
.brand:hover img, .brand:focus-visible img { transform: rotate(-8deg); }

.nav { margin-left: auto; }
.nav ul {
  display: flex;
  gap: clamp(1rem, 2.2vw, 2.25rem);
  margin: 0; padding: 0;
  list-style: none;
}
.nav a {
  position: relative;
  display: inline-block;
  padding-block: 0.5rem;
  color: var(--white);
  text-decoration: none;
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: var(--tracking-head);
  text-transform: uppercase;
}
/* Underline that grows from the centre; also marks the section in view */
.nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0.15rem;
  height: 2px;
  background: var(--accent-ink);
  transform: scaleX(0);
  transition: transform 0.35s var(--ease-out);
}
.nav a:hover, .nav a[aria-current] { color: var(--white); }
.nav a:hover::after, .nav a[aria-current]::after { transform: scaleX(1); }

.menu-toggle {
  display: none;
  margin-left: auto;
  width: 3rem; height: 3rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--white);
  cursor: pointer;
  position: relative;
  z-index: 60;
}
.menu-toggle span,
.menu-toggle span::before,
.menu-toggle span::after {
  position: absolute;
  left: 50%;
  width: 1.5rem; height: 2px;
  margin-left: -0.75rem;
  background: currentColor;
  transition: transform 0.3s var(--ease-out), opacity 0.2s;
}
.menu-toggle span { top: 50%; }
.menu-toggle span::before, .menu-toggle span::after { content: ""; left: 0; margin-left: 0; }
.menu-toggle span::before { transform: translateY(-7px); }
.menu-toggle span::after { transform: translateY(7px); }
.menu-toggle[aria-expanded="true"] span { background: transparent; }
.menu-toggle[aria-expanded="true"] span::before { transform: rotate(45deg); background: var(--white); }
.menu-toggle[aria-expanded="true"] span::after { transform: rotate(-45deg); background: var(--white); }

@media (max-width: 64rem) {
  :root { --header-h: 5rem; }
  .brand img { height: 3.25rem; }
  .menu-toggle { display: block; }

  /* Full-screen menu, as in the Ideas mobile frame */
  .nav {
    position: fixed;
    inset: 0;
    z-index: 55;
    display: grid;
    place-items: center;
    background: var(--black);
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.35s var(--ease-out), visibility 0s linear 0.35s;
  }
  .nav.is-open {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.35s var(--ease-out), visibility 0s;
  }
  .nav ul { flex-direction: column; align-items: center; gap: 1.75rem; }
  .nav a { font-size: var(--step-1); }
  .nav li {
    opacity: 0;
    transform: translateY(0.75rem);
    transition: opacity 0.4s var(--ease-out), transform 0.4s var(--ease-out);
  }
  .nav.is-open li { opacity: 1; transform: none; }
  .nav.is-open li:nth-child(2) { transition-delay: 0.04s; }
  .nav.is-open li:nth-child(3) { transition-delay: 0.08s; }
  .nav.is-open li:nth-child(4) { transition-delay: 0.12s; }
  .nav.is-open li:nth-child(5) { transition-delay: 0.16s; }
  .nav.is-open li:nth-child(6) { transition-delay: 0.20s; }
  body.menu-open { overflow: hidden; }
}

/* ---------- Layout ---------- */
main { display: block; }

.section {
  padding-inline: var(--gutter);
  margin-block: var(--section-gap);
}
.section > .inner {
  max-width: var(--measure);
  margin-inline: auto;
}
.section-head {
  text-align: center;
  margin-bottom: 2rem;
}
.lede { font-size: var(--step-1); line-height: 1.55; }
.muted { color: var(--grey-1); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: calc(var(--header-h) + 2rem) var(--gutter) 4rem;
  overflow: hidden;
  text-align: center;
  isolation: isolate;
}
.hero__stage {
  position: relative;
  /* Fixed stage the spiral centres on; keeps the headline above the fold */
  width: min(20rem, 62vw, calc(48svh * 414 / 542));
  aspect-ratio: 414 / 542;
  margin-inline: auto;
}
.hero__spiral {
  position: absolute;
  z-index: -1;
  top: 50%; left: 50%;
  width: min(62rem, 150vw);
  max-width: none;
  translate: -50% -50%;
  opacity: 0.35;
  will-change: transform;
  /* rotation is driven by --spin (set in JS from scroll position) */
  transform: rotate(calc(var(--spin, 0) * 1deg));
}
.hero__copy {
  max-width: 44rem;
  margin: clamp(1.75rem, 4vh, 3rem) auto 0;
}
@media (max-width: 40rem) {
  :root { --tracking-head: 0.1em; }
}
.hero__copy h1 { margin-bottom: 1.25rem; }
.hero__copy p { color: var(--grey-1); font-size: var(--step-1); }

.scroll-cue {
  position: absolute;
  left: 50%; bottom: 1.5rem;
  translate: -50% 0;
  width: 3px; height: 4rem;
  background: linear-gradient(var(--white), transparent);
  opacity: 0.6;
  animation: cue 2.4s var(--ease-in-out) infinite;
  transform-origin: top;
}
@keyframes cue {
  0%   { transform: scaleY(0); opacity: 0; }
  30%  { opacity: 0.6; }
  60%  { transform: scaleY(1); opacity: 0.6; }
  100% { transform: scaleY(1); opacity: 0; }
}

/* ---------- Services ---------- */
.service + .service { margin-top: calc(var(--section-gap) * 0.9); }
.service h2 { margin-bottom: 1.75rem; }
.service .body { max-width: var(--measure); margin-inline: auto; }

.caps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.35rem 2rem;
  margin: 2rem 0 0;
  padding: 1.5rem 0 0;
  border-top: 1px solid var(--grey-2);
  list-style: none;
  color: var(--grey-1);
  font-size: var(--step--1);
}
.caps li { padding-left: 1rem; position: relative; }
.caps li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.72em;
  width: 0.4rem; height: 1px;
  background: var(--accent-ink);
}

.proof {
  margin-top: 1.25rem;
  font-size: var(--step--1);
  color: var(--grey-1);
}
.proof button {
  font: inherit;
  color: var(--white);
  background: none;
  border: 0;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.proof button:hover { color: var(--accent-ink); }

/* ---------- Clients ---------- */
.clients {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  align-items: end;            /* bottom-align logos in each row */
  gap: 3rem 2rem;
  max-width: 48rem;
  margin: 3rem auto 0;
  padding: 0;
  list-style: none;
}
.clients li {
  grid-column: span 2;         /* 3 per row */
  display: flex;
  justify-content: center;
}
.clients li.wide { grid-column: span 3; }   /* 2 per row */

.clients img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 4.5rem;
  filter: grayscale(1);
  opacity: 0.7;
}

@media (max-width: 36rem) {
  .clients { grid-template-columns: repeat(4, 1fr); gap: 2rem 1.5rem; }
  .clients li.wide { grid-column: span 4; }   /* 2 per row, wide logos alone */
  .clients img { max-height: 3rem; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0.75rem 1.75rem;
  border: 1px solid var(--accent-fill);
  border-radius: var(--radius);
  background: var(--accent-fill);
  color: var(--white);
  font: inherit;
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: var(--tracking-head);
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.25s, border-color 0.25s, transform 0.25s var(--ease-out);
}
.btn:hover { background: var(--accent-fill-hover); border-color: var(--accent-fill-hover); color: var(--white); }
.btn:active { transform: translateY(1px); }
.btn--ghost { background: transparent; border-color: var(--white); }
.btn--ghost:hover { background: var(--white); border-color: var(--white); color: var(--black); }

.cta { text-align: center; }
.cta p { margin-bottom: 2rem; }

/* ---------- Page header (inner pages) ---------- */
.page-head {
  padding: calc(var(--header-h) + clamp(3rem, 8vw, 6rem)) var(--gutter) 0;
  text-align: center;
}
.page-head .inner { max-width: var(--measure); margin-inline: auto; }
.page-head h1 { margin-bottom: 1.25rem; }
.page-head p { color: var(--grey-1); font-size: var(--step-1); }

/* ---------- Contact ---------- */
.contact-grid {
  display: grid;
  gap: 3rem;
  max-width: 64rem;
  margin-inline: auto;
}
@media (min-width: 56rem) {
  .contact-grid { grid-template-columns: 1fr 1.6fr; gap: 5rem; }
}
.contact-details h2 { font-size: var(--step-1); margin-bottom: 1rem; }
.contact-details dl { margin: 0; }
.contact-details dt {
  margin-top: 1.5rem;
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--grey-1);
}
.contact-details dd { margin: 0.25rem 0 0; }

.form { display: grid; gap: 1.5rem; }
.field { display: grid; gap: 0.5rem; }
.field label { font-weight: 700; font-size: var(--step--1); letter-spacing: 0.04em; }
.field .hint { font-size: var(--step--1); color: var(--grey-1); }
.input, .select, .textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid #4d4d4d;
  border-radius: var(--radius);
  background: var(--grey-3);
  color: var(--white);
  font: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input:hover, .select:hover, .textarea:hover { border-color: #808080; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent-ink);
  box-shadow: 0 0 0 3px rgb(240 106 203 / 0.25);
}
.select {
  appearance: none;
  padding-right: 2.75rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 0.75rem;
}
.textarea { min-height: 10rem; resize: vertical; }
.counter { justify-self: end; font-size: var(--step--1); color: var(--grey-1); }
.counter.is-near { color: var(--accent-ink); }
.hp { display: none; }

/* ---------- Team (stub) ---------- */
.team {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 2rem;
  margin: 2.5rem 0 0;
  padding: 0;
  list-style: none;
}
.team-member__photo {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px dashed #4d4d4d;
  border-radius: var(--radius);
  color: var(--grey-1);
  font-size: var(--step--1);
  margin-bottom: 1rem;
}
.team-member__photo img { width: 40%; opacity: 0.6; }
.team-member h3 { font-size: var(--step-0); margin-bottom: 0.25rem; }
.team-member p { color: var(--grey-1); font-size: var(--step--1); }

/* ---------- Prose (legal, privacy) ---------- */
.prose { max-width: var(--measure); margin-inline: auto; }
.prose > ul { list-style: none; }
.prose ul h2 { text-align: center; }
.prose h2 { font-size: var(--step-1); margin: 3rem 0 1rem; }
.prose .todo {
  padding: 1rem 1.25rem;
  border: 1px dashed var(--accent-ink);
  border-radius: var(--radius);
  color: var(--grey-1);
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: var(--section-gap);
  padding: 4rem var(--gutter) 2.5rem;
  text-align: center;
}
.site-footer .brand { display: inline-block; }
.site-footer .brand img { height: 4.5rem; margin-inline: auto; }
.footer-nav ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem 2rem;
  margin: 2rem 0;
  padding: 0;
  list-style: none;
}
.footer-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  max-width: 80rem;
  margin: 3rem auto 0;
  padding-top: 1.5rem;
  font-size: var(--step--1);
  color: var(--grey-1);
}
.footer-meta ul { display: flex; gap: 1.5rem; margin: 0; padding: 0; list-style: none; }
.footer-meta a { color: var(--grey-1); }
.footer-meta a:hover { color: var(--accent-ink); }

/* ==========================================================================
   Motion
   Only applied when JS has run (html.js) and the visitor hasn't asked for
   reduced motion. Without JS, everything is simply visible.
   ========================================================================== */

/* 1. Headings "track in": letters start wide and faint, settle to the
      Ideas-style tracking. One motif, used for every section heading.     */
.js [data-reveal="heading"] {
  opacity: 0;
  letter-spacing: 0.6em;
  transition: opacity 0.9s var(--ease-out), letter-spacing 1.2s var(--ease-out);
}
.js [data-reveal="heading"].is-in { opacity: 1; letter-spacing: var(--tracking-head); }

/* 2. Body copy eases in just after its heading */
.js [data-reveal="body"] {
  opacity: 0;
  transform: translateY(1rem);
  transition: opacity 0.8s var(--ease-out) 0.25s, transform 0.8s var(--ease-out) 0.25s;
}
.js [data-reveal="body"].is-in { opacity: 1; transform: none; }

/* 3. Client tiles cascade in */
.js .clients li {
  opacity: 0;
  transform: translateY(0.75rem);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 50ms);
}
.js .clients.is-in li { opacity: 1; transform: none; }

/* 4. Hero entrance: spiral unwinds into place, copy follows */
.js .hero__spiral { animation: spiral-in 2.4s var(--ease-out) both; }
.js .hero__copy { animation: rise 1.2s var(--ease-out) 0.7s both; }
@keyframes spiral-in {
  from { opacity: 0; scale: 0.6; rotate: -120deg; }
  to   { opacity: 0.35; scale: 1; rotate: 0deg; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(1.5rem); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
  .js [data-reveal], .js .clients li { opacity: 1 !important; transform: none !important; }
  .js [data-reveal="heading"] { letter-spacing: var(--tracking-head) !important; }
  .scroll-cue { display: none; }
}
