/* ============================================================================
   Power Userful LLC — styles.css
   The only stylesheet. One <link>, no @import (an @import serialises a
   round-trip before any paint).

   Order is load-bearing:
     1. Primitive tokens      raw hex, never touched by components
     2. Semantic tokens       the only thing components may reference
     3. Reset
     4. Type & space scales
     5. Layout primitives
     6. Base elements
     7. Components
     8. Utilities
     9. Dark mode + reduced motion   (remap semantic tokens ONLY)

   Palette is validated by tools/contrast.mjs. Re-run it after any colour
   change. Amber (#E8A33D) is 2.06:1 on light paper — decoration and button
   fill only. In dark mode it measures 8.22:1 and IS valid text. That
   asymmetry lives in --text-accent, never at a call site.
   ============================================================================ */

/* --- 1. PRIMITIVE TOKENS ------------------------------------------------- */

:root {
  /* light */
  --c-paper:        #FAFAF7;
  --c-surface:      #FFFFFF;
  --c-ink:          #1B1D3A;
  --c-muted:        #5A5C7A;
  --c-indigo:       #3D3F8F;
  --c-indigo-hover: #2E3070;
  --c-amber:        #E8A33D;
  --c-amber-hover:  #D8912A;
  --c-border:       #D6D6CE;
  --c-error:        #A32424;
  --c-success:      #1F6B45;

  /* dark */
  --c-paper-dk:        #14162E;
  --c-surface-dk:      #1D2040;
  --c-ink-dk:          #EDEEF5;
  --c-muted-dk:        #A0A3C0;
  --c-indigo-dk:       #9FA2E8;
  --c-indigo-hover-dk: #BFC1F2;
  --c-border-dk:       #32345A;
  --c-error-dk:        #FF9BA1;
  --c-success-dk:      #6EE7A0;
}

/* --- 2. SEMANTIC TOKENS -------------------------------------------------- */

:root {
  color-scheme: light;

  --bg:           var(--c-paper);
  --surface:      var(--c-surface);
  --text:         var(--c-ink);
  --text-muted:   var(--c-muted);
  --text-accent:  var(--c-indigo);        /* amber would FAIL here */
  --link:         var(--c-indigo);
  --link-hover:   var(--c-indigo-hover);
  --border:       var(--c-border);
  --focus-ring:   var(--c-indigo);

  --brand:        var(--c-indigo);
  --brand-hover:  var(--c-indigo-hover);
  --on-brand:     var(--c-paper);

  --accent:       var(--c-amber);         /* fill / decoration */
  --accent-hover: var(--c-amber-hover);
  --on-accent:    var(--c-ink);

  --error:        var(--c-error);
  --success:      var(--c-success);

  /* the inline logo reads these three */
  --mark-ring: var(--c-indigo);
  --mark-stem: var(--c-ink);
  --mark-tip:  var(--c-amber);
}

/* --- 3. RESET ------------------------------------------------------------ */

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

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

body {
  min-height: 100svh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img, picture, svg, video, canvas { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: none; }

h1, h2, h3, h4, h5, h6 { text-wrap: balance; line-height: 1.15; }
p, li, figcaption { text-wrap: pretty; }

:target { scroll-margin-block-start: 5ex; }

/* --- 4. TYPE & SPACE SCALES ---------------------------------------------- */
/* Fluid between a 320px and a 1280px viewport. No media queries for type. */

:root {
  --step--1: clamp(0.8750rem, 0.8542rem + 0.1042vw, 0.9375rem);
  --step-0:  clamp(1.0000rem, 0.9583rem + 0.2083vw, 1.1250rem);
  --step-1:  clamp(1.2500rem, 1.1875rem + 0.3125vw, 1.4375rem);
  --step-2:  clamp(1.5000rem, 1.3958rem + 0.5208vw, 1.8125rem);
  --step-3:  clamp(1.8125rem, 1.6458rem + 0.8333vw, 2.3125rem);
  --step-4:  clamp(2.1875rem, 1.9375rem + 1.2500vw, 2.9375rem);
  --step-5:  clamp(2.6250rem, 2.2500rem + 1.8750vw, 3.7500rem);

  --space-2xs: 0.5rem;
  --space-xs:  0.75rem;
  --space-s:   1rem;
  --space-m:   1.5rem;
  --space-l:   2rem;
  --space-xl:  clamp(2.5rem, 5vw, 4rem);
  --space-2xl: clamp(4rem, 8vw, 6rem);

  --radius: 0.5rem;
  --radius-sm: 0.375rem;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
               Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

/* --- 5. LAYOUT PRIMITIVES ------------------------------------------------ */

.wrapper {
  width: min(100% - 2rem, 72rem);
  margin-inline: auto;
}

/* Owl. Override per-context with --flow-space. */
.flow > * + * { margin-block-start: var(--flow-space, 1em); }

.grid-auto {
  display: grid;
  gap: var(--gap, var(--space-l));
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap, var(--space-s));
  align-items: center;
}

/* Two-up rather than three-up. For cards carrying bullet lists, where a
   third column squeezes every line to two or three words. */
.grid-auto--wide {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr));
}

/* Put .prose on a child of .wrapper, never on the .wrapper itself — .wrapper
   centres with margin-inline:auto, so the two together centre the whole
   column and it stops aligning with the rest of the page. For a single
   narrow paragraph inside a full-width section, use .measure instead. */
.prose { max-width: 65ch; }

.section { padding-block: var(--space-2xl); }

/* Flow-space presets. These exist as classes rather than as inline
   `style="--flow-space:…"` because `default-src 'self'` blocks style
   attributes (style-src-attr falls back to style-src falls back to
   default-src). Nothing in this site may carry a style attribute. */
.flow-s { --flow-space: var(--space-s); }
.flow-m { --flow-space: var(--space-m); }
.flow-l { --flow-space: var(--space-l); }

/* --- 6. BASE ELEMENTS ---------------------------------------------------- */

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

h1 { font-size: var(--step-4); letter-spacing: -0.02em; }
h2 { font-size: var(--step-3); letter-spacing: -0.015em; }
h3 { font-size: var(--step-2); letter-spacing: -0.01em; }
h4 { font-size: var(--step-1); }

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

hr {
  border: none;
  border-block-start: 1px solid var(--border);
  margin-block: var(--space-xl);
}

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

::selection {
  background-color: var(--accent);
  color: var(--on-accent);
}

/* --- 7. COMPONENTS ------------------------------------------------------- */

/* Skip link — first focusable element on every page. :focus, not
   :focus-visible: it must appear for any keyboard entry into the page. */
.skip-link {
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  z-index: 100;
  padding: var(--space-xs) var(--space-s);
  background-color: var(--surface);
  color: var(--link);
  border: 1px solid var(--border);
  border-start-start-radius: 0;
  border-end-end-radius: var(--radius-sm);
  transform: translateY(-120%);
  transition: transform 0.15s ease-out;
}
.skip-link:focus { transform: none; }

/* Header ------------------------------------------------------------------ */

.site-header {
  background-color: var(--surface);
  border-block-end: 1px solid var(--border);
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-s) var(--space-l);
  padding-block: var(--space-s);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--text);
  text-decoration: none;
}

.brand__mark {
  inline-size: 2.5rem;
  block-size: 2.5rem;
  flex: none;
}

.brand__name {
  font-size: var(--step-1);
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand__rule {
  inline-size: 1px;
  block-size: 1.75rem;
  background-color: var(--border);
  flex: none;
}

.brand__tagline {
  font-size: var(--step--1);
  color: var(--text-muted);
}

/* The tagline is the first thing to go when the header gets tight. */
@media (width < 48rem) {
  .brand__rule, .brand__tagline { display: none; }
}

/* Nav — no JS, no hamburger. Links wrap on narrow screens. */

.nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-s) var(--space-m);
  list-style: none;
  padding: 0;
}

.nav a {
  position: relative;
  display: flex;
  align-items: center;
  min-block-size: 44px;      /* tap target */
  color: var(--text-muted);
  font-weight: 500;
  text-decoration: none;
}
.nav a:hover { color: var(--link); }

/* Active state is set by the body class, NEVER by editing the nav markup.
   The nav block stays byte-identical across all pages. */
.page-services .nav-services,
.page-approach .nav-approach,
.page-about    .nav-about,
.page-contact  .nav-contact { color: var(--text); }

.page-services .nav-services::after,
.page-approach .nav-approach::after,
.page-about    .nav-about::after,
.page-contact  .nav-contact::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0.5rem;
  block-size: 2px;
  background-color: var(--accent);   /* decoration — amber is safe here */
}

/* Buttons ----------------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  min-block-size: 44px;
  padding: var(--space-xs) var(--space-m);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.button--primary { background-color: var(--brand); color: var(--on-brand); }
.button--primary:hover { background-color: var(--brand-hover); color: var(--on-brand); }

.button--accent { background-color: var(--accent); color: var(--on-accent); }
.button--accent:hover { background-color: var(--accent-hover); color: var(--on-accent); }

.button--ghost { border-color: var(--border); color: var(--link); }
.button--ghost:hover { border-color: var(--link); background-color: var(--surface); }

.button[disabled] { opacity: 0.6; cursor: not-allowed; }

/* Hero — CSS only. No photography exists, so gradients and type carry it. */

.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding-block: var(--space-2xl);
  background-color: var(--bg);
  background-image:
    radial-gradient(60rem 40rem at 88% -15%, color-mix(in oklab, var(--accent) 16%, transparent), transparent 70%),
    radial-gradient(50rem 40rem at -5% 0%,  color-mix(in oklab, var(--brand) 14%, transparent), transparent 65%);
}

/* Faint engineering-paper grid, faded out toward the bottom. */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    repeating-linear-gradient(to right,  color-mix(in oklab, var(--text) 6%, transparent) 0 1px, transparent 1px 4rem),
    repeating-linear-gradient(to bottom, color-mix(in oklab, var(--text) 6%, transparent) 0 1px, transparent 1px 4rem);
  mask-image: linear-gradient(to bottom, black, transparent 85%);
}

/* Oversized watermark of the mark. Decorative: aria-hidden in markup. */
.hero__watermark {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-end: -4rem;
  z-index: -1;
  inline-size: min(38rem, 60vw);
  block-size: auto;
  translate: 0 -50%;
  opacity: 0.05;
  pointer-events: none;
}

.hero h1 { font-size: var(--step-5); }

/* Opening paragraph of any page, hero or not. */
.lede {
  font-size: var(--step-1);
  color: var(--text-muted);
  max-width: 55ch;
}

/* Cards ------------------------------------------------------------------- */

.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1.25rem, 3vw, 2rem);
}

/* Inline SVG icons inherit currentColor, so dark mode is free. */
.card__icon {
  inline-size: 2.5rem;
  block-size: 2.5rem;
  color: var(--text-accent);
  margin-block-end: var(--space-s);
}

/* Bullet lists inside cards. The marker picks up the accent, which is one
   more place the mark's amber recurs in dark mode. */
.bullets {
  padding-inline-start: 1.25rem;
  color: var(--text-muted);
}
.bullets > li + li { margin-block-start: var(--space-2xs); }
.bullets li::marker { color: var(--text-accent); }

/* Closing aside — the "all services are delivered with…" note. */
.note {
  color: var(--text-muted);
  font-style: italic;
  max-width: 65ch;
}

/* Privacy and Terms. Dense, section-heavy prose needs more air before each
   heading than the default .flow rhythm gives. Must come after .flow (equal
   specificity, later wins). */
.legal h2 { margin-block-start: var(--space-xl); }
.legal h3 { margin-block-start: var(--space-m); }
.legal ul { padding-inline-start: 1.25rem; }
.legal li + li { margin-block-start: var(--space-2xs); }
.legal li::marker { color: var(--text-accent); }

/* Numbered steps — the five Approach principles. */

.steps {
  list-style: none;
  padding: 0;
  counter-reset: step;
}

.step {
  position: relative;
  padding-inline-start: 5rem;
  padding-block: var(--space-m);
}

.step::before {
  counter-increment: step;
  content: counter(step, decimal-leading-zero);
  position: absolute;
  inset-inline-start: 0;
  inset-block-start: var(--space-m);
  font-size: var(--step-3);
  font-weight: 700;
  line-height: 1;
  color: var(--text-accent);
  font-variant-numeric: tabular-nums;
}

/* Connecting rule between numerals. */
.step:not(:last-child)::after {
  content: "";
  position: absolute;
  inset-inline-start: 1.4rem;
  inset-block: calc(var(--space-m) + 2.5rem) 0;
  inline-size: 1px;
  background-color: var(--border);
}

/* Forms ------------------------------------------------------------------- */

.field { display: grid; gap: var(--space-2xs); }
.field label { font-weight: 600; }

.field :is(input, textarea) {
  inline-size: 100%;
  padding: var(--space-xs);
  background-color: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.field :is(input, textarea)[aria-invalid="true"] { border-color: var(--error); }
.field textarea { min-block-size: 8rem; resize: vertical; }

.field__error { color: var(--error); font-size: var(--step--1); }
.field__error:empty { display: none; }

/* Honeypot. Hidden here rather than via a style attribute, because
   `default-src 'self'` blocks inline style attributes (style-src-attr). */
.honeypot { display: none; }

#form-status:empty { display: none; }
#form-status[data-state="error"]   { color: var(--error); }
#form-status[data-state="success"] { color: var(--success); }

/* Footer ------------------------------------------------------------------ */

.site-footer {
  margin-block-start: var(--space-2xl);
  padding-block: var(--space-xl);
  border-block-start: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--step--1);
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--link); }

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-s) var(--space-l);
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-s) var(--space-m);
}

/* --- 8. UTILITIES -------------------------------------------------------- */

.visually-hidden:not(:focus):not(:active) {
  clip-path: inset(50%);
  block-size: 1px;
  inline-size: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
}

.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.measure     { max-width: 65ch; }

/* --- 9. DARK MODE -------------------------------------------------------- */
/* Remaps semantic tokens only. Nothing below touches a component rule. */

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg:          var(--c-paper-dk);
    --surface:     var(--c-surface-dk);
    --text:        var(--c-ink-dk);
    --text-muted:  var(--c-muted-dk);
    --text-accent: var(--c-amber);          /* 8.22:1 — amber IS text here */
    --link:        var(--c-indigo-dk);
    --link-hover:  var(--c-indigo-hover-dk);
    --border:      var(--c-border-dk);
    --focus-ring:  var(--c-amber);

    --brand:       var(--c-indigo-dk);
    --brand-hover: var(--c-indigo-hover-dk);
    --on-brand:    var(--c-paper-dk);

    --error:       var(--c-error-dk);
    --success:     var(--c-success-dk);

    --mark-ring: var(--c-indigo-dk);
    --mark-stem: var(--c-ink-dk);
    /* --mark-tip stays amber in both modes. */
  }
}

/* --- 9b. MOTION ---------------------------------------------------------- */

/* One flourish: the mark draws itself in. Only when motion is welcome.
   Each path carries pathLength="100", so one dasharray fits all four. */
@media (prefers-reduced-motion: no-preference) {
  .brand__mark path {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: mark-draw 0.7s ease-out forwards;
  }
  .brand__mark path:nth-child(2) { animation-delay: 0.1s; }
  .brand__mark path:nth-child(3) { animation-delay: 0.2s; }
  .brand__mark path:nth-child(4) { animation-delay: 0.35s; }
}

@keyframes mark-draw { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
