/* Day mode (default): black and white */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-raised: rgba(255, 255, 255, 0.85);
  --text: #0a0a0a;
  --muted: rgba(10, 10, 10, 0.5);
  --faint: rgba(10, 10, 10, 0.18);
  --line: rgba(0, 0, 0, 0.08);
  --fill: rgba(0, 0, 0, 0.05);
  --tile: #f3f3f3;
  --contact: rgba(0, 0, 0, 0.14);
  --drop: rgba(0, 0, 0, 0.1);
  --raise: rgba(0, 0, 0, 0.08);
  --sheet: #ffffff;
  --backdrop: rgba(0, 0, 0, 0.25);
  --info-bg: #0a0a0a;
  --info-fg: #ffffff;
  --info-glow: none;
  --font: "Geist", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: 20px;
  --stagger: 96px;
  --head-h: 132px;
}

/* Dark mode: follows the phone/computer setting, unless the visitor picked Day in the ⓘ panel */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #464a47;
    --bg-raised: rgba(58, 62, 59, 0.82);
    --text: #ecece8;
    --muted: rgba(236, 236, 232, 0.5);
    --faint: rgba(236, 236, 232, 0.22);
    --line: rgba(255, 255, 255, 0.07);
    --fill: rgba(255, 255, 255, 0.06);
    --tile: #f2f1ee;
    --contact: rgba(0, 0, 0, 0.28);
    --drop: rgba(0, 0, 0, 0.18);
    --raise: rgba(0, 0, 0, 0.18);
    --sheet: #3d413e;
    --backdrop: rgba(20, 22, 21, 0.55);
    --info-bg: linear-gradient(145deg, #fafaf8, #e3e2de);
    --info-fg: #9a9a96;
    --info-glow: inset 0 1px 0 #fff;
  }
}

/* Dark mode picked manually (same values as above) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #464a47;
  --bg-raised: rgba(58, 62, 59, 0.82);
  --text: #ecece8;
  --muted: rgba(236, 236, 232, 0.5);
  --faint: rgba(236, 236, 232, 0.22);
  --line: rgba(255, 255, 255, 0.07);
  --fill: rgba(255, 255, 255, 0.06);
  --tile: #f2f1ee;
  --contact: rgba(0, 0, 0, 0.28);
  --drop: rgba(0, 0, 0, 0.18);
  --raise: rgba(0, 0, 0, 0.18);
  --sheet: #3d413e;
  --backdrop: rgba(20, 22, 21, 0.55);
  --info-bg: linear-gradient(145deg, #fafaf8, #e3e2de);
  --info-fg: #9a9a96;
  --info-glow: inset 0 1px 0 #fff;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-x: none;
}

button { font: inherit; color: inherit; }
a { color: inherit; }

/* ── Big category titles ─────────────────────────── */
.head {
  position: sticky; top: 0; z-index: 20;
  height: var(--head-h);
  padding-top: env(safe-area-inset-top);
  background: linear-gradient(var(--bg) 78%, transparent);
}

.cats {
  display: flex; align-items: flex-start;
  height: 100%;
  padding: 20px calc(var(--gutter) + 52px) 0 var(--gutter);
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-padding-left: var(--gutter);
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 110px), transparent calc(100% - 52px));
          mask-image: linear-gradient(90deg, #000 calc(100% - 110px), transparent calc(100% - 52px));
}
.cats::-webkit-scrollbar { display: none; }

.cat {
  flex: none;
  display: inline-flex; align-items: flex-start;
  border: 0; background: none; padding: 0 0.22em 0 0; margin: 0;
  /* --cat-size is set by app.js so the longest title fits on screen */
  font-size: var(--cat-size, clamp(48px, 14vw, 132px));
  font-weight: 600; letter-spacing: -0.045em; line-height: 1.02;
  white-space: nowrap; cursor: pointer;
  color: var(--text); opacity: 0.26;
  scroll-snap-align: start;
  transition: opacity 0.35s ease;
}
.cat[aria-current="true"] { opacity: 1; }
.cat:hover { opacity: 0.6; }
.cat[aria-current="true"]:hover { opacity: 1; }
.cat sup {
  font-size: 15px; font-weight: 400; letter-spacing: 0;
  margin: 0.15em 0 0 0.25em; line-height: 1;
  opacity: 0.85; font-variant-numeric: tabular-nums;
}

.info-btn {
  position: absolute; right: 12px; top: calc(env(safe-area-inset-top) + 26px);
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0; border-radius: 2px; cursor: pointer;
  background: var(--info-bg);
  color: var(--info-fg);
  box-shadow: 0 6px 18px var(--raise), var(--info-glow);
}
.info-btn:active { transform: scale(0.96); }

/* ── Product grid ────────────────────────────────── */
main {
  max-width: 1180px; margin: 0 auto;
  padding: 24px var(--gutter) calc(140px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

.grid {
  list-style: none; margin: 0; padding: 0 0 var(--stagger);
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 40px 16px;
}
.grid > li:nth-child(even) { transform: translateY(var(--stagger)); }
/* A lone item in the last row sits centred */
.grid > li:last-child:nth-child(odd) { grid-column: 1 / -1; justify-self: center; width: 62%; }

.item {
  display: block; text-decoration: none; text-align: center;
  opacity: 0; animation: rise 0.5s ease forwards;
  animation-delay: calc(var(--i, 0) * 40ms);
  -webkit-tap-highlight-color: transparent;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.shot {
  position: relative;
  aspect-ratio: 1 / 1.02;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 14px;
}
/* Soft contact shadow under each object */
.shot::after {
  content: ""; position: absolute; left: 18%; right: 18%; bottom: 4px; height: 16px;
  background: radial-gradient(closest-side, var(--contact), transparent);
  pointer-events: none;
}
.shot img {
  position: relative; z-index: 1;
  max-width: 88%; max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 8px 10px var(--drop));
  transition: transform 0.4s cubic-bezier(.2, .7, .2, 1);
}
.item:hover .shot img { transform: translateY(-6px); }
.item:active .shot img { transform: scale(0.97); }

/* Normal (non-transparent) photos sit on a light tile */
.shot.tile img {
  max-width: 78%; max-height: 92%;
  padding: 10%;
  background: var(--tile);
  border-radius: 6px;
  filter: none;
  box-shadow: 0 10px 24px var(--raise);
}

.placeholder {
  position: relative; z-index: 1;
  width: 62%; aspect-ratio: 1;
  display: grid; place-items: center;
  border-radius: 6px;
  background: var(--fill);
  border: 1px solid var(--line);
  font-size: 44px; font-weight: 500; letter-spacing: -0.04em;
  color: var(--faint);
}

.caption { padding: 10px 6px 0; }
.name { display: block; font-size: 15px; line-height: 1.3; text-wrap: balance; }
.price {
  display: block; margin-top: 3px;
  color: var(--muted); font-variant-numeric: tabular-nums;
}

.mark {
  display: inline-block; width: 7px; height: 7px;
  margin-right: 8px; vertical-align: 2px;
  border: 1px solid currentColor; opacity: 0.75;
}
.mark.owned { background: currentColor; }

.empty { color: var(--muted); font-size: 17px; margin: 56px 0 0; }
.empty button {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--text); text-decoration: underline; text-underline-offset: 4px;
}

/* ── Bottom status bar ───────────────────────────── */
.status {
  position: fixed; z-index: 20;
  left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 4px; border-radius: 4px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 10px 30px var(--raise);
}
.seg {
  border: 0; background: none; cursor: pointer;
  padding: 12px 6px; border-radius: 2px;
  font-size: 16px; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; gap: 0;
  transition: background 0.2s ease, color 0.2s ease;
}
.seg .count { font-size: 13px; margin-left: 8px; opacity: 0.8; font-variant-numeric: tabular-nums; }
.seg[aria-pressed="true"] { color: var(--text); background: var(--fill); }

/* ── Info sheet ──────────────────────────────────── */
.sheet {
  width: min(440px, calc(100vw - 24px));
  margin: auto; padding: 0;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--sheet); color: var(--text);
  box-shadow: 0 30px 80px var(--raise);
}
.sheet::backdrop { background: var(--backdrop); backdrop-filter: blur(4px); }
.sheet-inner { position: relative; padding: 28px 24px 24px; }
.sheet h2 { font-size: 40px; font-weight: 600; letter-spacing: -0.04em; margin: 0 0 10px; line-height: 1; }
.sheet p { margin: 0 0 16px; color: var(--muted); }
.eyebrow { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px !important; }
.close {
  position: absolute; top: 12px; right: 14px;
  width: 36px; height: 36px; border: 0; background: none; cursor: pointer;
  font-size: 26px; color: var(--muted);
}
.legend { display: flex; gap: 20px; margin: 0 0 20px; }
.legend div { display: flex; align-items: center; }
.legend dt, .legend dd { margin: 0; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.field select {
  font: inherit; color: var(--text); background: var(--fill);
  border: 1px solid var(--line); border-radius: 4px; padding: 6px 10px; cursor: pointer;
}
.field select option { color: #111; }
.field + .field { border-top: 0; margin-top: -18px; }

.theme-switch {
  display: inline-grid; grid-template-columns: repeat(3, auto);
  padding: 3px; border-radius: 6px;
  background: var(--fill); border: 1px solid var(--line);
}
.theme-switch button {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; background: none; cursor: pointer;
  padding: 6px 10px; border-radius: 4px;
  font-size: 13px; color: var(--muted);
  transition: background 0.2s ease, color 0.2s ease;
}
.theme-switch button svg { width: 14px; height: 14px; }
.theme-switch button[aria-pressed="true"] { background: var(--bg); color: var(--text); box-shadow: 0 1px 3px var(--raise); }
html.theming, html.theming * { transition: background-color 0.3s ease, color 0.3s ease !important; }
.fine { font-size: 12.5px; }

/* ── Larger screens ──────────────────────────────── */
@media (min-width: 760px) {
  :root { --gutter: 40px; --stagger: 140px; --head-h: 190px; }
  .info-btn { width: 56px; height: 56px; top: 44px; right: 24px; }
  .cats { padding-right: calc(var(--gutter) + 72px); }
  .cats { padding-top: 28px; }
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 56px 28px; }
  .grid > li:nth-child(even) { transform: none; }
  .grid > li:last-child:nth-child(odd) { grid-column: auto; justify-self: stretch; width: auto; }
  .grid > li:nth-child(4n+2), .grid > li:nth-child(4n+4) { transform: translateY(var(--stagger)); }
}

/* ── Review preview (books) ──────────────────────── */
.grid > li { position: relative; }
.grid > li.has-review:hover, .grid > li.has-review:focus-within, .grid > li.show-review { z-index: 6; }
.review {
  position: absolute; z-index: 2; left: 2%; right: 2%; top: 30%;
  padding: 14px 14px 12px;
  background: var(--sheet); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 14px 34px var(--raise);
  font-size: 13.5px; line-height: 1.5; text-align: left;
  opacity: 0; transform: translateY(6px); pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.review::before {
  content: "Review"; display: block; margin-bottom: 6px;
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.review p {
  margin: 0 0 10px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.review a { font-size: 13px; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.review a:hover { text-decoration-thickness: 2px; }
@media (hover: hover) {
  /* Wider than the item on desktop, centred over it */
  .review { left: 50%; right: auto; width: max(100%, 270px); transform: translate(-50%, 6px); }
  .has-review:hover .review, .has-review:focus-within .review { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
}
.show-review .review { opacity: 1; transform: none; pointer-events: auto; }

.review-btn { display: none; }
@media (hover: none) {
  .has-review { text-align: center; }
  .review-btn {
    display: inline-block; margin-top: 6px; cursor: pointer;
    padding: 3px 10px; border-radius: 999px;
    border: 1px solid var(--line); background: none;
    font-size: 12px; color: var(--muted);
  }
  .review-btn[aria-expanded="true"] { color: var(--text); border-color: var(--muted); }
}

/* ── Site sidebar (matches the rest of Chai & Claude) ── */
:root { --side: 220px; --serif: "Fraunces", Georgia, serif; }
.site { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.things { min-width: 0; position: relative; }

.side { position: sticky; top: 0; height: 100vh; padding: 48px 0 40px 52px; z-index: 25; }
.brand, .menu-btn { display: none; }
.side-panel { height: 100%; display: flex; flex-direction: column; justify-content: space-between; }
.nav { display: flex; flex-direction: column; }
.nav a { padding: 13px 0; font-size: 16px; line-height: 1.4; color: var(--muted); text-decoration: none; transition: color 0.2s ease; }
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); font-weight: 600; }
.nav a[aria-current="page"]::after { content: " •"; }
.side-foot { display: grid; gap: 22px; }
.socials { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.socials a { text-decoration: none; color: var(--muted); font-size: 15px; }
.socials a:hover { color: var(--text); }
.socials b { color: var(--text); font-weight: 400; margin-right: 6px; }
.side .theme-switch { width: max-content; }
.side .theme-switch button { padding: 4px 9px; font-size: 12px; }

/* Keep the status bar centred in the content column, not the whole window */
.status { left: calc(var(--side) + 12px); }

/* Page header: same font, size and position as the other pages (see .page-head in assets/site.css) */
.page-head { padding: 48px 52px 0 28px; }
.page-title {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(44px, 6vw, 88px); line-height: 1; letter-spacing: -0.03em;
  margin: 0 0 18px;
}
.page-head .lede { color: var(--muted); max-width: 52ch; margin: 0; font-size: 16px; line-height: 1.75; letter-spacing: 0.005em; }
/* Line the category titles up with the page title */
@media (min-width: 901px) { .cats { padding-left: 28px; scroll-padding-left: 28px; } }

@media (max-width: 900px) {
  .site { grid-template-columns: 1fr; }
  .side {
    position: sticky; top: 0; z-index: 30;
    height: calc(52px + env(safe-area-inset-top));
    display: flex; justify-content: space-between; align-items: center;
    padding: env(safe-area-inset-top) 20px 0;
    background: var(--bg);
  }
  .brand { display: block; font-family: var(--serif); font-size: 21px; letter-spacing: -0.02em; line-height: 1.2; text-decoration: none; }
  .menu-btn { display: block; border: 0; background: none; cursor: pointer; font-size: 15px; font-weight: 500; padding: 4px 0; }
  .side-panel {
    display: none; position: fixed; inset: 0; z-index: 29;
    top: calc(52px + env(safe-area-inset-top));
    height: auto; padding: 24px 20px 40px; background: var(--bg);
  }
  .side.open .side-panel { display: flex; }
  .nav a { font-family: var(--serif); font-size: 40px; letter-spacing: -0.02em; padding: 4px 0; }
  .page-head { padding: 20px 20px 0; }
  /* Category titles stick just below the site bar */
  .head { top: calc(52px + env(safe-area-inset-top)); padding-top: 0; }
  .info-btn { top: 26px; }
  .status { left: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .item { animation: none; opacity: 1; }
  .cat, .shot img { transition: none; }
}
