/* ==========================================================================
   Prism — an image-first theme for Counterglow.
   Split-screen hero, full-bleed photography, oversized type, spectral accents.
   Built for portfolios, studios and photo essays.
   ========================================================================== */

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

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  }
  img, svg, video, iframe { display: block; max-width: 100%; height: auto; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { cursor: pointer; background: none; border: 0; }
  :focus-visible { outline: 2px solid var(--c2); outline-offset: 3px; }
}

@layer tokens {
  :root {
    color-scheme: light dark;

    --font-display: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, "Helvetica Neue", sans-serif;
    --font-body: var(--font-display);
    --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;

    /* the spectrum: three stops that get mixed everywhere */
    --c1: oklch(0.66 0.21 25);
    --c2: oklch(0.62 0.2 300);
    --c3: oklch(0.72 0.16 205);
    --accent: var(--c2);
    --spectrum: linear-gradient(100deg, var(--c1), var(--c2) 52%, var(--c3));

    --bg: oklch(0.99 0.003 300);
    --bg-2: oklch(0.955 0.006 300);
    --fg: oklch(0.16 0.014 300);
    --fg-dim: oklch(0.5 0.014 300);
    --line: oklch(0.89 0.008 300);

    --gutter: clamp(1.15rem, 4vw, 3rem);
    --wide: 84rem;
    --measure: 34rem;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);

    --step--1: clamp(0.82rem, 0.8rem + 0.1vw, 0.88rem);
    --step-0:  clamp(1rem, 0.96rem + 0.2vw, 1.12rem);
    --step-1:  clamp(1.2rem, 1.1rem + 0.5vw, 1.5rem);
    --step-2:  clamp(1.55rem, 1.3rem + 1.15vw, 2.4rem);
    --step-3:  clamp(2.1rem, 1.55rem + 2.6vw, 4rem);
    --step-4:  clamp(2.8rem, 1.7rem + 5.2vw, 7rem);
  }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: oklch(0.14 0.012 300);
      --bg-2: oklch(0.19 0.014 300);
      --fg: oklch(0.96 0.005 300);
      --fg-dim: oklch(0.68 0.012 300);
      --line: oklch(0.28 0.014 300);
      --c1: oklch(0.72 0.19 25);
      --c2: oklch(0.72 0.18 300);
      --c3: oklch(0.79 0.14 205);
    }
  }
  :root[data-theme="dark"] {
    --bg: oklch(0.14 0.012 300);
    --bg-2: oklch(0.19 0.014 300);
    --fg: oklch(0.96 0.005 300);
    --fg-dim: oklch(0.68 0.012 300);
    --line: oklch(0.28 0.014 300);
    --c1: oklch(0.72 0.19 25);
    --c2: oklch(0.72 0.18 300);
    --c3: oklch(0.79 0.14 205);
  }
}

@layer base {
  body {
    font-family: var(--font-body);
    font-size: var(--step-0);
    line-height: 1.6;
    color: var(--fg);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
  }
  h1, h2, h3 { font-weight: 700; line-height: 1.02; letter-spacing: -0.045em; text-wrap: balance; }
  p, li { text-wrap: pretty; }
  a { color: inherit; text-underline-offset: 0.18em; }
  ::selection { background: color-mix(in oklab, var(--c2) 30%, transparent); }
  hr { border: 0; height: 1px; background: var(--line); }
  code { font-family: var(--font-mono); font-size: 0.88em; }
}

@layer layout {
  .container { width: min(100% - var(--gutter) * 2, var(--wide)); margin-inline: auto; }
  .container--narrow { width: min(100% - var(--gutter) * 2, 46rem); margin-inline: auto; }
  .bleed { width: 100%; }
  .section { padding-block: clamp(3rem, 8vw, 7rem); }
}

@layer components {
  /* --- header ------------------------------------------------------------ */
  .top {
    position: fixed; inset-block-start: 0; inset-inline: 0; z-index: 40;
    transition: background .3s, backdrop-filter .3s, border-color .3s;
    border-bottom: 1px solid transparent;
  }
  .top.is-stuck {
    background: color-mix(in oklab, var(--bg) 82%, transparent);
    backdrop-filter: blur(16px) saturate(1.6);
    border-bottom-color: var(--line);
  }
  .top__inner { display: flex; align-items: center; gap: 1rem; padding-block: 1rem; }
  .mark {
    display: inline-flex; align-items: center; gap: .55rem;
    font-weight: 800; letter-spacing: -0.04em; font-size: 1.05rem; text-decoration: none;
  }
  .mark__dot {
    width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--spectrum);
    box-shadow: 0 0 0 1px color-mix(in oklab, var(--c2) 30%, transparent);
  }
  .top nav { display: flex; align-items: center; gap: .2rem; margin-left: auto; }
  .top nav a {
    padding: .4rem .75rem; border-radius: 999px; text-decoration: none;
    font-size: var(--step--1); font-weight: 600; color: var(--fg-dim);
  }
  .top nav a:hover { color: var(--fg); background: var(--bg-2); }
  .top nav a[aria-current="page"] { color: var(--fg); background: var(--bg-2); }
  .icon-btn { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 999px; color: var(--fg-dim); }
  .icon-btn:hover { background: var(--bg-2); color: var(--fg); }

  /* --- split hero -------------------------------------------------------- */
  .split { display: grid; min-height: 82svh; }
  @media (min-width: 56rem) { .split { grid-template-columns: 1.05fr 1fr; } }
  .split__text {
    display: flex; flex-direction: column; justify-content: center;
    padding: clamp(5.5rem, 12vw, 8rem) var(--gutter) clamp(3rem, 8vw, 5rem);
  }
  .split__text > * { max-width: 30rem; }
  .split__media { position: relative; overflow: hidden; background: var(--bg-2); min-height: 45svh; }
  .split__media img { width: 100%; height: 100%; object-fit: cover; }
  .split__media::after {
    content: ""; position: absolute; inset: 0; mix-blend-mode: overlay; opacity: .28;
    background: var(--spectrum);
  }
  .eyebrow {
    display: inline-flex; align-items: center; gap: .5rem; width: fit-content;
    font-size: var(--step--1); font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
    margin-bottom: 1.25rem;
    background: var(--spectrum); -webkit-background-clip: text; background-clip: text; color: transparent;
  }
  .split h1 { font-size: var(--step-4); }
  .split .lead { font-size: var(--step-1); color: var(--fg-dim); margin-top: 1.25rem; }

  .button {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .75rem 1.4rem; border-radius: 999px; font-size: var(--step--1); font-weight: 700;
    text-decoration: none; color: var(--bg); background: var(--fg);
    transition: transform .25s var(--ease), box-shadow .25s;
  }
  .button:hover { transform: translateY(-2px); box-shadow: 0 8px 24px color-mix(in oklab, var(--c2) 30%, transparent); }
  .button--spectrum { background: var(--spectrum); color: #fff; }
  .button--ghost { background: none; color: var(--fg); border: 1px solid var(--line); }

  /* --- work grid --------------------------------------------------------- */
  .work { display: grid; gap: clamp(1rem, 2.5vw, 2rem); grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr)); }
  .work > :first-child:nth-last-child(3) { grid-column: 1 / -1; }
  .tile {
    position: relative; display: block; text-decoration: none; overflow: hidden;
    border-radius: 18px; background: var(--bg-2); aspect-ratio: 4 / 3;
    transition: transform .5s var(--ease);
  }
  .work > :first-child:nth-last-child(3).tile { aspect-ratio: 21 / 9; }
  .tile:hover { transform: translateY(-4px); }
  .tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .8s var(--ease), filter .5s; }
  .tile:hover img { transform: scale(1.05); }
  .tile__body {
    position: absolute; inset-block-end: 0; inset-inline: 0; padding: clamp(1.1rem, 2.5vw, 1.75rem);
    color: #fff; background: linear-gradient(to top, oklch(0.12 0.02 300 / .88), oklch(0.12 0.02 300 / .35) 55%, transparent);
  }
  .tile__kicker { font-size: var(--step--1); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; opacity: .85; }
  .tile__title { font-size: var(--step-2); margin-top: .2rem; }
  .tile__excerpt { font-size: var(--step--1); opacity: .82; margin-top: .35rem; max-width: 32rem; }

  .section-head { display: flex; align-items: end; gap: 1rem; margin-bottom: clamp(1.5rem, 3vw, 2.5rem); }
  .section-head h2 { font-size: var(--step-3); }
  .section-head a { margin-left: auto; font-size: var(--step--1); font-weight: 600; color: var(--fg-dim); text-decoration: none; white-space: nowrap; }
  .section-head a:hover { color: var(--fg); }

  /* --- entries ----------------------------------------------------------- */
  .entries { list-style: none; padding: 0; display: grid; }
  .entry { padding-block: clamp(1.2rem, 2.5vw, 1.8rem); border-top: 1px solid var(--line); display: grid; gap: .3rem; }
  .entry:last-child { border-bottom: 1px solid var(--line); }
  @media (min-width: 48rem) { .entry { grid-template-columns: 1fr auto; align-items: baseline; column-gap: 2rem; } .entry__excerpt { grid-column: 1; } }
  .entry a { text-decoration: none; }
  .entry__title { font-size: var(--step-2); transition: color .2s; }
  .entry:hover .entry__title { background: var(--spectrum); -webkit-background-clip: text; background-clip: text; color: transparent; }
  .entry__meta { font-size: var(--step--1); color: var(--fg-dim); font-variant-numeric: tabular-nums; }
  .entry__excerpt { color: var(--fg-dim); max-width: var(--measure); }

  /* --- article ----------------------------------------------------------- */
  .article-hero { position: relative; min-height: 60svh; display: grid; align-items: end; overflow: hidden; }
  .article-hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
  .article-hero__body {
    position: relative; padding: clamp(2rem, 6vw, 5rem) 0 clamp(1.5rem, 4vw, 3rem); color: #fff;
    background: linear-gradient(to top, oklch(0.1 0.02 300 / .9), transparent);
    width: 100%;
  }
  .article-hero h1 { font-size: var(--step-3); max-width: 20ch; }
  .article-head { padding-block: clamp(4.5rem, 10vw, 7rem) clamp(1rem, 3vw, 2rem); }
  .article-head h1 { font-size: var(--step-3); max-width: 20ch; }
  .article-meta { display: flex; flex-wrap: wrap; gap: .8rem; font-size: var(--step--1); margin-top: 1rem; opacity: .85; }

  .prose { font-size: var(--step-0); line-height: 1.72; }
  .prose > * + * { margin-top: 1.35em; }
  .prose > p, .prose > ul, .prose > ol, .prose > blockquote, .prose > h2, .prose > h3 { max-width: var(--measure); }
  .prose > h2 { font-size: var(--step-2); margin-top: 2.2em; letter-spacing: -0.035em; }
  .prose > h3 { font-size: var(--step-1); margin-top: 1.9em; }
  .prose ul, .prose ol { padding-left: 1.25em; display: grid; gap: .35em; }
  .prose li::marker { color: var(--c2); }
  .prose li.task { list-style: none; margin-left: -1.25em; }
  .prose a { text-decoration: underline; text-decoration-color: color-mix(in oklab, var(--c2) 50%, transparent); }
  .prose blockquote {
    border: 0; padding-left: 1.25rem; font-size: var(--step-1); line-height: 1.4;
    letter-spacing: -0.02em; border-left: 3px solid transparent;
    border-image: var(--spectrum) 1;
  }
  .prose code { background: var(--bg-2); padding: .14em .38em; border-radius: 5px; }
  .prose pre { background: var(--bg-2); border-radius: 14px; padding: 1.1rem 1.25rem; overflow-x: auto; font-size: .84rem; line-height: 1.6; }
  .prose pre code { background: none; padding: 0; }
  .prose figure { margin-block: clamp(2rem, 5vw, 3.5rem); }
  .prose figure img { width: 100%; border-radius: 14px; }
  .prose figcaption { margin-top: .7rem; font-size: var(--step--1); color: var(--fg-dim); max-width: var(--measure); }
  .prose .callout { border-radius: 14px; background: var(--bg-2); padding: 1.1rem 1.3rem; font-size: var(--step--1); max-width: var(--measure); border-left: 3px solid var(--c2); }
  .table-scroll { overflow-x: auto; }
  .prose table { border-collapse: collapse; width: 100%; font-size: var(--step--1); }
  .prose th, .prose td { text-align: left; padding: .6rem .9rem; border-bottom: 1px solid var(--line); }
  .gallery { display: grid; grid-template-columns: repeat(var(--cols, 3), 1fr); gap: .6rem; margin-block: clamp(2rem, 5vw, 3.5rem); }
  .gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; }
  .embed { position: relative; aspect-ratio: 16/9; border-radius: 14px; overflow: hidden; background: var(--bg-2); }
  .embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
  .file-link { display: inline-flex; gap: .5rem; align-items: baseline; padding: .45rem .9rem; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; font-size: var(--step--1); }

  .tag { display: inline-block; padding: .15rem .65rem; border-radius: 999px; border: 1px solid var(--line); font-size: var(--step--1); font-weight: 600; text-decoration: none; color: var(--fg-dim); }
  .tag:hover { border-color: var(--c2); color: var(--fg); }

  .pager { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr)); margin-top: clamp(2.5rem, 6vw, 4rem); }
  .pager a { display: grid; gap: .25rem; padding: 1.2rem 1.4rem; border-radius: 16px; background: var(--bg-2); text-decoration: none; transition: transform .3s var(--ease); }
  .pager a:hover { transform: translateY(-3px); }
  .pager span { font-size: var(--step--1); color: var(--fg-dim); font-weight: 600; }
  .pager strong { font-size: var(--step-1); letter-spacing: -0.03em; }
  .pager .next { text-align: right; }

  /* --- footer ------------------------------------------------------------ */
  .foot { margin-top: clamp(3rem, 8vw, 6rem); padding-block: clamp(2.5rem, 6vw, 4rem); border-top: 1px solid var(--line); }
  .foot__inner { display: flex; flex-wrap: wrap; gap: 2rem; align-items: baseline; }
  .foot__big { font-size: var(--step-3); letter-spacing: -0.05em; font-weight: 800; }
  .foot a { color: var(--fg-dim); text-decoration: none; font-size: var(--step--1); font-weight: 600; }
  .foot a:hover { color: var(--fg); }
  .foot nav { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-left: auto; }

  dialog.search { width: min(36rem, 92vw); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--bg); color: var(--fg); margin-top: 12vh; box-shadow: 0 30px 80px oklch(0 0 0 / .3); }
  dialog.search::backdrop { background: oklch(0.12 0.02 300 / .55); backdrop-filter: blur(4px); }
  dialog.search input { width: 100%; padding: 1.1rem 1.3rem; border: 0; border-bottom: 1px solid var(--line); background: none; font-size: 1.05rem; font-weight: 600; }
  dialog.search input:focus { outline: none; }
  dialog.search ul { list-style: none; margin: 0; padding: .4rem; max-height: 58vh; overflow-y: auto; }
  dialog.search a { display: grid; gap: .1rem; padding: .65rem .8rem; border-radius: 12px; text-decoration: none; }
  dialog.search a:hover, dialog.search li.is-active a { background: var(--bg-2); }
  dialog.search .r-title { font-weight: 700; }
  dialog.search .r-excerpt { font-size: var(--step--1); color: var(--fg-dim); }
  dialog.search .hint { padding: 1.75rem; text-align: center; color: var(--fg-dim); font-size: var(--step--1); }

  .js .reveal { opacity: 0; transform: translateY(1.1rem); transition: opacity .7s var(--ease), transform .7s var(--ease); }
  .reveal.is-in { opacity: 1; transform: none; }
  @media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; } }

  /* --- mobile menu ------------------------------------------------------- */
  .nav-toggle { display: inline-flex; flex-direction: column; justify-content: center; gap: 5px; width: 2.5rem; height: 2.5rem; padding: .55rem; margin-left: .1rem; background: none; border: 0; cursor: pointer; color: inherit; }
  .nav-toggle span { display: block; height: 2px; width: 100%; background: currentColor; transition: transform .28s var(--ease, ease), opacity .2s; }
  [data-nav-open] .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  [data-nav-open] .nav-toggle span:nth-child(2) { opacity: 0; }
  [data-nav-open] .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .menu-links { display: none; }
  [data-nav-open] .menu-links { display: flex; flex-direction: column; align-items: stretch; position: absolute; top: 100%; left: 0; right: 0; z-index: 40; background: var(--bg, var(--surface, Canvas)); border-block: 1px solid var(--line, color-mix(in oklab, currentColor 16%, transparent)); padding: .4rem var(--gutter, 1.25rem) 1rem; }
  [data-nav-open] .menu-links a { padding: .85rem .2rem; font-size: 1.15rem; border-bottom: 1px solid var(--line, color-mix(in oklab, currentColor 12%, transparent)); }
  [data-nav-open] .menu-links a:last-child { border-bottom: 0; }
  @media (min-width: 48rem) {
    .nav-toggle { display: none; }
    .menu-links { display: flex; align-items: center; gap: .25rem; }
    [data-nav-open] .menu-links { position: static; background: none; border: 0; padding: 0; }
    [data-nav-open] .menu-links a { padding: 0; font-size: inherit; border: 0; }
  }

  .skip { position: absolute; left: .5rem; top: -4rem; z-index: 100; padding: .6rem 1rem; border-radius: 999px; background: var(--fg); color: var(--bg); transition: top .2s; }
  .skip:focus { top: .5rem; }
}

@layer utilities {
  .muted { color: var(--fg-dim); }
  .small { font-size: var(--step--1); }
  .mono { font-family: var(--font-mono); }
  .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}
