/* ==================================================
   Chi Yuen Chung — Film Photography
   Square mounts + museum labels (fixed grid, no holes)
   ================================================== */

/* ---------- 1) Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&family=Lora:ital,wght@0,400;0,600;1,400&display=swap');

/* ---------- 2) Design tokens ---------- */
:root{
  --bg:#ffffff;
  --fg:#111111;
  --muted:#666666;

  --page-max:1200px;
  --gap:24px;

  --font-body:'Inter',system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  --font-caption:'Lora',Georgia,serif;
}
@media (prefers-color-scheme: dark){
  :root{ --bg:#0d0f12; --fg:#e7e7e7; --muted:#b8b8b8; }
}

/* ---------- 3) Base ---------- */
*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background:var(--bg);
  color:var(--fg);
  font-family:var(--font-body);
  line-height:1.55;
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}
a{ color:inherit; }
a:focus-visible,button:focus-visible{
  outline:2px solid #7aa7ff;
  outline-offset:2px;
  border-radius:6px;
}

/* ---------- 4) Header & Footer ---------- */
header,footer{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:.35rem;
  text-align:center;
}
header{ padding:44px 16px 24px; }
footer{ padding:40px 16px; }
header h1{
  margin:0; font-weight:600; letter-spacing:.2px;
  font-size:clamp(22px,2.6vw,36px);
}
header p{ margin:0; color:var(--muted); font-size:.98rem; }
.brand{ text-decoration:none; border-bottom:1px solid transparent; }
.brand:hover{ border-color:currentColor; }

/* ---------- 5) Grid (fills gaps, no weird centering) ---------- */
.grid{
  max-width:var(--page-max);
  margin:0 auto;
  padding:0 16px 72px;
  display:grid;
  gap:var(--gap);

  /* auto-fit lets tracks collapse cleanly; min 280px each */
  grid-template-columns:repeat(auto-fit,minmax(280px,1fr));

  /* keep items packed and top-aligned */
  grid-auto-flow:row dense;
  align-items:start;
}
@media (min-width:1100px){
  .grid{ grid-template-columns:repeat(auto-fit,minmax(300px,1fr)); }
}

/* IMPORTANT: prevent grid children from forcing wide tracks */
.grid > *{ min-width:0; }

/* Each card is a flex column so its internal pieces stack nicely */
.card{
  display:flex;
  flex-direction:column;
  text-decoration:none;
  color:inherit;
  width:100%;    /* fit the track */
  max-width:unset;
}

/* ---------- 6) Square mount (consistent white “print” border) ---------- */
@supports (aspect-ratio:1){
  .square{
    aspect-ratio:1 / 1;
    width:100%;
    background:#fff;
    border:12px solid #fff;
    border-radius:0;
    overflow:hidden;
    position:relative;
    box-shadow:0 8px 20px rgba(0,0,0,.35);
    transition:transform .18s ease, box-shadow .18s ease;

    display:flex; align-items:center; justify-content:center;
    flex:0 0 auto;
  }
  .square > img{
    max-width:100%; max-height:100%;
    width:auto; height:auto;
    object-fit:contain; /* preserves portrait/landscape with white border */
    display:block;
  }
}
@supports not (aspect-ratio:1){
  .square{
    position:relative; width:100%; padding-top:100%;
    background:#fff; border:12px solid #fff; border-radius:0; overflow:hidden;
    box-shadow:0 8px 20px rgba(0,0,0,.35);
    transition:transform .18s ease, box-shadow .18s ease;
    flex:0 0 auto;
  }
  .square > img{
    position:absolute; inset:12px;
    width:calc(100% - 24px); height:calc(100% - 24px);
    object-fit:contain;
  }
}
.card:hover .square{
  transform:translateY(-2px);
  box-shadow:0 12px 26px rgba(0,0,0,.45);
}

/* Make meta links look deliberate but not pill-y */
.meta-link{
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}
.meta-link:hover{
  border-bottom-style: solid;
}

/* Optional hover overlay on the tile */
.tile-overlay{
  position:absolute; left:0; right:0; bottom:0;
  padding:10px 12px;
  background:linear-gradient(180deg,rgba(0,0,0,0) 0%, rgba(0,0,0,.62) 100%);
  color:#fff; font-size:.9rem; letter-spacing:.15px;
  opacity:0; transition:opacity .2s ease; pointer-events:none;
}
.card:hover .tile-overlay{ opacity:1; }

/* ---------- 7) Museum-style label ---------- */
.museum-label{
  display:block;
  margin-top:14px;
  padding:10px 8px 2px;
  text-align:center;
  max-width:520px;
  margin-left:auto; margin-right:auto;
  flex:0 0 auto;
}
.caption{ display:block; color:var(--fg); font-family:var(--font-caption); line-height:1.35; }
.caption-title{
  font-variant-caps:small-caps; letter-spacing:.06em;
  font-weight:600; font-size:1.02rem;
}
.date-badge{
  display:inline-block; margin-left:.45rem;
  padding:.1rem .38rem; font-size:.78rem; color:var(--muted);
  border:1px solid rgba(0,0,0,.15); border-radius:4px; opacity:.9;
}
@media (prefers-color-scheme: dark){
  .date-badge{ border-color:rgba(255,255,255,.2); }
}
.museum-rule{
  display:block; height:1px; width:64px; margin:10px auto 8px;
  background:currentColor; opacity:.18;
}
.card:hover .museum-rule{ opacity:.26; }
@media (prefers-color-scheme: dark){ .museum-rule{ opacity:.24; } }

/* Stacked metadata (with emoji bullets) */
.meta{ margin:0; padding:0; list-style:none; color:var(--muted); font-family:var(--font-caption); }
.meta--stack{ display:flex; flex-direction:column; gap:4px; align-items:center; font-size:.92rem; }
.meta-item{ white-space:nowrap; opacity:.95; display:inline-flex; align-items:center; gap:6px; }

/* Make the image link block-level and inherit colors */
.tile-link{ display:block; color:inherit; text-decoration:none; }

/* ---------- Tag pills ---------- */
.tags{
  margin:10px 0 0; padding:0; list-style:none;
  display:flex; flex-wrap:wrap; gap:6px; justify-content:center;
  flex:0 0 auto;
}
.tags li{ margin:0; padding:0; }
.tag-pill{
  display:inline-block; font-size:.82rem; line-height:1;
  padding:6px 10px; border-radius:999px; text-decoration:none;
  color:var(--fg); border:1px solid rgba(0,0,0,.14); background:rgba(0,0,0,.03);
}
.tag-pill:hover{ background:rgba(0,0,0,.06); }
@media (prefers-color-scheme: dark){
  .tag-pill{ color:var(--fg); border-color:rgba(255,255,255,.22); background:rgba(255,255,255,.06); }
  .tag-pill:hover{ background:rgba(255,255,255,.1); }
}
.tag-pill--solid{ background:#111; color:#fff; border-color:#111; }
@media (prefers-color-scheme: dark){
  .tag-pill--solid{ background:#e7e7e7; color:#0d0f12; border-color:#e7e7e7; }
}

/* ---------- Tag filter banner ---------- */
.tag-filter{ max-width:var(--page-max); margin:0 auto 10px; padding:0 16px; }
.tag-filter-inner{
  margin:0 auto 8px; max-width:820px; display:flex; align-items:center;
  gap:10px; justify-content:center; color:var(--muted); font-size:.95rem;
}
.tag-clear{
  text-decoration:none; border:1px solid rgba(0,0,0,.14);
  padding:2px 8px; border-radius:999px; color:var(--muted);
}
@media (prefers-color-scheme: dark){ .tag-clear{ border-color:rgba(255,255,255,.22); } }

/* ---------- 8) Lightbox ---------- */
.lightbox-overlay{ cursor:zoom-out; }
.lb-arrow{
  position:absolute; top:50%; transform:translateY(-50%);
  background:rgba(255,255,255,.14); backdrop-filter:blur(2px);
  border:1px solid rgba(255,255,255,.25); color:#fff;
  width:44px; height:44px; border-radius:999px;
  display:grid; place-items:center; font-size:28px; line-height:1;
  cursor:pointer; user-select:none; z-index:10000;
  transition:background .2s ease, transform .12s ease, box-shadow .2s ease;
  box-shadow:0 6px 16px rgba(0,0,0,.35);
}
.lb-prev{ left:24px; } .lb-next{ right:24px; }
.lb-arrow:hover{ background:rgba(255,255,255,.22); }
.lb-arrow:active{ transform:translateY(-50%) scale(.98); }
.lb-arrow:focus-visible{ outline:2px solid #7aa7ff; outline-offset:2px; }
@media (max-width:640px){
  .lb-arrow{ width:52px; height:52px; font-size:30px; }
  .lb-prev{ left:16px; } .lb-next{ right:16px; }
}
.lb-close{
  position:absolute; top:16px; right:20px;
  font-size:2.2rem; font-weight:700; line-height:1; color:#fff;
  cursor:pointer; text-shadow:0 2px 20px rgba(0,0,0,.45); user-select:none;
}

/* Center items inside each grid cell */
.grid{
  justify-items: center;      /* NEW */
}

/* Keep every card at a sane max width (also fixes the single-card case) */
.card{
  width: 100%;
  max-width: 560px;           /* NEW: pick 520–600px to taste */
  margin: 0 auto;             /* keep centered if the track is wider */
}
