/* SamArt: a downtown-gourmet-grocer feel. Gallery-white walls, true-black type, silver hairlines,
   wide-tracked engraved capitals for signage (Marcellus) and a clean geometric sans for everything
   else (Jost). Square corners throughout. Both fonts are SIL OFL, self-hosted in /static/fonts. */

@font-face {
  font-family: "Marcellus";
  src: url("/static/fonts/marcellus-latin-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Jost";
  src: url("/static/fonts/jost-latin-wght.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f4f1;          /* paper */
  --ink: #111111;
  --muted: #6f6f6c;
  --line: #d6d6d3;               /* silver hairline */
  --silver: #a8a9ab;
  --accent: #111111;             /* black buttons, white type */
  --accent-ink: #ffffff;
  --fav: #111111;
  --shadow: 0 0 0 1px var(--line);
  --radius: 0px;
  --gutter: clamp(16px, 3vw, 40px);
  --display: "Marcellus", "Copperplate", "Optima", Georgia, serif;
  --sans: "Jost", "Futura", "Avenir Next", system-ui, sans-serif;
  --tile: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='36'%3E%3Cg fill='none' stroke='%23efefec' stroke-width='1'%3E%3Cpath d='M0 .5h72M0 18.5h72M.5 0v18M36.5 18v18'/%3E%3C/g%3E%3C/svg%3E");
  font-family: var(--sans);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d0d;
    --surface: #141414;
    --surface-2: #1b1b1b;
    --ink: #f1f1ee;
    --muted: #9b9b97;
    --line: #2d2d2b;
    --silver: #7d7e80;
    --accent: #f1f1ee;
    --accent-ink: #0d0d0d;
    --fav: #f1f1ee;
    --tile: none;
  }
}

* { box-sizing: border-box; }
/* Author display rules (e.g. .button { display: inline-flex }) must not override the hidden attribute. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
a { color: var(--ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }

/* Signage: wide-tracked capitals, the way a deli counter or shelf label reads. */
.eyebrow, .tagline, .link-button, .chip, .toggle, .button, legend, .options > label,
.result-count, .foot, .howto summary, th {
  font-family: var(--sans); text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.72rem; font-weight: 500;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---- header ---------------------------------------------------------------------------- */

.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--tile) center top / 72px 36px, var(--bg);
  border-bottom: 1px solid var(--ink);
  padding: 18px var(--gutter) 0;
}

.top-row {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding-bottom: 14px;
}

.brand {
  font-family: var(--display); font-weight: 400; font-size: clamp(1.7rem, 4.2vw, 2.6rem);
  letter-spacing: 0.3em; margin-right: -0.3em; /* optically re-center the tracking */
  text-transform: uppercase; color: var(--ink); text-decoration: none; line-height: 1.1;
}

.tagline { margin: 0; color: var(--muted); }

.top-links { position: absolute; right: 0; top: 4px; display: flex; gap: 18px; }
.link-button {
  background: none; border: 0; padding: 6px 0; color: var(--ink); cursor: pointer; text-decoration: none;
  border-bottom: 1px solid var(--ink);
}
@media (max-width: 640px) {
  .top-links { position: static; margin-top: 8px; }
}

.controls {
  display: flex; gap: 0; flex-wrap: wrap;
  border-top: 1px solid var(--line); background: var(--bg);
  margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter);
}
.controls > * { border-right: 1px solid var(--line); }
.controls > *:last-child { border-right: 0; }
.search { flex: 1 1 260px; }

input[type="search"], select {
  width: 100%; min-height: 46px; padding: 10px 14px;
  border: 0; border-radius: 0; background: transparent;
  font-family: var(--sans); font-size: 0.95rem;
}
select { appearance: none; padding-right: 34px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23111'/%3E%3C/svg%3E") no-repeat right 14px center;
}
@media (prefers-color-scheme: dark) {
  select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23f1f1ee'/%3E%3C/svg%3E"); }
}
select option { color: #111; }

input[type="search"]:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--ink); outline-offset: 2px;
}

.toggle {
  min-height: 46px; padding: 0 18px; cursor: pointer; border: 0; border-radius: 0;
  background: transparent; white-space: nowrap;
}
.toggle.on { background: var(--accent); color: var(--accent-ink); }
.toggle span { font-size: 0.9rem; }

/* Collections read like aisle signs: tracked capitals, a rule under the current one. */
.collections { display: grid; border-top: 1px solid var(--line); background: var(--bg); margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); }
.chip-row {
  display: flex; gap: 22px; overflow-x: auto; scrollbar-width: none; padding: 0 2px;
  justify-content: safe center;
}
.chip-row + .chip-row { border-top: 1px solid var(--line); }
.chip {
  min-height: 42px; padding: 0; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  background: none; cursor: pointer; white-space: nowrap; color: var(--muted);
}
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--ink); }

.banner {
  margin: 14px var(--gutter) 0; padding: 12px 16px; border: 1px solid var(--ink);
  background: var(--surface); color: var(--ink); font-size: 0.9rem;
}

/* ---- grid: goods on metro shelving ------------------------------------------------------ */

main { padding: 18px var(--gutter) 56px; }
.result-count, .favorites-note { color: var(--muted); margin: 6px 0 18px; }
.favorites-note { text-transform: none; letter-spacing: 0; font-size: 0.85rem; }

.grid {
  display: grid; column-gap: clamp(14px, 2.4vw, 32px); row-gap: clamp(22px, 3vw, 40px);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
}
@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.card { position: relative; background: transparent; border-bottom: 1px solid var(--silver); }
.card-link { display: block; color: inherit; text-decoration: none; }
.thumb { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); }
.thumb img {
  position: absolute; inset: 14px; width: calc(100% - 28px); height: calc(100% - 28px);
  object-fit: contain; filter: drop-shadow(0 3px 6px rgb(0 0 0 / 0.22));
}
.meta { padding: 12px 34px 14px 0; }
.meta h3 {
  margin: 0; font-family: var(--display); font-weight: 400; font-size: 0.98rem;
  letter-spacing: 0.06em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.meta p {
  margin: 3px 0 0; color: var(--muted); font-size: 0.82rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.fav {
  position: absolute; right: -6px; bottom: 12px; width: 34px; height: 34px;
  border: 0; background: transparent; color: var(--silver);
  font-size: 1.05rem; cursor: pointer; line-height: 1;
}
.fav:hover { color: var(--ink); }
.fav.on, .button.on { color: var(--fav); }

.empty { color: var(--muted); text-align: center; padding: 56px 0; }
#sentinel { height: 1px; }

.foot {
  padding: 28px var(--gutter) 44px; color: var(--muted); text-align: center;
  border-top: 1px solid var(--ink);
}
.foot p { margin: 0; }

/* ---- dialogs --------------------------------------------------------------------------- */

dialog {
  border: 1px solid var(--ink); padding: 0; color: var(--ink); background: var(--surface);
  border-radius: 0; box-shadow: 0 24px 70px rgb(0 0 0 / 0.3);
  max-width: min(1240px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); width: 100%;
}
dialog::backdrop { background: rgb(255 255 255 / 0.82); }
@media (prefers-color-scheme: dark) { dialog::backdrop { background: rgb(0 0 0 / 0.8); } }

.close {
  position: absolute; top: 10px; right: 12px; z-index: 2;
  width: 40px; height: 40px; border: 1px solid var(--ink); border-radius: 0;
  background: var(--surface); font-size: 1.4rem; line-height: 1; cursor: pointer;
}

.detail-body {
  position: relative; display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr);
}
@media (max-width: 820px) {
  .detail-body { grid-template-columns: 1fr; }
}

.stage {
  margin: 0; padding: clamp(18px, 3vw, 40px); background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
}
.screen {
  width: 100%; max-height: 70dvh; aspect-ratio: 16 / 9; background: #000;
  border: 10px solid #151515; box-shadow: 0 10px 30px rgb(0 0 0 / 0.25);
  display: flex; overflow: hidden;
}
.screen.portrait { width: auto; height: min(70dvh, 640px); }
.screen img { width: 100%; height: 100%; object-fit: contain; display: block; }
.stage figcaption { color: var(--muted); font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; text-align: center; }

.info { padding: clamp(22px, 3vw, 36px); padding-top: 30px; overflow-y: auto; max-height: calc(100dvh - 32px); }
@media (max-width: 820px) { .info { max-height: none; } }
.eyebrow { margin: 0; color: var(--muted); }
.info h2 {
  margin: 8px 44px 0 0; font-family: var(--display); font-weight: 400;
  font-size: clamp(1.5rem, 2.4vw, 2rem); line-height: 1.2; letter-spacing: 0.04em; text-transform: uppercase;
}
.artist { margin: 6px 0 0; color: var(--muted); font-size: 1rem; }
.description { white-space: pre-line; }
.description:empty, .artist:empty, .credit:empty, .eyebrow:empty { display: none; }
.credit { font-size: 0.88rem; color: var(--muted); }

.tags { list-style: none; padding: 0; margin: 16px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags button {
  border: 1px solid var(--line); background: transparent; border-radius: 0;
  padding: 3px 10px; font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; cursor: pointer;
}
.tags button:hover { border-color: var(--ink); }

.options { display: grid; gap: 14px; margin: 22px 0; padding-top: 18px; border-top: 1px solid var(--ink); }
.options > label { display: grid; gap: 6px; }
.options select { border: 1px solid var(--ink); text-transform: none; letter-spacing: 0; }
fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 0.92rem; }
legend { padding: 0; margin-bottom: 6px; }
fieldset label { display: flex; gap: 10px; align-items: center; cursor: pointer; }
input[type="radio"] { accent-color: var(--ink); }
.note { margin: 0; font-size: 0.85rem; color: var(--muted); }
#d-upscale { color: var(--ink); border-left: 2px solid var(--ink); padding-left: 10px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 10px 22px;
  border-radius: 0; border: 1px solid var(--ink); background: transparent; color: var(--ink);
  text-decoration: none; cursor: pointer;
}
.button:hover { background: var(--surface-2); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.button.primary:hover { opacity: 0.86; }

.howto { border-top: 1px solid var(--line); padding-top: 14px; }
.howto summary { cursor: pointer; }
.howto h3, .help h3 {
  font-family: var(--display); font-weight: 400; font-size: 0.95rem; letter-spacing: 0.08em;
  text-transform: uppercase; margin: 18px 0 6px;
}
.howto ol, .help ol { padding-left: 1.3em; margin: 0; }

.help { max-width: min(580px, calc(100vw - 32px)); padding: 32px; }
.help h2 {
  margin: 0 44px 10px 0; font-family: var(--display); font-weight: 400; letter-spacing: 0.06em; text-transform: uppercase;
}
.help .note { margin-top: 18px; }

@media (prefers-reduced-motion: no-preference) {
  .thumb img { transition: transform 0.25s ease; }
  .card:hover .thumb img { transform: translateY(-2px); }
}

.tv-send { margin: 4px 0 22px; padding-top: 18px; border-top: 1px solid var(--ink); display: grid; gap: 10px; }
.tv-send .eyebrow { margin: 0; }
.tv-send .button:disabled { opacity: 0.55; cursor: progress; }

/* Sign-in hand-off pages (/auth/...) */
.auth-page { max-width: 32rem; margin: 18vh auto; padding: 0 16px; text-align: center; }
.auth-page h1 { font-family: "Marcellus", serif; letter-spacing: .12em; text-transform: uppercase; font-weight: 400; }

/* The public website shows previews only; the app does the sending. */
body.no-downloads [data-download-help], body.no-downloads .howto { display: none; }
.get-app-cta { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 14px 0 16px; margin: 18px 0; }
.get-app-cta p:not(.eyebrow) { margin: 6px 0 12px; }
