/* ---------- Fonts ---------- */
@font-face {
  font-family: "Inter";
  src: url("../fonts/Inter.var.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/JetBrainsMono.var.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- Design tokens (all tweakable via the design panel) ---------- */
:root {
  /* Colors */
  --bg: #fff;
  --text: rgba(0, 0, 0, 0.85);
  --text-soft: rgba(0, 0, 0, 0.75);
  --text-muted: rgba(0, 0, 0, 0.35);
  --text-faint: rgba(0, 0, 0, 0.22);
  --rule: rgba(0, 0, 0, 0.08);
  --accent: #ff9300;          /* Wendi's orange — tweakable */

  /* Fonts */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Layout (Wendi's tweak values, 2026-06) */
  --sidebar-w: 264px;
  --sidebar-gap: 52px;
  --page-pad-x: 68px;
  --page-pad-y: 36px;
  --main-max: 1060px;

  /* Body */
  --body-size: 16px;
  --body-line: 1.45;

  /* Sidebar typography */
  --sidebar-brand-size: 1.95rem;
  --sidebar-brand-weight: 300;
  --sidebar-nav-size: 0.8rem;
  --sidebar-nav-weight: 375;
  --sidebar-year-size: 0.7rem;
  --sidebar-line: 1.2;
  --sidebar-item-gap: 2px;
  --sidebar-section-gap: 1.9em;

  /* Sort pills */
  --pill-size: 0.7rem;
  --pill-gap: 2rem;
  --pills-top-padding: 44px;     /* vertical offset to align with brand baseline */

  /* Homepage feed */
  --feed-gap: 4.25rem;
  --feed-gap-secondary: 2.5rem;
  --feed-title-size: 0.85rem;
  --feed-title-weight: 400;
  --feed-year-size: 0.8rem;
  --feed-caption-gap: 0.3rem;

  /* Secondary (small) projects in tag view */
  --feed-secondary-cols: 3;
  --feed-secondary-gap: 3rem;
  --feed-secondary-title-size: 0.7rem;

  /* Project detail */
  --project-max: 1200px;
  --project-title-size: 1.8rem;
  --project-title-weight: 300;
  --project-meta-size: 0.7rem;
  --project-meta-gap: 2.5rem;
  --project-body-size: 0.8rem;
  --project-body-line: 1.45;
  --project-body-max: 60ch;
  --project-paragraph-gap: 1.7em;
  --project-body-bottom: 2.75rem;
  --project-media-gap: 0.5rem;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { font-size: var(--body-size); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 400;
  line-height: var(--body-line);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
a:active { opacity: 0.6; }
img, video, iframe {
  display: block;
  max-width: 100%;
  border: 0;
}
h1, h2, h3, p { margin: 0; padding: 0; font-weight: 400; }

/* ---------- App layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: var(--sidebar-gap);
  padding: var(--page-pad-y) var(--page-pad-x);
  min-height: 100vh;
  max-width: 1600px;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: var(--page-pad-y);
  align-self: start;
  max-height: calc(100vh - var(--page-pad-y) * 2);
  overflow-y: auto;
  overflow-x: hidden;
  font-size: var(--sidebar-nav-size);
  font-weight: var(--sidebar-nav-weight);
  line-height: var(--sidebar-line);
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}
.sidebar { scrollbar-color: var(--accent) transparent; }
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 2px; }

.sidebar a { color: var(--text); display: inline-block; }
.sidebar a:hover { color: #000; }
.sidebar a.active { color: var(--accent); font-weight: 600; }
.menu-featured li a.active::before { color: var(--accent); }

.sidebar-brand {
  font-size: var(--sidebar-brand-size);
  font-weight: var(--sidebar-brand-weight);
  margin-bottom: 1.8rem;
  letter-spacing: -0.01em;
}
.sidebar-brand a { display: inline-flex; align-items: baseline; gap: 0.4em; }

.menu ol, .menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.menu-year {
  font-family: var(--font-sans);
  color: var(--text-faint);
  font-size: var(--sidebar-year-size);
  margin: var(--sidebar-section-gap) 0 0.25em;
}

.menu ul li { margin: 0 0 var(--sidebar-item-gap); }

.menu-about { margin-top: var(--sidebar-section-gap); }
.menu-about a { font-weight: 500; }

.menu-ig {
  margin-top: 0.6em;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
}
.menu-ig a { color: var(--text-muted); }

/* ---------- Main content ---------- */
.main {
  min-width: 0;
  max-width: var(--main-max);
}

/* ---------- Sort pills — sticky on every page, aligned with brand baseline ---------- */
.feed-controls {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: var(--pill-gap);
  align-items: baseline;
  margin: calc(var(--page-pad-y) * -1) calc(var(--page-pad-x) * -1) 2.5rem;
  padding: var(--pills-top-padding) var(--page-pad-x) 1.2rem;
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: var(--pill-size);
  color: var(--text-muted);
}
.feed-controls .label { color: var(--text-faint); }
.feed-controls a {
  color: var(--text-muted);
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: border-color 120ms ease, color 120ms ease;
}
.feed-controls a:hover { color: var(--text); }
.feed-controls a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Homepage: year-grouped small-thumbnail grid (default + all view) ---------- */
.layout-grid { display: block; }
.layout-grid[hidden] { display: none; }
.year-section { margin-bottom: 3.5rem; }
.year-heading {
  font-family: var(--font-mono);
  font-size: var(--sidebar-year-size);
  font-weight: 400;
  color: var(--text-faint);
  margin-bottom: 1rem;
  letter-spacing: 0.04em;
}
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(var(--feed-secondary-cols), minmax(0, 1fr));
  gap: var(--feed-secondary-gap);
}
.thumb-grid .feed-item { width: 100%; }
.thumb-grid .feed-image { aspect-ratio: 4 / 3; overflow: hidden; }
.thumb-grid .feed-image img { width: 100%; height: 100%; object-fit: cover; }
.thumb-grid .feed-title { font-size: var(--feed-secondary-title-size); }
.thumb-grid .feed-year { display: none; }
/* Hide archived items in default view; show under "all" */
.layout-grid .feed-item[data-archived="true"] { display: none; }
body[data-show-archived="1"] .layout-grid .feed-item[data-archived="true"] { display: block; }

/* ---------- Tag mode: re-layout year-grouped grid into single column of big cards ---------- */
/* Same DOM, CSS-only transform. No duplicate rendering. */
body[data-tag-mode="product"] .layout-grid,
body[data-tag-mode="ux"] .layout-grid,
body[data-tag-mode="graphic"] .layout-grid {
  display: flex;
  flex-direction: column;
  gap: var(--feed-gap);
}
body[data-tag-mode="product"] .year-section,
body[data-tag-mode="ux"] .year-section,
body[data-tag-mode="graphic"] .year-section { display: contents; }
body[data-tag-mode="product"] .thumb-grid,
body[data-tag-mode="ux"] .thumb-grid,
body[data-tag-mode="graphic"] .thumb-grid { display: contents; }
body[data-tag-mode="product"] .year-heading,
body[data-tag-mode="ux"] .year-heading,
body[data-tag-mode="graphic"] .year-heading { display: none; }
/* Filter to only featured-in items */
body[data-tag-mode="product"] .feed-item:not([data-featured~="product"]),
body[data-tag-mode="ux"] .feed-item:not([data-featured~="ux"]),
body[data-tag-mode="graphic"] .feed-item:not([data-featured~="graphic"]) { display: none; }
/* Big-card styling: full-width image, larger title */
body[data-tag-mode="product"] .feed-image,
body[data-tag-mode="ux"] .feed-image,
body[data-tag-mode="graphic"] .feed-image { aspect-ratio: auto; }
body[data-tag-mode="product"] .feed-image img,
body[data-tag-mode="ux"] .feed-image img,
body[data-tag-mode="graphic"] .feed-image img { height: auto; object-fit: contain; }
body[data-tag-mode="product"] .feed-title,
body[data-tag-mode="ux"] .feed-title,
body[data-tag-mode="graphic"] .feed-title { font-size: var(--feed-title-size); }
body[data-tag-mode="product"] .feed-year,
body[data-tag-mode="ux"] .feed-year,
body[data-tag-mode="graphic"] .feed-year { display: inline; }

.feed-item { display: block; width: 100%; }

.feed-image {
  width: 100%;
  background: rgba(0, 0, 0, 0.03);
  overflow: hidden;
}
.feed-image img {
  width: 100%;
  height: auto;
  transition: opacity 200ms ease;
}
.feed-item:hover .feed-image img { opacity: 0.88; }

.feed-caption {
  margin-top: var(--feed-caption-gap);
  display: flex;
  align-items: baseline;
  gap: 1rem;
}
.feed-title {
  font-size: var(--feed-title-size);
  font-weight: var(--feed-title-weight);
  color: var(--text);
}
.feed-year {
  font-family: var(--font-mono);
  font-size: var(--feed-year-size);
  color: var(--text-faint);
}

/* ---------- Secondary section (smaller grid when a tag is active) ---------- */
.feed-secondary {
  display: grid;
  grid-template-columns: repeat(var(--feed-secondary-cols), minmax(0, 1fr));
  gap: var(--feed-secondary-gap);
  margin-top: var(--feed-gap);
  padding-top: var(--feed-gap-secondary);
  border-top: 1px solid var(--rule);
}
.feed-secondary .feed-item { width: 100%; }
.feed-secondary .feed-image { aspect-ratio: 4 / 3; }
.feed-secondary .feed-image img { width: 100%; height: 100%; object-fit: cover; }
.feed-secondary .feed-title { font-size: var(--feed-secondary-title-size); }
.feed-secondary .feed-year { font-size: 0.78rem; }
.feed-secondary-label {
  grid-column: 1 / -1;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-faint);
  margin-bottom: -0.5rem;
}
.feed-secondary[hidden] { display: none; }

/* ---------- Project page ---------- */
.project { max-width: var(--project-max); }

.project-title {
  font-size: var(--project-title-size);
  font-weight: var(--project-title-weight);
  margin-bottom: 0.3rem;
  letter-spacing: -0.01em;
}

.project-meta {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: var(--project-meta-size);
  margin-bottom: var(--project-meta-gap);
}

.project-body {
  max-width: var(--project-body-max);
  margin-bottom: var(--project-body-bottom);
  font-size: var(--project-body-size);
  line-height: var(--project-body-line);
  color: var(--text-soft);
}
.project-body p { margin: 0 0 var(--project-paragraph-gap); }
.project-body p:last-child { margin-bottom: 0; }

.about .project-body { font-size: 1.05rem; }
.about-portrait {
  max-width: 320px;
  margin-bottom: 2.5rem;
}
.about-portrait img { width: 100%; height: auto; display: block; }

.project-media {
  display: flex;
  flex-direction: column;
  gap: var(--project-media-gap);
}
.project-media img,
.project-media video { width: 100%; }

.video-wrap {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: #000;
}
.video-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.video-link {
  display: inline-block;
  margin-top: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}
.video-link:hover { color: var(--accent); }

/* External-link image wrapper (e.g. Warping Time → p5.js sketch) */
.external-link-img {
  position: relative;
  display: block;
}
.external-link-img::after {
  content: attr(data-label);
  position: absolute;
  inset: auto 0 0 0;
  padding: 14px 16px;
  background: linear-gradient(to top, rgba(0,0,0,0.65), rgba(0,0,0,0));
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease;
}
.external-link-img:hover::after { opacity: 1; }

/* Carousel (e.g. Gibbo's) */
.carousel {
  position: relative;
  background: rgba(0, 0, 0, 0.03);
  overflow: hidden;
  user-select: none;
}
.carousel-track {
  display: flex;
  transition: transform 320ms ease;
}
.carousel-slide {
  flex: 0 0 100%;
  width: 100%;
}
.carousel-slide img {
  width: 100%;
  height: auto;
  display: block;
}
.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #000;
  border: 1px solid var(--rule);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 180ms ease;
}
.carousel:hover .carousel-arrow { opacity: 1; }
.carousel-arrow.prev { left: 12px; }
.carousel-arrow.next { right: 12px; }
.carousel-arrow:disabled { opacity: 0.25; cursor: default; }
.carousel-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 10px 0;
  background: rgba(255, 255, 255, 0.85);
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}
.carousel-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.2);
  border: 0;
  padding: 0;
  cursor: pointer;
}
.carousel-dot.active { background: var(--accent); }

/* Archived item state — hidden by default, restored when ?tag=all */
.feed-item[data-archived="true"],
.sidebar [data-archived="true"] { display: none; }
body[data-show-archived="1"] .feed-item[data-archived="true"],
body[data-show-archived="1"] .sidebar [data-archived="true"] { display: block; }
/* Archived items render in the normal text color when they're visible
   (i.e. under the "all" view or on an archived project's detail page).
   No dimming — everything reads as a peer of the rest. */

/* Sidebar tag-mode: when filtering by product/ux/graphic, hide year headers and
   non-matching projects. Show flat list of only matching projects. */
body[data-tag-mode="product"] .menu-year,
body[data-tag-mode="product"] .menu-featured,
body[data-tag-mode="ux"] .menu-year,
body[data-tag-mode="ux"] .menu-featured,
body[data-tag-mode="graphic"] .menu-year,
body[data-tag-mode="graphic"] .menu-featured { display: none; }
/* In tag mode, sidebar mirrors the FEATURED-IN list (matches the big cards on the feed exactly) */
body[data-tag-mode="product"] .sidebar li[data-slug]:not([data-featured~="product"]),
body[data-tag-mode="ux"] .sidebar li[data-slug]:not([data-featured~="ux"]),
body[data-tag-mode="graphic"] .sidebar li[data-slug]:not([data-featured~="graphic"]) { display: none; }
/* In tag mode, flatten the sidebar's year-grouped <ul>s into a single
   flex column so all visible <li>s sit in one continuous run AND can be
   reordered with the `order` property regardless of which year <ul>
   they originally lived in. */
body[data-tag-mode="product"] .sidebar .menu,
body[data-tag-mode="ux"] .sidebar .menu,
body[data-tag-mode="graphic"] .sidebar .menu { display: flex; flex-direction: column; }
body[data-tag-mode="product"] .sidebar .menu ul,
body[data-tag-mode="ux"] .sidebar .menu ul,
body[data-tag-mode="graphic"] .sidebar .menu ul { display: contents; }
/* About + IG always pinned to the bottom of the sidebar in tag mode */
body[data-tag-mode="product"] .menu-about,
body[data-tag-mode="ux"] .menu-about,
body[data-tag-mode="graphic"] .menu-about { order: 998; }
body[data-tag-mode="product"] .menu-ig,
body[data-tag-mode="ux"] .menu-ig,
body[data-tag-mode="graphic"] .menu-ig { order: 999; }

/* Per-project priority in specific tag views (lower = earlier).
   Add more rules here as Wendi wants to promote/demote particular projects. */
body[data-tag-mode="ux"] .feed-item[data-slug="Both-Sides-Now"],
body[data-tag-mode="ux"] .sidebar li[data-slug="Both-Sides-Now"] { order: -10; }

/* Award callout */
.award {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 1.6rem;
  padding: 5px 10px;
  background: rgba(240, 107, 0, 0.08);
  border: 1px solid rgba(240, 107, 0, 0.25);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
  transition: background 150ms ease;
}
.award:hover { background: rgba(240, 107, 0, 0.16); }
.award-icon { font-size: 0.9rem; line-height: 1; }

/* ---------- Mobile drawer ---------- */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 20;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 900px) {
  :root {
    --page-pad-x: 22px;
    --page-pad-y: 22px;
    --pills-top-padding: 16px;
    --sidebar-brand-size: 1.2rem;
  }
  .app { display: block; padding: 0 var(--page-pad-x) 64px; }
  .main { max-width: 100%; }
  .feed { gap: 3rem; }
  .thumb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* No hamburger, no slide-out menu, no nav list — minimal on mobile.
     The brand and the sticky pills are the only navigation. */
  .mobile-menu-toggle { display: none; }
  .sidebar {
    position: static;
    width: 100%;
    max-height: none;
    height: auto;
    padding: 16px 0 0;
    overflow: visible;
    background: transparent;
    box-shadow: none;
    transform: none;
  }
  .sidebar-brand { margin-bottom: 0; }
  .sidebar .menu { display: none; }
  /* Pills sit just below the brand with tight padding */
  .feed-controls {
    margin: 0 calc(var(--page-pad-x) * -1) 1.5rem;
    padding: var(--pills-top-padding) var(--page-pad-x) 1rem;
  }
  .project-title { font-size: 1.5rem; }
}

/* ---------- Design tweak panel (localhost / ?tweak=1 only) ---------- */
.tweak-toggle {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 30;
  background: #111;
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.tweak-panel {
  position: fixed;
  bottom: 60px;
  right: 16px;
  z-index: 29;
  width: 340px;
  max-height: 78vh;
  background: #1a1a1a;
  color: #fff;
  border-radius: 8px;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  display: none;
}
.tweak-panel.open { display: block; }
.tweak-panel h3 {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  margin: 14px 0 6px;
  font-weight: 600;
}
.tweak-panel h3:first-child { margin-top: 0; }
.tweak-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.tweak-row label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tweak-row input[type="range"] {
  grid-column: 1 / 3;
  width: 100%;
  accent-color: #6cf;
  margin: 2px 0 0;
}
.tweak-row .v {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.55);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.tweak-buttons {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.tweak-buttons button {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 0;
  border-radius: 4px;
  padding: 7px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  cursor: pointer;
}
.tweak-buttons button:hover { background: rgba(255, 255, 255, 0.16); }
