/* ==========================================================================
   The Wiser — stylesheet
   Palette: night prairie (deep green-black) + Kansas wheat gold.
   Modern CSS only: cascade layers, custom properties, nesting, container
   queries, fluid type. No preprocessor, no framework, no build step.
   ========================================================================== */

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

/* --------------------------------------------------------------- reset -- */

@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  body,
  h1,
  h2,
  h3,
  p,
  figure,
  dl,
  dd,
  ol,
  ul {
    margin: 0;
  }

  ol[class],
  ul[class] {
    padding: 0;
    list-style: none;
  }

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

  input,
  button,
  textarea,
  select {
    font: inherit;
    color: inherit;
  }
}

/* -------------------------------------------------------------- tokens -- */

@layer tokens {
  :root {
    /* Surfaces */
    --bg: #0d100c;
    --bg-raised: #151a13;
    --bg-card: #1b2118;
    --border: #2c3527;

    /* Ink */
    --text: #ddd9cd;
    --text-dim: #99a08c;

    /* Accents */
    --gold: #d9a441;
    --gold-dim: #8a6b2c;
    --rust: #a3532b;

    /* Type */
    --font-display: Georgia, "Times New Roman", serif;
    --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

    /* Fluid type scale — grows with the viewport, no breakpoints needed. */
    --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
    --step-1: clamp(1.1rem, 1.03rem + 0.35vw, 1.25rem);
    --step-2: clamp(1.4rem, 1.2rem + 1vw, 2rem);
    --step-3: clamp(2rem, 1.5rem + 2.5vw, 3.4rem);
    --step-small: clamp(0.82rem, 0.8rem + 0.1vw, 0.88rem);

    /* Space scale */
    --space-2xs: 0.35rem;
    --space-xs: 0.6rem;
    --space-s: 1rem;
    --space-m: 1.6rem;
    --space-l: 2.6rem;
    --space-xl: clamp(3rem, 2rem + 5vw, 5.5rem);

    --wrap: 68rem;
    --measure: 42rem;
    --radius: 4px;

    color-scheme: dark;
  }
}

/* ---------------------------------------------------------------- base -- */

@layer base {
  html {
    scroll-behavior: smooth;
    /* Anchored sightings shouldn't land under the sticky header. */
    scroll-padding-block-start: 5rem;
  }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: var(--step-0);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  /* Film grain. Decorative only — hidden from assistive tech by construction. */
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  }

  h1,
  h2,
  h3 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.15;
    text-wrap: balance;
  }

  h1 {
    font-size: var(--step-3);
  }
  h2 {
    font-size: var(--step-2);
  }
  h3 {
    font-size: var(--step-1);
  }

  p {
    text-wrap: pretty;
  }

  a {
    color: var(--gold);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.15em;

    &:hover {
      text-decoration: underline;
    }
  }

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

  ::selection {
    background: var(--gold);
    color: var(--bg);
  }

  @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;
    }
  }
}

/* -------------------------------------------------------------- layout -- */

@layer layout {
  .wrap {
    width: 100%;
    max-width: var(--wrap);
    margin-inline: auto;
    /* env() keeps content clear of notches and rounded corners on phones. */
    padding-inline: max(1.25rem, env(safe-area-inset-left));
  }

  .section {
    padding-block: var(--space-xl);
    border-block-end: 1px solid var(--border);

    &:last-of-type {
      border-block-end: none;
    }
  }

  .section-head {
    max-width: var(--measure);
    margin-block-end: var(--space-l);

    & p {
      color: var(--text-dim);
      margin-block-start: var(--space-xs);
    }
  }

  .prose {
    max-width: var(--measure);

    & > * + * {
      margin-block-start: var(--space-s);
    }
  }

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

  .after-grid {
    margin-block-start: var(--space-m);
  }
}

/* ---------------------------------------------------------- components -- */

@layer components {
  /* --- skip link ---------------------------------------------------- */

  .skip-link {
    position: absolute;
    inset-inline-start: -9999px;
    z-index: 10000;

    &:focus {
      inset-inline-start: 1rem;
      inset-block-start: 1rem;
      padding: 0.75rem 1rem;
      background: var(--gold);
      color: var(--bg);
      border-radius: var(--radius);
    }
  }

  /* --- header ------------------------------------------------------- */

  .site-header {
    position: sticky;
    inset-block-start: 0;
    z-index: 100;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(8px);
    border-block-end: 1px solid var(--border);

    & .wrap {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: var(--space-s);
      flex-wrap: wrap;
      min-block-size: 4rem;
      padding-block: var(--space-2xs);
    }
  }

  .brand {
    font-family: var(--font-display);
    font-size: var(--step-1);
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;

    & span {
      color: var(--gold);
    }
    &:hover {
      color: var(--gold);
      text-decoration: none;
    }
  }

  .nav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs) var(--space-m);

    & a {
      color: var(--text-dim);
      font-size: var(--step-small);
      text-transform: uppercase;
      letter-spacing: 0.09em;
      text-decoration: none;
      /* Comfortable touch target without changing the visual rhythm. */
      padding-block: 0.6rem;
      border-block-end: 2px solid transparent;

      &:hover {
        color: var(--text);
        text-decoration: none;
      }
      &.is-active {
        color: var(--gold);
        border-block-end-color: var(--gold);
      }
    }
  }

  /* --- hero --------------------------------------------------------- */

  .hero {
    padding-block: var(--space-xl);
    text-align: center;
    border-block-end: 1px solid var(--border);
    background:
      radial-gradient(ellipse at 50% 0%, rgb(217 164 65 / 0.1), transparent 62%),
      linear-gradient(180deg, var(--bg-raised), var(--bg));

    & .eyebrow {
      color: var(--gold);
      font-size: var(--step-small);
      text-transform: uppercase;
      letter-spacing: 0.28em;
      margin-block-end: var(--space-m);
    }

    & .lead {
      max-width: 40rem;
      margin-inline: auto;
      margin-block-start: var(--space-s);
      font-size: var(--step-1);
      color: var(--text-dim);
    }

    & .actions {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      gap: var(--space-xs);
      margin-block-start: var(--space-m);
    }
  }

  /* --- buttons ------------------------------------------------------ */

  .btn {
    display: inline-block;
    padding: 0.75rem 1.6rem;
    border: 1px solid var(--gold-dim);
    border-radius: var(--radius);
    background: transparent;
    color: var(--gold);
    font-size: var(--step-small);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    text-decoration: none;
    cursor: pointer;
    transition:
      background-color 0.18s,
      color 0.18s;

    &:hover {
      background: var(--gold);
      color: var(--bg);
      text-decoration: none;
    }
  }

  .btn-plain {
    border-color: var(--border);
    color: var(--text-dim);

    &:hover {
      background: var(--border);
      color: var(--text);
    }
  }

  /* --- cards -------------------------------------------------------- */

  .card {
    /* Each card sizes its own contents by its own width, not the viewport —
       so a card in a 4-up grid and the same card in a 2-up grid both read well. */
    container-type: inline-size;
    padding: var(--space-m);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);

    & h3 {
      color: var(--gold);
      margin-block-end: var(--space-2xs);
    }
  }

  @container (min-width: 22rem) {
    .card {
      padding: var(--space-l);
    }
  }

  /* --- field profile ------------------------------------------------ */

  .traits {
    max-width: var(--wrap);

    & .trait {
      display: grid;
      grid-template-columns: minmax(9rem, 12rem) 1fr;
      gap: var(--space-s);
      padding-block: var(--space-s);
      border-block-end: 1px dashed var(--border);
    }
    & .trait:last-child {
      border-block-end: none;
    }

    & dt {
      color: var(--gold);
      font-size: var(--step-small);
      text-transform: uppercase;
      letter-spacing: 0.1em;
      line-height: 1.5;
      padding-block-start: 0.15em;
    }
    & dd {
      margin: 0;
    }
  }

  @media (width < 40rem) {
    .traits .trait {
      grid-template-columns: 1fr;
      gap: var(--space-2xs);
    }
  }

  /* --- sightings ---------------------------------------------------- */

  .sighting {
    position: relative;
    padding-inline-start: var(--space-m);
    padding-block-end: var(--space-l);
    border-inline-start: 2px solid var(--border);

    &::before {
      content: "";
      position: absolute;
      inset-inline-start: -6px;
      inset-block-start: 0.6rem;
      inline-size: 10px;
      block-size: 10px;
      border-radius: 50%;
      background: var(--gold);
    }

    &:last-child {
      padding-block-end: 0;
    }

    & > * + * {
      margin-block-start: var(--space-s);
    }

    & .meta {
      color: var(--text-dim);
      font-size: var(--step-small);
      text-transform: uppercase;
      letter-spacing: 0.12em;
    }

    & .witnesses {
      color: var(--text-dim);
    }
  }

  .sighting-photo {
    margin-block: var(--space-s);

    & img {
      border: 1px solid var(--border);
      border-radius: var(--radius);
    }
    & figcaption {
      margin-block-start: var(--space-2xs);
      color: var(--text-dim);
      font-size: var(--step-small);
    }
  }

  /* --- evidence ----------------------------------------------------- */

  .exhibit {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;

    & img {
      inline-size: 100%;
      aspect-ratio: 4 / 3;
      object-fit: cover;
    }

    & figcaption {
      padding: var(--space-s) var(--space-m) var(--space-m);
      font-size: var(--step-small);
      line-height: 1.6;
    }

    & figcaption strong {
      display: block;
      color: var(--gold);
      font-size: var(--step-0);
      font-family: var(--font-display);
    }
  }

  .status {
    display: inline-block;
    margin-block: 0.5rem;
    padding: 0.15rem 0.5rem;
    border: 1px solid currentcolor;
    border-radius: 999px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
  }
  .status-pending {
    color: var(--text-dim);
  }
  .status-unverified {
    color: var(--rust);
  }
  .status-corroborated {
    color: var(--gold);
  }

  .photo-placeholder {
    display: grid;
    place-items: center;
    aspect-ratio: 4 / 3;
    padding: var(--space-s);
    color: var(--text-dim);
    font-size: var(--step-small);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    text-align: center;
    background: repeating-linear-gradient(45deg, #171d15 0 12px, #1b2118 12px 24px);
  }

  /* --- report checklist --------------------------------------------- */

  .checklist {
    counter-reset: step;
    display: grid;
    gap: var(--space-s);
    grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr));

    & li {
      counter-increment: step;
      position: relative;
      padding: var(--space-m);
      padding-inline-start: calc(var(--space-m) + 2rem);
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: var(--radius);
    }

    & li::before {
      content: counter(step, decimal-leading-zero);
      position: absolute;
      inset-inline-start: var(--space-m);
      color: var(--gold-dim);
      font-family: var(--font-display);
      font-size: var(--step-1);
    }

    & h3 {
      color: var(--gold);
      margin-block-end: var(--space-2xs);
    }
    & p {
      color: var(--text-dim);
      font-size: var(--step-small);
    }
  }

  /* --- form --------------------------------------------------------- */

  .report-form {
    & .form-row + .form-row {
      margin-block-start: var(--space-s);
    }

    & label {
      display: block;
      margin-block-end: var(--space-2xs);
      color: var(--gold);
      font-size: var(--step-small);
      text-transform: uppercase;
      letter-spacing: 0.1em;
    }

    & input,
    & select,
    & textarea {
      inline-size: 100%;
      padding: 0.7rem 0.8rem;
      background: var(--bg-raised);
      border: 1px solid var(--border);
      border-radius: var(--radius);

      &:focus {
        border-color: var(--gold-dim);
      }
    }

    & textarea {
      min-block-size: 9rem;
      resize: vertical;
    }

    & .field-hint {
      margin-block-start: var(--space-2xs);
      color: var(--text-dim);
      font-size: var(--step-small);
    }

    & button {
      margin-block-start: var(--space-m);
    }
  }

  /* Off-screen rather than display:none — some bots skip hidden inputs. */
  .honeypot {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* --- footer ------------------------------------------------------- */

  .site-footer {
    padding-block: var(--space-l);
    padding-block-end: max(var(--space-l), env(safe-area-inset-bottom));
    border-block-start: 1px solid var(--border);
    color: var(--text-dim);
    font-size: var(--step-small);

    & .wrap {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      gap: var(--space-xs);
    }
  }
}

/* ----------------------------------------------------------- utilities -- */

@layer utilities {
  .muted {
    color: var(--text-dim);
  }
  .small {
    font-size: var(--step-small);
  }
  .center {
    text-align: center;

    & .prose,
    & .section-head {
      margin-inline: auto;
    }
  }
}
