/* ---------- CSS VARIABLES ---------- */
:root{
  /* Base theme */
  --bg: #ffffff;
  --ink: #111111;
  --muted: #6b7280;
  --rule: rgba(0,0,0,0.14);
  --soft: rgba(0,0,0,0.04);

  /* Dynamic tonal background (set by tone.js) */
  --tone-bg: var(--bg);     /* fallback */
  --tone-bg-2: var(--bg);   /* optional 2nd tone */
  --tone-ink: var(--ink);   /* optional auto ink */

  /* Wall tuning */
  --tile-min: 240px;        /* minimum tile width before wrapping */
  --tile-gap: 14px;         /* spacing between tiles */
  --radius: 9px;           /* card radius */
  --shadow: 0 10px 24px rgba(0,0,0,0.08);
}

html.dark{
  --bg: #0f0f0f;
  --ink: #f5f5f5;
  --muted: #9ca3af;
  --rule: rgba(255,255,255,0.22);
  --soft: rgba(255,255,255,0.06);
  --shadow: 0 10px 24px rgba(0,0,0,0.50);

  /* Tone defaults in dark mode (tone.js can still override) */
  --tone-bg: var(--bg);
  --tone-bg-2: var(--bg);
  --tone-ink: var(--ink);
}

/* ---------- RESET ---------- */
*,
*::before,
*::after{
  box-sizing: border-box;
}

html{
  scroll-behavior: smooth;
}

body{
  margin: 0;

  /* Dynamic tonal background driven by --tone-bg vars */
  background:
    radial-gradient(1100px 800px at 18% 10%,
      color-mix(in srgb, var(--tone-bg) 70%, transparent) 0%,
      transparent 60%),
    radial-gradient(1100px 800px at 82% 0%,
      color-mix(in srgb, var(--tone-bg-2) 70%, transparent) 0%,
      transparent 55%),
    var(--tone-bg);

  color: var(--tone-ink);
  font-family: Inter, system-ui, -apple-system, "Segoe UI",
               Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;

  transition: background-color .35s ease, color .35s ease;
}

/* ---------- LAYOUT ---------- */
.wrap{
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 48px);
}

.header{
  margin-bottom: 24px;
}

.section{
  margin-top: 32px;
}

.footer{
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
}

/* ---------- TYPOGRAPHY ---------- */
h1{
  margin: 0 0 6px;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  letter-spacing: 0.1px;
}

h2{
  margin: 0 0 12px;
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

p{
  margin: 0 0 12px;
}

.subhead{
  max-width: 52ch;
}

.small{ font-size: 0.95rem; }
.tiny{ font-size: 0.8rem; }
.muted{ color: var(--muted); }
.caps{
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---------- LINKS ---------- */
a{
  color: inherit;
  text-decoration: none;
}
a:hover{
  text-decoration: underline;
}

/* ---------- NAVIGATION ---------- */
.nav{
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* ---------- BADGES (NAV + CONTROLS ONLY) ---------- */
.badge{
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  border: 1px solid var(--rule);
  background: transparent;
  color: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.badge:hover{
  background: var(--soft);
}

/* ---------- FORMS / FILTERS ---------- */
input,
select,
button{
  font: inherit;
  color: inherit;
}

input,
select{
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 10px 12px;
  border-radius: 12px;
}

input::placeholder{
  color: var(--muted);
}

/* Filters as a neat grid row */
.filters{
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}
@media (max-width: 980px){
  .filters{ grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px){
  .filters{ grid-template-columns: 1fr; }
}

/* ---------- GRID (PALETTE WALL) ---------- */
.grid{
  display: grid;
  gap: var(--tile-gap);
  margin-top: 24px;
  grid-template-columns: repeat(auto-fit, minmax(var(--tile-min), 1fr));
}

/* Slightly larger tiles on roomy screens */
@media (min-width: 1200px){
  :root{ --tile-min: 230px; }
}

/* Slightly tighter on very small screens */
@media (max-width: 420px){
  :root{ --tile-min: 170px; --tile-gap: 12px; }
}

/* ---------- CARD ---------- */
.card{
  border: 1px solid var(--rule);
  border-radius: 0;
  overflow: visible;
  background: var(--bg);
  transition: transform .12s ease, box-shadow .12s ease;
}
.card:hover{
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

/* Whole tile behaves as a “unit” */
.card a{
  display: flex;
  flex-direction: column;
}

/* SQUARE THUMB = wall consistency */
.thumb{
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: center;
  display: block;
  background: var(--soft);
  height: auto;
  border-radius: 0 !important;
}

/* Card body spacing */
.body{
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.title{
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.25;

  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- METADATA (MOOD / OCCASION / UNDERTONE) ---------- */
.meta{
  display: grid;
  gap: 6px;
  margin-top: 2px;
  padding-left: 2px;
}

.meta-row{
  display: flex;
  align-items: center;
  gap: 8px;

  font-size: 0.78rem;
  line-height: 1.3;
  color: var(--muted);
  letter-spacing: 0.02em;

  white-space: normal;
}


.meta-label{
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  opacity: 0.8;
  min-width: 70px;
  flex-shrink: 0;
}
.meta-row span:last-child{
  overflow-wrap: anywhere;
}
/* ---------- PAGINATION ---------- */
.pager{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 20px;
}

.pager button{
  min-width: 40px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--rule);
  background: transparent;
  cursor: pointer;
  line-height: 1;
}

.pager button:hover{
  background: var(--soft);
}

.pager button[disabled]{
  opacity: 0.45;
  cursor: not-allowed;
}

.pager button[aria-current="true"],
.pager button.active{
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.pager .spacer{
  padding: 0 4px;
  color: var(--muted);
}

.pager .meta{
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--muted);
}

.grid {
    display:grid;
    grid-template-columns:repeat(auto-fill,minmax(200px,1fr));
    gap:16px;
}

.card {
    border:1px solid #ddd;
    border-radius:10px;
    padding:10px;
    background:white;
}

.suggested-grid {
  display:grid;
  ...
}

/* ---------- PALETTE IMAGE (DETAIL PAGES) ---------- */
.palette-image{
  display: block;
  width: 100%;
  max-width: 720px;
  margin: 0 auto 24px;
  height: auto;
}

.palette-note{
  max-width: 60ch;
  margin: 0 auto;
}

/* ---------- ACCESSIBILITY ---------- */
:focus-visible{
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

html.dark :focus-visible{
  outline: 2px solid #ffffff;
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce){
  .card, .card:hover{
    transition: none;
    transform: none;
  }
}
