/* ---------- Design tokens ---------- */
:root {
  --bg: #f6f3ee;
  --tile-bg: #ffffff;
  --tile-border: #e7e0d5;
  --text: #221d18;
  --text-muted: #6b6259;
  --accent: #b8543a;
  --accent-contrast: #ffffff;
  --radius: 20px;
  --gap: 16px;
  --shadow: 0 1px 2px rgba(40, 24, 12, 0.05), 0 10px 28px rgba(40, 24, 12, 0.06);
  --maxw: 1080px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14110e;
    --tile-bg: #1e1a16;
    --tile-border: #322c25;
    --text: #f2ede6;
    --text-muted: #a89d90;
    --accent: #e0745a;
    --accent-contrast: #14110e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 28px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme="dark"] {
  --bg: #14110e;
  --tile-bg: #1e1a16;
  --tile-border: #322c25;
  --text: #f2ede6;
  --text-muted: #a89d90;
  --accent: #e0745a;
  --accent-contrast: #14110e;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 28px rgba(0, 0, 0, 0.4);
}

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

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

body {
  margin: 0;
  padding: clamp(16px, 4vw, 48px);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

h1, h2 { line-height: 1.15; margin: 0; }

.skip-link { position: absolute; left: -999px; }
.skip-link:focus {
  left: 16px; top: 16px;
  background: var(--tile-bg);
  padding: 8px 14px;
  border-radius: 10px;
  z-index: 10;
}

/* ---------- Theme toggle ---------- */
#theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--tile-border);
  background: var(--tile-bg);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  z-index: 5;
}
#theme-toggle:hover { border-color: var(--accent); }

/* ---------- Bento grid ---------- */
.bento {
  display: grid;
  gap: var(--gap);
  max-width: var(--maxw);
  margin: 0 auto;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(170px, auto);
  grid-auto-flow: row dense;
}

.tile {
  background: var(--tile-bg);
  border: 1px solid var(--tile-border);
  border-radius: var(--radius);
  padding: clamp(18px, 2.5vw, 28px);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.tile h2 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.tile p { margin: 0; }

/* Spans */
.tile--hero { grid-column: span 2; grid-row: span 2; justify-content: center; }
.tile--wide { grid-column: span 2; }
.tile--tall { grid-row: span 2; }

.tile--accent { background: var(--accent); border-color: transparent; }
.tile--accent h2 { color: var(--accent-contrast); opacity: 0.85; }
.tile--accent a { color: var(--accent-contrast); }
.tile--accent p { color: var(--accent-contrast); }

.tile--note {
  border-color: var(--accent);
  border-style: dashed;
  background: color-mix(in srgb, var(--accent) 6%, var(--tile-bg));
}
.arrow { font-weight: 600; text-decoration: none; }
.arrow::after { content: " \2192"; }
.arrow:hover { text-decoration: underline; }

/* Hero content */
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
  margin: 0;
}
.tile--hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 5vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.lead { color: var(--text-muted); font-size: 1.05rem; max-width: 34ch; }

/* Button */
.button {
  display: inline-block;
  margin-top: 4px;
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  text-decoration: none;
}
.button:hover { filter: brightness(1.05); }

/* Image tiles */
.tile--image { margin: 0; padding: 0; overflow: hidden; gap: 0; }
.tile--image img,
.tile--image .ph {
  display: block;
  width: 100%;
  flex: 1;
  min-height: 170px;
  object-fit: cover;
}
.tile--image figcaption {
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--tile-border);
}
.ph { background: linear-gradient(135deg, #c9b8a3, #8a6f57); }
.ph--1 { background: linear-gradient(135deg, #d9a679, #b8543a); }
.ph--2 { background: linear-gradient(135deg, #9aa9a0, #4f6b5d); }
.ph--3 { background: linear-gradient(135deg, #a9c4d6, #5b7f99); }
.ph--4 { background: linear-gradient(135deg, #d6c1a1, #9c7b4f); }
.ph--5 { background: linear-gradient(135deg, #c7a9b4, #7d5a6b); }

/* Lists */
.links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.links li { display: flex; flex-direction: column; }
.links a { font-weight: 600; text-decoration: none; }
.links a:hover { text-decoration: underline; }
.links span { color: var(--text-muted); font-size: 0.9rem; }
.links--compact { gap: 8px; }
.links--compact li { flex-direction: row; }

.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: flex; flex-direction: column; gap: 16px; }
.steps li { display: flex; flex-direction: column; gap: 2px; padding-left: 34px; position: relative; }
.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.8rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.steps strong { font-weight: 600; }
.steps span { color: var(--text-muted); font-size: 0.9rem; }

.tags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.tags li {
  border: 1px solid var(--tile-border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ---------- Footer ---------- */
footer {
  max-width: var(--maxw);
  margin: 32px auto 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .bento { grid-template-columns: repeat(2, 1fr); }
  .tile--hero,
  .tile--wide { grid-column: span 2; }
  .tile--hero { grid-row: span 1; }
  .tile--tall { grid-row: span 1; }
}

@media (max-width: 520px) {
  .bento { grid-template-columns: 1fr; }
  .tile--hero,
  .tile--wide { grid-column: span 1; }
}

@media (prefers-reduced-motion: no-preference) {
  .tile { transition: border-color 0.15s ease, transform 0.15s ease; }
}
