/* =========================================================
   Forma Libera — styles.css
   Plain CSS. Tokens at the top, then base, layout, components.
   ========================================================= */

/* ---------- Design Tokens ---------- */
:root {
  /* Brand palette (from inspirational palette) */
  --color-teal: #3b8aa0;
  --color-forest: #213b33; /* dark green */
  --color-deep-teal: #1f5a6e;
  --color-gold: #e8c75a;
  --color-olive: #5e7320;
  --color-lime: #dcf06a;

  /* Neutrals */
  --color-paper: #faf7f0;        /* warm off-white background */
  --color-paper-2: #f2ede2;      /* slightly deeper cream for alternating sections */
  --color-paper-3: #e8e1cf;      /* deeper still, used sparingly */
  --color-ink: #1f2421;          /* off-black, leans toward forest — ~14:1 on paper */
  --color-ink-soft: #4a524d;     /* muted body text where appropriate */
  --color-rule: rgba(31, 36, 33, 0.14);

  /* Semantic */
  --color-bg: var(--color-paper);
  --color-fg: var(--color-ink);
  --color-accent: var(--color-deep-teal);   /* primary accent, ~7:1 on paper */
  --color-accent-2: var(--color-olive);     /* secondary accent */
  --color-highlight: var(--color-lime);     /* highlight chip / hover bg */
  --color-warm: var(--color-gold);

  /* Type families */
  --font-display: "Playfair Display", "Iowan Old Style", "Georgia", serif;
  --font-body: "Hind", "Inter", system-ui, -apple-system, "Helvetica Neue",
    Arial, sans-serif;

  /* Type scale (Fibonacci-ish, in px). Used directly or via clamp() below. */
  --fs-xs: 13px;
  --fs-sm: 16px;
  --fs-base: 18px;
  --fs-lg: 21px;
  --fs-xl: 34px;
  --fs-2xl: 55px;
  --fs-3xl: 89px;

  /* Fluid display sizes for responsive headings */
  --fs-hero: clamp(40px, 8vw, 89px);
  --fs-h2: clamp(28px, 4.5vw, 55px);
  --fs-h3: clamp(20px, 2.4vw, 34px);

  /* Spacing scale (Fibonacci, in px) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 13px;
  --sp-4: 21px;
  --sp-5: 34px;
  --sp-6: 55px;
  --sp-7: 89px;
  --sp-8: 144px;

  /* Layout */
  --content-max: 1100px;
  --content-narrow: 720px;
  --radius-sm: 4px;
  --radius-md: 8px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur-fast: 160ms;
  --dur: 280ms;
  --dur-slow: 480ms;

  /* Header/nav sizing */
  --nav-toggle-size: 56px;
  --nav-toggle-inset: 21px;
}

/* ---------- Reset (light) ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}
body,
h1,
h2,
h3,
h4,
p,
ul,
ol,
figure {
  margin: 0;
}
ul {
  padding: 0;
  list-style: none;
}
img,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}
a {
  color: var(--color-accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--dur-fast) var(--ease);
}
a:hover {
  color: var(--color-forest);
}
button {
  font: inherit;
  cursor: pointer;
}

/* Section anchor offset so sticky/fixed elements don't cover headings */
section[id] {
  scroll-margin-top: var(--sp-6);
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}

/* ---------- Base typography ---------- */
body {
  background: var(--color-bg);
  color: var(--color-fg);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.55;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.01em;
  color: var(--color-forest);
}

h1 { font-size: var(--fs-hero); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }

p { max-width: 65ch; }

em {
  font-style: italic;
  font-family: var(--font-display);
  color: var(--color-accent);
}

code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.9em;
  background: var(--color-paper-3);
  padding: 0 var(--sp-1);
  border-radius: var(--radius-sm);
}

.eyebrow {
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 600;
  color: var(--color-olive);
  margin-bottom: var(--sp-4);
}

/* ---------- Utilities ---------- */
.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;
  top: -40px;
  left: var(--sp-3);
  background: var(--color-forest);
  color: var(--color-paper);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  z-index: 100;
}
.skip-link:focus {
  top: var(--sp-3);
}

/* ---------- Layout: sections ---------- */
.section {
  padding: var(--sp-7) var(--sp-4);
}
.section__inner {
  max-width: var(--content-max);
  margin: 0 auto;
}
.section__title {
  max-width: 22ch;
  margin-bottom: var(--sp-5);
}
.prose p + p {
  margin-top: var(--sp-4);
}
.prose p {
  font-size: var(--fs-base);
  color: var(--color-ink);
}

/* Section backgrounds — color-experiment v1.
   To roll back to monochrome cream alternation, run:
     git revert HEAD
   (or replace these four rules with:
       .section--about    { background: var(--color-paper); }
       .section--services { background: var(--color-paper-2); }
       .section--contact  { background: var(--color-paper); } )
*/
.section--about {
  /* Soft sage: lime-tinted cream */
  background: #ecf0d9;
}
.section--services {
  /* Bold dark teal section with cream cards (see overrides below) */
  background: var(--color-deep-teal);
  color: var(--color-paper);
}
.section--contact {
  /* Warm gold-tinted cream */
  background: #f4e8c4;
}

/* Color overrides for the dark services section so contrast holds */
.section--services .section__title,
.section--services h3 {
  color: var(--color-paper);
}
.section--services .eyebrow {
  color: var(--color-lime);
}
.section--services .service-card {
  background: var(--color-paper);
  border-color: rgba(250, 247, 240, 0.18);
}
.section--services .service-card__title {
  color: var(--color-forest);
}
.section--services .service-card__body {
  color: var(--color-ink);
}
.section--services .service-card:hover {
  border-color: var(--color-lime);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
}

/* ---------- Topbar (combines #2 blurred bar + #3 reveal-on-scroll) ---------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--nav-toggle-inset);
  /* Default state: chromeless over the hero */
  background: transparent;
  border-bottom: 1px solid transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  transition:
    background var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    backdrop-filter var(--dur) var(--ease),
    -webkit-backdrop-filter var(--dur) var(--ease);
}

/* Scrolled past hero: translucent cream bar with blur + hairline rule */
body.scrolled .site-header {
  background: rgba(250, 247, 240, 0.78); /* paper @ ~78% */
  border-bottom-color: var(--color-rule);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  backdrop-filter: saturate(140%) blur(14px);
}

/* Brand mark sits inside the topbar; hidden over hero, fades in on scroll */
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-1);
  border-radius: var(--radius-md);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition:
    opacity var(--dur) var(--ease),
    transform var(--dur) var(--ease),
    filter var(--dur) var(--ease);
}
.brand-mark img {
  height: 40px;
  width: auto;
  display: block;
}
.brand-mark:focus-visible {
  outline: 3px solid var(--color-lime);
  outline-offset: 3px;
}
@media (min-width: 900px) {
  .brand-mark img {
    height: 48px;
  }
}

/* Reveal brand mark once scrolled past hero */
body.scrolled .brand-mark {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* When the menu overlay opens, the topbar should let the forest show through cleanly */
body.nav-open .site-header {
  background: transparent;
  border-bottom-color: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
/* Invert brand mark to cream while overlay is open */
body.nav-open .brand-mark img {
  filter: brightness(0) invert(1);
}
/* Even on hero, while menu is open, show the brand mark on the forest */
body.nav-open .brand-mark {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.nav-toggle {
  position: relative;
  width: var(--nav-toggle-size);
  height: var(--nav-toggle-size);
  border-radius: 999px;
  background: var(--color-forest);
  color: var(--color-paper);
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 6px 20px rgba(31, 36, 33, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
.nav-toggle:hover {
  background: var(--color-deep-teal);
}
.nav-toggle:focus-visible {
  outline: 3px solid var(--color-lime);
  outline-offset: 3px;
}

.nav-toggle__bars {
  position: relative;
  display: block;
  width: 22px;
  height: 14px;
}
.nav-toggle__bars span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition:
    transform var(--dur) var(--ease),
    opacity var(--dur-fast) var(--ease),
    top var(--dur) var(--ease);
}
.nav-toggle__bars span:nth-child(1) { top: 0; }
.nav-toggle__bars span:nth-child(2) { top: 6px; }
.nav-toggle__bars span:nth-child(3) { top: 12px; }

/* When nav open: morph bars into an X */
body.nav-open .nav-toggle__bars span:nth-child(1) {
  top: 6px;
  transform: rotate(45deg);
}
body.nav-open .nav-toggle__bars span:nth-child(2) {
  opacity: 0;
}
body.nav-open .nav-toggle__bars span:nth-child(3) {
  top: 6px;
  transform: rotate(-45deg);
}

/* Full-screen overlay nav */
.primary-nav {
  position: fixed;
  inset: 0;
  background: var(--color-forest);
  color: var(--color-paper);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
  z-index: 40; /* below the toggle */
}
body.nav-open .primary-nav {
  opacity: 1;
  pointer-events: auto;
}

.primary-nav[hidden] {
  display: flex; /* override the HTML hidden attr — we manage visibility via opacity for transitions */
}

.primary-nav ul {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  text-align: center;
}
.primary-nav a {
  font-family: var(--font-display);
  font-size: clamp(34px, 7vw, 72px);
  font-weight: 500;
  color: var(--color-paper);
  text-decoration: none;
  letter-spacing: -0.01em;
  padding: var(--sp-2) var(--sp-3);
  display: inline-block;
  transition: color var(--dur-fast) var(--ease);
}
.primary-nav a:hover,
.primary-nav a:focus-visible {
  color: var(--color-lime);
}
.primary-nav a:focus-visible {
  outline: 2px solid var(--color-lime);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}

/* Lock body scroll when nav is open */
body.nav-open {
  overflow: hidden;
}

/* ---------- Hero ---------- */
.section--hero {
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background:
    radial-gradient(
      ellipse at 20% 0%,
      rgba(220, 240, 106, 0.18),
      transparent 60%
    ),
    radial-gradient(
      ellipse at 100% 100%,
      rgba(31, 90, 110, 0.14),
      transparent 55%
    ),
    var(--color-paper);
  padding: var(--sp-7) var(--sp-4);
}
.hero__inner {
  max-width: 880px;
  text-align: center;
  display: grid;
  gap: var(--sp-5);
  justify-items: center;
}
.hero__logo {
  width: min(86vw, 720px);
  height: auto;
}
.hero__tagline {
  font-family: var(--font-body);
  font-size: clamp(18px, 2.2vw, 21px);
  color: var(--color-ink);
  max-width: 50ch;
  line-height: 1.5;
}
.hero__scroll-cue {
  position: absolute;
  bottom: var(--sp-5);
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--fs-xs);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-ink-soft);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: var(--sp-3) var(--sp-5);
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--dur) var(--ease),
    color var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    transform var(--dur-fast) var(--ease);
}
.btn--primary {
  background: var(--color-forest);
  color: var(--color-paper);
}
.btn--primary:hover {
  background: var(--color-deep-teal);
  color: var(--color-paper);
}
.btn--primary:focus-visible {
  outline: 3px solid var(--color-lime);
  outline-offset: 3px;
}
.btn:active {
  transform: translateY(1px);
}

/* ---------- Services ---------- */
.services-grid {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: 1fr;
  margin-top: var(--sp-5);
}
@media (min-width: 720px) {
  .services-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-5);
  }
}
.service-card {
  background: var(--color-paper);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
  padding: var(--sp-5);
  transition:
    transform var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}
.service-card:hover {
  transform: translateY(-2px);
  border-color: var(--color-deep-teal);
  box-shadow: 0 10px 30px rgba(31, 90, 110, 0.08);
}
.service-card__title {
  font-size: var(--fs-h3);
  margin-bottom: var(--sp-3);
}
.service-card__body {
  color: var(--color-ink);
  font-size: var(--fs-base);
}

/* ---------- Contact ---------- */
.contact__intro {
  margin-bottom: var(--sp-5);
  font-size: var(--fs-base);
}
.contact__email {
  font-weight: 600;
}

.contact-form {
  display: grid;
  gap: var(--sp-4);
  max-width: var(--content-narrow);
}
.field {
  display: grid;
  gap: var(--sp-2);
}
.field label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--color-forest);
}
.field input,
.field textarea {
  font: inherit;
  color: var(--color-ink);
  background: var(--color-paper);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-3);
  transition:
    border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}
.field textarea {
  resize: vertical;
  min-height: 144px;
}
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--color-deep-teal);
  box-shadow: 0 0 0 3px rgba(31, 90, 110, 0.18);
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--color-forest);
  color: var(--color-paper-2);
  padding: var(--sp-5) var(--sp-4);
}
.site-footer__inner {
  max-width: var(--content-max);
  margin: 0 auto;
  font-size: var(--fs-sm);
}

/* ---------- Larger screens: section padding scales up ---------- */
@media (min-width: 900px) {
  .section {
    padding: var(--sp-8) var(--sp-6);
  }
  .section--hero {
    padding: var(--sp-8) var(--sp-6);
  }
}
