/* ==========================================================================
   ROVE - weekend field guide
   Editorial listings aesthetic. One accent (vermilion), one radius (0),
   one primary theme at a time with a system-aware dark translation.
   ========================================================================== */

/* ----- Fonts (self-hosted, local only) --------------------------------- */
@font-face {
  font-family: "Space Grotesk";
  src: url("assets/space-grotesk.ttf") format("truetype");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Work Sans";
  src: url("assets/work-sans.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

/* ----- Tokens ---------------------------------------------------------- */
:root {
  --paper: #edefe9;
  --paper-2: #e2e5dc;
  --surface: #f6f7f2;
  --surface-2: #eef0ea;
  --ink: #16181a;
  --ink-2: #3b403d;
  --muted: #666d68;
  --line: #c7ccc4;
  --line-strong: #9aa197;
  --accent: #c23b1c;
  --accent-2: #9f2d12;
  --accent-ink: #fdf3ef;
  --shadow: 0 1px 0 rgba(22, 24, 26, 0.04), 0 18px 50px -34px rgba(22, 24, 26, 0.45);

  --font-display: "Space Grotesk", "Work Sans", system-ui, sans-serif;
  --font-body: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --shell: 1160px;
  --pad: clamp(1rem, 4vw, 3rem);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #101210;
    --paper-2: #171a18;
    --surface: #141715;
    --surface-2: #191d1a;
    --ink: #ecefe9;
    --ink-2: #c1c6bf;
    --muted: #878d86;
    --line: #2a2e2b;
    --line-strong: #454b46;
    --accent: #ff6a4d;
    --accent-2: #ff8a72;
    --accent-ink: #180b06;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 22px 60px -34px rgba(0, 0, 0, 0.9);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #101210;
  --paper-2: #171a18;
  --surface: #141715;
  --surface-2: #191d1a;
  --ink: #ecefe9;
  --ink-2: #c1c6bf;
  --muted: #878d86;
  --line: #2a2e2b;
  --line-strong: #454b46;
  --accent: #ff6a4d;
  --accent-2: #ff8a72;
  --accent-ink: #180b06;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 22px 60px -34px rgba(0, 0, 0, 0.9);
  color-scheme: dark;
}

/* ----- Base ------------------------------------------------------------ */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; height: auto; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }
a { color: inherit; }

::selection { background: var(--accent); color: var(--accent-ink); }

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

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

.skip-link {
  position: absolute;
  left: 0.75rem; top: -4rem;
  z-index: 50;
  background: var(--ink);
  color: var(--paper);
  padding: 0.6rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
  transition: top 0.18s ease;
}
.skip-link:focus { top: 0.75rem; }

/* ----- Shared button --------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.85rem 1.3rem;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.12s ease, border-color 0.18s ease;
}
.btn:active { transform: translateY(1px); }
.btn--solid { background: var(--ink); color: var(--paper); }
.btn--solid:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ==========================================================================
   Masthead
   ========================================================================== */
.masthead {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.masthead__inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem) var(--pad) clamp(2rem, 5vw, 3.5rem);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: end;
}

.brandrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}
.brand__mark {
  display: grid;
  place-items: center;
  width: 2rem; height: 2rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1;
}
.brand__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.24em;
}

.theme-toggle {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--line-strong); }

.masthead__kicker {
  margin-top: clamp(2rem, 5vw, 3.25rem);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-2);
}
.masthead__title {
  margin-top: 0.7rem;
  font-size: clamp(2.6rem, 5.4vw, 4.6rem);
  line-height: 0.98;
  max-width: 12ch;
}
.masthead__sub {
  margin-top: 1.1rem;
  max-width: 34ch;
  color: var(--ink-2);
  font-size: 1.05rem;
  line-height: 1.5;
}

.masthead__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0 clamp(1.25rem, 3vw, 2.75rem);
  margin: 1.75rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}
.masthead__facts dt {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.masthead__facts dd {
  margin: 0.25rem 0 0;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 500;
}

.masthead__media {
  margin: 0;
  position: relative;
  align-self: end;
}
.masthead__media img {
  width: 100%;
  aspect-ratio: 4 / 5;
  height: auto;
  min-height: 320px;
  max-height: 460px;
  object-fit: cover;
  filter: grayscale(1) contrast(1.05);
}
.masthead__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  mix-blend-mode: multiply;
  opacity: 0.5;
  pointer-events: none;
}
.masthead__media figcaption {
  position: absolute;
  left: 0; bottom: -1.4rem;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* ==========================================================================
   Controls
   ========================================================================== */
.controls {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.controls__inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0.9rem var(--pad);
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 0.85fr) auto;
  gap: 0.9rem 1.1rem;
  align-items: end;
}
.field { display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; }
.field > label,
.field__label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input,
.field select {
  font-family: var(--font-body);
  font-size: 0.98rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0.7rem 0.85rem;
  width: 100%;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}
.field input::placeholder { color: var(--muted); opacity: 1; }
.field input:hover,
.field select:hover { border-color: var(--line-strong); }
.field input:focus,
.field select:focus { border-color: var(--accent); outline: none; }

.field--select select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 1.15rem) 55%, calc(100% - 0.8rem) 55%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.4rem;
  cursor: pointer;
}

.field--toggle { align-items: flex-start; }
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.toggle:hover { border-color: var(--line-strong); }
.toggle__track {
  width: 1.9rem;
  height: 1rem;
  border: 1px solid var(--line-strong);
  position: relative;
  flex: none;
}
.toggle__track::after {
  content: "";
  position: absolute;
  top: 1px; left: 1px;
  width: 0.65rem; height: 0.65rem;
  background: var(--muted);
  transition: transform 0.18s ease, background-color 0.18s ease;
}
.toggle[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.toggle[aria-pressed="true"] .toggle__track { border-color: var(--accent-ink); }
.toggle[aria-pressed="true"] .toggle__track::after { background: var(--accent-ink); transform: translateX(0.85rem); }
.toggle__count {
  font-size: 0.72rem;
  min-width: 1.3rem;
  text-align: center;
  border: 1px solid currentColor;
  padding: 0.05rem 0.3rem;
}

.results {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 var(--pad) 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ==========================================================================
   Browse / list
   ========================================================================== */
.browse {
  max-width: var(--shell);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 2.75rem) var(--pad) clamp(3rem, 8vw, 6rem);
  min-height: 40vh;
}

.group { margin-bottom: clamp(2rem, 5vw, 3.25rem); }
.group__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--ink);
}
.group__day {
  font-size: clamp(1.3rem, 2.6vw, 1.9rem);
  font-weight: 600;
}
.group__count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.items { display: block; }

/* First-paint reveal only; subsequent renders stay still. */
.groups--intro .item {
  animation: item-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}
@keyframes item-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.item {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: clamp(0.85rem, 2.4vw, 1.6rem);
  padding: clamp(1.1rem, 2.6vw, 1.5rem) 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}
.items .item:first-child { border-top: 0; }
.item:hover .item__title button { color: var(--accent); }
.item:focus-within { background: var(--surface-2); }

.item__media { position: relative; overflow: hidden; aspect-ratio: 1 / 1; }
.item__media img {
  width: 100%; height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.06) brightness(1.02);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.item:hover .item__media img { transform: scale(1.06); }
.item__media::after {
  content: "";
  position: absolute; inset: 0;
  background: var(--accent);
  mix-blend-mode: multiply;
  opacity: 0.42;
  pointer-events: none;
}

.item__kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.item__cat { color: var(--accent-2); }
.item__sep { color: var(--line-strong); }

.item__title {
  margin: 0.35rem 0 0;
  font-size: clamp(1.2rem, 2.5vw, 1.7rem);
  line-height: 1.1;
}
.item__title button {
  all: unset;
  font: inherit;
  cursor: pointer;
  color: var(--ink);
  transition: color 0.18s ease;
}
.item__title button:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.item__summary {
  margin-top: 0.5rem;
  max-width: 62ch;
  color: var(--ink-2);
  font-size: 0.98rem;
}
.item__meta {
  margin-top: 0.7rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1.4rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.item__price { color: var(--ink); }
.item__price--free { color: var(--accent-2); }
.item__saved {
  color: var(--accent-2);
  border: 1px solid var(--accent);
  padding: 0.1rem 0.4rem;
}

/* Duotone translation for the dark theme: multiply would crush the image,
   so the accent blends as a light tint instead. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .masthead__media::after,
  :root:not([data-theme="light"]) .item__media::after {
    mix-blend-mode: soft-light;
    opacity: 0.62;
  }
}
:root[data-theme="dark"] .masthead__media::after,
:root[data-theme="dark"] .item__media::after {
  mix-blend-mode: soft-light;
  opacity: 0.62;
}

/* ==========================================================================
   Empty state
   ========================================================================== */
.empty {
  border: 1px dashed var(--line-strong);
  padding: clamp(2rem, 6vw, 4rem) clamp(1.25rem, 4vw, 3rem);
  text-align: left;
  background: var(--surface);
}
.empty__mark {
  font-family: var(--font-display);
  font-size: clamp(3rem, 9vw, 5.5rem);
  line-height: 0.8;
  font-weight: 700;
  color: var(--accent);
}
.empty__title { margin-top: 1rem; font-size: clamp(1.5rem, 3vw, 2.1rem); }
.empty__body { margin-top: 0.6rem; max-width: 46ch; color: var(--ink-2); }
.empty .btn { margin-top: 1.5rem; }

/* ==========================================================================
   Detail dialog
   ========================================================================== */
.detail {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.detail::backdrop {
  background: rgba(12, 13, 12, 0.62);
  backdrop-filter: blur(2px);
}
.detail[open] { display: grid; place-items: center; }

.detail__shell {
  position: relative;
  width: min(760px, calc(100vw - 2rem));
  max-height: min(88dvh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--ink);
  box-shadow: var(--shadow);
  animation: detail-in 0.28s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes detail-in {
  from { opacity: 0; transform: translateY(14px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

.detail__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.detail__cat {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-2);
}
.detail__close {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line-strong);
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.detail__close:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.detail__scroll {
  overflow-y: auto;
  padding: clamp(1.25rem, 4vw, 2.25rem);
  flex: 1 1 auto;
}
.detail__title {
  font-size: clamp(1.75rem, 4vw, 2.7rem);
  line-height: 1.03;
  letter-spacing: -0.025em;
  max-width: 20ch;
}
.detail__body p:first-child {
  font-size: 1.12rem;
  color: var(--ink);
  max-width: 60ch;
}

.detail__facts {
  margin: 1.75rem 0 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
}
.detail__facts > div {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}
.detail__facts > div:nth-child(odd) { padding-right: 1.25rem; }
.detail__facts dt {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.detail__facts dd {
  margin: 0.25rem 0 0;
  font-size: 1rem;
  font-weight: 500;
}

.detail__body { margin-top: 1.75rem; max-width: 62ch; }
.detail__body p { margin-top: 0.9rem; color: var(--ink-2); }
.detail__body p:first-child { margin-top: 0; }

.detail__foot {
  flex: none;
  padding: 0.9rem 1.1rem;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  display: flex;
  justify-content: flex-end;
}
.btn--save { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn--save:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--save[aria-pressed="true"] {
  background: transparent;
  color: var(--accent-2);
  border-color: var(--accent);
}
.btn--save[aria-pressed="true"]:hover { background: var(--accent); color: var(--accent-ink); }

/* ==========================================================================
   Footer
   ========================================================================== */
.footer { border-top: 1px solid var(--line); background: var(--paper-2); }
.footer__inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 3.25rem) var(--pad);
  display: grid;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.86rem;
}
.footer__brand {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.24em;
  color: var(--ink);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 900px) {
  .masthead__inner { grid-template-columns: 1fr; align-items: start; }
  .masthead__media img { aspect-ratio: 16 / 9; min-height: 220px; max-height: 300px; }
  .masthead__media figcaption { position: static; display: block; margin-top: 0.5rem; }
  .masthead__title { max-width: 100%; }

  .controls__inner { grid-template-columns: 1fr 1fr; }
  .field--search { grid-column: 1 / -1; }
  .field--toggle { grid-column: 1 / -1; }
  .field--toggle .toggle { width: 100%; justify-content: space-between; }
}

@media (max-width: 620px) {
  .masthead__title { font-size: clamp(2.3rem, 11vw, 3rem); }
  .masthead__facts { gap: 0 1.5rem; }
  .controls__inner { grid-template-columns: 1fr; }
  .field--search,
  .field--toggle { grid-column: auto; }
  .results { padding-top: 0.15rem; }

  .item { grid-template-columns: 56px minmax(0, 1fr); gap: 0.85rem; }
  .item__summary { font-size: 0.94rem; }
  .item__meta { gap: 0.35rem 1rem; }

  .detail__facts { grid-template-columns: 1fr; }
  .detail__facts > div:nth-child(odd) { padding-right: 0; }
  .detail__shell { width: calc(100vw - 1.25rem); max-height: 92dvh; }
  .detail__foot .btn { width: 100%; }
}

/* Explicit mobile collapse for the sticky controls on very small screens */
@media (max-width: 380px) {
  .brand__name { letter-spacing: 0.16em; }
}

/* ==========================================================================
   Motion preferences
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .item:hover .item__media img { transform: none; }
}
