/* =========================================================
   Livan Felix — site styles
   Static rebuild (no WordPress).
   ========================================================= */

/* ---------- Fonts ----------
   Drop the original .woff2 / .ttf files into /assets/fonts/
   to match the original site exactly. The @font-face rules
   below already point at the expected filenames; until those
   files are present, the named fallbacks take over. */
@font-face {
  font-family: "Vollkorn";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("../fonts/Vollkorn-VariableFont_wght.woff2") format("woff2");
}
@font-face {
  font-family: "Vollkorn";
  font-style: italic;
  font-weight: 400 900;
  font-display: swap;
  src: url("../fonts/Vollkorn-Italic-VariableFont_wght.woff2") format("woff2");
}
@font-face {
  font-family: "Fira Code";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../fonts/FiraCode-VariableFont_wght.woff2") format("woff2");
}
@font-face {
  font-family: "BrownBagLunch";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/BrownBagLunch.ttf") format("truetype");
}
/* ---------- Tokens ---------- */
:root {
  --color-base: #ffffff;
  --color-contrast: #111111;
  --color-muted: #686868;
  --color-accent-cream: #fbfaf3;
  --color-accent-violet: #503aa8;

  --shadow-natural: 6px 6px 9px rgba(0, 0, 0, 0.2);

  --space-20: 1rem;
  --space-30: 1.5rem;
  --space-40: 1.75rem;
  --space-50: 2.5rem;
  --space-60: 3rem;

  --max-width: 1280px;

  --font-serif: "Vollkorn", Georgia, "Times New Roman", serif;
  --font-mono: "Fira Code", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --font-display: "BrownBagLunch", "Vollkorn", Georgia, serif;
}

/* ---------- Reset-ish ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
/* Keep the active/mouse-focus ring suppressed (avoids the iOS tap
   outline), but restore a clearly-visible keyboard focus ring. */
a:focus { outline: 0; }
a:focus-visible { outline: 2px solid var(--color-accent-violet); outline-offset: 2px; }

/* ---------- Body / background ---------- */
body {
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.55;
  color: var(--color-contrast);
  background-color: var(--color-accent-cream);
  background-image: url("../images/rough_diagonal.webp");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* ---------- Site frame ----------
   Full-height flex column on every page: header on top, footer
   anchored to the bottom of the viewport via .site-main flex: 1,
   and whatever main content sits in between. Pages that need their
   main content vertically centered (art.html) layer additional
   flex centering on top of .site-main further down. */
.site {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-50);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ---------- Header / wordmark ---------- */
.site-header {
  padding-top: 18px;
  padding-bottom: 18px;
  text-align: center;
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.22rem, calc(2.22rem + ((1vw - 0.2rem) * 1.6)), 3.22rem);
  line-height: 1.1;
  margin: 0;
  padding: 0 0 10px;
}
.wordmark a { text-decoration: none; }

/* ---------- Main / footer ---------- */
/* flex: 1 makes <main> grow to fill the leftover space in the .site
   flex column, pushing the footer to the bottom of every viewport. */
.site-main { padding-top: var(--space-20); padding-bottom: 0; flex: 1; }
.site-footer {
  padding: var(--space-50) 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-muted);
}

/* ---------- Polaroid card grid (Home) ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-40);
  align-items: end;
  justify-items: center;
  padding: var(--space-20) 0;
}

/* ---------- Home polaroid grid ----------
   Single container holds all 6 cards. CSS Grid with explicit
   3-col (≥1001px) → 2-col (≤1000px) keeps the layout exact and
   never lets a single card orphan to its own row. */
.home-grid .card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  column-gap: 60px;
  row-gap: 50px;
  padding: 0;
  justify-items: stretch;
  align-items: end;
  max-width: 880px;
  margin: 0 auto;
}
.home-grid .card { width: 100%; max-width: none; }

/* 50px gap between wordmark and first row. */
body:has(.home-grid) .site-header { padding-bottom: 0; }
body:has(.home-grid) .wordmark { padding-bottom: 0; }
.home-grid { padding-top: 50px; padding-bottom: 0; margin-top: 0; }

.card {
  display: block;
  width: 100%;
  transition: transform 220ms ease;
  position: relative;
}
.card img {
  width: 100%;
  height: auto;
  filter: drop-shadow(var(--shadow-natural));
}
.card:hover, .card:focus { transform: scale(1.06); }

/* Caption layered over the polaroid's bottom white border. The hand-lettered
   captions on the original burned-in polaroids sit roughly centered in the
   bottom border (~10% of the image height from the bottom). */
.card-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 7%;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.72rem, 2.65vw, 2.38rem);
  color: #111;
  pointer-events: none;
  line-height: 1;
  letter-spacing: 0.01em;
}

/* Split caption: a main word group on the left + a smaller two-line
   stack on the right. Used for longer polaroid titles ("Dreaming w/
   Symara Stone", "Ollie & the Scary Story"). The stack runs at
   0.525em with line-height 0.85 — intentionally a touch shorter than
   the main word group so the two lines sit visually tight. */
.card-caption-split {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.2em;
}
.card-caption-stack {
  display: inline-flex;
  flex-direction: column;
  text-align: center;
  font-size: 0.525em;
  line-height: 0.85;
}

/* ≤1000px: lock home grid to 2 columns × 3 rows.
   Cards always size as a fraction of the row — never 1 column. */
@media (max-width: 1000px) {
  .home-grid .card-grid { grid-template-columns: repeat(2, 1fr); }
  .site { padding: 0 var(--space-30); }
}

/* ---------- Art page ----------
   art-grid--two stacks its cards in a single centered column
   (max-width 283px), vertically centered between header and footer
   by the flex layout below. */
body:has(.art-grid) .site-header { padding-bottom: 0; }
body:has(.art-grid) .wordmark { padding-bottom: 0; }

/* Art-specific: vertically center the polaroid grid inside <main>.
   The full-height flex column on .site (above) already anchors the
   footer; this layer adds inner-axis centering for the photos. */
.art-grid {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.art-grid .card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  column-gap: 60px;
  row-gap: 50px;
  padding: 0;
  justify-items: stretch;
  align-items: end;
  max-width: 1180px;
  margin: 0 auto;
}
.art-grid .card { width: 100%; max-width: none; margin: auto; }
.art-grid--two .card-grid { grid-template-columns: repeat(2, 1fr); max-width: 566px; }

@media (max-width: 1000px) {
  .art-grid .card-grid { grid-template-columns: repeat(2, 1fr); max-width: 880px; }
}

/* ---------- Back arrow (project pages) ---------- */
.back-link-wrap {
  display: flex;
  justify-content: center;
  margin-top: 28px;
  width: 100%;
}
.back-link {
  display: inline-block;
  position: relative;
  transition: transform 180ms ease;
}
/* Tape sits behind the arrow on film pages; arrow centers on top of
   it via absolute positioning. Tape width matches home.html's tape. */
.back-link-tape {
  display: block;
  width: 100px;
  height: auto;
  max-width: 100%;
}
.back-link-arrow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50px;
  height: auto;
  display: block;
}
.back-link:hover, .back-link:focus { transform: translateX(-4px) scale(1.05); }

/* ---------- Films page: collapsible panels ----------
   Panel titles sit 100px from the actual viewport edge (not the
   centered .site max-width), so .films breaks out of .site's
   max-width and padding by overriding both via body:has(). */
body:has(.films) .site { max-width: none; padding: 0; }
body:has(.films) .site-header { padding-bottom: 0; }
body:has(.films) .wordmark { padding-bottom: 0; }

.films {
  max-width: none;
  margin: 0;
  padding: 0 100px;
}
.panel { border: 0; padding: 0; margin: 0; }
.panel + .panel { margin-top: 8px; }

.panel-summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  font-family: var(--font-mono);
  font-size: 1.26rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  user-select: none;
  color: var(--color-contrast);
  transition: color 150ms ease;
}
.panel-summary::-webkit-details-marker { display: none; }
.panel-summary:hover { color: var(--color-accent-violet); }
.panel-summary:focus-visible {
  outline: 2px solid var(--color-accent-violet);
  outline-offset: 4px;
  border-radius: 4px;
}

/* Caret: small triangle that rotates between closed (▶) and open (▼). */
.panel-chevron {
  width: 0;
  height: 0;
  margin: 0;
  border-left: 6px solid currentColor;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 0;
  transition: transform 180ms ease;
  flex-shrink: 0;
  position: relative;
  top: 0;
  background: none;
}
.panel[open] > .panel-summary .panel-chevron {
  transform: rotate(90deg);
}

.panel-body {
  padding: 4px 0 18px;
}

/* Films grid: behaves like home grid — 4 columns max, 2 columns min,
   never collapses to a single column. Cards size as a fraction of the
   row; images preserve aspect ratio inside their card. */
.films-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  column-gap: 60px;
  row-gap: 50px;
  padding: 6px 0;
  justify-items: stretch;
  align-items: end;
  max-width: 1192px;
  margin: 0 auto;
}
.films-grid .card {
  width: 100%;
  max-width: none;
}
.films-grid .card img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

/* Panels with 3 polaroids show 3 across when there's room. */
.films-grid--three { grid-template-columns: repeat(3, 1fr); max-width: 880px; }
/* Panels with 2 polaroids show 2 across. */
.films-grid--two { grid-template-columns: repeat(2, 1fr); max-width: 566px; }

@media (max-width: 1100px) {
  .films { padding-left: 60px; padding-right: 60px; }
}
@media (max-width: 1000px) {
  /* Always two columns on smaller screens — never one.
     minmax(0, 1fr) keeps the polaroid's intrinsic pixel width from
     forcing columns wider than the container can hold. */
  .films-grid,
  .films-grid--two,
  .films-grid--three,
  .films-grid--four { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 566px; }
}
@media (max-width: 720px) {
  .films { padding-left: 32px; padding-right: 32px; }
  .films-grid { column-gap: 40px; row-gap: 40px; }
}
@media (max-width: 480px) {
  .films { padding-left: 20px; padding-right: 20px; }
  .films-grid { column-gap: 24px; row-gap: 28px; }
}

/* ---------- Two-column block (About) ---------- */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-60) var(--space-50);
  align-items: center;
  padding: var(--space-30) 0 0;
  max-width: 1100px;
  margin: 0 auto;
}
.two-col .col-media { display: flex; justify-content: center; }
.two-col .col-media figure { margin: 0; max-width: 514px; }
.two-col .col-media img {
  width: 100%;
  height: auto;
  filter: drop-shadow(var(--shadow-natural));
}
.two-col .col-media figcaption {
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--color-muted);
  text-align: center;
}
.two-col .col-body {
  max-width: 450px;
}
.two-col h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(1.75rem, 2.5vw, 2.4rem);
  margin: 0 0 var(--space-20);
}
.two-col p {
  font-size: 1.125rem;
  line-height: 1.6;
  margin: 0 0 1em;
  text-wrap: pretty;
  text-align: justify;
}

@media (max-width: 781px) {
  .two-col { grid-template-columns: 1fr; gap: var(--space-30); }
}

/* ---------- Project page (Cicada / Developing) ---------- */
.project {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-50);
  align-items: center;
  padding: var(--space-50) 0;
  max-width: 1300px;
  margin: 0 auto;
}
.project .project-media {
  display: flex;
  justify-content: center;
}
.project .project-media img {
  width: 100%;
  max-width: 500px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(var(--shadow-natural));
}
.project .project-body {
  max-width: 450px;
}
.project .project-body h1,
.project .project-body h2 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(2rem, 3.5vw, 2.75rem);
  margin: 0 0 0.5rem;
}
.project .project-body .byline {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 1.05rem;
  color: var(--color-muted);
  margin: 0 0 var(--space-30);
}
.project .project-body p {
  font-size: 1.125rem;
  line-height: 1.6;
  margin: 0;
  text-wrap: pretty;
  text-align: justify;
}
/* Project pages without a .byline (Developing, 404) center their
   heading and paragraph instead of using justified body copy. */
.project .project-body:not(:has(.byline)),
.project .project-body:not(:has(.byline)) p {
  text-align: center;
}

@media (max-width: 781px) {
  .project { grid-template-columns: 1fr; gap: var(--space-30); padding: var(--space-30) 0; }
  .project .project-media img { width: 100%; max-width: 500px; height: auto; }
  .project .project-body { text-align: center; }
}

/* ---------- Utilities ---------- */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: #eee;
  color: #444;
  padding: 14px 22px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  z-index: 100000;
}
.skip-link:focus { left: 5px; top: 5px; }
