/* pawgge.rs design system: two layers over the background photo (content/site.json -> background_image).

   1. GLASS  (.glass)   frosted, see-through shells that FRAME sections (home page). Never holds bare text.
   2. PLATE  (.plate)   flat, solid colour fields that hold ALL readable content. Every plate has the same
                        3D-pop bevel: light top edge, dark bottom edge, soft drop shadow.
      .tint-<colour>    picks a plate's colour (pastel in light mode, deep smoked shade in dark mode).
      .interactive      a plate you can press (links, project cards, buttons): bumps up 2px and brightens on hover.

   Layout below only places things; it never restyles glass or plates. Order: tokens, background, glass,
   plate + tints, interactive, page layout. Themes: html[data-theme] (templates/base.html, toggled by alive.js).
   No text-shadow anywhere. */

/* ---------------------------------------------------------------- tokens */
:root {
  --red: #ffadadff;
  --orange: #ffd6a5ff;
  --yellow: #fdffb6ff;
  --green: #caffbfff;
  --light-blue: #9bf6ffff;
  --blue: #a0c4ffff;
  --purple: #bdb2ffff;
  --pink: #ffc6ffff;
  --white: #fffffcff;
  --red-rgb: 255, 173, 173;
  --orange-rgb: 255, 214, 165;
  --yellow-rgb: 253, 255, 182;
  --green-rgb: 202, 255, 191;
  --light-blue-rgb: 155, 246, 255;
  --blue-rgb: 160, 196, 255;
  --purple-rgb: 189, 178, 255;
  --pink-rgb: 255, 198, 255;
  --white-rgb: 255, 255, 252;

  /* frosted micro-grain (inline SVG noise): white specks + dark specks */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
  --grain-ink: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='170' height='170'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.12 0 0 0 0 0.2 0 0 0 0.9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");

  /* light theme */
  color-scheme: light;
  --page: #eef2fa;
  --ink: #0f1526;
  --ink-2: #27314a;
  --link: #173a7a;
  --heading: #3a3196;
  --line: rgba(20, 30, 65, 0.14);
  --well: rgba(255, 255, 255, 0.55);              /* text inputs, empty tiles */
  --bg-filter: blur(5px) saturate(1.3) brightness(0.95);
  --bg-filter-hover: blur(4.75px) saturate(1.3) brightness(1);
  --bg-filter-dim: blur(5px) saturate(1.2) brightness(0.86);
  /* glass */
  --glass-a: 0.24; --glass-b: 0.20; --glass-base: transparent;
  --glass-rim: 1px solid rgba(255, 255, 255, 0.48);
  --glass-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.52), inset 0 -1.5px 0 rgba(20, 30, 65, 0.22),
    0 14px 36px rgba(30, 48, 90, 0.16), 0 2px 6px rgba(30, 48, 90, 0.08);
  /* plate bevel: top highlight, bottom shading, outline, drop shadow; and the lifted (hover) version */
  --bevel-edges: inset 0 1.5px 0 rgba(255, 255, 255, 0.65), inset 0 -2.5px 0 rgba(20, 30, 65, 0.2), 0 0 0 1px rgba(20, 30, 65, 0.1);
  --plate-shadow: var(--bevel-edges), 0 2px 3px rgba(20, 30, 65, 0.08), 0 6px 16px rgba(20, 30, 65, 0.12);
  --plate-shadow-lift: var(--bevel-edges), 0 4px 6px rgba(20, 30, 65, 0.1), 0 14px 28px rgba(20, 30, 65, 0.18);
  --press-bright: 1.05;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b0f18;
  --ink: var(--white);
  --ink-2: rgba(255, 255, 252, 0.74);
  --link: var(--blue);
  --heading: var(--purple);
  --line: rgba(255, 255, 255, 0.12);
  --well: rgba(5, 8, 14, 0.5);
  --bg-filter: blur(5px) saturate(1.25) brightness(0.45);
  --bg-filter-hover: blur(4.75px) saturate(1.25) brightness(0.5);
  --bg-filter-dim: blur(5px) saturate(1.15) brightness(0.38);
  --glass-a: 0.12; --glass-b: 0.08; --glass-base: rgba(10, 13, 22, 0.58);
  --glass-rim: 1px solid rgba(255, 255, 255, 0.16);
  --glass-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.14), inset 0 -1.5px 0 rgba(0, 0, 0, 0.45),
    0 14px 36px rgba(0, 0, 0, 0.42), 0 2px 6px rgba(0, 0, 0, 0.26);
  --bevel-edges: inset 0 1.5px 0 rgba(255, 255, 255, 0.14), inset 0 -2.5px 0 rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.07);
  --plate-shadow: var(--bevel-edges), 0 2px 3px rgba(0, 0, 0, 0.25), 0 6px 16px rgba(0, 0, 0, 0.3);
  --plate-shadow-lift: var(--bevel-edges), 0 4px 6px rgba(0, 0, 0, 0.3), 0 14px 28px rgba(0, 0, 0, 0.42);
  --press-bright: 1.25;
}

/* ---------------------------------------------------------------- base + background */
* { box-sizing: border-box; }
/* One base size that grows with the screen: 16px at 1440 wide, ~18px at 1920, 20px from ~2300 up (4K). */
html { background: var(--page); font-size: clamp(16px, 0.42vw + 10px, 20px); }
body {
  margin: 0; min-height: 100vh; color: var(--ink);
  font: 1rem/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body::before { /* the photo; build.py adds the url(). Scaled up so the blur has no soft edges. */
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: 30% center / cover no-repeat;
  filter: var(--bg-filter); transform: scale(1.04);
  transition: filter 0.7s ease;
}
body::after { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: var(--grain), var(--grain-ink); }
body.bg-hover::before { filter: var(--bg-filter-hover); } /* alive.js: pointer over the background */
body.bg-dimmed::before { filter: var(--bg-filter-dim); }  /* alive.js: window unfocused / tab hidden */

h1, h2, h3 { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif; font-weight: 650; letter-spacing: -0.015em; line-height: 1.2; }
a { color: var(--link); text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); text-decoration-thickness: 1.5px; text-underline-offset: 0.2em; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2.5px solid var(--heading); outline-offset: 3px; }
::selection { background: rgba(var(--purple-rgb), 0.55); }
ul { list-style: none; margin: 0; padding: 0; }
.stack { --gap: clamp(0.85rem, 1.3vw, 1.35rem); display: flex; flex-direction: column; gap: var(--gap); }

/* ---------------------------------------------------------------- layer 1: glass */
/* Frosted shell. Tint with --t (and optional --t2 for a two-colour gradient); untinted = clear. */
.glass {
  position: relative; min-width: 0;
  padding: clamp(1.4rem, 2.3vw, 2.4rem);
  border: var(--glass-rim); border-radius: 1.6rem;
  background: var(--grain-ink),
    linear-gradient(160deg, rgba(var(--t, var(--white-rgb)), var(--glass-a)), rgba(var(--t2, var(--t, var(--white-rgb))), var(--glass-b))),
    var(--glass-base);
  -webkit-backdrop-filter: blur(14px) saturate(1.8); backdrop-filter: blur(14px) saturate(1.8);
  box-shadow: var(--glass-shadow);
}

/* ---------------------------------------------------------------- layer 2: plates + tints */
.tint-red { --c: var(--red); --t: var(--red-rgb); }
.tint-orange { --c: var(--orange); --t: var(--orange-rgb); }
.tint-yellow { --c: var(--yellow); --t: var(--yellow-rgb); }
.tint-green { --c: var(--green); --t: var(--green-rgb); }
.tint-light-blue { --c: var(--light-blue); --t: var(--light-blue-rgb); }
.tint-blue { --c: var(--blue); --t: var(--blue-rgb); }
.tint-purple { --c: var(--purple); --t: var(--purple-rgb); }
.tint-pink { --c: var(--pink); --t: var(--pink-rgb); }
.tint-white { --c: var(--white); --t: var(--white-rgb); }
/* the plate fill and its text colours, worked out on the tinted element itself so var(--c) resolves */
[class*="tint-"] { --plate: var(--c); --plate-ink: #0f1526; --plate-ink-2: #27314a; --plate-link: #15295c; }
[data-theme="dark"] [class*="tint-"] {
  --plate: color-mix(in srgb, var(--c) 15%, #0c111b); --plate-ink: var(--white); --plate-ink-2: rgba(255, 255, 252, 0.74); --plate-link: var(--c);
}

.plate {
  position: relative; margin: 0;
  padding: clamp(1.05rem, 1.5vw, 1.5rem) clamp(1.15rem, 1.7vw, 1.75rem);
  border: 0; border-radius: 1.05rem;
  background: var(--plate); color: var(--plate-ink);
  box-shadow: var(--plate-shadow);
}
.plate a { color: var(--plate-link); }

/* ---------------------------------------------------------------- interactive plates */
.interactive {
  display: block; cursor: pointer; text-decoration: none; color: var(--plate-ink); font: inherit;
  transition: transform 0.16s ease, filter 0.16s ease, box-shadow 0.16s ease;
}
.interactive:hover { color: var(--plate-ink); transform: translateY(-2px); filter: brightness(var(--press-bright)); box-shadow: var(--plate-shadow-lift); }
.interactive:active { transform: translateY(0); filter: none; box-shadow: var(--plate-shadow); transition-duration: 0.05s; }

/* ---------------------------------------------------------------- page layout */
/* Light/dark toggle: a small round interactive plate, top right of every page. */
.theme-toggle {
  position: fixed; top: clamp(0.6rem, 1.5vw, 1.25rem); right: clamp(0.6rem, 1.5vw, 1.25rem); z-index: 10;
  display: grid; place-items: center; width: 2.75rem; height: 2.75rem; padding: 0; border-radius: 50%;
}
.theme-toggle svg { width: 1.25rem; height: 1.25rem; }
.theme-toggle .sun, [data-theme="dark"] .theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: block; }

/* Home: profile glass 1/3, projects glass 2/3, centred in a wide container; stacked on narrow screens. */
.home {
  width: min(1440px, 92vw); min-height: 100vh; margin: 0 auto; padding: clamp(1rem, 3vh, 3rem) 0;
  display: grid; grid-template-columns: 1fr 2fr; gap: clamp(1rem, 1.8vw, 2rem); align-content: center; align-items: stretch;
  font-size: 1.1rem;
}
.home .glass { will-change: transform; } /* alive.js tilts these */
.profile { --t: var(--light-blue-rgb); container-type: inline-size; }
.projects { --t: var(--white-rgb); --t2: var(--blue-rgb); }   /* crystal */

.id h1 { margin: 0.8rem 0 0.2rem; font-size: 2rem; }
.bio { margin: 0; color: var(--plate-ink-2); }
.avatar {
  display: block; width: clamp(104px, 7vw, 120px); height: auto; aspect-ratio: 1; border-radius: 50%;
  box-shadow: 0 0 0 3px var(--c), 0 0 0 4px var(--line), 0 6px 18px rgba(20, 30, 65, 0.2);
}
/* Credits: each credit is exactly one line. The font follows the profile glass width (cqi): the longest line is
   ~23.5em, and 3.8cqi x 23.5em fits the 92% left after the 4cqi side padding. */
.credits { padding: 0.8rem 4cqi; font-size: min(0.78rem, 3.8cqi); color: var(--plate-ink-2); }
.credits p { margin: 0; white-space: nowrap; }

/* Socials: one interactive plate per row, icon + handle. On hover/focus the platform name slides out after the icon
   (grid column 0fr -> 1fr animates to its natural width) and pushes the handle right. The font follows the profile
   glass width (cqi), so icon + platform + handle always fit on one line. */
.socials { display: grid; gap: 0.7rem; }
.socials a {
  display: flex; align-items: center; padding: 0.95em 1em; border-radius: 0.85rem; overflow: hidden;
  font-size: min(0.92rem, 5.2cqi); white-space: nowrap;
}
.socials .icon { flex: none; width: 1.3em; height: 1.3em; margin-right: 0.65em; }
[data-theme="dark"] .socials .icon { color: var(--c); }
.platform { display: grid; grid-template-columns: 0fr; opacity: 0; transition: grid-template-columns 0.28s ease, opacity 0.2s ease; }
.platform > span { min-width: 0; overflow: hidden; color: var(--plate-ink-2); font-weight: 500; }
/* the label ends in a real space (so copied text reads "Bluesky @handle"); the dot is CSS-only, so it never copies */
.platform > span::after { content: "·"; margin: 0 0.5em 0 0.22em; }
.socials a:hover .platform, .socials a:focus-visible .platform { grid-template-columns: 1fr; opacity: 1; }
.handle { font-weight: 650; letter-spacing: 0.005em; }

/* Projects: a header plate, then project cards (3:1 interactive plates). The left half (--split) is the solid
   text plate; the right half is the art, crisp and flush to the card edges, under a barely-there flat clear tint
   (::before). The plate's 1px hairline is the only line between them. Art is 1.5:1 (900x600), so object-fit
   centres it in the slot. ::after redraws the card bevel over everything. */
.head { padding-block: 0.85rem; font-size: 1.3rem; }
.banner { --split: 50%; display: flex; aspect-ratio: 3 / 1; container-type: inline-size; padding: 0; overflow: hidden; isolation: isolate; border-radius: 1.15rem; }
.banner::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; box-shadow: var(--bevel-edges); }
.banner-art, .banner::before { position: absolute; top: 0; bottom: 0; left: var(--split); right: 0; }
.banner-art { z-index: -1; width: calc(100% - var(--split)); height: 100%; object-fit: cover; object-position: center; }
.banner::before { content: ""; z-index: 0; pointer-events: none; background: rgba(255, 255, 255, 0.04); }
[data-theme="dark"] .banner::before { background: rgba(10, 13, 22, 0.1); }
.banner-text {
  display: flex; flex-direction: column; justify-content: center; width: 50%;
  padding: max(0.9rem, 3.5cqi) 4cqi;
  background: var(--plate); box-shadow: 1px 0 0 var(--line);
}
/* Titles: uppercase, one line. Sized from the card width (cqi) so the longest (~13.5em) always fits the plate. */
.banner strong { font-size: min(3cqi, 1.75rem); font-weight: 750; letter-spacing: 0.03em; line-height: 1.2; text-transform: uppercase; white-space: nowrap; }
.banner-text span { margin-top: 0.4rem; color: var(--plate-ink-2); font-size: clamp(0.85rem, 1.9cqi, 1.05rem); font-weight: 500; }

/* Blog pages (content/*.md, body.blog-page): no photo and no glass. The page itself is the white surface
   (the same colour as a tint-white plate, smoked in dark mode), with one reading column. Figures and tables
   sit on tint-white plates with the usual bevel; equations are plain MathML (build.py renders them). */
html:has(> body.blog-page) { --page: var(--white); }
:root[data-theme="dark"]:has(> body.blog-page) { --page: color-mix(in srgb, var(--white) 15%, #0c111b); }
body.blog-page::before, body.blog-page::after { display: none; }
.blog {
  --plate-ink: var(--ink); --plate-ink-2: var(--ink-2);
  max-width: 1040px; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2rem) clamp(3rem, 8vh, 6rem);
  font-size: 1.05rem;
}
.blog-bar { display: flex; align-items: center; min-height: calc(2 * clamp(0.6rem, 1.5vw, 1.25rem) + 2.75rem); margin-bottom: clamp(1rem, 3vh, 2rem); }
.back { padding: 0.5rem 0.95rem; border-radius: 0.8rem; font-size: 0.92rem; font-weight: 600; }
.blog-head { margin-bottom: 1.6rem; }
.prose h1 { font-size: 2.3rem; margin: 0 0 0.35rem; }
.subtitle { margin: 0; font-size: 1.2rem; color: var(--ink-2); }
.prose h2 { font-size: 1.5rem; margin: 2.8rem 0 0.6rem; color: var(--heading); }
.prose h3 { font-size: 1.15rem; margin: 2rem 0 0.3rem; color: var(--ink-2); }
.prose ul { list-style: disc; padding-left: 1.4em; margin: 1em 0; }
.prose li + li { margin-top: 0.25em; }
.fig { margin: 1.6rem 0; padding: clamp(0.6rem, 1.2vw, 0.9rem); }
.fig img { display: block; width: 100%; height: auto; border-radius: 0.6rem; }
.fig figcaption { margin-top: 0.7rem; padding: 0 0.2rem; font-size: 0.88rem; line-height: 1.5; color: var(--plate-ink-2); }
/* One math font everywhere: STIX Two Math (OFL), a local copy if installed, else a subset (static/fonts, see README). */
@font-face { font-family: "pawggers math"; src: local("STIX Two Math"), local("STIXTwoMath-Regular"), url("fonts/STIXTwoMath-2.13-subset.woff2?v=77f922ae1b") format("woff2"); font-display: swap; }
.math math { font-family: "pawggers math", "STIX Two Math", math; }
.math { margin: 1.1rem 0; overflow-x: auto; overflow-y: hidden; padding: 0.2rem 0; font-size: 1.08em; }
.blog .table-wrap { padding: 0.9rem 1.1rem; border-radius: 1.05rem; background: var(--page); box-shadow: var(--plate-shadow); } /* a tint-white plate */
[data-theme="dark"] .fig img { filter: brightness(0.9); } /* the diagrams are drawn on white */
.prose img { max-width: 100%; }
.prose code { font: 0.87em ui-monospace, SFMono-Regular, Menlo, monospace; background: rgba(var(--purple-rgb), 0.35); padding: 1px 6px; border-radius: 6px; }
[data-theme="dark"] .prose code { background: rgba(var(--purple-rgb), 0.16); color: var(--purple); }
[data-theme="dark"] .prose a { color: var(--blue); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; font-size: 0.93em; }
th, td { padding: 0.4em 0.7em; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--heading); font-weight: 650; }
thead th { border-bottom: 2px solid rgba(var(--purple-rgb), 0.8); }
tbody th { color: var(--plate-ink); font-weight: 500; }
caption { caption-side: top; text-align: left; padding-bottom: 0.5em; color: var(--plate-ink-2); }
video, iframe { display: block; width: 100%; border: 0; border-radius: 0.75rem; background: #1b2238; }
.video { margin: 0 0 1.5rem; }
video, iframe { aspect-ratio: 16 / 9; } /* reserve the 1920x1080 frame before metadata loads */

/* Frame explorer: a controls plate (jump box, Go button, Show Original) over a grid of 4:3 tile plates.
   gallery.js measures the row height from the first tile; its GAP must match .g-row's gap. */
.gallery { margin-top: 1.5rem; display: grid; gap: clamp(0.85rem, 1.3vw, 1.35rem); }
.g-bar { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: center; padding-block: 0.75rem; font-size: 0.9rem; }
.g-bar form { display: flex; gap: 0.5rem; margin: 0; }
.g-bar label { font-weight: 500; cursor: pointer; }
.g-count { margin-left: auto; color: var(--plate-ink-2); }
.g-jump button { padding: 0.35em 1em; border-radius: 0.65rem; font-weight: 650; }
input { font: inherit; color: var(--plate-ink); }
input::placeholder { color: var(--plate-ink-2); opacity: 0.8; }
input[type="text"] { padding: 0.35em 0.7em; border: 0; border-radius: 0.65rem; background: var(--well); box-shadow: inset 0 2px 3px rgba(20, 30, 65, 0.18), 0 0 0 1px var(--line); }
input[type="text"]:focus { outline: none; box-shadow: inset 0 2px 3px rgba(20, 30, 65, 0.14), 0 0 0 3px rgba(var(--blue-rgb), 0.6); }
input[type="checkbox"] { accent-color: var(--purple); width: 1.05em; height: 1.05em; vertical-align: -0.14em; }
.g-grid { position: relative; }
.g-row { position: absolute; left: 0; right: 0; display: grid; gap: 12px; }
.fr { min-width: 0; padding: 0.5rem; border-radius: 0.85rem; font-size: 0.75rem; line-height: 1.35; }
.fr .pic { display: block; }
.fr img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 0.5rem; background: var(--well); }
.g-grid.orig .fr img { object-fit: contain; } /* Show Original: the whole artwork, letterboxed */
.fr .r1 { margin-top: 0.4rem; height: 1.35em; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.fr .r2 { height: 2.7em; overflow: hidden; color: var(--plate-ink-2); overflow-wrap: anywhere; } /* up to 2 lines, fixed height */
.fr.hl { box-shadow: var(--plate-shadow), 0 0 0 3px var(--heading); }

/* Desktop: the profile glass is as tall as the projects glass. Profile plate at the top, credits at the bottom,
   and the free height split evenly: space-evenly gives the gap above, between and below the buttons the same share,
   and the ul's padding-block equals its gap, so all seven gaps (plate, 6 buttons, credits) come out identical. */
@media (min-width: 901px) {
  .profile { gap: 0; }
  .profile .socials { flex: 1; align-content: space-evenly; gap: var(--gap); padding-block: var(--gap); }
}
@media (max-width: 900px) {
  .home { grid-template-columns: 1fr; align-content: start; width: min(640px, 100% - 2rem); padding-top: 3.75rem; }
  /* min-height with aspect-ratio would also force a min-width, so narrow screens drop the ratio instead */
  .banner { aspect-ratio: auto; min-height: 150px; }
  .banner { --split: 62%; }
  .banner-text { width: 62%; }
  .banner strong { font-size: min(3.9cqi, 1.75rem); }
}
@media (max-width: 560px) { /* phones: artwork strip on top, the text plate full width below it */
  .banner { flex-direction: column; min-height: 0; }
  .banner-text { width: 100%; margin-top: 5rem; padding: 0.9rem 4cqi; }
  .banner-art, .banner::before { left: 0; bottom: auto; width: 100%; height: 5rem; }
  .banner-text { box-shadow: 0 -1px 0 var(--line); }
  .banner strong { font-size: min(6.5cqi, 1.5rem); }
  .banner-text span { font-size: 0.9rem; }
}
@media (prefers-reduced-motion: reduce) { body::before, .interactive, .platform { transition: none; } }
