/* ═══════════════════════════════════════════════════════════════════
   jasonritz.com — production stylesheet
   ═══════════════════════════════════════════════════════════════════
   ARCHITECTURE
   - Single stylesheet shared across all pages.
   - Per-page theming via body classes (.theme-code/books/work).
   - Three things change per theme: --accent, --texture-image, --texture-blend.
   - Everything else (typography, layout, spacing) is constant — that's
     what makes the sub-pages feel like one site.
   ═══════════════════════════════════════════════════════════════════ */

/* ── tokens ──────────────────────────────────────────────────────── */
:root {
  /* palette — midnight is shared across every page */
  --bg:           #0b1424;
  --fg:           #e6ebf2;
  --muted:        #7d8696;
  --hair:         rgba(230, 235, 242, 0.10);

  /* accent — cobalt by default, overridden per page */
  --accent:       #3b82f6;
  --accent-soft:  rgba(59, 130, 246, 0.14);
  --accent-glow:  rgba(59, 130, 246, 0.35);

  /* type */
  --serif:        'Lora', 'Iowan Old Style', Georgia, serif;
  --sans:         'Outfit', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --mono:         'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* spacing */
  --gutter:       56px;
  --gutter-lg:    88px;
  --gutter-mob:   22px;

  /* texture (overridden per theme) */
  --texture-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.045 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  --texture-blend: screen;
}

/* ── per-page themes ─────────────────────────────────────────────── */
body.theme-code {
  --accent:      #22d3ee;
  --accent-soft: rgba(34, 211, 238, 0.10);
  --accent-glow: rgba(34, 211, 238, 0.40);
}
body.theme-code::after {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none; z-index: 1;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 2px,
    rgba(34, 211, 238, 0.04) 2px 3px
  );
}

body.theme-books {
  --accent:      #e6b85b;
  --accent-soft: rgba(230, 184, 91, 0.12);
  --accent-glow: rgba(230, 184, 91, 0.30);
  --texture-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.902  0 0 0 0 0.722  0 0 0 0 0.357  0 0 0 0.06 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

body.theme-work {
  --accent:      #ff7a4d;
  --accent-soft: rgba(255, 122, 77, 0.12);
  --accent-glow: rgba(255, 122, 77, 0.35);
  --texture-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.45' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 0.48  0 0 0 0 0.30  0 0 0 0.07 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* ── reset ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── background layers ───────────────────────────────────────────── */
.gradient-bg {
  position: fixed; inset: 0;
  z-index: 0; opacity: 0.25;
  pointer-events: none;
}
.gradient-1, .gradient-2, .gradient-3 {
  position: absolute; inset: -50% -50%;
  opacity: 0.1; will-change: transform;
}
.gradient-1 {
  background: radial-gradient(circle at 30% 30%, var(--accent) 0%, transparent 90%);
  animation: moveGradient1 30s ease-in-out infinite paused;
}
.gradient-2 {
  background: radial-gradient(circle at 70% 70%, var(--accent) 0%, transparent 90%);
  animation: moveGradient2 45s ease-in-out infinite paused;
}
.gradient-3 {
  background: radial-gradient(ellipse at center, var(--accent) 0%, transparent 90%);
  animation: moveGradient3 60s ease-in-out infinite paused;
}
@keyframes moveGradient1 {
  0%,100% { transform: translate(0,0) rotate(0deg); }
  25%     { transform: translate(25%,-15%) rotate(90deg); }
  50%     { transform: translate(-10%,25%) rotate(180deg); }
  75%     { transform: translate(-25%,-25%) rotate(270deg); }
}
@keyframes moveGradient2 {
  0%,100% { transform: translate(0,0) rotate(0deg); }
  33%     { transform: translate(-20%,25%) rotate(-120deg); }
  66%     { transform: translate(25%,-15%) rotate(240deg); }
}
@keyframes moveGradient3 {
  0%,100% { transform: scale(1) translate(0,0); }
  25%     { transform: scale(1.2) translate(10%,10%); }
  50%     { transform: scale(0.8) translate(-20%,20%); }
  75%     { transform: scale(1.1) translate(15%,-15%); }
}

.grain {
  position: fixed; inset: 0;
  background-image: var(--texture-image);
  background-repeat: repeat;
  mix-blend-mode: var(--texture-blend);
  pointer-events: none; z-index: 0;
}

/* ── physics canvas ──────────────────────────────────────────────── */
.physics-canvas {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1000;
}
.physics-canvas.active {
  cursor: grabbing; pointer-events: all;
}
.physics-canvas.interactive {
  pointer-events: all; cursor: grab;
}

/* ── dot markup (inside h1) ──────────────────────────────────────── */
.dot-container {
  display: inline;
  position: relative;
}
.dot {
  position: absolute;
  width: 0.2em; height: 0.2em;
  background: var(--accent);
  border-radius: 50%;
  cursor: grab;
  bottom: calc(0.15em - 0.0143em);
  left: 0.0214em;
  user-select: none; touch-action: none;
  z-index: 100;
}
.dot.hidden { opacity: 0; pointer-events: none; }
.dot-placeholder {
  position: absolute;
  width: 0.2em; height: 0.2em;
  border: 2px dashed rgba(230, 235, 242, 0.3);
  border-radius: 50%;
  opacity: 0;
  bottom: calc(0.15em - 0.0143em);
  left: 0.0214em;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.dot-placeholder.visible { opacity: 1; }

/* keep content above background layers */
.page { position: relative; z-index: 1; }

a { color: inherit; text-decoration: none; }

/* ── page shell ──────────────────────────────────────────────────── */
.page {
  min-height: 100vh;
  padding: 34px var(--gutter) 32px;
  display: flex; flex-direction: column;
}

/* home: true viewport center — both axes */
.page--home {
  padding: 40px var(--gutter-lg);
  align-items: center;
  justify-content: center;
}

@media (max-width: 768px) {
  .page { padding: 20px var(--gutter-mob) 24px; }
  .page--home { padding: 32px var(--gutter-mob); }
}

/* ── nav (sub-pages only) ────────────────────────────────────────── */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.nav__brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--fg); font-size: 15px; font-weight: 500;
  letter-spacing: 0.01em;
}
.nav__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
}
.nav__links {
  display: flex; gap: 32px;
  font-size: 14px; font-weight: 500;
}
.nav__links a {
  color: var(--muted);
  transition: color 0.15s ease;
}
.nav__links a:hover,
.nav__links a[aria-current="page"] {
  color: var(--fg);
}

@media (max-width: 768px) {
  .nav__brand { font-size: 14px; }
  .nav__links { gap: 20px; font-size: 13px; }
}

/* ── home hero ───────────────────────────────────────────────────── */
.hero {
  display: flex; flex-direction: column;
  max-width: 920px;
  width: 100%;
}
.hero__title {
  font-family: var(--serif);
  font-size: clamp(64px, 12vw, 140px); line-height: 0.92;
  margin: 0; letter-spacing: -0.03em; font-weight: 700;
}
#dot-anchor { display: inline; opacity: 0; }
.hero__punct { display: inline; }
.hero__punct--sm { font-size: 0.84em; }
.hero__punct--xs { font-size: 0.75em; vertical-align: top; }
.hero__intro {
  font-family: var(--serif); font-style: italic;
  font-size: 28px; line-height: 1.45;
  margin: 48px 0 0; font-weight: 400; max-width: 680px;
  color: rgba(230, 235, 242, 0.88);
}
.hero__intro a {
  color: var(--accent);
  border-bottom: 1px solid var(--accent);
  padding-bottom: 1px;
}
.hero__list {
  list-style: none; padding: 0;
  margin: 28px 0 0;
  display: flex; flex-direction: column; gap: 18px;
  font-family: var(--sans);
  font-size: 17px; line-height: 1.6;
  font-weight: 400; letter-spacing: 0.01em;
  max-width: 680px;
}
.hero__list li {
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: baseline;
}
.hero__roman {
  font-family: var(--mono);
  color: var(--accent); font-size: 11px;
  letter-spacing: 0.08em;
  padding-top: 0.25em;
}
.hero__list a {
  color: var(--fg);
  border-bottom: 1px solid var(--accent);
  padding-bottom: 1px;
  background-image: linear-gradient(var(--accent-soft), var(--accent-soft));
  background-size: 0% 100%;
  background-repeat: no-repeat;
  background-position: left center;
  transition: background-size 0.3s cubic-bezier(0.76, 0, 0.24, 0.8);
}
.hero__list a:hover {
  background-size: 100% 100%;
}


/* the period — static accent on sub-page headers only */
.period {
  color: var(--accent);
  display: inline-block;
}

@media (max-width: 768px) {
  .hero__title  { font-size: clamp(48px, 16vw, 64px); }
  .hero__intro  { font-size: 19px; line-height: 1.5; margin-top: 22px; }
  .hero__list   { font-size: 15px; gap: 14px; margin-top: 24px; letter-spacing: 0.005em; }
  .hero__list li { grid-template-columns: 28px 1fr; }
  .hero__roman  { font-size: 10px; }
}

/* ── sub-page header ─────────────────────────────────────────────── */
.section-head {
  padding-top: 40px; padding-bottom: 24px;
}
.section-head__eyebrow {
  font-family: var(--mono);
  font-size: 11px; color: var(--muted);
  letter-spacing: 0.2em; margin-bottom: 12px;
}
.section-head__title {
  font-family: var(--serif);
  font-size: 64px; line-height: 1;
  margin: 0; letter-spacing: -0.025em; font-weight: 700;
}
.section-head__title .period {
  cursor: default;
  text-shadow: 0 0 14px var(--accent-glow);
}
.section-head__sub {
  font-family: var(--serif); font-style: italic;
  font-size: 18px; color: var(--muted);
  margin-top: 14px; max-width: 640px;
}

@media (max-width: 768px) {
  .section-head { padding-top: 24px; padding-bottom: 18px; }
  .section-head__eyebrow { font-size: 10px; margin-bottom: 8px; }
  .section-head__title { font-size: 36px; }
  .section-head__sub { font-size: 13px; margin-top: 8px; }
}

/* ── /code grid ──────────────────────────────────────────────────── */
.code-grid-wrap {
  max-width: 1712px;
  margin-left: auto;
  margin-right: auto;
}
.code-grid {
  display: grid;
  grid-template-columns: repeat(4, 410px);
  justify-content: center;
  gap: 24px;
}
@media (max-width: 1711px) {
  .code-grid { grid-template-columns: repeat(3, 410px); }
}
@media (max-width: 1277px) {
  .code-grid { grid-template-columns: repeat(2, 410px); }
}
@media (max-width: 843px) {
  .code-grid { grid-template-columns: 410px; }
}
@media (max-width: 430px) {
  .code-grid { grid-template-columns: 1fr; }
}
.code-card { display: block; cursor: pointer; }
.code-card__thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  background:
    linear-gradient(135deg, var(--accent-soft), rgba(11, 20, 36, 0.4));
  border: 1px dashed color-mix(in oklab, var(--accent) 33%, transparent);
  border-radius: 2px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px; overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.code-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.code-card:hover .code-card__thumb {
  border-color: var(--accent);
  box-shadow: 0 0 24px var(--accent-soft);
}
.code-card__placeholder {
  font-family: var(--mono); font-size: 10px;
  color: var(--accent); letter-spacing: 0.18em;
}
.code-card__path {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
}
.code-card__name {
  font-family: var(--mono); font-size: 13px;
  color: var(--accent); letter-spacing: 0.02em;
  margin-top: 14px;
}
.code-card__blurb {
  margin: 6px 0 10px; font-size: 13px; line-height: 1.5;
}
.code-card__launch {
  font-family: var(--mono); font-size: 11px;
  color: var(--muted); letter-spacing: 0.14em;
}
.code-card__launch span { color: var(--accent); }


/* ── /books list ─────────────────────────────────────────────────── */
.book-sort {
  display: flex; gap: 18px; flex-wrap: wrap; align-items: baseline;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--hair);
}
.book-sort__label {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  letter-spacing: 0.18em; text-transform: uppercase;
}
.book-sort__tab {
  font-size: 13px; color: var(--muted);
  border-bottom: 1px solid transparent; padding-bottom: 3px;
  cursor: pointer;
}
.book-sort__tab.is-active {
  color: var(--accent); border-bottom-color: var(--accent);
}
.book-sort__count {
  margin-left: auto;
  font-family: var(--mono); font-size: 11px; color: var(--muted);
}

.book-row {
  display: grid;
  grid-template-columns: 56px 56px 1fr 110px;
  gap: 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--hair);
  align-items: center;
  cursor: pointer;
}
.book-row__cover {
  width: 56px; height: 84px;
  background:
    linear-gradient(155deg, var(--accent-soft), rgba(11, 20, 36, 0.3));
  border: 1px solid var(--hair);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 24px;
  color: var(--muted); font-style: italic;
  overflow: hidden;
}
.book-row__cover img { width: 100%; height: 100%; object-fit: cover; }
.book-row__score {
  font-family: var(--mono); font-size: 13px;
  text-align: center; padding: 4px 0;
  border: 1px solid; border-radius: 2px;
  letter-spacing: 0.02em;
  align-self: center;
}
.book-row__score--high { color: var(--accent); border-color: color-mix(in oklab, var(--accent) 40%, transparent); }
.book-row__score--mid  { color: var(--muted);  border-color: var(--hair); }
.book-row__score--low  { color: #a86a55;        border-color: rgba(168,106,85,0.4); }
.book-row__title {
  font-family: var(--serif); font-size: 20px;
  letter-spacing: -0.005em; line-height: 1.2;
}
.book-row__mini {
  font-size: 13px; color: var(--muted);
  margin-top: 4px; font-style: italic;
}
.book-row__date {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  text-align: right; letter-spacing: 0.06em;
  align-self: center;
}
.book-row__full {
  display: none;
  grid-column: 3 / -1;
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--accent-soft);
  border-left: 2px solid var(--accent);
  font-size: 14px; line-height: 1.6;
}
.book-row.is-open .book-row__full { display: block; }

@media (max-width: 768px) {
  .book-row {
    grid-template-columns: 44px 44px 1fr;
    gap: 12px; padding: 14px 0;
  }
  .book-row__cover { width: 44px; height: 64px; font-size: 18px; }
  .book-row__score { font-size: 12px; }
  .book-row__title { font-size: 17px; }
  .book-row__mini  { font-size: 12px; }
  .book-row__date  {
    grid-column: 3; text-align: left; margin-top: 6px;
    font-size: 10px;
  }
  .book-row__full { grid-column: 1 / -1; }
}

/* ── /work ruffle grid ───────────────────────────────────────────── */
.work-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}
.work-card { display: block; }
.work-card__frame {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #1a1410;
  border: 1px dashed color-mix(in oklab, var(--accent) 40%, transparent);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px;
  position: relative; overflow: hidden;
  transition: border-color 0.2s ease;
}
.work-card:hover .work-card__frame { border-color: var(--accent); border-style: solid; }
.work-card__play {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.work-card__play::after {
  content: '';
  width: 0; height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid var(--accent);
  margin-left: 3px;
}
.work-card__label {
  font-family: var(--mono); font-size: 9px;
  color: var(--accent); letter-spacing: 0.2em;
}
.work-card__meta {
  margin-top: 12px;
  display: flex; justify-content: space-between;
  align-items: baseline; gap: 12px;
}
.work-card__name {
  font-family: var(--serif); font-size: 18px;
  letter-spacing: -0.005em;
}
.work-card__year {
  font-family: var(--mono); font-size: 11px;
  color: var(--accent);
}

@media (max-width: 768px) {
  .work-grid { grid-template-columns: 1fr; gap: 18px; }
  .work-card__name { font-size: 16px; }
}
@media (min-width: 769px) and (max-width: 1024px) {
  .work-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── reduced motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .gradient-1, .gradient-2, .gradient-3 { animation: none; }
  .physics-canvas { display: none; }
  .dot-placeholder { transition: none; }
}
