/* Favorite Picker — hand-written, no build step. CSP forbids inline styles,
   so every visual comes from a class here.
   1. tokens  2. base  3. chrome  4. layout  5. components  6. picker grid */

/* 1. tokens */
:root {
  --bg: #fbf9f6;
  --surface: #ffffff;
  --ink: #1d1a17;
  --ink-soft: #5b554e;
  --line: #e6e0d8;
  --accent: #c8452b;
  --accent-ink: #ffffff;
  --accent-soft: #f7e6e1;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(29, 26, 23, .06), 0 8px 24px rgba(29, 26, 23, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --max: 1080px;
}

/* 2. base */
*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--accent); }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
p { margin: 0 0 1em; }
button { font: inherit; }

/* 3. chrome */
.page { min-height: 100vh; display: flex; flex-direction: column; }
.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.site-header__inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: -.01em;
}
.brand__mark { color: var(--accent); }
.nav { display: flex; gap: 1rem; align-items: center; }
.nav a { color: var(--ink-soft); text-decoration: none; }
.nav a:hover { color: var(--ink); }
.nav__form { display: inline; margin: 0; }
.linkish {
  background: none;
  border: 0;
  padding: 0;
  color: var(--ink-soft);
  cursor: pointer;
}
.linkish:hover { color: var(--ink); }
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: .875rem;
}
.site-footer__inner { max-width: var(--max); margin: 0 auto; padding: 1rem; }

/* 4. layout */
main { flex: 1; }
.container { max-width: var(--max); margin: 0 auto; padding: 1.5rem 1rem; }
.container--narrow { max-width: 640px; }
.section { margin: 2rem 0; }
.hero { padding: 3rem 0 2rem; }
.hero p { color: var(--ink-soft); font-size: 1.125rem; max-width: 40rem; }

/* 5. components */
.button {
  display: inline-block;
  padding: .6rem 1.1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}
.button:hover { filter: brightness(.95); }
.button--ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.button:disabled { opacity: .5; cursor: default; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}
.muted { color: var(--ink-soft); }
.empty { color: var(--ink-soft); font-style: italic; }

/* 6. picker grid: square tiles, object-fit cover, so no per-image inline
   styles are ever needed (CSP: style-src 'self') */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .75rem;
  padding: 0;
  margin: 0;
  list-style: none;
}
.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--line);
  border: 3px solid transparent;
  cursor: pointer;
}
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile--picked { border-color: var(--accent); }

/* 7. feed cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  padding: 0;
  margin: 0;
  list-style: none;
}
.card--template { padding: 0; overflow: hidden; }
.card__cover { display: block; aspect-ratio: 1 / 1; background: var(--line); }
.card__cover img { width: 100%; height: 100%; object-fit: cover; }
.card__title { margin: .75rem 1rem .25rem; font-size: 1.05rem; }
.card__title a { color: var(--ink); text-decoration: none; }
.card--template .muted { margin: 0 1rem .9rem; font-size: .875rem; }
.hero--compact { padding: 1.5rem 0 .5rem; }

/* 8. picker */
.picker { margin: 1rem 0 3rem; }
.picker--loading { min-height: 12rem; }
.picker__bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: .75rem;
}
.picker__hint { color: var(--ink-soft); margin: 0 0 .75rem; }
.picker__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 1rem;
  position: sticky;
  bottom: 0;
  padding: .75rem 0;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tile--picked::after {
  content: "★";
  position: absolute;
  top: .35rem;
  right: .5rem;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 999px;
  width: 1.6rem;
  height: 1.6rem;
  line-height: 1.6rem;
  text-align: center;
  font-size: .9rem;
}
.error { color: var(--accent); font-weight: 600; }

/* 9. ranked list (done view + result page) */
.ranked {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  display: grid;
  gap: .5rem;
}
.ranked__item {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .5rem;
}
.ranked__item img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
}
.ranked__num {
  min-width: 2rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--accent);
  text-align: center;
}
