/* ============================================================
   base.css — reset, typography, page chrome, scroll-reveal
   ============================================================ */

@import url("./tokens.css");

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

html {
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--lh-body);
  color: var(--color-text);
  background-color: var(--color-page-bg);
  /* Subtle warm grain — SVG noise data URI, very faint */
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.16  0 0 0 0 0.23  0 0 0 0 0.20  0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-repeat: repeat;
  background-size: 160px 160px;
  -moz-text-size-adjust: 100%;
}

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

/* Any <img> placed in a container with a fixed aspect-ratio (the wrapper
   sets the box; the image fills it). Cover crops to fill without distortion.
   Targets the named media wrappers used across the site plus a generic
   .media-frame escape hatch for ad-hoc images dropped in later. */
.hero-img-wrap > img,
.event-card-img > img,
.portrait-block-img > img,
.media-frame > img {
  min-width: 100%;
  min-height: 100%;
  object-fit: cover;
  object-position: center;
}

/* Generic media frame: sets a 4/5 portrait box by default; override the
   --ratio var inline (e.g. style="--ratio: 16/9") when needed. */
.media-frame {
  position: relative;
  width: 100%;
  aspect-ratio: var(--ratio, 4 / 5);
  overflow: hidden;
  border-radius: var(--radius-img);
}

button { font: inherit; color: inherit; cursor: pointer; }

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

p { margin: 0 0 var(--sp-6); }
p:last-child { margin-bottom: 0; }

ul, ol { margin: 0 0 var(--sp-6); padding-left: var(--sp-6); }
ul li, ol li { margin-bottom: var(--sp-2); }

hr {
  border: 0;
  border-top: 1px solid var(--color-rule);
  margin: var(--sp-12) 0;
}

::selection {
  background: var(--color-accent-soft);
  color: var(--color-primary-deep);
}

/* ---- Typography scale ----------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-body);
  color: var(--color-primary-deep);
  margin: 0 0 var(--sp-6);
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-snug);
  font-weight: var(--weight-semibold);
}

h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--text-3xl);
  line-height: var(--lh-tight);
  letter-spacing: -0.025em;
  font-variation-settings: "opsz" 144, "SOFT" 60;
  color: var(--color-primary-deep);
}

h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--text-2xl);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 96, "SOFT" 50;
  color: var(--color-primary-deep);
}

h3 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: 0;
}

h4 {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

@media (max-width: 720px) {
  h1 { font-size: 2.5rem; }
  h2 { font-size: 2rem; }
  h3 { font-size: 1.375rem; }
}

/* ---- Containers + page rhythm --------------------------- */
.container-text   { max-width: var(--container-text); margin: 0 auto; padding: 0 var(--page-px); }
.container-prose  { max-width: var(--container-prose); margin: 0 auto; padding: 0 var(--page-px); }
.container-wide   { max-width: var(--container-wide); margin: 0 auto; padding: 0 var(--page-px); }
.container-outer  { max-width: var(--container-outer); margin: 0 auto; padding: 0 var(--page-px); }

@media (min-width: 768px) {
  .container-text, .container-prose, .container-wide, .container-outer {
    padding-left: var(--page-px-lg);
    padding-right: var(--page-px-lg);
  }
}

main { display: block; }
section { padding: var(--sp-20) 0; }
section + section { padding-top: 0; }

@media (min-width: 768px) {
  section { padding: var(--sp-24) 0; }
}

/* ---- Editorial primitives -------------------------------- */

/* Section eyebrow — small caps label above section heading */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--sp-5);
}
.eyebrow::before {
  content: "";
  width: 1.75rem;
  height: 1px;
  background: currentColor;
  display: block;
}

/* Hairline divider — used between sections for editorial rhythm */
.hairline {
  border: 0;
  height: 1px;
  background: linear-gradient(to right,
    transparent 0%,
    var(--color-rule) 25%,
    var(--color-rule) 75%,
    transparent 100%);
  margin: 0 auto;
  max-width: 32rem;
}

/* Asterism — three dots between sections, ornament */
.asterism {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--sp-4);
  color: var(--color-blush);
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 0.5em;
  margin: var(--sp-8) auto;
  user-select: none;
}
.asterism::before { content: "\2042"; }

/* Drop cap — for first paragraph of intro sections */
.drop-cap::first-letter {
  font-family: var(--font-display);
  font-weight: 400;
  font-variation-settings: "opsz" 144, "SOFT" 60;
  font-size: 4.75em;
  float: left;
  line-height: 0.85;
  margin: 0.05em 0.12em 0 -0.05em;
  color: var(--color-primary);
}

/* Pull quote — large display italic, with green vertical rule */
.pull-quote {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  line-height: 1.35;
  color: var(--color-primary-deep);
  border-left: 2px solid var(--color-primary-light);
  padding-left: var(--sp-6);
  margin: var(--sp-12) 0;
  font-variation-settings: "opsz" 96, "SOFT" 80;
}

/* Section heading with emoji (preserves Phase 4 §3.4 spec, restyled) */
.section-heading {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--text-2xl);
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--color-primary-deep);
  margin: 0 0 var(--sp-6);
  font-variation-settings: "opsz" 144, "SOFT" 50;
}

.section-heading .emoji-prefix {
  display: inline-block;
  margin-right: var(--sp-3);
  font-size: 0.75em;
  vertical-align: 0.06em;
  filter: saturate(0.85);
}

@media (max-width: 720px) {
  .section-heading { font-size: 1.75rem; }
}

/* Section number tag — optional editorial flourish */
.section-number {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--text-sm);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--color-text-muted);
  display: block;
  margin-bottom: var(--sp-3);
}

/* Inline links inside body copy — orange, animated underline */
.prose a,
section p a,
section li a {
  color: var(--color-primary-deep);
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 100% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  padding-bottom: 1px;
  transition: color var(--transition-fast), background-size var(--transition-fast);
}
.prose a:hover,
section p a:hover,
section li a:hover {
  color: var(--color-accent);
  background-size: 100% 2px;
}

/* Service list (used in the home page approach section) */
.tagged-list {
  list-style: none;
  padding-left: 0;
  margin: var(--sp-6) 0;
  display: grid;
  gap: var(--sp-3);
}
.tagged-list li {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  position: relative;
  padding-left: var(--sp-5);
  margin-bottom: 0;
}
.tagged-list li::before {
  content: "—";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--color-accent);
  font-weight: var(--weight-bold);
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--sp-4);
  background: var(--color-primary-deep);
  color: var(--color-page-bg);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-sm);
  z-index: calc(var(--z-drawer) + 1);
  font-family: var(--font-body);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  transition: top var(--transition-fast);
}
.skip-link:focus { top: var(--sp-3); }

/* Visually hidden — for honeypot, screen-reader-only labels */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus ring */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---- Scroll reveal — only hide when JS is ready --------- */
.js-reveal [data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 700ms cubic-bezier(0.22, 0.61, 0.36, 1),
              transform 700ms cubic-bezier(0.22, 0.61, 0.36, 1);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}
.js-reveal [data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .js-reveal [data-reveal] { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}
