/* ═══════════════════════════════════════════════════════════════════
   media-system.css — Natural-Ratio Media & Bento Grid System
   ourhome. portfolio
   Link AFTER style.css in: index.html, project.html, admin.html
   ═══════════════════════════════════════════════════════════════════ */

/* ── GLOBAL IMAGE RESET (natural ratio contexts) ──────────────────
   Override style.css global: img { height: 100%; object-fit: cover }
   We scope resets tightly so thumbnail/hero contexts keep cover.     */

/* Any img that is a direct child of a natural-ratio block */
.b-gallery-natural img,
.b-image--natural img,
.b-col--natural img,
.b-natural img {
  width: 100% !important;
  height: auto !important;
  object-fit: unset !important;
  display: block;
}

/* ── BENTO / NATURAL GALLERY GRID ─────────────────────────────────
   .b-gallery-natural wraps the entire gallery block.
   Each item uses grid-column span set by JS inline style.
   align-items: start is the CORE rule: rows size to content.        */

.b-gallery-natural {
  display: grid;
  grid-template-columns: repeat(var(--gcols, 3), 1fr);
  align-items: start;     /* ← prevents stretching to fill row height */
  row-gap: var(--ggap, 8px);
  column-gap: var(--ggap, 8px);
}

.b-gallery-natural__item {
  overflow: hidden;
  background: var(--surface, #141414);
  position: relative;
  /* No fixed aspect-ratio — natural dimensions drive height */
}

.b-gallery-natural__item img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: unset;      /* Never crop */
  transition: transform 0.4s ease;
}

.b-gallery-natural__item:hover img {
  transform: scale(1.02);
}

/* Size span helpers — applied inline via JS but available as fallbacks */
.b-gallery-natural__item[data-size="small"]  { grid-column: span 1; }
.b-gallery-natural__item[data-size="medium"] { grid-column: span 1; }
.b-gallery-natural__item[data-size="large"]  { grid-column: span 2; }
.b-gallery-natural__item[data-size="wide"]   { grid-column: 1 / -1; }

/* ── STRIP GALLERY (horizontal scroll of natural images) ──────────  */
.b-gallery-strip {
  display: flex;
  gap: var(--ggap, 8px);
  overflow-x: auto;
  align-items: flex-start;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.b-gallery-strip::-webkit-scrollbar { height: 4px; }
.b-gallery-strip::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.b-gallery-strip__item {
  flex-shrink: 0;
  max-width: 80%;
  scroll-snap-align: start;
  overflow: hidden;
  border-radius: var(--item-radius, 8px);
}

.b-gallery-strip__item img {
  height: var(--strip-h, 320px);
  width: auto;
  max-width: none;
  display: block;
  object-fit: unset;
}

/* ── HERO BENTO (one big + side stack) ────────────────────────────  */
.b-gallery-hero {
  display: grid;
  grid-template-columns: 3fr 2fr;
  align-items: start;
}

.b-gallery-hero .b-gallery-hero__main {
  overflow: hidden;
}

.b-gallery-hero__main img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: unset;
}

.b-gallery-hero__stack {
  display: flex;
  flex-direction: column;
  gap: inherit;
}

.b-gallery-hero__stack img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: unset;
}

/* ── SINGLE IMAGE BLOCK ────────────────────────────────────────────  */
.b-image--natural {
  overflow: hidden;
}

.b-image--natural img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: unset;
}

/* ── COLUMN BLOCK — natural image ratio ───────────────────────────  */
.b-col--natural {
  background: var(--surface, #141414);
  border-radius: 12px;
  overflow: hidden;
}

.b-col--natural img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: unset;
}

/* ── PROJECT CARD — natural cover image on portfolio index ─────────
   Overrides .project-card__media fixed-height if present             */

.project-card__media {
  overflow: hidden;
  position: relative;
}

.project-card__media img {
  width: 100%;
  height: auto !important;  /* override global height:100% */
  display: block;
  object-fit: unset !important;
  transition: transform 0.5s ease;
}

.project-card:hover .project-card__media img {
  transform: scale(1.03);
}

.project-card__overlay {
  position: absolute;
  inset: 0;
  background: rgba(9, 9, 9, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display, 'Switzer', sans-serif);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.project-card:hover .project-card__overlay {
  opacity: 1;
}

/* ── PROJECT CARD GRID (portfolio index — bento auto-flow) ─────────  */
.portfolio-bento {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  align-items: start;
}

/* Default card: 4 cols */
.portfolio-bento .project-card {
  grid-column: span 4;
}

/* Featured: 8 cols */
.portfolio-bento .project-card--featured {
  grid-column: span 8;
}

/* Wide card: full row */
.portfolio-bento .project-card--wide {
  grid-column: span 12;
}

@media (max-width: 1024px) {
  .portfolio-bento .project-card          { grid-column: span 6; }
  .portfolio-bento .project-card--featured { grid-column: span 12; }
  .portfolio-bento .project-card--wide    { grid-column: span 12; }
}

@media (max-width: 640px) {
  .portfolio-bento .project-card,
  .portfolio-bento .project-card--featured,
  .portfolio-bento .project-card--wide    { grid-column: span 12; }

  .b-gallery-natural {
    grid-template-columns: repeat(min(var(--gcols, 3), 2), 1fr) !important;
  }

  /* Clamp large spans on mobile */
  .b-gallery-natural__item[style*="span 3"],
  .b-gallery-natural__item[style*="span 4"],
  .b-gallery-natural__item[data-size="wide"] {
    grid-column: 1 / -1 !important;
  }

  .b-gallery-strip__item img {
    height: var(--strip-h-mobile, 200px);
  }
}

/* ── NATURAL IMAGE CAPTIONS ────────────────────────────────────────  */
.b-natural-caption {
  padding: 8px 4px;
  font-family: var(--font-mono, 'Space Grotesk', monospace);
  font-size: 11px;
  color: var(--text-muted, #888);
  text-align: center;
  letter-spacing: 0.04em;
}