@layer reset, tokens, base, layout, components, utilities;

/* ============================================
   RESET — minimal, respectful
   ============================================ */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  body { margin: 0; }
  h1, h2, h3, h4, p, figure, blockquote { margin: 0; }
  img, video, svg, canvas { display: block; max-width: 100%; height: auto; }
  button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
  a { color: inherit; text-decoration: none; }
  ul { list-style: none; margin: 0; padding: 0; }
  :focus-visible {
    outline: 2px solid var(--ember);
    outline-offset: 3px;
  }
}

/* ============================================
   TOKENS — my own voice for this place
   ============================================ */
@layer tokens {
  :root {
    /* Night forest + fire */
    --night: #0C1110;
    --forest: #151F1C;
    --bark: #2C2522;
    --coal: #3A2F2B;
    --ember: #C45C2A;
    --ember-soft: #E07A47;
    --gold: #C9A46B;
    --birch: #E8DFD0;
    --mist: #9BA89A;
    --moss: #4A5C4A;

    /* Type — book + journal */
    --font-display: "Fraunces", "DejaVu Serif", Georgia, "Times New Roman", serif;
    --font-body: "Mona Sans", "Ubuntu Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

    --step--1: clamp(0.875rem, 0.82rem + 0.22vw, 1rem);
    --step-0:  clamp(1.0rem, 0.94rem + 0.3vw, 1.15rem);
    --step-1:  clamp(1.25rem, 1.12rem + 0.6vw, 1.6rem);
    --step-2:  clamp(1.65rem, 1.4rem + 1.1vw, 2.1rem);
    --step-3:  clamp(2.1rem, 1.7rem + 1.9vw, 2.9rem);
    --step-4:  clamp(2.7rem, 2.0rem + 3.2vw, 4.1rem);

    --space-s:  clamp(0.65rem, 0.6rem + 0.25vw, 0.9rem);
    --space-m:  clamp(1.1rem, 0.95rem + 0.7vw, 1.6rem);
    --space-l:  clamp(1.8rem, 1.5rem + 1.4vw, 2.8rem);
    --space-xl: clamp(2.8rem, 2.2rem + 2.8vw, 4.6rem);
    --space-2xl: clamp(4.2rem, 3.4rem + 4vw, 7rem);

    --radius: 6px;
    --radius-soft: 14px;

    --ease: cubic-bezier(0.22, 1, 0.36, 1);
  }

  @media (prefers-reduced-motion: reduce) {
    :root { --ease: linear; }
  }
}

/* ============================================
   BASE
   ============================================ */
@layer base {
  body {
    font-family: var(--font-body);
    font-size: var(--step-0);
    line-height: 1.65;
    color: var(--birch);
    background: var(--night);
    -webkit-font-smoothing: antialiased;
  }

  .font-display {
    font-family: var(--font-display);
    font-feature-settings: "kern" 1, "tnum" 0;
  }

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

  .container {
    max-width: 1080px;
    margin-inline: auto;
    padding-inline: var(--space-m);
  }

  .lead {
    font-size: var(--step-1);
    line-height: 1.5;
    max-width: 52ch;
  }

  .subtle {
    color: var(--mist);
  }
}

/* ============================================
   LAYOUT & RHYTHM
   ============================================ */
@layer layout {
  .site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--night) 88%, transparent);
    backdrop-filter: blur(10px);
    transition: background 200ms var(--ease);
  }
  .site-header.scrolled {
    background: color-mix(in srgb, var(--night) 96%, transparent);
  }

  .nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-block: var(--space-s);
    min-height: 68px;
  }

  .wordmark {
    font-family: var(--font-display);
    font-size: var(--step-1);
    letter-spacing: -0.01em;
    font-weight: 600;
  }

  @media (min-width: 60rem) {
    #nav-cta { display: inline-flex !important; }
  }

  .hero {
    position: relative;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--night);
  }

  .hero-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
  }

  .hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
      to bottom,
      rgba(12,17,16,0.45) 0%,
      rgba(12,17,16,0.72) 42%,
      rgba(12,17,16,0.88) 78%,
      var(--night) 100%
    );
    z-index: 2;
  }

  .hero-content {
    position: relative;
    z-index: 3;
    text-align: center;
    max-width: 780px;
    padding-inline: var(--space-m);
    padding-bottom: var(--space-xl);
  }

  .hero-label {
    font-size: var(--step--1);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: var(--space-s);
  }

  .hero-title {
    font-size: var(--step-4);
    line-height: 0.96;
    font-weight: 600;
    letter-spacing: -0.03em;
    margin-bottom: var(--space-m);
  }

  .hero-subtitle {
    font-size: var(--step-1);
    max-width: 38ch;
    margin-inline: auto;
    color: var(--mist);
  }

  .orientation {
    background: var(--forest);
    padding-block: var(--space-l);
    border-bottom: 1px solid var(--coal);
  }

  .signals {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-s) var(--space-l);
    justify-content: center;
    margin-top: var(--space-m);
    font-size: var(--step--1);
    color: var(--mist);
  }

  .signal {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
  }
  .signal::before {
    content: "•";
    color: var(--ember);
  }

  /* Philosophy */
  .philosophy-grid {
    display: grid;
    gap: var(--space-xl);
  }
  @media (min-width: 60rem) {
    .philosophy-grid {
      grid-template-columns: repeat(3, 1fr);
      gap: var(--space-l);
    }
  }

  .belief {
    display: flex;
    flex-direction: column;
    gap: var(--space-s);
  }
  .belief svg {
    width: 52px;
    height: 52px;
    color: var(--ember);
    margin-bottom: var(--space-s);
  }
  .belief h3 {
    font-family: var(--font-display);
    font-size: var(--step-1);
    color: var(--birch);
  }

  /* Programs */
  .fires {
    display: grid;
    gap: var(--space-m);
  }
  @media (min-width: 40rem) {
    .fires {
      grid-template-columns: repeat(2, 1fr);
    }
  }
  @media (min-width: 72rem) {
    .fires {
      grid-template-columns: repeat(4, 1fr);
    }
  }

  .fire {
    background: var(--forest);
    border: 1px solid var(--coal);
    border-radius: var(--radius-soft);
    padding: var(--space-l) var(--space-m);
    display: flex;
    flex-direction: column;
    transition: border-color 180ms var(--ease), transform 180ms var(--ease);
  }
  .fire:hover {
    border-color: var(--ember);
    transform: translateY(-2px);
  }

  .fire-emblem {
    width: 46px;
    height: 46px;
    color: var(--gold);
    margin-bottom: var(--space-s);
  }

  .fire h3 {
    font-family: var(--font-display);
    font-size: var(--step-1);
    margin-bottom: 0.35rem;
  }

  .fire .promise {
    color: var(--mist);
    font-size: var(--step--1);
    line-height: 1.5;
    flex: 1;
  }

  .fire .tend {
    margin-top: var(--space-m);
    font-size: var(--step--1);
    color: var(--ember);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 120ms var(--ease);
  }
  .fire .tend:hover {
    color: var(--ember-soft);
  }

  /* Stories */
  .stories {
    display: grid;
    gap: var(--space-l);
  }
  @media (min-width: 60rem) {
    .stories {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  .story {
    background: var(--forest);
    border-radius: var(--radius-soft);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .story-media {
    aspect-ratio: 4 / 2.65;
    background-size: cover;
    background-position: center;
    position: relative;
  }
  .story-media::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent, rgba(12,17,16,0.55));
  }

  .story-content {
    padding: var(--space-l) var(--space-m);
    flex: 1;
    display: flex;
    flex-direction: column;
  }

  .story blockquote {
    font-family: var(--font-display);
    font-size: var(--step-1);
    line-height: 1.45;
    flex: 1;
  }

  .story figcaption {
    margin-top: var(--space-s);
    font-size: var(--step--1);
    color: var(--mist);
  }

  /* The next fire — CTA */
  .next-fire {
    background: var(--forest);
    position: relative;
  }

  .next-fire::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 30%, rgba(196,92,42,0.08) 0%, transparent 60%);
    pointer-events: none;
  }

  .dates {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-s);
    margin: var(--space-l) 0;
  }
  .date-pill {
    background: var(--bark);
    border: 1px solid var(--coal);
    padding: 6px 16px;
    border-radius: 999px;
    font-size: var(--step--1);
    white-space: nowrap;
  }

  .form {
    max-width: 420px;
    margin-top: var(--space-l);
  }

  .form input {
    width: 100%;
    background: var(--night);
    border: 1px solid var(--coal);
    color: var(--birch);
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: var(--step-0);
    margin-bottom: var(--space-s);
  }
  .form input:focus {
    border-color: var(--ember);
    outline: none;
  }

  .form .btn {
    width: 100%;
  }

  /* Footer */
  .site-footer {
    background: var(--night);
    padding-block: var(--space-xl);
    font-size: var(--step--1);
    color: var(--mist);
    border-top: 1px solid var(--coal);
  }

  .footer-inner {
    display: flex;
    flex-direction: column;
    gap: var(--space-l);
  }
  @media (min-width: 50rem) {
    .footer-inner {
      flex-direction: row;
      justify-content: space-between;
      align-items: flex-end;
    }
  }

  .insignia {
    display: flex;
    align-items: center;
    gap: var(--space-s);
    color: var(--gold);
  }
  .insignia svg {
    width: 28px;
    height: 28px;
  }
}

/* ============================================
   COMPONENTS
   ============================================ */
@layer components {
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 26px;
    border-radius: var(--radius);
    font-size: var(--step--1);
    letter-spacing: 0.01em;
    min-height: 48px;
    transition: all 140ms var(--ease);
    border: 1px solid transparent;
    white-space: nowrap;
  }

  .btn-primary {
    background: var(--ember);
    color: var(--night);
    font-weight: 600;
  }
  .btn-primary:hover {
    background: var(--ember-soft);
    transform: translateY(-1px);
  }

  .btn-ghost {
    border-color: var(--coal);
    color: var(--birch);
  }
  .btn-ghost:hover {
    border-color: var(--ember);
    color: var(--ember);
  }

  .btn-small {
    padding: 7px 16px;
    font-size: 0.8rem;
    min-height: 40px;
  }

  .hamburger {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    color: var(--birch);
    border: 1px solid var(--coal);
    border-radius: var(--radius);
  }

  /* Mobile nav overlay */
  .nav-overlay {
    position: fixed;
    inset: 0;
    background: var(--night);
    z-index: 100;
    padding: var(--space-2xl) var(--space-m);
    display: none;
    flex-direction: column;
  }
  .nav-overlay.open {
    display: flex;
  }
  .nav-overlay a {
    font-family: var(--font-display);
    font-size: var(--step-2);
    padding-block: var(--space-s);
    border-bottom: 1px solid var(--coal);
  }
  .nav-overlay .close {
    margin-left: auto;
    font-size: 2rem;
    line-height: 1;
    color: var(--mist);
  }

  /* Modal — "stepping closer to the fire" */
  .modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-m);
    background: rgba(12,17,16,0.88);
  }
  .modal.open {
    display: flex;
  }
  .modal-inner {
    background: var(--forest);
    border: 1px solid var(--coal);
    border-radius: var(--radius-soft);
    max-width: 620px;
    width: 100%;
    max-height: 92dvh;
    overflow: auto;
    position: relative;
  }
  .modal-header {
    padding: var(--space-m) var(--space-m) 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .modal-body {
    padding: var(--space-m);
  }
  .modal-close {
    font-size: 1.6rem;
    line-height: 1;
    color: var(--mist);
    padding: 4px;
  }

  .modal-media {
    margin: 0 calc(-1 * var(--space-m)) var(--space-m);
  }
  .modal-media img {
    width: 100%;
    border-radius: 0;
  }

  /* Fire intensity visual feedback (the "tending" system) */
  .fire.is-tended {
    border-color: var(--ember);
    box-shadow: 0 0 0 1px rgba(196,92,42,0.3);
  }
}

/* ============================================
   UTILITIES + MOTION
   ============================================ */
@layer utilities {
  .sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
  }

  .section-title {
    font-family: var(--font-display);
    font-size: var(--step-3);
    margin-bottom: var(--space-m);
    max-width: 28ch;
  }

  .ember-rule {
    height: 1px;
    background: linear-gradient(to right, transparent, var(--ember), transparent);
    opacity: 0.35;
    margin-block: var(--space-l);
  }

  .video-controls {
    position: absolute;
    bottom: var(--space-m);
    right: var(--space-m);
    z-index: 4;
  }

  .video-controls button {
    background: rgba(12,17,16,0.6);
    color: var(--birch);
    border: 1px solid var(--coal);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    backdrop-filter: blur(4px);
  }

  /* Gentle reveal on scroll */
  .reveal {
    opacity: 0.6;
    transform: translateY(12px);
    transition: opacity 420ms var(--ease), transform 420ms var(--ease);
  }
  .reveal.is-visible {
    opacity: 1;
    transform: none;
  }

  @media (prefers-reduced-motion: reduce) {
    .reveal,
    .fire,
    .btn {
      transition: none !important;
      transform: none !important;
    }
  }
}

