/* =========================================================
   Barry — portfolio
   Graphite, paper, and mineral light.
   Palette tokens are shared; geometry and motion stay in each page stylesheet.
   ========================================================= */

:root {
  /* --- ground --- */
  color-scheme: dark;
  --void:      #101213;
  --graphite:  #1c1f21;
  --charcoal:  #242829;
  --charcoal-hi:#2b3031;
  --ground-rgb: 16,18,19;
  --light-rgb: 137,165,181;
  --rim-rgb: 221,228,226;
  --shade-rgb: 15,17,18;
  --shadow-rgb: 0,0,0;
  --shadow-strength: 1;

  /* --- type --- */
  --ivory:     #e8e6df;
  --ivory-mid: #b1b5b2;
  --ivory-dim: #a3abab;

  /* --- the lamp --- */
  --accent:   #92aebe;
  --accent-lit:#bfd1db;
  --accent-deep:#4e6572;
  --accent-edge: rgba(var(--light-rgb),.42);
  --button-hi: #2b3439;
  --button-base: #252c30;
  --workspace-low: #181b1d;
  --card-low: #24282a;
  --card-base: #2a2e31;
  --card-hi: #34393d;

  /* --- edges --- */
  --hairline:  rgba(219,226,223,.13);
  --hairline-lit: rgba(219,226,223,.25);

  /* --- light geometry: shadows all fall from upper-left --- */
  --lift-1: 0 2px 6px rgba(0,0,0,.18);
  --lift-2: 0 10px 24px -8px rgba(0,0,0,.28);
  --lift-3: 0 34px 70px -24px rgba(0,0,0,.42);
  --bevel:  inset 0 1px 0 rgba(231,235,232,.045);
  --inset: inset 0 2px 7px rgba(0,0,0,.25);
  --grain-opacity: .045;
  --grain-blend: soft-light;
  --field-blend: screen;
  --field-dim: .60, .63, .64;
  --field-cool: .39, .56, .68;
  --field-lit: .86, .89, .90;
  --field-pigment: .67, .55, .43;

  /* --- editorial type scale: readable supporting text, 17px body --- */
  --t-xs:   0.8125rem;
  --t-sm:   0.9375rem;
  --t-base: 1.0625rem;
  --t-md:   1.4rem;
  --t-lg:   1.95rem;
  --t-xl:   2.6rem;
  --t-2xl:  clamp(2.4rem, 5vw, 4rem);

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans:  "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --gutter: clamp(1.5rem, 5vw, 5.5rem);
  --measure: 62ch;

  --ease-settle: cubic-bezier(.16, .84, .32, 1);
  --ease-out:    cubic-bezier(.22, 1, .36, 1);
}

/* A separate paper palette, including pigment, shadows and the moving lamp. */
:root[data-theme="light"] {
  color-scheme: light;
  --void: #f2f0e9;
  --graphite: #e8e7df;
  --charcoal: #eeede6;
  --charcoal-hi: #f8f7f1;
  --ground-rgb: 242,240,233;
  --light-rgb: 94,126,144;
  --rim-rgb: 255,255,250;
  --shade-rgb: 219,220,212;
  --shadow-rgb: 55,61,58;
  --shadow-strength: .16;
  --ivory: #292e30;
  --ivory-mid: #555e60;
  --ivory-dim: #596365;
  --accent: #496b7e;
  --accent-lit: #34596c;
  --accent-deep: #c7d5da;
  --button-hi: #eef2f1;
  --button-base: #e3eae9;
  --workspace-low: #e4e5df;
  --card-low: #e7e9e4;
  --card-base: #eff0ea;
  --card-hi: #f7f8f2;
  --hairline: rgba(44,60,64,.16);
  --hairline-lit: rgba(44,60,64,.30);
  --lift-1: 0 2px 6px rgba(55,61,58,.06);
  --lift-2: 0 10px 24px -8px rgba(55,61,58,.12);
  --lift-3: 0 34px 70px -24px rgba(55,61,58,.17);
  --bevel: inset 0 1px 0 rgba(255,255,250,.7);
  --inset: inset 0 2px 7px rgba(55,61,58,.055);
  --grain-opacity: .035;
  --grain-blend: multiply;
  --field-blend: multiply;
  /* The light field is pigment on paper, not white light over white. */
  --field-dim: .38, .41, .41;
  --field-cool: .20, .36, .45;
  --field-lit: .22, .30, .34;
  --field-pigment: .52, .40, .29;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--void);
  color: var(--ivory);
  font-family: var(--sans);
  font-size: var(--t-base);
  line-height: 1.65;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* The lamp itself — a single static wash. It does not move,
   so the particle field is the only ambient motion on the site. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(120vw 90vh at 12% -10%, rgba(var(--light-rgb),.055), transparent 62%),
    radial-gradient(70vw 60vh at 88% 108%, rgba(var(--rim-rgb),.014), transparent 70%);
}

/* Static, fine material grain. It never intercepts a pointer or animates. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  background: url("../img/grain.svg") repeat;
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
}

img { max-width: 100%; display: block; }

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

/* --- headings ---------------------------------------------------- */

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 400;
  font-variation-settings: "opsz" 120;
  letter-spacing: -0.018em;
  line-height: 1.08;
  margin: 0;
  color: var(--ivory);
}

h2 { font-size: var(--t-2xl); font-variation-settings: "opsz" 48; }
h3 { font-size: var(--t-lg); font-variation-settings: "opsz" 32; line-height: 1.2; }

p { margin: 0 0 1.1em; max-width: var(--measure); }

a { color: inherit; }

/* --- focus, always visible ---------------------------------------- */

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

/* =========================================================
   Navigation
   ========================================================= */

.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 60;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.55rem var(--gutter);
  mix-blend-mode: normal;
  transition: background .5s var(--ease-out), backdrop-filter .5s var(--ease-out);
}

.nav.is-stuck {
  background: linear-gradient(to bottom, rgba(var(--ground-rgb),.92), rgba(var(--ground-rgb),.55) 70%, transparent);
  backdrop-filter: blur(14px);
}

.nav__mark {
  font-family: var(--serif);
  font-size: 1.18rem;
  font-variation-settings: "opsz" 20;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--ivory);
  white-space: nowrap;
}
.nav__mark span { color: var(--ivory-dim); }

.nav__links {
  display: flex;
  gap: clamp(1.1rem, 3vw, 2.6rem);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav__link {
  position: relative;
  font-size: var(--t-sm);
  letter-spacing: .01em;
  color: var(--ivory-mid);
  text-decoration: none;
  padding-bottom: 3px;
  transition: color .35s var(--ease-out);
}
.nav__link::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  height: 1px; width: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .45s var(--ease-settle);
}
.nav__link:hover { color: var(--accent-lit); }
.nav__link:hover::after,
.nav__link[aria-current="page"]::after { transform: scaleX(1); }
.nav__link[aria-current="page"] { color: var(--accent-lit); }

/* Sits in the existing gutter without shifting any navigation links. */
.theme-toggle {
  position: absolute;
  right: max(.1rem, calc((var(--gutter) - 2.75rem) / 2));
  top: 1.2rem;
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ivory-mid);
  cursor: pointer;
  transition: color .35s var(--ease-out), background .35s var(--ease-out);
}
.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { color: var(--accent-lit); background: rgba(var(--light-rgb),.09); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle__disc { fill: currentColor; }
[data-theme="light"] .theme-toggle__disc { fill: none; }

@media (min-width: 781px) and (max-width: 960px) {
  .theme-toggle { left: calc(var(--gutter) + 8rem); right: auto; }
}

@media (max-width: 780px) {
  .theme-toggle { right: var(--gutter); top: .65rem; }
}

/* five items no longer fit on a phone, so the links drop to their own row */
@media (max-width: 780px) {
  .nav { flex-wrap: wrap; gap: .45rem 1rem; padding-block: 1.05rem; }
  .nav__links { width: 100%; gap: 1.05rem; }
  .nav__link { font-size: .82rem; }
}
@media (max-width: 420px) {
  .nav__links { gap: .8rem; }
  .nav__link { font-size: .78rem; }
  .nav__mark { font-size: 1.05rem; }
}

/* Page-to-page fade. The lift is a CSS animation, not a JS class, so a
   failed script can never leave the visitor staring at a black rectangle. */
.veil {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--void);
  pointer-events: none;
  opacity: 0;
  animation: veil-lift .5s var(--ease-out) both;
}
@keyframes veil-lift { from { opacity: 1; } to { opacity: 0; } }

.veil.is-closing {
  animation: none;
  opacity: 1;
  transition: opacity .26s var(--ease-out);
}

/* =========================================================
   Shared page furniture
   ========================================================= */

main { position: relative; z-index: 1; }

.page-head {
  padding: clamp(8rem, 18vh, 13rem) var(--gutter) clamp(3rem, 7vh, 5rem);
  max-width: 1500px;
  margin: 0 auto;
}

.page-head h1 {
  font-size: clamp(2.8rem, 7.5vw, 6rem);
  font-variation-settings: "opsz" 144;
  margin-bottom: .9rem;
}

.page-head__note {
  color: var(--ivory-mid);
  max-width: 46ch;
  font-size: clamp(1.0625rem, 1.6vw, 1.25rem);
  line-height: 1.5;
  font-family: var(--sans);
}

/* placeholder convention: anything you replace is marked with this */
.ph {
  color: var(--ivory-mid);
  font-family: var(--sans);
  font-style: normal;
}

/* =========================================================
   Footer
   ========================================================= */

.foot {
  position: relative;
  z-index: 1;
  padding: 4.5rem var(--gutter) 3rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem 3rem;
  align-items: baseline;
  justify-content: space-between;
  border-top: 1px solid var(--hairline);
  margin-top: 6rem;
  color: var(--ivory-dim);
  font-size: var(--t-sm);
}
.foot a { color: var(--ivory-mid); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color .3s, color .3s; }
.foot a:hover { color: var(--ivory); border-bottom-color: var(--accent); }
.foot__links { display: flex; gap: 1.6rem; flex-wrap: wrap; }

/* =========================================================
   Reduced motion
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
