/* Pearcache Projects (served from the tools-pearcache Worker).
 *
 * A hand-kept COPY of pearcache.com's Cabinet design: the tokens, the bar, the
 * cabinet frame and frieze, and the directory's row language, taken from
 * pearcache-site/assets/css/pearcache.css on 2 Oct 2026. Copied rather than
 * imported because this site deploys on its own and cannot reach the front
 * page's assets at runtime. If pearcache.css changes any rule named here, make
 * the same change here by hand; nothing will tell you.
 *
 * Contrast: the front page's bar, WCAG AAA (7:1 text), measured against the
 * actual background. Ratios are noted next to each colour.
 */

/* Fraunces, SIL Open Font License 1.1 (assets/fonts/Fraunces-OFL.txt). One
   variable file carries weight, optical size, SOFT and WONK. Byte-identical to
   the front page's copy. */
@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces-latin-full-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;

  --ground: #170204;
  --ink: #F7ECE6;          /* 17.29 on --ground, 13.48 on --frame, 17.74 on --niche-back */
  --ink-soft: #D9D2D0;     /* 13.45 on --ground, 13.81 on --niche-back */
  --sage: #A8C4B6;         /* 11.02 on --niche-back, 10.73 on --ground, 8.37 on --frame */
  --frame: #4A0A10;
  --line: #B5D1C4;         /* 9.60 on --frame, 12.63 on --niche-back (non-text) */
  --niche-back: #0B0103;
  --plate: #F2E4DA;
  --plate-ink: #2A0508;    /* 15.03 on --plate */
  --focus: #B5D1C4;
  --hairline: rgba(247, 236, 230, .42);  /* decorative row rules */
  --key: #0B0103;
  --glow-rim: #fff7d6;
  --glow-core: rgba(255, 244, 200, .85);
  --glow-mid: rgba(255, 226, 150, .4);
  --glow-edge: rgba(255, 226, 150, 0);

  --font-display: "Fraunces", Georgia, serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;

  --dur-fast: 160ms;
  --dur-med: 320ms;
  --ease-out: cubic-bezier(.16, .9, .32, 1);

  --header-h: 44px;
  --shelf: 10px;
}

/* Day: the colour-inverted theme, reached only by the easter egg on the pear
   mark in the header (assets/js/theme.js). A hand-kept copy of the day block
   in pearcache.css, ratios included: change both together. Nothing follows
   prefers-color-scheme, on purpose. Photographs are not inverted. */
:root[data-theme="day"] {
  color-scheme: light;
  --ground: #E7E0E4;
  --ink: #242F3B;          /* 10.47 on --ground, 8.56 on --frame, 11.91 on --niche-back */
  --ink-soft: #283846;     /* 9.28 on --ground, 7.58 on --frame, 10.55 on --niche-back */
  --sage: #5D2460;         /* 8.58 on --ground, 7.01 on --frame, 9.75 on --niche-back */
  --frame: #D6CAD1;
  --line: #5F2A63;         /* 6.62 on --frame, 9.21 on --niche-back (non-text) */
  --niche-back: #F2EFF2;
  --plate: #F2EFF2;
  --plate-ink: #242F3B;    /* 11.91 on --plate */
  --focus: #2526E5;        /* 5.32 on --frame, 6.51 on --ground (non-text) */
  --hairline: rgba(36, 47, 59, .42);
  --key: #242F3B;          /* 13.0 on the glow's near-white core */
  --glow-rim: #E8FFFA;
  --glow-core: rgba(232, 255, 250, .96);
  --glow-mid: rgba(65, 239, 216, .5);
  --glow-edge: rgba(65, 239, 216, 0);
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ground);
  color: var(--ink);
  font: 400 1rem/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--sage); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--ink); }

:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }

.skip-link {
  position: absolute; left: 1rem; top: -100px; z-index: 100;
  padding: .6rem 1rem; border-radius: 4px;
  background: var(--plate); color: var(--plate-ink); font-weight: 700;
}
.skip-link:focus { top: 1rem; color: var(--plate-ink); }

/* ---------- bar: pearcache.css ".bar", unchanged ---------- */
.bar {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: var(--header-h);
  padding: 0 1.25rem;
}
.bar__brand {
  display: inline-flex; align-items: center; gap: .5rem;
  min-height: 44px;
  color: var(--ink); text-decoration: none;
  font: 500 1.3rem/1 var(--font-display);
  font-variation-settings: "SOFT" 100, "WONK" 1;
  letter-spacing: -.01em;
}
.bar__brand:hover { color: var(--ink); }
/* The easter egg: the pear mark is a button; it turns over as the theme does. */
.bar__home { display: inline-flex; align-items: center; gap: .5rem; min-height: 44px; color: inherit; text-decoration: none; }
.bar__mode {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; margin: 0 -.5rem 0 -.6rem; padding: 0;
  background: none; border: 0; color: inherit; cursor: pointer;
}
.bar__mode img { transition: transform var(--dur-med) var(--ease-out); }
:root[data-theme="day"] .bar__mode img { transform: rotate(180deg); }
/* Colours ease across during a switch; theme.js adds the class for ~450ms. */
.theme-fade, .theme-fade *, .theme-fade *::before, .theme-fade *::after {
  transition: background-color .35s, color .35s, border-color .35s, fill .35s, stroke .35s !important;
}
/* Arrival: the cabinet and the GitHub mark fade in, so a click from another
   Pearcache site does not pop. The bar itself is static, so it reads as one
   header across sites. */
@keyframes pc-in { from { opacity: 0; } to { opacity: 1; } }
.cabinet { animation: pc-in .4s var(--ease-out) backwards; }
.bar__github { animation: pc-in .6s var(--ease-out) .25s backwards; }
.bar nav { display: flex; gap: .25rem; font-size: .95rem; }
/* 2.5.5-sized hit areas: every link is its own 44px-tall target. */
.bar nav a {
  display: inline-flex; align-items: center;
  min-height: 44px; padding: 0 .7rem;
  color: var(--ink-soft); text-decoration: none;
}
.bar nav a:hover { color: var(--ink); }
.bar nav a[aria-current="page"] {
  color: var(--ink);
  text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px;
  text-decoration-color: var(--line);
}

/* The GitHub link, kept from the old page's bar. Not on pearcache.com's bar;
   desktop only here, and on phones it moves to the footer. Only one of the
   two is ever displayed, so a screen reader meets it once. */
.bar nav a.bar__github { justify-content: center; min-width: 44px; padding: 0; }
.bar__github svg { display: block; width: 18px; height: 18px; }
.site-footer__github { display: none; }

/* ---------- the cabinet: the front page's directory view ---------- */
/* The window behind the glass: one of the owner's photographs, darkened so
   it sits back. No text is ever set directly on it; the cabinet and its page
   are the two glass layers, and text lives on the second. */
main {
  position: relative; isolation: isolate; overflow: clip;
  flex: 1 1 auto; display: flex; align-items: center; padding: .5rem 1.25rem;
  background: var(--ground);
}
/* The photograph, on its own layer so it can be blurred without blurring the
   cabinet. Oversized by the blur radius so the soft edges stay off-screen. */
main::before {
  content: ""; position: absolute; inset: -24px; z-index: -1;
  background:
    linear-gradient(rgba(23, 2, 4, .38), rgba(23, 2, 4, .58)),
    url("../img/backdrop.jpg") center 40% / cover no-repeat;
  filter: blur(6px);
}

.cabinet {
  flex: 0 1 auto;
  width: 100%; max-width: 880px; margin-inline: auto;
  display: flex; flex-direction: column;
  padding: calc(var(--shelf) + 6px);
  /* Glass one: the frame, frosted. Without backdrop-filter it falls back to
     the solid frame colour below, so nothing is ever less legible than before. */
  background: var(--frame);
  border-radius: 14px;
  /* The painted line just inside the edge. */
  box-shadow: inset 0 0 0 2px var(--frame), inset 0 0 0 4px var(--line);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) and (background: color-mix(in srgb, red 50%, blue)) {
  .cabinet {
    background:
      linear-gradient(135deg, rgba(255, 255, 255, .13), rgba(255, 255, 255, 0) 45%),
      color-mix(in srgb, var(--frame) 52%, transparent);
    -webkit-backdrop-filter: blur(16px) saturate(1.15);
    backdrop-filter: blur(16px) saturate(1.15);
  }
  /* Glass two: the page. Dense enough (.9) that the text on it keeps 7:1
     over even a white photograph; see the contrast note on .cabinet__page. */
  .cabinet__page {
    background: color-mix(in srgb, var(--niche-back) 90%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .10);
  }
}

/* Drawn from the marks. One SVG used as a mask, so the colour is a variable.
   A CSS mask is fetched under img-src, which _headers allows for 'self'. */
.cabinet__frieze {
  flex: 0 0 auto;
  height: 22px; margin-bottom: 6px;
  background: var(--line);
  /* The tile repeats from the centre and clips wherever the panel ends, so
     the ends fade out rather than showing a sliver of a glyph. */
  -webkit-mask: url("../img/frieze.svg") center / auto 100% repeat-x,
    linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent) center / 100% 100% no-repeat;
  -webkit-mask-composite: source-in;
  mask: url("../img/frieze.svg") center / auto 100% repeat-x,
    linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent) center / 100% 100% no-repeat;
  mask-composite: intersect;
}

/* Contrast on glass, worst case: rgba(11,1,3,.9) over pure white composites
   to about #231A1C. --ink 14.6:1, --ink-soft 11.4:1, --sage 9.1:1 on that, so
   every text pair clears 7:1 whatever the photograph does behind it. */
.cabinet__page {
  padding: .9rem 1.25rem 1rem;
  border-radius: 3px;
  background: var(--niche-back);
}

/* The directory's caption style. */
h1 {
  margin: 0;
  font: 500 1.5rem/1.2 var(--font-display);
  font-variation-settings: "SOFT" 100, "WONK" 1;
  letter-spacing: -.015em;
}
.page-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: .1rem .9rem; margin: 0 0 .5rem; }
.intro { margin: 0; color: var(--ink-soft); font-size: .95rem; }

/* ---------- the rows: the directory's .dir-row, one link each ---------- */
.projects {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: 1fr 1fr; column-gap: 2rem;
}
.project { border-top: 1px solid var(--hairline); } /* 3:1+ on --niche-back */
.project__link {
  display: block;
  padding: .55rem .5rem;
  color: var(--ink); text-decoration: none;
  border-radius: 3px;
}
.project__name {
  font: 600 1.1rem/1.3 var(--font-display);
  font-variation-settings: "SOFT" 100, "WONK" 0;
}
.project__link:hover .project__name { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.project__meta { display: block; margin-top: .2rem; font-size: .92rem; line-height: 1.7; color: var(--ink-soft); }
.project__domain { color: var(--sage); }

.status-badge { font-size: .8rem; font-weight: 600; letter-spacing: .04em; color: var(--ink); }
.status-badge[data-status="live"]::before {
  content: ""; display: inline-block;
  width: .5em; height: .5em; margin-right: .35em; border-radius: 50%;
  background: var(--line);
}

/* The mini gate: the front page's closed arch at link size. The keyhole is
   static: the aura loops only on pearcache.com, where it is the one thing
   allowed to. */
.back { margin: .75rem 0 0; display: flex; justify-content: center; }
.mini-gate {
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  min-height: 44px; padding: .25rem .5rem;
  color: var(--ink); text-decoration: none;
}
.mini-gate:hover { color: var(--ink); }
.mini-gate__arch {
  position: relative; display: block;
  width: 72px; height: 90px;
  border-radius: 999px 999px 0 0;
  background: var(--niche-back) url("../img/mini-arch.jpg") center / cover no-repeat;
  box-shadow: 0 0 0 3px var(--plate), 0 0 0 5px var(--niche-back);
  transition: transform var(--dur-fast) var(--ease-out);
}
.mini-gate__key {
  position: absolute; left: 50%; top: 60%; translate: -50% -50%;
  display: grid; place-items: center; width: 44px; height: 44px;
  color: var(--key);
}
.mini-gate__key svg { position: relative; width: 11px; height: 17px; filter: drop-shadow(0 0 2px var(--glow-rim)); }
.mini-gate__key::before {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  background: radial-gradient(closest-side, var(--glow-core), var(--glow-mid) 40%, var(--glow-edge) 72%);
}
/* The name plate, as on the front page. */
.mini-gate__label {
  padding: .28rem .9rem .32rem;
  border: 1.5px solid var(--line); border-radius: 3px;
  background: var(--frame); color: var(--ink);
  font: 600 .95rem/1.3 var(--font-display);
  font-variation-settings: "SOFT" 100, "WONK" 1;
  transition: background-color var(--dur-fast), border-color var(--dur-fast);
}
.mini-gate:hover .mini-gate__label { background: var(--niche-back); border-color: var(--ink); }
.mini-gate:hover .mini-gate__arch { transform: scale(1.04); }
.mini-gate:active .mini-gate__arch { transform: scale(.97); }

/* Short desktop windows (laptops): trim the vertical rhythm
   so the whole page still sits above the fold. Desktop only: phones scroll. */
@media (max-height: 720px) and (min-width: 681px) {
  main { padding-block: .25rem; }
  .project__link { padding-block: .35rem; }
  .back { margin-top: .4rem; }
  .mini-gate { gap: .35rem; }
  .mini-gate__arch { width: 56px; height: 70px; }
  .mini-gate__label { padding-block: .15rem .2rem; }
  .cabinet__frieze { margin-bottom: 4px; }
}

/* ---------- foot ---------- */
.site-footer {
  flex: 0 0 auto;
  padding: 0 1.25rem .45rem;
  text-align: center; font-size: .8rem; color: var(--ink-soft);
}
.site-footer p { margin: 0; }
.site-footer a { color: inherit; }

/* ---------- phones: pearcache.css's 680px and 380px steps ---------- */
@media (max-width: 680px) {
  /* One column on phones, descriptions kept; scrolling is fine here. Only
     desktop is held to one screen. */
  .projects { grid-template-columns: 1fr; }
  .project__link { padding: .5rem .3rem; }
  .project__meta { font-size: .88rem; line-height: 1.6; }
  .bar nav a.bar__github { display: none; }
  .site-footer__github { display: inline; }
  main { padding-inline: .75rem; }
  .bar { padding-inline: .75rem; gap: .5rem; }
  .bar nav a { padding: 0 .45rem; }
  .cabinet__page { padding: .75rem .75rem 1rem; }
}
/* Tighter than pearcache.css here: "Projects" is three letters longer than
   the front page's "Tools", and at 320px the brand (a flex item) shrank under
   its own text, which then ran 8px into "Home". The brand no longer shrinks;
   the nav gives up the room instead. The front page needs the same when its
   nav link becomes Projects. */
@media (max-width: 380px) {
  .bar { gap: .25rem; }
  .bar__brand { flex-shrink: 0; font-size: 1.05rem; gap: .35rem; }
  .bar nav { font-size: .84rem; gap: 0; }
  .bar nav a { padding: 0 .3rem; }
}

@media (prefers-reduced-motion: reduce) {
  .cabinet, .bar__github { animation: none; }
  .bar__mode img, :root[data-theme="day"] .bar__mode img { transition: none; }
  .theme-fade, .theme-fade *, .theme-fade *::before, .theme-fade *::after { transition: none !important; }
  .mini-gate__arch, .mini-gate:hover .mini-gate__arch, .mini-gate:active .mini-gate__arch { transition: none; transform: none; }
}
