/* ==========================================================================
   Stephanie Perry ONeal: site styles
   No framework. Cascade layers, nesting, grid for layout, flex for flow.
   Features used are Baseline Widely available as of late 2026:
   @layer, CSS nesting, :has(), size container queries,
   oklch/color-mix, clamp(), logical properties, aspect-ratio.
   text-wrap: balance/pretty are progressive enhancements only.
   ========================================================================== */

/* Self-hosted variable fonts (SIL Open Font License, see fonts/).
   Latin subset. Fraunces carries weight + optical size axes. */
@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

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

/* ---------- reset ---------- */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: none; text-size-adjust: none; }
  body { min-block-size: 100vh; }
  img, svg, picture, video { display: block; max-inline-size: 100%; block-size: auto; }
  input, button, textarea, select { font: inherit; }
  :where(ul, ol)[role="list"], .list-plain { list-style: none; padding: 0; }
}

/* ---------- tokens ---------- */
@layer tokens {
  :root {
    /* Palette: jewel tones (deepened from the Behr 2026 picks) */
    --emerald: #0d5c4b;        /* home; primary accent */
    --emerald-deep: #063a30;
    --teal: #0a6b6b;           /* about */
    --sapphire: #14438f;       /* work + case studies */
    --topaz: #eaa21a;          /* cv; highlight accent */
    --garnet: #7e0f14;         /* outcome callout */
    --garnet-deep: #3f070c;    /* quote callout */
    --midnight: #08122b;       /* footer */
    --mist: #c9d6d3;           /* image fallback */
    --blank-canvas: #fbfbf8;
    --cracked-pepper: #111412;

    /* Roles */
    --c-bg: var(--blank-canvas);
    --c-surface: #fff;
    --c-text: var(--cracked-pepper);
    --c-muted: #3d4644;
    --c-line: color-mix(in oklch, var(--cracked-pepper) 18%, transparent);
    --c-accent: var(--emerald);
    --c-accent-warm: var(--garnet);
    --c-on-dark: #fff;
    --c-on-dark-muted: color-mix(in oklch, white 82%, var(--mist));

    /* Masthead band: each page sets --band (and ink if the band is light) */
    --band: var(--emerald);
    --band-ink: #fff;
    --band-ink-muted: rgb(255 255 255 / 0.82);
    --band-rule: rgb(255 255 255 / 0.18);

    /* Type */
    --f-serif: "Fraunces", ui-serif, Georgia, serif;
    --f-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --step--1: clamp(0.84rem, 0.8rem + 0.15vw, 0.9rem);
    --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
    --step-1: clamp(1.2rem, 1.1rem + 0.4vw, 1.35rem);
    --step-2: clamp(1.45rem, 1.3rem + 0.8vw, 1.8rem);
    --step-3: clamp(1.8rem, 1.5rem + 1.4vw, 2.5rem);
    --step-4: clamp(2.2rem, 1.7rem + 2.4vw, 3.4rem);

    /* Space */
    --space-2xs: 0.25rem;
    --space-xs: 0.5rem;
    --space-s: 0.875rem;
    --space-m: 1.25rem;
    --space-l: clamp(1.75rem, 1.4rem + 1.6vw, 2.5rem);
    --space-xl: clamp(2.5rem, 2rem + 2.5vw, 4rem);
    --space-2xl: clamp(3.5rem, 2.6rem + 4vw, 6rem);

    --wrap: 72rem;
    --wrap-text: 42rem;
    --gutter: clamp(1.25rem, 4vw, 2.5rem);
    --radius: 6px;
    --shadow: 0 1px 2px rgb(20 23 20 / 0.06), 0 8px 24px -12px rgb(20 23 20 / 0.18);
  }
}

/* ---------- base ---------- */
@layer base {
  html { color-scheme: light; scroll-padding-block-start: var(--space-l); }

  body {
    background: var(--c-bg);
    color: var(--c-text);
    font-family: var(--f-sans);
    font-size: var(--step-0);
    line-height: 1.6;
    font-optical-sizing: auto;
    -webkit-font-smoothing: antialiased;
  }

  h1, h2, h3, h4 {
    font-family: var(--f-serif);
    font-weight: 600;
    line-height: 1.12;
    letter-spacing: -0.01em;
    text-wrap: balance;
  }
  h1 { font-size: var(--step-4); }
  h2 { font-size: var(--step-3); }
  h3 { font-size: var(--step-1); }

  p, li, dd { text-wrap: pretty; }
  p + p { margin-block-start: 1em; }

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

  :focus-visible {
    outline: 3px solid var(--topaz);
    outline-offset: 2px;
    box-shadow: 0 0 0 5px var(--midnight);
    outline-offset: 3px;
    border-radius: 2px;
  }

  ::selection { background: var(--topaz); color: var(--cracked-pepper); }

  @media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
  }
}

/* ---------- layout ---------- */
@layer layout {
  .wrap {
    inline-size: min(100% - 2 * var(--gutter), var(--wrap));
    margin-inline: auto;
  }
  .wrap-text {
    inline-size: min(100% - 2 * var(--gutter), var(--wrap-text));
    margin-inline: auto;
  }

  .section { padding-block: var(--space-xl); }
  .section + .section { padding-block-start: 0; }

  .section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-xs) var(--space-m);
    margin-block-end: var(--space-l);
  }

  .stack > * + * { margin-block-start: var(--space-m); }

  main { display: block; }
}

/* ---------- components ---------- */
@layer components {

  /* Skip link */
  .skip-link {
    position: absolute;
    inset-inline-start: var(--space-s);
    inset-block-start: -10rem;
    padding: var(--space-xs) var(--space-s);
    background: var(--c-surface);
    color: var(--c-text);
    z-index: 10;
    &:focus { inset-block-start: var(--space-s); }
  }

  /* Masthead: compact gradient band. Holds site nav plus the page title.
     Deliberately short so the work below is the visual focus. */
  .masthead {
    --band-pad-end: var(--space-xl);
    background:
      linear-gradient(160deg, var(--band-deep, color-mix(in oklch, var(--band), black 34%)), var(--band) 70%);
    color: var(--band-ink);
    padding-block-end: var(--band-pad-end);
    position: relative;
    isolation: isolate;

    /* Bokeh texture: a static SVG of soft light circles, weighted to the
       right so titles stay clean. Tune strength with --bokeh. */
    &::before {
      content: "";
      position: absolute;
      inset: 0;
      z-index: -1;
      background: right center / cover no-repeat;  /* image set per page below */
      opacity: var(--bokeh, 0.7);
      pointer-events: none;
    }

    a { color: inherit; }

    /* when a lead image overlaps the band, add room under the text */
    &:has(+ main .lead-figure) { --band-pad-end: calc(var(--space-xl) + clamp(3rem, 10vw, 8rem)); }
  }

  .site-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-xs) var(--space-l);
    padding-block: var(--space-m);
    border-block-end: 1px solid var(--band-rule);
  }

  .brand {
    font-family: var(--f-serif);
    font-size: var(--step-1);
    font-weight: 600;
    letter-spacing: -0.005em;
    text-decoration: none;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 0.6em;
    > span { white-space: nowrap; }
  }
  .brand-role {
    font-family: var(--f-sans);
    font-size: var(--step--1);
    font-weight: 400;
    letter-spacing: 0;
    color: var(--band-ink-muted);
  }

  .site-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs) var(--space-m);
    list-style: none;
    padding: 0;
  }
  .site-nav a {
    display: inline-block;
    padding-block: 0.6rem; /* 44px touch target */
    font-size: var(--step-0);
    font-weight: 500;
    text-decoration: none;
    color: var(--band-ink-muted);
    /* Underline sits on the text, not the padded box, so the 44px
       touch target doesn't push it away from the words. */
    text-decoration-thickness: 2px;
    text-underline-offset: 0.3em;
    &:hover { color: var(--band-ink); }
    &[aria-current="page"] {
      color: var(--band-ink);
      text-decoration-line: underline;
      text-decoration-color: currentColor;
    }
  }

  .intro {
    padding-block-start: var(--space-xl);
    max-inline-size: 46rem;
    > * + * { margin-block-start: var(--space-s); }
  }
  .lede {
    font-size: var(--step-1);
    line-height: 1.5;
    color: var(--band-ink-muted);
  }

  /* Lead image overlapping the band */
  .lead-figure {
    position: relative;   /* sits above the masthead's stacking context */
    z-index: 1;
    margin-block-start: calc(-1 * clamp(3rem, 10vw, 8rem));
    img {
      inline-size: 100%;
      aspect-ratio: 16 / 9;
      object-fit: cover;
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      background: var(--mist);
    }
  }

  /* Buttons / text links */
  .button {
    display: inline-flex;
    align-items: center;
    min-block-size: 44px;
    padding-inline: var(--space-m);
    border-radius: 999px;
    background: var(--emerald);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    &:hover { background: var(--emerald-deep); color: #fff; }
  }

  /* Tags */
  .tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs) var(--space-xs);
    list-style: none;
    padding: 0;
    font-size: var(--step--1);
    color: var(--c-muted);
    li + li::before { content: "/"; margin-inline-end: var(--space-xs); color: var(--mist); }
  }

  /* Project card. The image leads; text is short. */
  .card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
    gap: var(--space-xl) var(--space-l);
  }

  .card {
    container: card / inline-size;
    position: relative;
    display: grid;
    gap: var(--space-s);
    align-content: start;

    img {
      inline-size: 100%;
      aspect-ratio: 16 / 10;
      object-fit: cover;
      border-radius: var(--radius);
      background: var(--mist);
      transition: box-shadow 0.3s ease;
    }
    h3 a {
      color: var(--c-text);
      text-decoration: none;
      /* whole card is clickable via the title link */
      &::after { content: ""; position: absolute; inset: 0; }
    }
    p { color: var(--c-muted); }

    &:has(a:hover, a:focus-visible) {
      img { box-shadow: var(--shadow); }
      h3 a { color: var(--c-accent); }
    }
  }

  /* Featured card spans the row and goes side-by-side when it has room */
  .card--feature {
    grid-column: 1 / -1;
    .card-body > * + * { margin-block-start: var(--space-s); }
  }
  @container card (inline-size > 44rem) {
    .card--feature .card-inner {
      display: grid;
      grid-template-columns: 3fr 2fr;
      gap: var(--space-l);
      align-items: center;
    }
    .card--feature h3 { font-size: var(--step-3); }
  }
  .card-inner { display: grid; gap: var(--space-s); }

  /* Definition list used for project facts */
  .facts {
    display: grid;
    gap: var(--space-m);
    dt {
      font-size: var(--step--1);
      font-weight: 600;
      color: var(--c-muted);
    }
    dd { margin-block-start: var(--space-2xs); }
  }


  /* Pull quote
     Markup: <figure class="quote"><blockquote><p>…</p></blockquote><figcaption>…</figcaption></figure>
     Attribution sits outside the blockquote (it isn't part of the quote).
     Marks come from open-quote/close-quote so they follow the page's lang. */
  .quote {
    --q-size: clamp(1.75rem, 1.15rem + 2.4vw, 2.75rem); /* ~2.5x body */
    --q-hang: calc(var(--q-size) * 1.5);                 /* mark column */
    container: quote / inline-size;
    margin-block: var(--space-xl);

    blockquote {
      quotes: auto;
      display: grid;
      grid-template-columns: 1fr;
      font-family: var(--f-serif);
      font-size: var(--q-size);
      font-weight: 500;
      line-height: 1.2;
      letter-spacing: -0.015em;
      color: var(--c-text);

      /* Opening mark: big, heavy, garnet. Stacks above on narrow widths,
         hangs in its own column when there's room. */
      &::before {
        content: open-quote;
        font-size: 3.4em;
        font-weight: 800;
        line-height: 1;
        color: var(--garnet);
        block-size: 0.55em;          /* trims the glyph's empty descent */
      }

      p { text-wrap: balance; }

      /* Closing mark rides at the end of the last line */
      p:last-child::after {
        content: close-quote;
        font-size: 1.6em;
        font-weight: 800;
        line-height: 0;
        vertical-align: -0.28em;
        color: var(--garnet);
        margin-inline-start: 0.04em;
      }
    }

    figcaption {
      margin-block-start: var(--space-m);
      font-size: var(--step-0);
      color: var(--c-muted);
      cite { font-style: normal; font-weight: 600; color: var(--c-text); }
    }
  }

  @container quote (inline-size > 34rem) {
    .quote blockquote {
      grid-template-columns: var(--q-hang) 1fr;
      column-gap: 0;
      &::before { block-size: 0.5em; margin-block-start: -0.08em; }
    }
    .quote figcaption { padding-inline-start: var(--q-hang); }
  }

  figure figcaption {
    margin-block-start: var(--space-xs);
    font-size: var(--step--1);
    color: var(--c-muted);
  }

  /* Prev / next between case studies */
  .pager {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
    gap: var(--space-m);
    padding-block: var(--space-l);
    border-block-start: 1px solid var(--c-line);
    a {
      display: grid;
      gap: var(--space-2xs);
      text-decoration: none;
      color: var(--c-text);
      &:hover strong { color: var(--c-accent); }
    }
    span { font-size: var(--step--1); color: var(--c-muted); }
    strong { font-family: var(--f-serif); font-weight: 500; font-size: var(--step-1); }
    a:last-child:not(:first-child) { text-align: end; }
  }

  /* Footer */
  .site-footer {
    margin-block-start: var(--space-2xl);
    padding-block: var(--space-xl) var(--space-l);
    background: var(--midnight);
    color: var(--c-on-dark-muted);
    a { color: var(--c-on-dark); }
    a:hover { color: var(--topaz); }
  }
  .footer-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: end;
    gap: var(--space-l);
    h2 { color: var(--c-on-dark); font-size: var(--step-2); }
    p { margin-block-start: var(--space-xs); }
  }
  .footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs) var(--space-m);
    list-style: none;
    padding: 0;
    a { display: inline-block; padding-block: 0.6rem; }
  }
  .footer-meta {
    margin-block-start: var(--space-l);
    padding-block-start: var(--space-m);
    border-block-start: 1px solid rgb(255 255 255 / 0.12);
    font-size: var(--step--1);
  }

  /* Placeholders: unstyled. Search the HTML for class="ph" (or "[")
     to find every spot that still needs real content. */
}

/* ---------- pages ---------- */
@layer pages {

  /* Per-page bokeh render (same generator, different seed per page) */
  .page-home .masthead::before      { background-image: url("../images/bokeh-home.svg"); }
  .page-about .masthead::before     { background-image: url("../images/bokeh-about.svg"); }
  .page-work .masthead::before      { background-image: url("../images/bokeh-work.svg"); }
  .page-cv .masthead::before        { background-image: url("../images/bokeh-cv.svg"); }
  .case-narrative .masthead::before { background-image: url("../images/bokeh-case-narrative.svg"); }
  .case-showcase .masthead::before  { background-image: url("../images/bokeh-case-showcase.svg"); }

  /* Per-page masthead color */
  .page-home  { --band: var(--emerald); }
  .page-about { --band: var(--teal); }
  .page-work  { --band: var(--sapphire); }
  .page-cv {
    --band: var(--topaz);
    --band-ink: var(--cracked-pepper);
    --band-ink-muted: color-mix(in oklch, var(--cracked-pepper) 80%, var(--topaz));
    --band-rule: rgb(0 0 0 / 0.14);
    --band-deep: #d98a0b;
    --bokeh: 0.9;
  }

  /* Home: short about strip */
  .about-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
    gap: var(--space-l);
    align-items: start;
    padding-block-start: var(--space-xl);
    border-block-start: 1px solid var(--c-line);
    h2 { font-size: var(--step-2); }
  }

  /* About: two columns only when a portrait is present */
  .about {
    display: grid;
    gap: var(--space-xl);
    &:has(.portrait) {
      @media (width >= 52rem) { grid-template-columns: 18rem 1fr; }
    }
    .portrait img {
      inline-size: 100%;
      aspect-ratio: 4 / 5;
      object-fit: cover;
      border-radius: var(--radius);
      background: var(--mist);
    }
    .prose { max-inline-size: var(--wrap-text); }
    .prose h2 { font-size: var(--step-2); margin-block: var(--space-l) var(--space-s); }
  }

  /* CV */
  .cv {
    display: grid;
    gap: var(--space-xl);
    @media (width >= 56rem) {
      grid-template-columns: 1fr 17rem;
      .cv-aside { position: sticky; inset-block-start: var(--space-l); align-self: start; }
    }
    h2 {
      font-size: var(--step-2);
      padding-block-end: var(--space-xs);
      margin-block-end: var(--space-m);
      border-block-end: 1px solid var(--c-line);
    }
    section + section { margin-block-start: var(--space-xl); }
  }
  .cv-aside {
    display: grid;
    gap: var(--space-l);
    h2 { font-size: var(--step-1); }
    ul { padding-inline-start: 1.1em; }
    .list-plain { padding: 0; }
    li + li { margin-block-start: var(--space-2xs); }
    section + section { margin-block-start: 0; }
    .edu li + li { margin-block-start: var(--space-s); }
  }
  .role {
    display: grid;
    gap: var(--space-2xs) var(--space-m);
    grid-template-columns: 1fr auto;
    & + & { margin-block-start: var(--space-l); }
    h3 { grid-column: 1; }
    .role-dates { grid-column: 2; grid-row: 1; font-size: var(--step--1); color: var(--c-muted); white-space: nowrap; align-self: baseline; }
    .role-org { grid-column: 1 / -1; color: var(--c-muted); }
    ul { grid-column: 1 / -1; margin-block-start: var(--space-xs); padding-inline-start: 1.1em; }
    li + li { margin-block-start: var(--space-2xs); }
  }
  @media (width < 32rem) {
    .role { grid-template-columns: 1fr; }
    .role .role-dates { grid-column: 1; grid-row: auto; }
  }

  /* Case study A: narrative, facts sidebar + long-form */
  .cs-narrative {
    display: grid;
    gap: var(--space-xl);
    padding-block: var(--space-xl);
    @media (width >= 60rem) {
      grid-template-columns: 15rem minmax(0, 1fr);
      .cs-facts { position: sticky; inset-block-start: var(--space-l); align-self: start; }
    }
  }
  .cs-body {
    max-inline-size: var(--wrap-text);
    > section + section { margin-block-start: var(--space-xl); }
    h2 { font-size: var(--step-3); margin-block-end: var(--space-s); }
    figure { margin-block: var(--space-l); }
    figure img { border-radius: var(--radius); inline-size: 100%; background: var(--mist); }
    ol, ul { padding-inline-start: 1.2em; }
    li + li { margin-block-start: var(--space-xs); }
  }
  /* Figure pair can break out wider than the text column */
  .figure-pair {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
    gap: var(--space-m);
    @media (width >= 76rem) { inline-size: calc(100% + 8rem); }
  }

  /* Case study B: showcase, image-led rows + gallery */
  .meta-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
    gap: var(--space-m);
    padding-block: var(--space-l);
    border-block-end: 1px solid var(--c-line);
  }

  .showcase-row {
    display: grid;
    gap: var(--space-l);
    align-items: center;
    padding-block: var(--space-xl);
    & + & { border-block-start: 1px solid var(--c-line); }
    figure img { inline-size: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--radius); background: var(--mist); }
    .text > * + * { margin-block-start: var(--space-s); }
    @media (width >= 52rem) {
      grid-template-columns: 7fr 5fr;
      &:nth-of-type(even) {
        grid-template-columns: 5fr 7fr;
        figure { order: 2; }
      }
    }
  }

  /* Artifact gallery. Images share one aspect ratio, so captions start
     at the same height across a row without subgrid. */
  .gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
    gap: var(--space-l) var(--space-m);
    list-style: none;
    padding: 0;
    > li { min-inline-size: 0; }
    img { inline-size: 100%; block-size: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); background: var(--mist); }
    figcaption { margin-block-start: var(--space-xs); }
    strong { display: block; color: var(--c-text); font-weight: 600; }
  }

  .outcome-band {
    margin-block-start: var(--space-xl);
    padding-block: var(--space-xl);
    background: var(--garnet);
    color: var(--c-on-dark-muted);
    h2 { color: #fff; }
    .outcome-grid {
      display: grid;
      gap: var(--space-l);
      @media (width >= 56rem) { grid-template-columns: 1fr 2fr; align-items: baseline; }
    }
    .outcome-statement {
      font-family: var(--f-serif);
      font-size: var(--step-2);
      line-height: 1.35;
      color: #fff;
      max-inline-size: 38rem;
    }
  }
}

/* ---------- utilities ---------- */
@layer utilities {
  .visually-hidden {
    position: absolute !important;
    inline-size: 1px; block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .muted { color: var(--c-muted); }
}

/* ---------- print (mainly for the CV) ---------- */
@layer print {
  @media print {
    @page { margin: 1.6cm; }
    body { background: #fff; color: #000; font-size: 10.5pt; }
    .site-bar, .site-footer, .skip-link, .no-print { display: none !important; }
    .masthead { background: none; color: #000; padding: 0; &::before { display: none; } }
    .masthead .intro { padding: 0; }
    .masthead .lede { color: #333; }
    a { color: #000; text-decoration: none; }
    .cv { grid-template-columns: 1fr 14rem; gap: 1.5rem; }
    .cv-aside { position: static; }
    .role { break-inside: avoid; }
    .section { padding-block: 1rem; }
  }
}
