/* ============================================================
   FORMA — After Hours
   Dark editorial studio catalogue.
   Ink ground, cream type, ember accent, hairline ledger rows.
   ============================================================ */

/* ---------- Fonts (local, no runtime CDN) ---------- */
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("assets/fonts/space-grotesk-400.woff2") format("woff2");
}
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("assets/fonts/space-grotesk-500.woff2") format("woff2");
}
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("assets/fonts/space-grotesk-700.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("assets/fonts/ibm-plex-mono-400.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("assets/fonts/ibm-plex-mono-500.woff2") format("woff2");
}

/* ---------- Tokens ---------- */
:root {
  --ink: #131110;          /* page ground */
  --ink-2: #1c1815;        /* raised ground */
  --ink-3: #262019;        /* hover ground */
  --paper: #f2ebdd;        /* primary text */
  --paper-dim: #b3a892;    /* secondary text (6.5:1 on ink) */
  --ember: #ff5a26;        /* accent */
  --ember-deep: #c23c0f;
  --line: #332c24;         /* hairline */
  --line-strong: #4a4033;

  --font-sans: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --pad: clamp(20px, 4vw, 48px);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---------- Reset-ish ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: clip;
}
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
h1, h2, h3, p, ul, dl, dd, figure { margin: 0; }
ul { padding: 0; list-style: none; }

.container { max-width: 1240px; margin-inline: auto; padding-inline: var(--pad); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* Visible focus everywhere */
:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 3px;
  border-radius: 1px;
}

/* Grain overlay (decorative, static) */
.grain {
  position: fixed; inset: 0; z-index: 60; pointer-events: none; opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(19, 17, 16, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1240px; margin-inline: auto; padding: 12px var(--pad);
  display: flex; align-items: center; gap: 16px;
}
.brand {
  font-weight: 700; font-size: 22px; letter-spacing: 0.02em;
  text-transform: uppercase; text-decoration: none; color: var(--paper);
  display: inline-flex; align-items: baseline; gap: 6px;
}
.brand-spark { width: 13px; height: 13px; color: var(--ember); align-self: center; }
.topbar-note {
  margin-inline: auto 0;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--paper-dim);
}

/* Saved-only switch */
.switch {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 12px; min-height: 44px;
  border: 1px solid var(--line-strong);
  transition: border-color 180ms var(--ease), background 180ms var(--ease);
}
.switch:hover { border-color: var(--ember); }
.switch-track {
  width: 34px; height: 18px; border: 1px solid var(--line-strong);
  background: var(--ink-2); position: relative; flex: none;
  transition: background 180ms var(--ease), border-color 180ms var(--ease);
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px; width: 12px; height: 12px;
  background: var(--paper-dim);
  transition: transform 180ms var(--ease), background 180ms var(--ease);
}
.switch-text {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--paper);
}
.switch-count { color: var(--ember); margin-left: 4px; }
.switch[aria-pressed="true"] { border-color: var(--ember); background: rgba(255, 90, 38, 0.08); }
.switch[aria-pressed="true"] .switch-track { background: var(--ember); border-color: var(--ember); }
.switch[aria-pressed="true"] .switch-thumb { transform: translateX(16px); background: var(--ink); }

/* ============================================================
   Masthead
   ============================================================ */
.masthead { padding-top: clamp(28px, 4.5vh, 56px); padding-bottom: clamp(24px, 3.5vh, 40px); }
.eyebrow {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--ember); margin-bottom: 18px;
}
.eyebrow::before {
  content: ""; display: inline-block; width: 34px; height: 1px;
  background: var(--ember); vertical-align: middle; margin-right: 12px;
}
.headline {
  font-size: clamp(48px, 8.2vw, 108px);
  line-height: 0.94; font-weight: 700; letter-spacing: -0.015em;
  text-transform: uppercase;
  text-wrap: balance;
}
.headline-dot { color: var(--ember); }
.lede {
  margin-top: 22px; max-width: 52ch;
  font-size: clamp(16px, 1.4vw, 19px); line-height: 1.6; color: var(--paper-dim);
}
.lede em { color: var(--paper); font-style: normal; }

/* Ticker */
.ticker {
  border-block: 1px solid var(--line);
  overflow: hidden; white-space: nowrap;
  padding-block: 9px;
  display: none;
}
.ticker-track {
  display: inline-flex; width: max-content;
  animation: ticker 30s linear infinite;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.3em;
  text-transform: uppercase; color: var(--paper-dim);
}
.ticker-track span:nth-child(2) { color: var(--ember); }
@keyframes ticker { to { transform: translateX(-50%); } }

/* ============================================================
   Query bar
   ============================================================ */
.querybar {
  position: sticky; top: 69px; z-index: 30;
  background: rgba(19, 17, 16, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.querybar-inner {
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) minmax(200px, 1fr) auto;
  gap: clamp(16px, 3vw, 40px);
  align-items: end;
  padding-block: 16px 18px;
}
.field-label {
  display: block; margin-bottom: 8px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--paper-dim);
}
.field-input, .field-select {
  width: 100%;
  background: transparent; color: var(--paper);
  border: none; border-bottom: 1px solid var(--line-strong);
  font-family: var(--font-mono); font-size: 15px;
  padding: 10px 2px; min-height: 44px;
  border-radius: 0;
  transition: border-color 160ms var(--ease);
}
.field-input::placeholder { color: #8a8073; }
.field-input:hover, .field-select:hover { border-color: var(--paper-dim); }
.field-input:focus, .field-select:focus {
  outline: none; border-bottom-color: var(--ember);
  box-shadow: 0 1px 0 var(--ember);
}
.field-select {
  appearance: none; -webkit-appearance: none;
  padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1 L6 6 L11 1' fill='none' stroke='%23f2ebdd' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 4px center;
}
.field-select option { background: var(--ink-2); color: var(--paper); }
.result-count {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--paper-dim);
  padding-bottom: 14px; white-space: nowrap;
}

/* ============================================================
   Catalogue layout: ledger + preview
   ============================================================ */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.9fr);
  gap: clamp(24px, 3.5vw, 56px);
  padding-top: clamp(24px, 4vh, 44px);
  padding-bottom: clamp(48px, 8vh, 96px);
  align-items: start;
}

/* Rows */
.list { border-top: 1px solid var(--line); }
.row {
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 20px;
  transition: background 160ms var(--ease);
}
.row:hover, .row:focus-within { background: var(--ink-2); }
.row-main {
  display: flex; align-items: baseline; gap: clamp(12px, 1.6vw, 22px);
  text-align: left; padding: clamp(14px, 2.2vh, 20px) 6px;
  width: 100%; min-height: 44px;
  position: relative;
}
.row-main::after {           /* ember underline sweep */
  content: ""; position: absolute; left: 0; right: 100%; bottom: 0;
  height: 2px; background: var(--ember);
  transition: right 260ms var(--ease);
}
.row:hover .row-main::after, .row:focus-within .row-main::after { right: 0; }
.row-no {
  font-family: var(--font-mono); font-size: 12px; color: var(--paper-dim);
  flex: none; width: 2.4em; letter-spacing: 0.08em;
  transition: color 160ms var(--ease);
}
.row:hover .row-no, .row:focus-within .row-no { color: var(--ember); }
.row-thumb { display: none; }
.row-info { min-width: 0; }
.row-title {
  display: block;
  font-size: clamp(19px, 1.9vw, 26px); font-weight: 500; letter-spacing: -0.01em;
  color: var(--paper); line-height: 1.15;
  transition: color 160ms var(--ease);
}
.row:hover .row-title, .row:focus-within .row-title { color: var(--ember); }
.row-meta {
  display: block; margin-top: 6px;
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--paper-dim);
}
.row-side {
  display: flex; align-items: center; gap: 14px;
  padding-right: 6px;
}
.row-price {
  font-family: var(--font-mono); font-size: 15px; font-weight: 500;
  color: var(--paper); white-space: nowrap;
}
.chip-saved {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ember);
  border: 1px solid var(--ember); padding: 4px 8px; white-space: nowrap;
}

/* Preview column */
.preview-col { position: sticky; top: 170px; }
.preview-frame {
  border: 1px solid var(--line-strong);
  padding: 10px; background: var(--ink-2);
}
.preview-frame img {
  width: 100%; aspect-ratio: 4 / 5; object-fit: cover;
  filter: saturate(0.92);
  transition: opacity 280ms var(--ease);
}
.preview-frame img.is-swapping { opacity: 0; }
.preview-caption {
  display: flex; justify-content: space-between; gap: 16px; align-items: baseline;
  margin-top: 12px;
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.08em;
  text-transform: uppercase;
}
#previewTitle { color: var(--paper); }
#previewMeta { color: var(--paper-dim); text-align: right; }

/* Empty state */
.empty {
  border: 1px dashed var(--line-strong);
  padding: clamp(32px, 5vh, 56px) clamp(20px, 4vw, 48px);
  text-align: center;
  display: grid; gap: 10px; justify-items: center;
  background: var(--ink-2);
}
.empty-title { font-size: clamp(20px, 2vw, 26px); font-weight: 700; text-transform: uppercase; letter-spacing: 0.01em; }
.empty-text { color: var(--paper-dim); max-width: 40ch; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 13px 20px; min-height: 44px;
  border: 1px solid var(--line-strong); color: var(--paper);
  transition: border-color 160ms var(--ease), background 160ms var(--ease), color 160ms var(--ease);
}
.btn:hover { border-color: var(--ember); color: var(--ember); }
.btn-solid { background: var(--ember); border-color: var(--ember); color: #16100c; font-weight: 500; }
.btn-solid:hover { background: var(--paper); border-color: var(--paper); color: var(--ink); }
.icon { width: 15px; height: 15px; flex: none; }

/* ============================================================
   Studio strip
   ============================================================ */
.studio-strip { padding-top: 12px; padding-bottom: clamp(56px, 9vh, 104px); }
.strip-title {
  font-size: clamp(22px, 2.6vw, 34px); text-transform: uppercase; font-weight: 700;
  letter-spacing: -0.01em; margin-bottom: 24px;
}
.strip-grid {
  display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: clamp(16px, 2.5vw, 32px);
  align-items: stretch;
}
.strip-figure { border-top: 1px solid var(--line); padding-top: 14px; }
.strip-figure img {
  width: 100%; aspect-ratio: 4 / 5; object-fit: cover;
  filter: saturate(0.9);
}
.strip-figure figcaption {
  margin-top: 10px; font-family: var(--font-mono); font-size: 11.5px;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--paper-dim);
}
.strip-copy {
  align-self: center; color: var(--paper-dim); font-size: 17px; line-height: 1.65;
  max-width: 40ch;
  border-top: 1px solid var(--line); padding-top: 14px;
}
.strip-note { display: block; margin-top: 14px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: #988c74; }

/* ============================================================
   Footer
   ============================================================ */
.footer { border-top: 1px solid var(--line); background: var(--ink-2); }
.footer-inner {
  display: flex; flex-wrap: wrap; gap: 12px 32px; align-items: baseline;
  padding-block: 26px;
}
.footer-brand { font-weight: 700; font-size: 20px; text-transform: uppercase; }
.footer-dot { color: var(--ember); }
.footer-note { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; color: var(--paper-dim); }

/* ============================================================
   Detail dialog
   ============================================================ */
.detail {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: clamp(10px, 3vh, 32px);
}
.detail[hidden] { display: none; }
.detail-backdrop {
  position: absolute; inset: 0;
  background: rgba(10, 8, 7, 0.78);
  backdrop-filter: blur(3px);
  animation: fade-in 220ms var(--ease) both;
}
.detail-panel {
  position: relative;
  width: min(1060px, 100%);
  max-height: min(92vh, 100%);
  overflow-y: auto;
  background: var(--ink);
  border: 1px solid var(--line-strong);
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) 1.1fr;
  animation: panel-in 320ms var(--ease) both;
}
.detail.is-closing .detail-backdrop { animation: fade-out 200ms var(--ease) both; }
.detail.is-closing .detail-panel { animation: panel-out 200ms var(--ease) both; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes panel-in { from { opacity: 0; transform: translateY(26px); } }
@keyframes panel-out { to { opacity: 0; transform: translateY(18px); } }

.detail-close {
  position: absolute; top: 14px; right: 14px; z-index: 5;
  width: 44px; height: 44px; min-height: 44px;
  display: grid; place-items: center;
  background: var(--ink);
  border: 1px solid var(--line-strong);
  transition: border-color 160ms var(--ease), color 160ms var(--ease);
}
.detail-close:hover { border-color: var(--ember); color: var(--ember); }
.detail-close .icon { width: 16px; height: 16px; }

.detail-media { position: relative; border-bottom: none; }
.detail-media img {
  width: 100%; height: 100%; min-height: 280px;
  object-fit: cover; filter: saturate(0.92);
}
.detail-media figcaption {
  position: absolute; left: 12px; bottom: 12px;
  background: rgba(19, 17, 16, 0.85);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--paper-dim);
  padding: 5px 9px;
}
.detail-content { padding: clamp(28px, 4.5vh, 52px) clamp(22px, 3.5vw, 52px); }
.detail-eyebrow {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--ember); margin-bottom: 14px;
}
.detail-title {
  font-size: clamp(30px, 3.6vw, 48px); font-weight: 700; line-height: 1.02;
  letter-spacing: -0.015em; text-transform: uppercase;
  padding-right: 44px;
  text-wrap: balance;
}
.detail-body {
  margin-top: 18px; font-size: clamp(16px, 1.4vw, 18px); line-height: 1.65;
  color: var(--paper-dim); max-width: 46ch;
}
.detail-meta {
  margin-top: 26px;
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr 1fr;
}
.detail-meta > div {
  display: flex; gap: 18px; justify-content: space-between;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}
.detail-meta > div:nth-last-child(-n+2) { border-bottom: none; }
.detail-meta dt {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--paper-dim); align-self: center;
}
.detail-meta dd {
  font-family: var(--font-mono); font-size: 14px; color: var(--paper);
  text-align: right;
}
.detail-actions { margin-top: 28px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.btn-save .icon-heart { transition: fill 160ms var(--ease); }
.btn-save[aria-pressed="true"] { background: var(--paper); border-color: var(--paper); color: var(--ink); }
.btn-save[aria-pressed="true"] .icon-heart { fill: currentColor; }
.detail-saved-note {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--paper-dim);
}
.detail-nav {
  margin-top: 30px; padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 12px;
}

/* ============================================================
   Responsive — mobile
   ============================================================ */
@media (max-width: 960px) {
  .ticker { display: block; }
  .layout { grid-template-columns: 1fr; }
  .preview-col { display: none; }
  .row-thumb {
    display: block; flex: none;
    width: 74px; aspect-ratio: 1; object-fit: cover;
    filter: saturate(0.9);
    align-self: center;
  }
  .row-main { align-items: center; gap: 14px; }
  .strip-grid { grid-template-columns: 1fr 1fr; }
  .strip-copy { grid-column: 1 / -1; }
  .detail-panel { grid-template-columns: 1fr; max-height: 94vh; }
  .detail-media img { min-height: 0; height: 34vh; }
}

@media (max-width: 640px) {
  .topbar-note { display: none; }
  .querybar-inner { grid-template-columns: 1fr; gap: 14px; padding-block: 14px; }
  .result-count { padding-bottom: 2px; }
  .row-side { flex-direction: column; align-items: flex-end; gap: 8px; }
  .row-meta { font-size: 10.5px; }
  .strip-grid { grid-template-columns: 1fr; }
  .detail-title { padding-right: 0; }
  .detail-close { top: 8px; right: 8px; }
  .detail-content { padding: 26px 20px 32px; }
  .detail-nav .btn { padding-inline: 14px; }
  .footer-inner { flex-direction: column; gap: 8px; }
}

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .ticker-track { animation: none; }
}
