/* René Cifuentes — portfolio. Austere art-institution minimalism (Judd / Dia). */

:root {
  --paper: #ffffff;
  --ink: #111111;
  --muted: #8a8a8a;
  --line: rgba(0, 0, 0, 0.08);
  --nav-h: 60px;
  --gap: 20px;
  --edge: 40px;
  --sans: "Helvetica Neue", Helvetica, Arial, "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* -------------------------------------------------------------- Navigation */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--edge);
  z-index: 20;
}
/* Home: nav floats over the full-bleed carousel, stays legible via blend. */
.page-home .nav { color: #fff; mix-blend-mode: difference; }
/* Inner pages: solid, quiet bar. */
.page-inner .nav {
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
}
.wordmark {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.menu { display: flex; gap: 28px; }
.menu a {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: inherit;
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 160ms ease;
}
.menu a:hover, .menu a.active { opacity: 1; }

/* Hamburger — pure CSS. The checkbox (visually hidden but focusable) holds the
   open state; the label is the icon. Both hidden on desktop (see media query). */
.nav-check {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0;
}
.nav-burger {
  display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  width: 40px; height: 40px; margin-right: -8px; padding: 8px;
  color: inherit; cursor: pointer;
}
.nav-burger span {
  display: block; width: 20px; height: 2px; border-radius: 2px;
  background: currentColor;
  transition: transform 200ms ease, opacity 160ms ease;
}
.nav-check:checked ~ .nav-burger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-check:checked ~ .nav-burger span:nth-child(2) { opacity: 0; }
.nav-check:checked ~ .nav-burger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.nav-check:focus-visible ~ .nav-burger { outline: 2px solid currentColor; outline-offset: 2px; border-radius: 6px; }
.nav-scrim { display: none; }
/* Studio is the private workspace — set it off from the content links. */
.menu-studio { position: relative; padding-left: 22px; }
.menu-studio::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 1px; height: 12px;
  background: currentColor;
  opacity: 0.3;
}

/* -------------------------------------------------------------- Mobile */
html, body { overflow-x: hidden; } /* guard against any stray horizontal scroll */
@media (max-width: 600px) {
  :root { --edge: 14px; --gap: 10px; --nav-h: 52px; }
  .wordmark { font-size: 12px; letter-spacing: 0.06em; }
  .nav-burger { display: inline-flex; }

  /* Collapse the links into a dropdown panel under the bar (toggled by :checked). */
  .menu {
    position: absolute; top: var(--nav-h); right: var(--edge);
    flex-direction: column; align-items: stretch; gap: 0;
    min-width: 168px; padding: 6px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
    opacity: 0; visibility: hidden; transform: translateY(-6px);
    transition: opacity 160ms ease, transform 160ms ease, visibility 160ms;
  }
  .nav-check:checked ~ .menu { opacity: 1; visibility: visible; transform: translateY(0); }
  .menu a {
    color: var(--ink); opacity: 0.85;
    padding: 12px 14px; border-radius: 8px; font-size: 12px; letter-spacing: 0.08em;
  }
  .menu a:hover, .menu a.active { opacity: 1; background: rgba(0, 0, 0, 0.05); }
  .menu-studio { padding-left: 14px; }
  .menu-studio::before { display: none; } /* the panel separates it clearly enough */

  /* Full-screen scrim to close on an outside tap (it's a <label> for the same
     checkbox, so tapping it unchecks — pure CSS, no JS). Auto z-index + source
     order keeps it above the page but below the dropdown, which follows it. */
  .nav-check:checked ~ .nav-scrim { display: block; position: fixed; inset: 0; }

  /* On the home page the bar floats over the carousel via blend; when the menu
     opens, make the bar solid so the wordmark, icon, and panel stay readable. */
  .page-home .nav:has(.nav-check:checked) {
    mix-blend-mode: normal;
    background: rgba(255, 255, 255, 0.98); color: var(--ink);
    border-bottom: 1px solid var(--line);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  }

  /* Lightbox: more image, controls tucked to the corners/edges. */
  .lightbox { padding: 56px 12px; }
  .lb-close { top: 10px; right: 12px; }
  .lb-nav { width: 44px; height: 44px; font-size: 30px; }
  .lb-prev { left: 0; }
  .lb-next { right: 0; }
}

/* Short viewports (phone landscape): trim the caption/controls; the padding
   (dvh-based) and the flex column already maximise the image. */
@media (max-height: 560px) {
  .lb-fig { gap: 6px; }
  .lb-close { top: 8px; right: 10px; }
  .lb-cap { font-size: 10px; }
  .lb-watch { font-size: 10px; }
}

/* -------------------------------------------------------------- Home / carousel */
.carousel {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 1;
}
.slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1400ms ease;
}
.slide.active { opacity: 1; }
.carousel-dots {
  position: fixed;
  bottom: 28px;
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  z-index: 10;
  mix-blend-mode: difference;
}
.carousel-dots button {
  width: 7px; height: 7px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: background 200ms ease, transform 200ms ease;
}
.carousel-dots button.on { background: #fff; transform: scale(1.25); }

/* ---------------------------------------------------------------- Paintings */
.page-inner main { padding-top: var(--nav-h); }
.work {
  padding: 80px var(--edge) 140px;
  max-width: 1500px;
  margin: 0 auto;
}
/* Row-major grid: works flow left→right, then top→bottom. */
.feed {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap);
  align-items: start;
}
@media (max-width: 1200px) { .feed { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 820px)  { .feed { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px)  { .feed { grid-template-columns: 1fr; } }

.item {
  position: relative;
  margin: 0; /* drop the default <figure> margin so the row gap matches the column gap */
  width: 100%; /* fill the grid cell (figures don't stretch under justify-items:normal) */
  cursor: pointer;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 700ms ease, transform 700ms ease;
}
.item.in { opacity: 1; transform: none; }
/* aspect-ratio is set per-item inline so the cell reserves height before the
   image loads (no layout shift, reliable infinite scroll). */
.item img { width: 100%; height: auto; display: block; background: #f3f3f3; object-fit: cover; }
/* Caption overlays the image on hover (absolute → reserves no layout height, so
   the vertical whitespace equals the horizontal grid gap). */
.item figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  margin: 0;
  padding: 26px 10px 9px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #fff;
  display: flex;
  justify-content: space-between;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
  opacity: 0;
  transition: opacity 240ms ease;
}
.item:hover figcaption { opacity: 1; }
.sentinel { height: 10px; }

/* -------------------------------------------------------------------- About */
.about { padding: 120px var(--edge); }
.about-inner { max-width: 620px; margin: 0 auto; }
.about h2 {
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  margin: 0 0 24px;
}
.about p { font-size: 17px; line-height: 1.7; color: #333; margin: 0 0 22px; }
.about p:last-child { margin-bottom: 0; }

/* --------------------------------------------------------------- Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: var(--paper);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Vertical padding scales with viewport height (shrinks on short/landscape
     screens so the image is never squeezed); horizontal keeps room for arrows. */
  padding: clamp(8px, 6dvh, 72px) var(--edge);
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
  touch-action: none; /* deliver horizontal swipes to the pointer handlers */
}
.lightbox.open { opacity: 1; pointer-events: auto; }
/* Fill the padded lightbox as a column so the image flexes to whatever height
   is left above the (always-visible) caption — robust to any viewport height,
   phone or tablet, browser chrome shown or not. */
.lb-fig { margin: 0; width: 100%; height: 100%; min-height: 0; max-width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
.lb-stage { position: relative; flex: 1 1 auto; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.lb-fig img, .lb-canvas {
  max-width: 100%;
  max-height: 100%;   /* of the flex stage (space above the caption) */
  object-fit: contain;
  display: block;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.12);
}
.lb-meta { flex: 0 0 auto; } /* caption + Replay stay visible */
.lb-canvas { cursor: pointer; }        /* click to pause / resume replay */
.hidden { display: none !important; }

.lb-meta { display: flex; align-items: center; gap: 20px; }
.lb-cap { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.lb-watch {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  cursor: pointer;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 2px;
  transition: opacity 160ms ease;
}
.lb-watch:hover { opacity: 0.6; }

/* Replay progress — a slim bar under the canvas, in the flex column (shown only
   while a replay is loaded). */
.lb-progress {
  flex: 0 0 auto;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.12);
  overflow: hidden;
}
/* NB: the fill is #lb-progress-fill (an id), not a class — match it correctly. */
#lb-progress-fill { height: 100%; width: 0%; background: var(--ink); border-radius: inherit; transition: width 80ms linear; }

.lb-close {
  position: absolute;
  top: 22px; right: var(--edge);
  width: 40px; height: 40px;
  border: none; background: none;
  font-size: 30px; line-height: 1;
  color: var(--ink); cursor: pointer;
  z-index: 2;
}

/* Prev/next navigation through the works (also ← / → keys). */
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px; height: 56px;
  border: none; background: none;
  font-size: 40px; line-height: 1;
  color: var(--ink); cursor: pointer;
  z-index: 2;
  opacity: 0.5;
  transition: opacity 160ms ease;
}
.lb-nav:hover { opacity: 1; }
.lb-nav:disabled { opacity: 0.12; cursor: default; }
.lb-prev { left: calc(var(--edge) / 2); }
.lb-next { right: calc(var(--edge) / 2); }

/* -------------------------------------------------------------- Studio (private) */
.hidden { display: none !important; }

.gate {
  min-height: calc(100vh - var(--nav-h));
  display: flex; align-items: center; justify-content: center;
}
.gate-form { display: flex; flex-direction: column; gap: 14px; width: 260px; align-items: stretch; }
.gate-label {
  font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted); text-align: center; margin-bottom: 4px;
}
.gate-form input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  font: inherit;
  font-size: 15px;
  text-align: center;
}
.gate-form input:focus { outline: none; border-color: var(--ink); }
.gate-error { color: #c0392b; font-size: 12px; text-align: center; min-height: 16px; margin: 0; }

.dash { max-width: 1100px; margin: 0 auto; padding: calc(var(--nav-h) + 40px) var(--edge) 120px; }
/* `.page-inner main { padding-top: var(--nav-h) }` (line above) outranks `.dash`,
   so override at higher specificity to give the header row real clearance below
   the fixed nav (otherwise the New painting button sits flush against it). */
.page-inner main.dash { padding-top: calc(var(--nav-h) + 40px); }
.dash-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 48px; }
.dash-head h2 { font-size: 22px; font-weight: 600; margin: 0; }
.btn-primary {
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  color: #fff; background: var(--ink); border: 1px solid var(--ink);
  border-radius: 8px; padding: 10px 18px; line-height: 1;
  transition: background 120ms ease, transform 60ms ease;
}
.btn-primary:hover { background: #000; }
.btn-primary:active { transform: translateY(1px); }
.dash-section { margin-bottom: 56px; }
.dash-section h3 {
  font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink); font-weight: 600; margin: 0 0 20px;
}
.dash-note { text-transform: none; letter-spacing: 0.02em; color: var(--muted); font-weight: 400; }
.dash-empty { color: var(--muted); font-size: 15px; }

/* Home carousel strip (ordered) */
.carousel-strip { display: flex; gap: 14px; flex-wrap: wrap; }
.strip-item {
  position: relative; width: 150px;
  /* pan-y: a quick vertical swipe scrolls the page; a long-press arms the drag
     (JS then suppresses scroll via a non-passive touchmove handler). */
  cursor: grab; touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
/* Original left as a dimmed drop-slot placeholder while the ghost is dragged. */
.strip-item.dragging { opacity: 0.25; }
.strip-item.dragging img { outline: 2px dashed var(--line); outline-offset: -2px; }
.strip-item img { width: 100%; height: 100px; object-fit: cover; display: block; border-radius: 6px; background: #f3f3f3; pointer-events: none; }

/* Floating clone that follows the finger/cursor during a drag. */
.strip-ghost {
  position: fixed; top: 0; left: 0; z-index: 100; margin: 0;
  border-radius: 6px; overflow: hidden; pointer-events: none;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
  opacity: 0.94; will-change: transform;
}
.strip-ghost img { width: 100%; height: 100%; object-fit: cover; display: block; }
.strip-ghost .ov-btn { display: none; }

/* All-work curator grid */
.curate-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.cur-card { margin: 0; }
.cur-thumb { position: relative; cursor: pointer; }
.cur-thumb:hover img { outline: 2px solid var(--ink); outline-offset: 2px; }
.cur-thumb img { width: 100%; height: auto; display: block; background: #f3f3f3; border-radius: 6px; }
.cur-badge {
  position: absolute; bottom: 6px; left: 6px;
  font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase;
  background: rgba(0, 0, 0, 0.6); color: #fff; padding: 2px 6px; border-radius: 999px;
  pointer-events: none;
}

/* Corner curation overlays: ☆ Home (top-left), 👁 Gallery (top-right).
   Shared by the carousel strip and the all-work grid. */
.ov-btn {
  position: absolute; top: 7px;
  width: 30px; height: 30px; border-radius: 999px; border: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.42); color: #fff; cursor: pointer;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
  opacity: 0.92; transition: background 140ms ease, transform 120ms ease, opacity 140ms ease;
  z-index: 2;
}
.ov-btn:hover { opacity: 1; transform: scale(1.09); }
.ov-btn svg { width: 17px; height: 17px; display: block; }
.ov-home { left: 7px; }
.ov-eye { right: 7px; }
/* star: outline when off, gold-filled when featured on Home */
.ov-home svg path { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.ov-home.on { color: #ffcf4d; }
.ov-home.on svg path { fill: #ffcf4d; stroke: #ffcf4d; }
/* eye: open when shown in the gallery, struck-through when hidden */
.ov-eye .eye-closed { display: none; }
.ov-eye:not(.on) .eye-open { display: none; }
.ov-eye:not(.on) .eye-closed { display: block; }
.ov-eye.on { background: rgba(28, 120, 60, 0.62); }

/* -------------------------------------------------------------- Footer */
.site-footer { font-size: 11px; letter-spacing: 0.06em; color: var(--muted); }
.foot-inner { display: flex; flex-wrap: wrap; gap: 6px 28px; align-items: baseline; }
.foot-legal { color: var(--muted); }

/* inner pages: a quiet rule at the bottom of the content */
.page-inner .site-footer {
  margin-top: 96px;
  border-top: 1px solid var(--line);
  padding: 26px var(--edge) 44px;
}

/* home: a whisper of copyright over the carousel, matching the nav blend */
.page-home .site-footer {
  position: fixed;
  left: 0; bottom: 26px;
  padding: 0 var(--edge);
  z-index: 10;
  color: #fff;
  mix-blend-mode: difference;
  pointer-events: none;
}
.page-home .foot-legal { display: none; }

/* Paintings (infinite scroll): a minimal copyright pinned to the bottom, on a
   soft fade so it stays legible over the feed and never blocks a click. */
.page-inner .site-footer.pinned {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  margin: 0;
  border: 0;
  padding: 26px var(--edge) 12px;
  background: linear-gradient(to top, var(--paper) 45%, rgba(255, 255, 255, 0));
  z-index: 30; /* above the feed, below the lightbox (40) */
  pointer-events: none;
}
.site-footer.pinned .foot-inner { justify-content: flex-end; }
.site-footer.pinned .foot-legal { display: none; }
