/*
  Iconogenic Elements — gallery styling
  Ported from the Iconogenic brand design system (Figtree + brown/tan/cream),
  shared with Iconogenic Models for a consistent look.
*/
:root {
  --brand-brown:      #6f4d36;
  --brand-brown-dark: #4b3323;
  --brand-tan:        #ad9980;
  --accent:           #c79d7f;
  --neutral-700:      #333333;
  --bg-cream:         #f5f3f0;
  --bg-stone:         #e0dbd2;
  --surface:          #ffffff;

  --filter-active:    #4e3e37;   /* active filter button */
  --png-bg:           #ededed;   /* pale gray behind pre-cropped PNG clipart */

  --line: #ece7e0;
  --accent-soft: #f1eae2;
  --radius: 5px;
  --shadow: 0 1px 2px rgba(60,50,40,.04), 0 10px 30px rgba(75,51,35,.07);
  font-family: 'Figtree', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  background: var(--bg-cream);
  color: var(--neutral-700);
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; min-height: 100vh;
}

/* ---- Header ---- */
.topbar {
  flex: 0 0 auto; text-align: center;
  padding: 26px 24px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative;
}
.topbar h1 {
  font-size: clamp(30px, 5vw, 50px);
  font-weight: 700; letter-spacing: 1px; line-height: 1.05;
  color: var(--brand-brown-dark);
}
.topbar h1 .home { color: inherit; text-decoration: none; }
.topbar .mark { color: var(--brand-brown); }
.topbar .tagline {
  margin-top: 8px;
  font-size: clamp(12px, 1.5vw, 16px);
  letter-spacing: .22em; text-transform: uppercase; font-weight: 500;
  color: var(--brand-tan);
}

/* header popup buttons (styled like the Pattern Fiesta reference) */
.topnav { margin-top: 16px; display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.navbtn {
  border: 1px solid var(--accent); background: var(--surface);
  color: var(--brand-brown-dark); font-family: inherit;
  font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  padding: 10px 18px; border-radius: var(--radius); cursor: pointer; transition: all .2s ease;
}
.navbtn:hover { background: var(--filter-active); color: #fff; border-color: var(--filter-active); }

/* account area (top-right): log-in button OR the access counter */
.account {
  position: absolute; top: 22px; right: 24px;
  display: flex; align-items: center; gap: 12px;
}
.login-btn {
  border: 1px solid var(--accent); background: var(--surface);
  color: var(--brand-brown-dark); font-family: inherit;
  font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  padding: 9px 16px; border-radius: var(--radius); cursor: pointer; transition: all .2s ease;
}
.login-btn:hover { background: var(--filter-active); color: #fff; border-color: var(--filter-active); }
/* the logged-in "remaining days / downloads" counter */
.pass {
  display: flex; align-items: stretch; gap: 0;
  border: 1px solid var(--accent); border-radius: var(--radius); overflow: hidden;
  background: var(--surface);
}
.pass .cell { padding: 6px 14px; text-align: center; line-height: 1.1; }
.pass .cell + .cell { border-left: 1px solid var(--line); }
.pass .num { font-size: 18px; font-weight: 700; color: var(--brand-brown-dark); }
.pass .lbl { font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--brand-tan); font-weight: 600; }
.pass .num.low { color: #b23b2e; }
.pass-out {
  border: 0; background: transparent; color: var(--brand-tan); cursor: pointer;
  font: inherit; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600;
}
.pass-out:hover { color: var(--brand-brown); text-decoration: underline; }
@media (max-width: 880px){
  .account { position: static; justify-content: center; margin-top: 16px; }
}

/* ---- Layout ---- */
.wrap { display: grid; grid-template-columns: 300px 1fr; flex: 1 1 auto; min-height: 0; }
/* gallery (scenes) view: no sidebar, stage spans full width */
.wrap.solo { grid-template-columns: 1fr; }
.wrap.solo .side { display: none; }
@media (max-width: 1024px){ .wrap { grid-template-columns: 270px 1fr; } }
@media (max-width: 880px){
  .wrap { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
}

/* ---- Sidebar / filters ---- */
.side {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 20px 60px;
}
.filter-head { display:flex; align-items:center; justify-content:space-between; margin-bottom: 14px; }
.filter-head .title { font-size: 12px; letter-spacing:.2em; text-transform: uppercase; color: var(--brand-tan); font-weight:600; }
.clear-btn {
  border:0; background:transparent; color: var(--brand-brown); cursor:pointer;
  font: inherit; font-size: 11px; letter-spacing:.08em; text-transform:uppercase; font-weight:600;
  opacity:.55; transition: opacity .2s ease;
}
.clear-btn.show { opacity:1; }
.clear-btn:hover { text-decoration: underline; }

.facet { margin-bottom: 22px; }
.facet > .label {
  font-size: 13px; letter-spacing:.14em; text-transform: uppercase;
  color: var(--brand-brown-dark); font-weight:700; margin-bottom: 10px; display:block;
}
.chips { display:flex; flex-wrap:wrap; gap:8px; }
.chip {
  border: 1px solid var(--accent); background: var(--surface);
  color: var(--brand-brown); font-family: inherit;
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  padding: 7px 12px; border-radius: 4px; cursor: pointer; transition: all .15s ease;
}
.chip:hover { background: var(--accent-soft); transform: translateY(-1px); }
.chip.on { background: var(--filter-active); color: #fff; border-color: var(--filter-active); }

/* color swatches: fixed grid, 7 per row, 1px black border */
.swatches { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; max-width: 252px; }
.swatch {
  position: relative; aspect-ratio: 1; border: 1px solid #000; border-radius: 4px;
  cursor: pointer; padding: 0; transition: transform .12s ease;
}
.swatch:hover { transform: scale(1.08); }
.swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--filter-active); }
.swatch.on::after {
  content: "✓"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}
/* tick mark contrasts on both light and dark swatches */
.swatch.on.light::after { color: #000; }
.swatch.on.dark::after  { color: #fff; }

/* ---- Stage ---- */
.stage { padding: 24px 30px 60px; min-width: 0; background: #fff; }
.stage-head {
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom: 20px; flex-wrap:wrap; gap:12px;
}
.counts { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; }
.lib-count { color: var(--brand-tan); font-size: 13px; letter-spacing:.04em; }
.lib-count b { color: var(--brand-brown-dark); font-weight:700; font-size: 15px; }
.new-count {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600;
  color: var(--brand-brown); background: var(--accent-soft);
  padding: 4px 10px; border-radius: 20px;
}
.result-count { color: var(--brand-tan); font-size: 13px; }
.result-count b { color: var(--brand-brown-dark); font-weight:600; }
.sort-row { display:flex; align-items:center; gap:8px; }
.sort-row label { font-size: 11px; letter-spacing:.12em; text-transform:uppercase; color: var(--brand-tan); font-weight:600; }
select {
  padding: 8px 10px; border:1px solid var(--accent);
  border-radius: 4px; background: var(--bg-cream); font-size: 13px; color: var(--neutral-700);
  font-family: inherit; cursor:pointer;
}
select:focus { outline:none; border-color: var(--brand-brown); background:#fff; }

/* ---- Grid (4 per row, square thumbs) ---- */
.grid { display:grid; grid-template-columns: repeat(4, 1fr); gap: 22px; }
@media (max-width: 1200px){ .grid { grid-template-columns: repeat(3,1fr);} }
@media (max-width: 880px){ .grid { grid-template-columns: repeat(2,1fr);} }
@media (max-width: 520px){ .grid { grid-template-columns: 1fr;} }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  transition: transform .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); }

/* square thumbnail; click to open the lightbox */
.thumb-wrap {
  position: relative; width: 100%; aspect-ratio: 1 / 1;
  display: block; cursor: zoom-in; background: var(--surface);
}
.thumb-wrap img { width: 100%; height: 100%; object-fit: contain; display: block; }
/* PNG clipart: pale gray bg with breathing room around the pre-cropped art */
.thumb-wrap.png { background: var(--png-bg); }
.thumb-wrap.png img { padding: 9%; }
/* JPG / photoreal: fill the square edge-to-edge */
.thumb-wrap.jpg img { object-fit: cover; }

/* logged-out: the preview is a pre-baked square (the © watermark covers the
   whole canvas), so let it fill the square thumbnail with no extra padding */
.thumb-wrap.locked { background: var(--png-bg); }
.thumb-wrap.locked img { object-fit: cover; padding: 0; }

/* download button under the thumbnail (logged-in only) */
.card-foot { padding: 10px; }
.dl-btn {
  width: 100%; border: 1px solid var(--filter-active); background: var(--filter-active);
  color: #fff; font-family: inherit; font-size: 11px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  padding: 9px 10px; border-radius: 4px; cursor: pointer; transition: filter .15s ease, opacity .15s ease;
}
.dl-btn:hover:not(:disabled) { filter: brightness(1.08); }
.dl-btn:disabled { opacity: .5; cursor: not-allowed; }
.dl-btn.unlocked { background: var(--surface); color: var(--brand-brown-dark); border-color: var(--accent); }

.empty-note { grid-column: 1/-1; color: var(--brand-tan); font-size: 14px; text-align:center; padding: 60px 20px; line-height:1.6; }

/* ---- Gallery (styled-scene masonry) ---- */
.gallery-intro { max-width: 760px; margin: 4px 0 22px; }
.gallery-intro h2 { font-size: clamp(20px, 2.6vw, 28px); font-weight: 700; color: var(--brand-brown-dark); letter-spacing: -.3px; margin-bottom: 6px; }
.gallery-intro p { font-size: 15px; line-height: 1.6; color: var(--brand-tan); }
.masonry { column-count: 4; column-gap: 16px; }
@media (max-width: 1200px){ .masonry { column-count: 3; } }
@media (max-width: 760px){ .masonry { column-count: 2; } }
@media (max-width: 460px){ .masonry { column-count: 1; } }
.masonry .scene { break-inside: avoid; margin: 0 0 16px; border-radius: var(--radius); overflow: hidden; cursor: zoom-in; display: block; border: 1px solid var(--line); background: var(--png-bg); }
.masonry .scene img { width: 100%; display: block; }
.masonry .scene:hover { border-color: var(--accent); }

/* ---- Pagination ---- */
.pager { display:flex; justify-content:center; align-items:center; gap:6px; margin-top: 34px; flex-wrap:wrap; }
.pager button {
  border: 1px solid var(--accent); background: var(--surface);
  color: var(--brand-brown-dark); font-family: inherit; font-size: 13px; font-weight: 600;
  min-width: 38px; padding: 8px 12px; border-radius: 4px; cursor: pointer; transition: all .2s ease;
}
.pager button:hover:not(:disabled) { background: var(--accent-soft); }
.pager button.on { background: var(--filter-active); color:#fff; border-color: var(--filter-active); }
.pager button:disabled { opacity:.4; cursor: default; }
.pager .gap { color: var(--brand-tan); padding: 0 2px; }

/* ---- Lightbox (native ratio, scaled to screen) ---- */
.lightbox {
  position: fixed; inset: 0; z-index: 1000; display: none;
  align-items: center; justify-content: center;
  background: rgba(30,22,16,.92); backdrop-filter: blur(2px);
}
.lightbox.open { display: flex; }
.lb-stage { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 64px 72px; }
/* a soft neutral panel behind transparent PNGs so they read nicely */
.lb-frame { background: var(--png-bg); border-radius: 8px; box-shadow: 0 16px 50px rgba(0,0,0,.55); padding: 14px; }
.lb-frame.bare { background: transparent; box-shadow: none; padding: 0; }
.lb-stage img {
  max-width: 86vw; max-height: 82vh; object-fit: contain; display: block; border-radius: 4px;
}
.lb-close, .lb-nav {
  position: absolute; z-index: 1001; border: 0; cursor: pointer; color: #fff;
  background: rgba(255,255,255,.12); border-radius: 50%; line-height: 1;
}
.lb-close:hover, .lb-nav:hover { background: rgba(255,255,255,.26); }
.lb-close { top: 18px; right: 22px; width: 42px; height: 42px; font-size: 26px; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 50px; height: 50px; font-size: 30px; }
.lb-prev { left: 18px; } .lb-next { right: 18px; }
.lb-dl {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 1001;
  border: 1px solid #fff; background: rgba(255,255,255,.14); color: #fff; font-family: inherit;
  font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  padding: 10px 20px; border-radius: 4px; cursor: pointer;
}
.lb-dl:hover { background: #fff; color: var(--brand-brown-dark); }
@media (max-width: 560px){
  .lb-stage { padding: 56px 16px; }
  .lb-nav { width: 42px; height: 42px; font-size: 24px; }
  .lb-prev { left: 8px; } .lb-next { right: 8px; }
}

/* ---- Modal (header popups + login) ---- */
.modal {
  position: fixed; inset: 0; z-index: 1100; display: none;
  align-items: center; justify-content: center; padding: 24px;
  background: rgba(30,22,16,.55); backdrop-filter: blur(2px);
}
.modal.open { display: flex; }
.modal-card {
  background: var(--surface); border-radius: 8px; box-shadow: 0 20px 60px rgba(40,28,18,.35);
  width: 100%; max-width: 520px; max-height: 86vh; overflow: auto; padding: 30px 32px 32px;
  position: relative;
}
.modal-card h2 {
  font-size: 24px; font-weight: 700; color: var(--brand-brown-dark); margin-bottom: 14px; letter-spacing: -.3px;
}
.modal-card p { font-size: 15px; line-height: 1.6; color: var(--neutral-700); margin-bottom: 12px; }
.modal-card p.tip { font-size: 13px; color: var(--brand-tan); margin-top: 6px; }
.modal-card a { color: var(--brand-brown); }
.modal-close {
  position: absolute; top: 14px; right: 16px; width: 34px; height: 34px;
  border: 0; background: var(--accent-soft); color: var(--brand-brown-dark);
  border-radius: 50%; font-size: 20px; cursor: pointer; line-height: 1;
}
.modal-close:hover { background: var(--accent); color: #fff; }

/* login form */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; font-weight: 600; color: var(--brand-tan); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--accent); border-radius: var(--radius);
  font-family: inherit; font-size: 15px; color: var(--neutral-700); background: var(--bg-cream);
}
.field input:focus { outline: none; border-color: var(--brand-brown); background: #fff; }
.modal-card .primary {
  width: 100%; border: 1px solid var(--filter-active); background: var(--filter-active); color: #fff;
  font-family: inherit; font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  padding: 12px; border-radius: var(--radius); cursor: pointer; margin-top: 4px;
}
.modal-card .primary:hover { filter: brightness(1.08); }
.form-msg { font-size: 13px; margin-top: 12px; min-height: 18px; }
.form-msg.error { color: #b23b2e; }
.form-msg.ok { color: #2f7d4f; }
