/* ==========================================================================
   Gamma Pixel Studios — portrait studio
   Design:  printed-magazine editorial. Newsprint cover + inverted portfolio.
   Palette: warm paper stock, process black, editorial red.
   Type:    Srisakdi (brand wordmark) / Bodoni Moda (didone display) /
            Instrument Sans (body) / IBM Plex Mono (labels)
   ========================================================================== */

:root {
  --paper:    #f2ede2;   /* page stock                         */
  --paper-2:  #e7e0d1;   /* tinted panels                      */
  --ink:      #14110e;   /* process black — text & portfolio    */
  --ink-2:    #211c17;   /* raised surface in the portfolio     */
  --muted:    #6f665a;   /* secondary text on paper             */
  --muted-dk: #9a9082;   /* secondary text on ink               */
  --red:      #dc3018;   /* editorial red                       */
  --red-dk:   #b32410;

  --rule:     color-mix(in srgb, var(--ink) 22%, transparent);
  --rule-ink: color-mix(in srgb, var(--paper) 20%, transparent);

  --font-brand: "Srisakdi", "Bodoni Moda", serif;   /* wordmark & brand only */
  --font-display: "Bodoni Moda", "Times New Roman", serif;
  --font-body: "Instrument Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --gap: 8px;
  --pad: clamp(14px, 4vw, 56px);
  --nav-h: 48px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
::selection { background: var(--red); color: var(--paper); }

.mono {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Hairlines and heavy rules — the backbone of the layout. */
.rule { height: 1px; background: var(--rule); }
.rule-thick { height: 4px; background: var(--ink); }

/* ===== Cover masthead ========================================== */

.masthead { padding: 14px var(--pad) 0; }

.mh-meta,
.mh-sub {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; padding: 8px 0;
}
.mh-meta-mid { color: var(--red); }

.mh-word {
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: clamp(44px, 13.6vw, 230px);
  line-height: 1.02;
  overflow: hidden;
  /* Srisakdi is a script — set it in its natural case, untracked. */
  letter-spacing: 0;
  text-align: center;
  padding: clamp(6px, 1.4vw, 18px) 0 clamp(2px, .8vw, 10px);
  white-space: nowrap;
}
/* JS sizes .fit-word so the wordmark spans the measure exactly; the clamp
   above is the no-JS fallback. */
.fit-word { display: inline-block; }
.fit-line { display: block; }

.mh-tagline {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(14px, 1.8vw, 20px);
  text-align: center;
}

/* ===== Sticky index rail ======================================= */

.menubar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  height: var(--nav-h);
  padding: 0 var(--pad);
  background: var(--ink);
  color: var(--paper);
}

.brand { display: flex; align-items: center; gap: 9px; }
.brand-name {
  font-family: var(--font-brand); font-weight: 700; font-size: 19px;
  letter-spacing: .01em;
}
.brand-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); }

.menu { display: flex; align-items: center; gap: 22px; font-size: 13.5px; font-weight: 500; }
.menu > a { display: inline-flex; align-items: baseline; gap: 7px; color: var(--paper); opacity: .72; transition: opacity .18s ease, color .18s ease; }
.menu > a:hover, .menu > a:focus-visible { opacity: 1; color: var(--paper); }
.menu .num { color: var(--red); font-size: 10px; }

.menu-wa {
  padding: 6px 13px;
  border: 1px solid var(--rule-ink);
  opacity: 1 !important;
}
.menu-wa:hover { background: var(--red); border-color: var(--red); }

.menu-toggle { display: none; flex-direction: column; gap: 5px; padding: 8px; }
.menu-toggle span { width: 20px; height: 2px; background: var(--paper); }

.progress { position: absolute; left: 0; bottom: 0; height: 2px; width: 0; background: var(--red); }

/* ===== Offer ticker ============================================ */

.ticker {
  overflow: hidden;
  background: var(--red);
  color: var(--paper);
  border-bottom: 1px solid var(--ink);
  padding: 7px 0;
}
.ticker-track { display: flex; width: max-content; animation: marquee 42s linear infinite; }
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker-item {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; white-space: nowrap;
  padding: 0 22px;
}
.ticker-item::after { content: "✳"; padding-left: 22px; opacity: .6; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ===== Feature spread ========================================== */

.hero { padding: clamp(28px, 5vw, 70px) var(--pad) clamp(24px, 4vw, 56px); }

.hero-kicker { margin-bottom: clamp(14px, 2vw, 26px); }
.hero-kicker .ast { color: var(--red); font-size: 13px; margin-right: 6px; }

.hero-title {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 900;
  font-size: clamp(40px, 8.6vw, 138px);
  line-height: .92;
  letter-spacing: -0.035em;
}
.hero-title em { font-style: italic; font-weight: 400; color: var(--red); }

.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1.55fr .82fr;
  gap: clamp(18px, 2.6vw, 40px);
  margin-top: clamp(26px, 4vw, 56px);
  padding-top: 18px;
  border-top: 1px solid var(--rule);
}

.lede { font-size: 17px; line-height: 1.5; }
.lede::first-letter {
  float: left;
  font-family: var(--font-display); font-weight: 900;
  font-size: 4.4em; line-height: .76;
  padding: .04em .1em 0 0;
  color: var(--red);
}
.hero-byline { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--rule); }

.hero-figure { position: relative; }
.hero-figure img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  filter: saturate(.92) contrast(1.04);
}
.hero-figure figcaption {
  display: flex; justify-content: space-between; gap: 12px;
  padding-top: 8px; margin-top: 8px;
  border-top: 1px solid var(--rule);
}
.hero-figure .cap-text { font-family: var(--font-display); font-style: italic; font-size: 14px; }

.hero-index-head { padding-bottom: 8px; border-bottom: 2px solid var(--ink); color: var(--ink); }
.issue-list { list-style: none; counter-reset: coll; }
.issue-list li {
  display: flex; align-items: baseline; gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 14px;
}
.issue-list a { display: flex; align-items: baseline; gap: 10px; width: 100%; }
.issue-list .il-no { font-family: var(--font-mono); font-size: 10px; color: var(--red); }
.issue-list .il-name {
  font-family: var(--font-display); font-weight: 500; font-size: 17px;
  text-transform: capitalize; transition: color .16s ease;
}
.issue-list .il-dots { flex: 1; border-bottom: 1px dotted var(--rule); transform: translateY(-4px); }
.issue-list .il-count { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.issue-list li:hover .il-name { color: var(--red); }

/* ===== Section heads =========================================== */

.sec-head {
  display: flex; align-items: baseline; gap: 14px;
  padding-bottom: 10px;
  border-bottom: 4px solid currentColor;
}
.sec-no { color: var(--red) !important; font-size: 12px; }
.sec-title {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(24px, 3.6vw, 46px);
  letter-spacing: -0.02em; line-height: 1;
  text-transform: uppercase;
}
.sec-note { margin-left: auto; text-align: right; }

/* ===== Notices (offers) ======================================== */

.notices { padding: clamp(20px, 3vw, 44px) var(--pad) clamp(30px, 5vw, 64px); }

.notice-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.notice {
  padding: clamp(18px, 2vw, 30px) clamp(14px, 1.8vw, 28px);
  border-right: 1px solid var(--rule);
  transition: background .22s ease, color .22s ease;
}
/* Column rules run per row of three, so any number of notices sits cleanly. */
.notice:nth-child(3n+1) { padding-left: 0; }
.notice:nth-child(3n) { border-right: 0; padding-right: 0; }
.notice:nth-child(n+4) { border-top: 1px solid var(--rule); }

.notice-no {
  display: block;
  font-family: var(--font-display); font-weight: 900;
  font-size: clamp(54px, 6vw, 88px); line-height: .8;
  color: transparent;
  -webkit-text-stroke: 1.4px var(--ink);
  transition: -webkit-text-stroke-color .22s ease, color .22s ease;
  margin-bottom: 14px;
}
.notice-title {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(19px, 1.9vw, 25px); line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}
.notice-price {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px;
  margin-bottom: 10px;
}
.notice-was {
  font-family: var(--font-display); font-size: 17px;
  color: var(--muted); text-decoration-thickness: 1.5px;
  transition: color .22s ease;
}
.notice-now {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(21px, 2.1vw, 28px); line-height: 1;
  letter-spacing: -0.01em; color: var(--red);
}
.notice-off {
  font-size: 10px; color: var(--red);
  border: 1px solid var(--red); padding: 3px 7px;
}
.notice-desc { color: var(--muted); font-size: 14.5px; transition: color .22s ease; }
.notice-badge {
  display: inline-block; margin-top: 14px;
  padding: 4px 10px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase;
  background: var(--ink); color: var(--paper);
  transition: background .22s ease, color .22s ease;
}

.notice-note {
  margin-top: clamp(14px, 1.6vw, 22px);
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  color: var(--red);
}

.notice:hover { background: var(--ink); color: var(--paper); }
.notice:hover .notice-no { -webkit-text-stroke-color: var(--red); }
.notice:hover .notice-desc, .notice:hover .notice-was { color: var(--muted-dk); }
.notice:hover .notice-badge { background: var(--red); color: var(--paper); }

/* ===== The portfolio (inverted section) =========================== */

.portfolio {
  background: var(--ink);
  color: var(--paper);
  padding: clamp(28px, 4vw, 60px) 0 clamp(20px, 3vw, 40px);
  scroll-margin-top: var(--nav-h);
}
.portfolio .mono { color: var(--muted-dk); }
.portfolio-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 14px;
  margin: 0 var(--pad);
  padding-bottom: 12px;
  border-bottom: 4px solid var(--paper);
}
.portfolio-head .sec-title { font-size: clamp(30px, 5.4vw, 76px); }
.portfolio-head .sec-note { margin-left: auto; text-align: right; }

/* ===== Toolbar ================================================= */

.toolbar {
  position: sticky; top: var(--nav-h); z-index: 30;
  display: flex; flex-wrap: wrap; gap: 14px;
  align-items: center; justify-content: space-between;
  padding: 12px var(--pad);
  margin-bottom: 14px;
  background: var(--ink);
  border-bottom: 1px solid var(--rule-ink);
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 13px;
  border: 1px solid var(--rule-ink);
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted-dk);
  transition: color .15s, border-color .15s, background .15s;
}
.chip:hover { color: var(--paper); border-color: var(--paper); }
.chip.is-active { color: var(--paper); background: var(--red); border-color: var(--red); }
.chip .count { opacity: .6; margin-left: 6px; }

.controls { display: flex; align-items: center; gap: 16px; }
.control { display: flex; align-items: center; gap: 9px; }
.control-label { font-size: 10px; }

select {
  background: var(--ink-2); color: var(--paper);
  border: 1px solid var(--rule-ink); border-radius: 0;
  padding: 6px 9px; font: inherit; font-size: 13px;
}

.layout-switch button {
  padding: 6px 8px; border: 1px solid var(--rule-ink); color: var(--muted-dk);
  margin-left: -1px;
}
.layout-switch button:hover { color: var(--paper); }
.layout-switch button.is-active { color: var(--paper); background: var(--red); border-color: var(--red); }

/* ===== Gallery ================================================= */

.gallery-wrap { padding: 0 var(--pad) 20px; }

.card {
  position: relative;
  overflow: hidden;
  background: var(--ink-2);
  cursor: pointer;
  animation: rise .55s cubic-bezier(.2, .7, .3, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.card img {
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0;
  filter: saturate(.86) contrast(1.05);
  transition: opacity .5s ease, transform .6s cubic-bezier(.2,.7,.3,1), filter .4s ease;
}
.card img.is-loaded { opacity: 1; }
.card:hover img { transform: scale(1.04); filter: saturate(1.05) contrast(1); }

/* Plate number, printed in the corner. */
.card-no {
  position: absolute; top: 0; left: 0; z-index: 2;
  padding: 4px 8px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: .1em;
  background: var(--paper); color: var(--ink);
}

/* Caption slab slides up like a pasted-on label. */
.card-veil {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 11px;
  background: var(--paper); color: var(--ink);
  transform: translateY(101%);
  transition: transform .3s cubic-bezier(.2, .7, .3, 1);
}
@media (hover: hover) {
  .card:hover .card-veil { transform: translateY(0); }
}
/* On touch there is no hover: the first tap reveals the caption (gallery.js),
   the second opens the plate. */
.card:focus-within .card-veil,
.card.is-revealed .card-veil { transform: translateY(0); }

.card-cap { min-width: 0; }
.card-name {
  display: block;
  font-family: var(--font-display); font-style: italic; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-tag {
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase; color: var(--red);
}

.card-share {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: var(--ink); color: var(--paper);
}
.card-share:hover { background: var(--red); }

/* --- Justified rows (justifyRows() sizes each row in js) --- */
.layout-justified { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--gap); }
.layout-justified .card { flex: 0 0 auto; }

/* --- Masonry (CSS columns) --- */
.layout-masonry { columns: 4 250px; column-gap: var(--gap); }
.layout-masonry .card { margin-bottom: var(--gap); break-inside: avoid; }

/* --- Square grid --- */
.layout-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--gap); }
.layout-grid .card { aspect-ratio: 1 / 1; }

/* ===== Infinite scroll sentinel ================================ */

.sentinel { display: flex; justify-content: center; padding: 34px 0; }
.loader { animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .3; } }
.gallery-end {
  text-align: center; padding: 26px 0 6px;
  color: var(--muted-dk) !important;
}

/* ===== Correspondence ========================================== */

.contact {
  padding: clamp(34px, 5vw, 74px) var(--pad) clamp(24px, 3vw, 48px);
  scroll-margin-top: var(--nav-h);
}
.contact-grid {
  display: grid; grid-template-columns: 1.2fr 1fr;
  gap: clamp(20px, 3vw, 48px);
  padding-top: 22px;
}
.contact-copy {
  font-family: var(--font-display);
  font-size: clamp(19px, 2.3vw, 30px);
  line-height: 1.28;
  letter-spacing: -0.01em;
}
.contact-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 24px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.btn-red { background: var(--red); color: var(--paper); }
.btn-red:hover { background: var(--ink); }
.btn-ghost { border: 1px solid var(--ink); }
.btn-ghost:hover { background: var(--ink); color: var(--paper); }

/* ===== Colophon ================================================ */

.footer { padding: 0 var(--pad) 30px; overflow: hidden; }
.colophon-word {
  font-family: var(--font-brand); font-weight: 700;
  font-size: clamp(44px, 13.6vw, 230px); line-height: 1.02;
  letter-spacing: 0;
  text-align: center; white-space: nowrap; overflow: hidden;
  color: transparent;
  -webkit-text-stroke: 1px var(--rule);
  user-select: none;
}
.footer .mono { padding-top: 14px; text-align: center; }

.totop {
  position: fixed; right: 0; bottom: clamp(16px, 4vh, 44px); z-index: 35;
  writing-mode: vertical-rl;
  padding: 12px 7px;
  background: var(--ink); color: var(--paper) !important;
  font-size: 10px;
}
.totop:hover { background: var(--red); }

/* ===== Cursor badge (plate pages, fine pointers only) ========== */

.cursor-badge {
  position: fixed; z-index: 55; top: 0; left: 0;
  padding: 7px 12px;
  background: var(--red); color: var(--paper) !important;
  font-size: 10px;
  pointer-events: none;
  opacity: 0; transform: translate(-50%, -160%) scale(.7);
  transition: opacity .18s ease, transform .18s ease;
}
.cursor-badge.is-on { opacity: 1; transform: translate(-50%, -160%) scale(1); }
@media (hover: none), (pointer: coarse) { .cursor-badge { display: none; } }

/* ===== Lightbox ================================================ */

.lightbox {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column;
  background: var(--ink);
  padding: clamp(44px, 6vh, 70px) var(--pad) 0;
}
/* The hidden attribute must always win over display:flex above. */
.lightbox[hidden] { display: none; }

.lb-figure { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.lb-figure img { max-height: 100%; max-width: 100%; width: auto; object-fit: contain; }

.lb-bar {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 12px 0 16px; margin-top: 12px;
  border-top: 1px solid var(--rule-ink);
  color: var(--paper);
}
.lb-label { min-width: 0; }
.lb-label .mono { color: var(--muted-dk); }
.lb-title {
  display: block;
  font-family: var(--font-display); font-style: italic; font-size: clamp(16px, 2.2vw, 24px);
}
.lb-tools { display: flex; align-items: center; gap: 8px; }

.lb-share {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; background: var(--red); color: var(--paper) !important;
}
.lb-share:hover { background: var(--red-dk); }

.lb-nav {
  width: 40px; height: 38px;
  border: 1px solid var(--rule-ink); color: var(--paper);
  font-size: 22px; line-height: 1;
}
.lb-nav:hover { background: var(--paper); color: var(--ink); }

.lb-close {
  position: absolute; top: 14px; right: var(--pad);
  color: var(--paper) !important;
  padding: 8px 0;
}
.lb-close:hover { color: var(--red) !important; }

/* ===== Focus & responsive ====================================== */

:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

@media (max-width: 1080px) {
  .hero-grid { grid-template-columns: 1fr 1fr; }
  .hero-index { grid-column: 1 / -1; padding-top: 8px; border-top: 1px solid var(--rule); }
  .notice-grid { grid-template-columns: 1fr 1fr; }
  .notice {
    padding-left: clamp(14px, 1.8vw, 28px);
    padding-right: clamp(14px, 1.8vw, 28px);
    border-right: 1px solid var(--rule);
    border-top: 0;
  }
  .notice:nth-child(2n+1) { padding-left: 0; }
  .notice:nth-child(2n) { border-right: 0; padding-right: 0; }
  .notice:nth-child(n+3) { border-top: 1px solid var(--rule); }
}

@media (max-width: 720px) {
  .menu {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: flex-start; gap: 0;
    padding: 6px var(--pad) 16px;
    background: var(--ink);
    border-bottom: 1px solid var(--rule-ink);
    display: none;
  }
  .menu.is-open { display: flex; }
  .menu > a { padding: 11px 0; width: 100%; border-bottom: 1px solid var(--rule-ink); }
  .menu-wa { margin-top: 12px; border: 1px solid var(--rule-ink) !important; }
  .menu-toggle { display: flex; }

  .mh-meta-mid, .mh-sub .mono:last-child { display: none; }
  .hero-grid, .contact-grid { grid-template-columns: 1fr; }
  .notice-grid { grid-template-columns: 1fr; }
  .notice { border-right: 0 !important; padding-left: 0 !important; padding-right: 0 !important; }
  .notice + .notice { border-top: 1px solid var(--rule); }
  .toolbar { flex-direction: column; align-items: flex-start; }
  .controls { flex-wrap: wrap; gap: 12px; }
  .totop { display: none; }
  .lb-bar { flex-wrap: wrap; gap: 12px; }
}
