/* Molten Layer — public print gallery (frames.moltenlayer.com).
   Vanilla, no framework, no build step. Paired with app.js + index.html.
   Mirrors the FrameForge app's dark theme (accent #D05525). */

:root {
  color-scheme: dark;
  --bg: #0f0f1a;
  --bg2: #1a1a2e;
  --bg3: #252540;
  --bg-hover: #2f2f4a;
  --border: #3a3a5c;
  --text: #e8e8f0;
  --text-dim: #9898b0;
  --accent: #D05525;
  --accent-hover: #E06535;
  --radius: 10px;
  --gap: 14px;
  --content-max: 2000px;     /* cap so cells don't balloon on ultrawide/8K */
  --cell-min: 220px;
  --tap: 44px;               /* minimum touch target */
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100dvh;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; display: block; }

.wrap { max-width: var(--content-max); margin-inline: auto; padding-inline: clamp(12px, 3vw, 32px); }

/* ── Header ──────────────────────────────────────────────────────────────── */
header.site {
  background: radial-gradient(120% 120% at 50% 0%, #2a1206 0%, #120a07 55%, #0a0705 100%);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-block: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand img { width: 44px; height: 44px; }
.brand .name { font-size: clamp(1.2rem, 3.5vw, 1.6rem); font-weight: 700; letter-spacing: .02em; }
.brand .name .accent { color: var(--accent); }
.brand .tagline { display: block; font-size: .8rem; color: var(--text-dim); font-weight: 400; }

.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.btn:hover { background: var(--bg-hover); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

/* ── Controls (search + chips, one line; wraps on narrow screens) ────────── */
.controls { display: flex; flex-flow: row wrap; align-items: center; gap: 12px 20px; padding-block: 20px 8px; }

.search-box { position: relative; flex: 1 1 240px; max-width: 420px; min-width: 200px; }
.search-box input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 40px 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font: inherit;
}
.search-box input::placeholder { color: var(--text-dim); }
.search-box input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.search-box .clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text-dim); cursor: pointer; font-size: 1.2rem; line-height: 1;
}
.search-box .clear:hover { color: var(--text); background: var(--bg-hover); }

.chip-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chip-label {
  flex: 0 0 auto;
  min-width: 48px;
  color: var(--text-dim);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text-dim);
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { background: var(--bg-hover); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Featured carousel ──────────────────────────────────────────────────── */
.featured { padding-block: 16px 8px; }
.featured h2 { font-size: 1rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .08em; margin: 0 0 12px; }
.carousel { position: relative; max-width: 1080px; margin-inline: auto; }
.carousel-track {
  --slide-w: clamp(200px, 42vw, 460px);
  display: flex;
  gap: 0;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  perspective: 1200px;               /* 3D depth for the cover-flow cascade */
  padding-block: 26px;               /* room for the scaled hero + shadow */
  padding-inline: calc(50% - var(--slide-w) / 2); /* first/last slide can reach center */
}
.carousel-track::-webkit-scrollbar { display: none; }
.slide {
  flex: 0 0 var(--slide-w);
  scroll-snap-align: center;
  cursor: pointer;
  border: 0; padding: 0 4px; margin-block: 0; background: none;
  /* Heavy horizontal overlap → the scroll step is a fraction of the slide width,
     so many stacked side slides fit in view (layoutCoverflow normalizes the
     cascade by the step, not the slide width). */
  margin-inline: calc(var(--slide-w) * -0.26);
  will-change: transform;
  /* transform/opacity/filter are set per-frame by JS (layoutCoverflow). */
}
.slide img {
  width: 100%;
  height: auto;                /* override the <img height> attr so aspect-ratio drives the box (16:10) */
  aspect-ratio: 16 / 10;       /* matches the cropped thumb → no letterboxing */
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--bg2);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  pointer-events: none;        /* clicks land on the .slide button */
}
/* Hover-enlarge any slide for interaction feedback. The scale is on the IMG so
   it nests inside the slide's JS-driven 3D transform instead of fighting it. */
@media (hover: hover) {
  .slide img { transition: transform .18s ease, box-shadow .18s ease; }
  .slide:hover img { transform: scale(1.06); box-shadow: 0 20px 52px rgba(0, 0, 0, 0.6); }
}
.carousel-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: var(--tap); height: var(--tap);
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(15, 15, 26, .7);
  color: var(--text);
  font-size: 1.4rem; line-height: 1; cursor: pointer;
  display: grid; place-items: center;
  backdrop-filter: blur(4px);
}
.carousel-btn:hover { background: rgba(47, 47, 74, .9); }
.carousel-btn.prev { left: 8px; }
.carousel-btn.next { right: 8px; }
.dots { display: flex; justify-content: center; gap: 8px; padding-top: 12px; }
.dot {
  width: 10px; height: 10px; padding: 0;
  border-radius: 50%; border: 0;
  background: var(--border); cursor: pointer;
}
.dot[aria-current="true"] { background: var(--accent); }
.dot:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ── Grid ───────────────────────────────────────────────────────────────── */
#grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--cell-min), 1fr));
  gap: var(--gap);
  padding-block: 12px 32px;
}
.card {
  display: block;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg2);
  /* skip layout/paint for off-screen cells; intrinsic size matches the 16:10 cell
     box (height = width × 10/16) so the scrollbar doesn't jump (CLS). */
  content-visibility: auto;
  contain-intrinsic-size: var(--cell-min) calc(var(--cell-min) * 0.625);
}
.card img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease; }
.card:hover img { transform: scale(1.04); }
.card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ── States ─────────────────────────────────────────────────────────────── */
.state { text-align: center; padding: clamp(40px, 12vh, 120px) 20px; color: var(--text-dim); }
.state h2 { color: var(--text); margin: 0 0 8px; }
.spinner {
  width: 40px; height: 40px; margin: 0 auto 20px;
  border: 4px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#sentinel { height: 1px; }
[hidden] { display: none !important; }

/* ── Lightbox (native <dialog>) ─────────────────────────────────────────── */
dialog.lightbox {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  touch-action: pan-y;          /* let our handler get horizontal swipes (nav) */
  margin: 0;
  border: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: transparent;
  color: var(--text);
  overflow: hidden;
}
dialog.lightbox::backdrop { background: rgba(0, 0, 0, .88); }
/* Blurred fill: a cover-scaled, blurred copy of the same photo fills the frame
   behind the contained sharp image — off-aspect photos read as intentional. */
.lb-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(30px) brightness(0.5) saturate(1.1);
  transform: scale(1.12);   /* overscan hides the blurred edge bleed */
  z-index: 0;
  pointer-events: none;
}
.lb-figure {
  position: relative;
  z-index: 1;
  margin: 0;
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
}
.lb-figure img {
  max-width: 100%;
  max-height: calc(100dvh - 80px);
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}
/* Hold the image + blurred fill hidden until the new photo has decoded, then
   fade in — kills the flash of the previously-shown image. */
#lb-image, .lb-bg { opacity: 0; transition: opacity .18s ease; }
.lightbox.img-ready #lb-image, .lightbox.img-ready .lb-bg { opacity: 1; }
.lb-caption {
  width: 100%;
  max-width: 900px;
  text-align: center;
  padding: 14px 20px;
  color: var(--text);
  font-size: 1rem;
}
.lb-caption .frame-name { display: inline-block; margin-top: 6px; color: var(--accent); font-size: .85rem; font-weight: 600; }
.lb-btn {
  position: fixed;
  z-index: 3;
  width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(15, 15, 26, .6);
  color: var(--text);
  font-size: 1.6rem; line-height: 1; cursor: pointer;
  backdrop-filter: blur(4px);
}
.lb-btn:hover { background: rgba(47, 47, 74, .9); }
.lb-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lb-close { top: calc(env(safe-area-inset-top) + 12px); right: calc(env(safe-area-inset-right) + 12px); }
.lb-prev { left: calc(env(safe-area-inset-left) + 12px); top: 50%; transform: translateY(-50%); }
.lb-next { right: calc(env(safe-area-inset-right) + 12px); top: 50%; transform: translateY(-50%); }

/* ── Contact modal (native <dialog>) ────────────────────────────────────── */
dialog.contact-modal {
  margin: auto;                 /* center on screen */
  width: calc(100vw - 32px);
  max-width: 400px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
}
dialog.contact-modal::backdrop { background: rgba(0, 0, 0, .72); backdrop-filter: blur(3px); }
.contact-card {
  position: relative;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 22px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
}
.contact-card h2 { margin: 0 0 4px; font-size: 1.3rem; }
.contact-sub { margin: 0 0 18px; color: var(--text-dim); font-size: .92rem; }
.contact-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.contact-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.contact-row:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--text); }
.contact-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.contact-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--accent); font-weight: 700; }
.contact-value { font-size: 1rem; font-weight: 600; }
.contact-hint { color: var(--text-dim); font-weight: 400; font-size: .85rem; }
.contact-close {
  position: absolute; top: 10px; right: 10px;
  width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--text-dim);
  cursor: pointer; font-size: 1.4rem; line-height: 1;
}
.contact-close:hover { color: var(--text); background: var(--bg-hover); }

/* ── Footer ─────────────────────────────────────────────────────────────── */
footer.site {
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  padding-block: 28px;
  margin-top: 20px;
}
.footer-inner { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; justify-content: space-between; }
footer.site .links { display: flex; gap: 20px; flex-wrap: wrap; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 560px) {
  .brand .tagline { display: none; }
  :root { --cell-min: 150px; }
  /* Wider, landscape-dominant hero on phones (otherwise the narrow slide + 3D
     side cards read as a tall/vertical strip). */
  .carousel-track { --slide-w: min(86vw, 380px); padding-block: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .carousel-track { scroll-behavior: auto; }
  .card img { transition: none; }
  .spinner { animation-duration: 2s; }
}
