/* =================================================================
   Joe Luciani — Design & Fabrication
   Design tokens
   Palette : cool drafting paper, ink, graphite, hairline, redline
   Type    : Space Grotesk (display) + IBM Plex Mono (titleblock data)
   Signature: the drawing "titleblock" that heads each project
   ================================================================= */
:root {
  --paper:    #faf9f6;
  --paper-2:  #f1f0ea;
  --ink:      #1a1a18;
  --graphite: #96948a;
  --hairline: #e5e3da;
  --redline:  #c62a20;

  --wpx: 268px;                 /* index sidebar width */
  --pad: clamp(1.25rem, 3.5vw, 3rem);

  --f-display: "Space Grotesk", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

/* Visually hidden but present for screen readers / search engines */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html {
  scroll-behavior: smooth;
  background: var(--paper) !important;   /* covers dark-mode overscroll/bounce areas */
  color-scheme: light only;              /* stronger than "light" — forbids forced dark rendering */
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Belt-and-braces: some mobile browsers/webviews auto-darken pages
   that don't explicitly declare a dark variant. Redeclaring the exact
   same light tokens here signals "this page has already been
   designed for dark mode" so nothing gets auto-inverted. */
@media (prefers-color-scheme: dark) {
  :root {
    --paper:    #faf9f6;
    --paper-2:  #f1f0ea;
    --ink:      #1a1a18;
    --graphite: #96948a;
    --hairline: #e5e3da;
    --redline:  #c62a20;
  }
  html, body { background: var(--paper) !important; color: var(--ink) !important; }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper) !important;
  color: var(--ink);
  font-family: var(--f-display);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-left: var(--wpx);      /* make room for the fixed index */
}

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

/* ---------- Mobile top bar (hidden on desktop) ---------- */
.topbar { display: none; }

/* ---------- Left index ---------- */
.index {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--wpx);
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  border-right: 1px solid var(--hairline);
  background: var(--paper);
  overflow-y: auto;
}

.index__mark {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.05;
  display: block;
}
.index__role {
  font-family: var(--f-mono);
  font-size: 0.66rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--graphite);
  margin: 0.6rem 0 0;
}

.index__list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
}
.index__list li { margin: 0; }

/* ---------- Year groups: native <details>, no JS required ---------- */
.index__year details { border-top: 1px solid var(--hairline); }
.index__year:last-child details { border-bottom: 1px solid var(--hairline); }

.index__year summary {
  display: grid;
  grid-template-columns: 2.9rem 1fr auto;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.5rem 0;
  cursor: pointer;
  list-style: none;
  position: relative;
}
.index__year summary::-webkit-details-marker { display: none; }
.index__year summary::marker { display: none; }

.index__year summary::after {   /* +/- disclosure indicator */
  content: "+";
  font-family: var(--f-mono);
  font-size: 0.85rem;
  color: var(--graphite);
  transition: color 0.18s ease;
}
.index__year details[open] summary::after { content: "–"; }

.index__yearcount {
  font-family: var(--f-mono);
  font-size: 0.7rem;
  color: var(--graphite);
}

/* redline: the marker used on hover + the current year/project */
.index__year summary::before {
  content: "";
  position: absolute;
  left: -0.75rem; top: 50%;
  width: 3px; height: 0;
  background: var(--redline);
  transform: translateY(-50%);
  transition: height 0.18s ease;
}
.index__year summary:hover::before,
.index__year summary:focus-visible::before,
.index__year summary.has-current::before { height: 100%; }
.index__year summary:hover .index__num,
.index__year summary:focus-visible .index__num,
.index__year summary.has-current .index__num { color: var(--redline); }
.index__year summary:hover::after,
.index__year summary.has-current::after { color: var(--redline); }

.index__projects {
  list-style: none;
  margin: 0;
  padding: 0 0 0.6rem 2.9rem;
}
.index__projects li { margin: 0; }
.index__projects a {
  display: block;
  padding: 0.3rem 0;
  font-size: 0.9rem;
  transition: color 0.18s ease, transform 0.18s ease;
}
.index__projects a:hover,
.index__projects a:focus-visible { color: var(--redline); transform: translateX(2px); }
.index__projects a.is-current { color: var(--redline); }

.index__num {
  font-family: var(--f-mono);
  font-size: 0.72rem;
  color: var(--graphite);
}
.index__name {
  font-size: 1.02rem;
  transition: color 0.18s ease, transform 0.18s ease;
}

.index__list a.is-current .index__name { color: var(--redline); }

.index__foot { display: flex; flex-direction: column; gap: 0.5rem; }
.index__info {
  font-size: 0.95rem;
  border-top: 1px solid var(--hairline);
  padding-top: 0.75rem;
}
.index__info:hover, .index__info:focus-visible { color: var(--redline); }
.index__meta {
  font-family: var(--f-mono);
  font-size: 0.62rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--graphite);
  margin: 0;
}

/* ---------- Sheet (main column) ---------- */
.sheet { padding: var(--pad); max-width: clamp(1180px, 78vw, 1760px); }

.project { padding: 1.5rem 0 clamp(3rem, 7vw, 6rem); }
.project:first-child { padding-top: 0.5rem; }

.project__body {
  display: flex;
  align-items: flex-start;
  gap: clamp(1.5rem, 4vw, 3rem);
}
.project__body .plates-wrap { flex: 1 1 0%; min-width: 0; }

/* ---------- Titleblock: the signature element ---------- */
.titleblock {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  flex-wrap: wrap;
  border-top: 1.5px solid var(--ink);
  border-bottom: 1px solid var(--hairline);
  padding: 0.75rem 0 0.85rem;
  margin-bottom: 1.5rem;
}
.titleblock__id { display: flex; align-items: baseline; gap: 0.9rem; }
.titleblock__num {
  font-family: var(--f-mono);
  font-size: 0.85rem;
  color: var(--redline);
  padding-top: 0.2rem;
}
.titleblock__title {
  font-size: clamp(1.7rem, 3.6vw, 2.7rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1;
}

.titleblock__data {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 0 1.6rem;
  margin: 0;
}
.titleblock__data div { display: flex; flex-direction: column; }
.titleblock__data dt {
  font-family: var(--f-mono);
  font-size: 0.58rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--graphite);
}
.titleblock__data dd {
  font-family: var(--f-mono);
  font-size: 0.8rem;
  margin: 0.15rem 0 0;
}

/* ---------- Catalog: every project, one uniform tile ----------
   The "system" made visible — same treatment, repeated, so the
   whole body of work reads at a glance before anyone scrolls. */
.catalog { padding: 0.5rem 0 clamp(2.5rem, 6vw, 4.5rem); }

.catalog__head {
  display: flex;
  justify-content: flex-end;
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 0.6rem;
  margin-bottom: 1.25rem;
}
.catalog__count {
  font-family: var(--f-mono);
  font-size: 0.62rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--graphite);
}

.catalog__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: clamp(1rem, 2.4vw, 1.75rem);
}

.catalog__item { display: block; }
.catalog__thumb {
  display: flex;
  aspect-ratio: 1 / 1;
  align-items: center;
  justify-content: center;
  background: var(--paper-2);
  border: 1px solid var(--hairline);
  overflow: hidden;
  position: relative;
  transition: border-color 0.18s ease;
}
.catalog__thumb::after {   /* same corner tick as a plate — same system */
  content: "";
  position: absolute;
  right: 8px; bottom: 8px;
  width: 10px; height: 10px;
  border-right: 1px solid var(--graphite);
  border-bottom: 1px solid var(--graphite);
  opacity: 0.5;
}
.catalog__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.catalog__meta { display: flex; flex-direction: column; gap: 0.2rem; margin-top: 0.6rem; }
.catalog__code {
  font-family: var(--f-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--graphite);
}
.catalog__title { font-size: 0.95rem; transition: color 0.18s ease; }

.catalog__item:hover .catalog__thumb,
.catalog__item:focus-visible .catalog__thumb { border-color: var(--redline); }
.catalog__item:hover .catalog__title,
.catalog__item:focus-visible .catalog__title { color: var(--redline); }

/* ---------- Plates: a horizontal run, like a contact sheet ----------
   Fixed row height; each image keeps its own natural width (no
   cropping). The row scrolls sideways — drag, swipe, or wheel. */
:root { --plate-h: clamp(380px, 78vh, 780px); }
/* Dynamic viewport height accounts for mobile browser chrome
   (address bar) collapsing as you scroll, so the row doesn't
   jump around while you're looking at it. */
@supports (height: 100dvh) {
  :root { --plate-h: clamp(380px, 78dvh, 780px); }
}

.plates-wrap { position: relative; }
.plates-wrap::after {   /* fade at the right edge = "there's more" */
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: clamp(2rem, 6vw, 4.5rem);
  background: linear-gradient(to right, transparent, var(--paper));
  pointer-events: none;
}

.plates {
  display: flex;
  align-items: flex-start;
  gap: clamp(0.4rem, 1vw, 0.75rem);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  padding-bottom: 0.9rem;             /* room for the scrollbar */
  cursor: grab;
  -webkit-overflow-scrolling: touch;

  scrollbar-width: thin;
  scrollbar-color: var(--graphite) transparent;
}
.plates.is-dragging { cursor: grabbing; scroll-snap-type: none; }
.plates::-webkit-scrollbar { height: 5px; }
.plates::-webkit-scrollbar-track { background: transparent; }
.plates::-webkit-scrollbar-thumb { background: var(--hairline); }
.plates:hover::-webkit-scrollbar-thumb { background: var(--graphite); }

.plate {
  flex: 0 0 auto;
  height: var(--plate-h);
  aspect-ratio: 4 / 3;                /* used only while it's a placeholder */
  margin: 0;
  background: var(--paper-2);
  border: 1px solid var(--hairline);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  scroll-snap-align: start;
}
/* Demo-only modifiers so placeholders show a real run's varied widths.
   Delete these classes once real photos (with their own ratios) are in. */
.plate--square  { aspect-ratio: 1 / 1; }
.plate--portrait{ aspect-ratio: 3 / 4; }
.plate--wide    { aspect-ratio: 16 / 9; }

/* Once you add a real <img>, it sets its own width — uncropped.
   The ratio above is a placeholder size, so drop it as soon as a plate
   holds a photo; otherwise every shot gets cropped to 4:3. */
.plate:has(img) { aspect-ratio: auto; width: auto; }
.plate img { height: 100%; width: auto; display: block; }

.plate--video iframe { width: 100%; height: 100%; border: 0; display: block; }

/* placeholder hint — disappears once you drop in a real <img> */
.plate__hint {
  font-family: var(--f-mono);
  font-size: 0.7rem;
  color: var(--graphite);
  letter-spacing: 0.04em;
  padding: 0 0.75rem;
  text-align: center;
}
.plate::after {   /* corner tick, like a drawing sheet crop mark */
  content: "";
  position: absolute;
  right: 8px; bottom: 8px;
  width: 10px; height: 10px;
  border-right: 1px solid var(--graphite);
  border-bottom: 1px solid var(--graphite);
  opacity: 0.5;
}

.project__note {
  /* Fully working baseline for no-JS visitors: a normal flowing
     column, height following its own content. app.js upgrades this
     (see .note-fit below) to match the photo's height instead, with
     the width computed from how much text there is. */
  flex: 0 0 clamp(220px, 24vw, 320px);
  max-width: clamp(220px, 24vw, 320px);
  margin: 0;
  color: #333;
  font-size: 0.98rem;
}
/* JS-enhanced sizing (class added by app.js once it can also set the
   matching width — see sizeNotes()). Fixed to the photo's height;
   app.js binary-searches for the narrowest width that still lets the
   text fit that height as a single block, so a short caption stays
   narrow and a long story widens instead of growing taller than the
   photo. */
.note-fit.project__note {
  height: var(--plate-h);
  flex: 0 0 auto;
  width: 240px;
  min-width: 220px;
  max-width: 640px;
  overflow: hidden;
}
.project__note em {   /* pending captions read differently from finished ones */
  font-style: italic;
  color: var(--graphite);
}
.project__note p { margin: 0 0 1em; }
.project__note p:last-child { margin-bottom: 0; }
.project__note a { border-bottom: 1px solid var(--hairline); }
.project__note a:hover { color: var(--redline); border-color: var(--redline); }

/* ---------- Info ---------- */
.info { padding: 1.5rem 0 3rem; }
.info__body { max-width: 52ch; }
.info__body p { margin: 0 0 1rem; }
.info__contact a { border-bottom: 1px solid var(--hairline); }
.info__contact a:hover { color: var(--redline); border-color: var(--redline); }

/* ---------- Colophon ---------- */
.colophon {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--hairline);
  padding: 1.25rem 0 2rem;
  font-family: var(--f-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--graphite);
}

/* ---------- Load-in motion (subtle, staggered index) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .index__list li { opacity: 0; transform: translateX(-6px); animation: slide-in 0.5s ease forwards; }
  .index__list li:nth-child(1) { animation-delay: 0.05s; }
  .index__list li:nth-child(2) { animation-delay: 0.11s; }
  .index__list li:nth-child(3) { animation-delay: 0.17s; }
  .index__list li:nth-child(4) { animation-delay: 0.23s; }
  .index__list li:nth-child(5) { animation-delay: 0.29s; }
  .index__list li:nth-child(6) { animation-delay: 0.35s; }
  @keyframes slide-in { to { opacity: 1; transform: none; } }
}

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  body { padding-left: 0; }

  .topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0; z-index: 20;
    padding: 0.9rem var(--pad);
    background: var(--paper);
    border-bottom: 1px solid var(--hairline);
  }
  .topbar__mark { font-weight: 600; font-size: 1.05rem; }
  .topbar__toggle {
    font-family: var(--f-mono);
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    background: none;
    border: 1px solid var(--ink);
    padding: 0.35rem 0.7rem;
    cursor: pointer;
    color: var(--ink);
  }

  .index {
    position: static;
    width: auto;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--hairline);
    gap: 1.5rem;
    display: none;
  }
  .index.is-open { display: flex; }
  .index__head { display: none; }

  .titleblock { align-items: flex-start; }
  .titleblock__data { grid-template-columns: repeat(2, auto); gap: 0.6rem 1.4rem; }
  .project__body { flex-direction: column; }
  .project__note,
  .note-fit.project__note {
    flex: none;
    min-width: 0;
    max-width: 46ch;
    width: auto;
    height: auto;
    overflow: visible;
  }
  :root { --plate-h: clamp(320px, 70vh, 680px); }   /* near full-height, like Indexhibit — spills off the right edge, inviting a swipe */
  .catalog__grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
}
@supports (height: 100dvh) {
  @media (max-width: 820px) {
    :root { --plate-h: clamp(320px, 70dvh, 680px); }
  }
}

/* keyboard focus visible everywhere */
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--redline);
  outline-offset: 3px;
}

/* =================================================================
   Additions — filter bar, scroll-reveal, lightbox
   All dependency-free; each degrades to the plain page without JS
   or on browsers that don't support the feature.
   ================================================================= */

/* ---------- Filter bar (catalog) ----------
   Same titleblock language: mono labels, hairline rules, redline
   for the active state. Revealed by app.js (starts [hidden] so it
   never shows if scripts fail — the full catalog is the fallback). */
.filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
}
.filterbar[hidden] { display: none; }
.filterbar__btn {
  font-family: var(--f-mono);
  font-size: 0.62rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--graphite);
  background: none;
  border: 1px solid var(--hairline);
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.filterbar__btn:hover { color: var(--ink); border-color: var(--graphite); }
.filterbar__btn.is-active {
  color: var(--redline);
  border-color: var(--redline);
}

/* Tiles filtered out are removed with the [hidden] attribute (so they
   leave the tab order and a11y tree too). Those remaining fade in as
   the grid reflows. */
.catalog__item { transition: opacity 0.35s ease; }
.catalog__item[hidden] { display: none; }
.catalog__grid.is-filtering .catalog__item { opacity: 0; }
.catalog__grid.is-filtering .catalog__item:not([hidden]) { opacity: 1; }

/* ---------- Scroll-triggered reveal (native, zero JS) ----------
   Uses CSS scroll-driven animations where supported. Double-guarded:
   only runs when the viewer allows motion AND the browser supports
   animation-timeline — otherwise everything is simply visible, no
   initial hidden state, so unsupported browsers never hide content. */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .catalog__item,
    .project .titleblock,
    .project .plates-wrap,
    .project .project__note {
      animation: reveal-rise linear both;
      animation-timeline: view();
      animation-range: entry 5% entry 40%;
    }
    @keyframes reveal-rise {
      from { opacity: 0; transform: translateY(22px); }
      to   { opacity: 1; transform: none; }
    }
  }
}

/* ---------- Lightbox (native <dialog>) ---------- */
.plate img { cursor: zoom-in; }

dialog.lightbox {
  border: none;
  padding: 0;
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
  margin: 0;
  background: transparent;
  overflow: hidden;
}
dialog.lightbox::backdrop {
  background: rgba(26, 26, 24, 0.92);   /* --ink, translucent */
}
/* Only lay out when open — a closed <dialog> must stay display:none so
   its fixed-position controls don't float over the page. */
dialog.lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox__img {
  max-width: 92vw;
  max-height: 86vh;
  width: auto;
  height: auto;
  object-fit: contain;
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: zoom-out;
}
.lightbox__nav,
.lightbox__close {
  position: fixed;
  font-family: var(--f-mono);
  color: var(--paper);
  background: rgba(26, 26, 24, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.22);
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.lightbox__nav:hover,
.lightbox__close:hover { color: var(--redline); border-color: var(--redline); }
.lightbox__nav {
  top: 50%;
  transform: translateY(-50%);
  width: 3rem; height: 3rem;
  font-size: 1.6rem;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.lightbox__prev { left: clamp(0.5rem, 2vw, 1.5rem); }
.lightbox__next { right: clamp(0.5rem, 2vw, 1.5rem); }
.lightbox__nav[hidden] { display: none; }
.lightbox__close {
  top: clamp(0.5rem, 2vw, 1.5rem);
  right: clamp(0.5rem, 2vw, 1.5rem);
  font-size: 0.62rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  padding: 0.5rem 0.75rem;
}

@media (max-width: 820px) {
  .lightbox__nav { width: 2.5rem; height: 2.5rem; font-size: 1.3rem; }
  .lightbox__img { max-width: 96vw; max-height: 80vh; }
}
