/* ── CSS Variables (overridden per-site via base.html <style> block) ────────── */
:root {
  --primary:       #1a3a5c;
  --accent:        #c8a830;
  --bg:            #f5f5f0;
  --text:          #222;
  --muted:         #666;
  --border:        #ddd;
  --white:         #fff;
  --row-alt:       #f9f9f6;
  --nav-height:    48px;
  --radius:        6px;
  --shadow:        0 2px 8px rgba(0,0,0,0.10);
  --transition:    0.18s ease;
}

/* ── Reset ───────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--accent); }
img { max-width: 100%; display: block; }

/* ── Header ─────────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--primary);
  color: var(--white);
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

/* Logo */
.site-logo { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: .02em;
}
.site-logo:hover .logo-text { color: var(--accent); }

/* Search */
.header-search { position: relative; flex: 1; max-width: 480px; }
.search-input {
  width: 100%;
  padding: .45rem .9rem;
  padding-right: 2.8rem;
  border: none;
  border-radius: var(--radius);
  font-size: .95rem;
  background: rgba(255,255,255,.15);
  color: var(--white);
  outline: none;
  transition: background var(--transition);
}
.search-input::placeholder { color: rgba(255,255,255,.6); }
.search-input:focus { background: rgba(255,255,255,.25); }
.search-btn {
  position: absolute;
  right: .5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: rgba(255,255,255,.8);
}
.search-btn:hover { color: var(--accent); }

/* Autocomplete */
.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  list-style: none;
  z-index: 200;
  box-shadow: var(--shadow);
}
.autocomplete-list li a {
  display: block;
  padding: .5rem .9rem;
  color: var(--text);
  font-size: .9rem;
}
.autocomplete-list li a:hover,
.autocomplete-list li.active a { background: var(--bg); color: var(--primary); }

/* Nav */
.main-nav { margin-left: auto; }
.main-nav > ul { list-style: none; display: flex; gap: .25rem; }
.main-nav ul { list-style: none; }
.main-nav li { position: relative; }
.main-nav a {
  display: block;
  padding: .3rem .7rem;
  color: rgba(255,255,255,.9);
  font-size: .85rem;
  border-radius: var(--radius);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.main-nav a:hover { background: rgba(255,255,255,.15); color: var(--white); }

/* Dropdown */
.dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  list-style: none;
  z-index: 150;
  max-height: 400px;
  overflow-y: auto;
}
.dropdown li a {
  color: var(--text);
  padding: .4rem 1rem;
  font-size: .88rem;
}
.dropdown li a:hover { background: var(--bg); color: var(--primary); }
.has-dropdown:hover .dropdown { display: block; }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--white);
  font-size: 1.4rem;
  cursor: pointer;
  margin-left: auto;
}

/* ── Hero ────────────────────────────────────────────────────────────────────── */
.hero {
  background: var(--primary);
  background-size: cover;
  background-position: center;
  color: var(--white);
  padding: 5rem 1.5rem;
  text-align: center;
  position: relative;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
}
.hero-inner { position: relative; max-width: 720px; margin: 0 auto; }
.hero h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: .5rem; }
.hero p  { font-size: 1.15rem; margin-bottom: 1.5rem; opacity: .9; }
.hero-search { display: flex; gap: .5rem; justify-content: center; }
.search-input--lg {
  background: rgba(255,255,255,.2);
  color: var(--white);
  padding: .7rem 1.2rem;
  font-size: 1rem;
  flex: 1;
  max-width: 480px;
}
.search-input--lg::placeholder { color: rgba(255,255,255,.7); }
.search-input--lg:focus { background: rgba(255,255,255,.3); }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: .55rem 1.4rem;
  background: var(--primary);
  color: var(--white);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.btn:hover { background: transparent; color: var(--primary); }
.btn--accent { background: var(--accent); border-color: var(--accent); color: #222; }
.btn--accent:hover { background: transparent; color: var(--accent); }
.btn--outline { background: transparent; color: var(--primary); }
.btn--outline:hover { background: var(--primary); color: var(--white); }
.btn--sm { padding: .35rem .9rem; font-size: .82rem; }

/* ── Sections ────────────────────────────────────────────────────────────────── */
.section { padding: 3rem 1.5rem; }
.section--alt { background: var(--white); }
.section-inner { max-width: 1280px; margin: 0 auto; }
.section-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 1.25rem; color: var(--primary); }
.center-link { text-align: center; margin-top: 1.5rem; }

/* ── Country chips ───────────────────────────────────────────────────────────── */
.country-grid { display: flex; flex-wrap: wrap; gap: .6rem; }
.country-chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .9rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .88rem;
  transition: border-color var(--transition), background var(--transition);
}
.country-chip:hover { border-color: var(--primary); background: var(--primary); color: var(--white); }
.country-chip:hover .chip-count { background: rgba(255,255,255,.25); color: var(--white); }
.country-chip--more { border-style: dashed; font-weight: 600; }
.chip-count {
  background: var(--bg);
  border-radius: 999px;
  padding: .05rem .45rem;
  font-size: .78rem;
  color: var(--muted);
}

/* ── Stamp card grid ─────────────────────────────────────────────────────────── */
.stamp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 1rem;
}
.stamp-card {
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.stamp-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stamp-card__img-wrap {
  aspect-ratio: 4/3;
  background: #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.stamp-card__img-wrap img { width: 100%; height: 100%; object-fit: contain; }
.stamp-card__no-img {
  font-size: .8rem;
  color: var(--muted);
}
.stamp-card__info {
  padding: .6rem .8rem;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.stamp-card__name { font-size: .88rem; font-weight: 600; line-height: 1.3; }
.stamp-card__country { font-size: .78rem; color: var(--muted); }
.stamp-card__scott { font-size: .75rem; color: var(--accent); font-weight: 600; }

/* ── Browse layout ───────────────────────────────────────────────────────────── */
.browse-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem;
  align-items: start;
}
.sidebar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: sticky;
  top: calc(var(--nav-height) + 1rem);
}
.sidebar-section { margin-bottom: 1.25rem; }
.sidebar-section h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .5rem; }
.filter-select {
  width: 100%;
  padding: .4rem .6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .88rem;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.filter-select:focus { outline: 2px solid var(--primary); }

.browse-header { margin-bottom: 1rem; }
.browse-header h1 { font-size: 1.4rem; font-weight: 700; color: var(--primary); }
.result-count { color: var(--muted); font-size: .88rem; }

/* ── Stamp table ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.stamp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.stamp-table th {
  text-align: left;
  padding: .6rem .8rem;
  background: var(--primary);
  color: var(--white);
  font-weight: 600;
  font-size: .82rem;
  letter-spacing: .04em;
  white-space: nowrap;
}
.stamp-table td {
  padding: .55rem .8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.stamp-row { cursor: pointer; transition: background var(--transition); }
.stamp-row:nth-child(even) { background: var(--row-alt); }
.stamp-row:hover { background: #eef3f8; }
.col-img { width: 70px; }
.thumb { width: 60px; height: 44px; object-fit: contain; border-radius: 3px; background: #eee; }
.no-img-sm { width: 60px; height: 44px; background: #eee; border-radius: 3px; display: flex; align-items: center; justify-content: center; font-size: .75rem; color: var(--muted); }
.stamp-name-link { font-weight: 600; color: var(--primary); }
.stamp-name-link:hover { color: var(--accent); }
.mono { font-family: monospace; font-size: .85rem; }
.muted { color: var(--muted); }

/* ── Pagination ──────────────────────────────────────────────────────────────── */
.pagination { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: 1.5rem; justify-content: center; }
.page-btn {
  padding: .4rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .88rem;
  color: var(--primary);
  background: var(--white);
  transition: background var(--transition), color var(--transition);
}
.page-btn:hover, .page-btn.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

/* ── Stamp detail ────────────────────────────────────────────────────────────── */
.detail-layout {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 2.5rem;
  align-items: start;
}
.detail-img {
  width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: #eee;
}
.detail-no-img {
  width: 100%;
  aspect-ratio: 4/3;
  background: #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  border-radius: var(--radius);
}
.breadcrumb { font-size: .83rem; color: var(--muted); margin-bottom: .75rem; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }
.detail-title { font-size: 1.7rem; font-weight: 800; color: var(--primary); margin-bottom: .25rem; }
.detail-series { color: var(--muted); font-size: .95rem; margin-bottom: 1rem; }
.detail-table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; font-size: .9rem; }
.detail-table th { text-align: left; padding: .45rem .6rem; color: var(--muted); font-weight: 600; width: 40%; font-size: .82rem; }
.detail-table td { padding: .45rem .6rem; border-bottom: 1px solid var(--border); }
.catalog-heading { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 1rem 0 .5rem; }
.detail-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.25rem; }

/* ── Countries page ──────────────────────────────────────────────────────────── */
.alpha-heading { font-size: 1.3rem; color: var(--primary); margin: 1.5rem 0 .5rem; border-bottom: 2px solid var(--border); padding-bottom: .25rem; }
.country-list { list-style: none; columns: 2; gap: 1rem; margin-bottom: .5rem; }
.country-list li { display: flex; justify-content: space-between; padding: .2rem 0; font-size: .9rem; }
.alpha-jump {
  position: fixed;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: .7rem;
}
.alpha-jump a { color: var(--primary); padding: 1px 4px; }
.alpha-jump a:hover { color: var(--accent); }

/* ── General ─────────────────────────────────────────────────────────────────── */
.content-page { max-width: 720px; padding: 2rem 1.5rem; }
.content-page h1 { margin-bottom: 1rem; }
.content-page p { margin-bottom: .75rem; }
.empty-state { text-align: center; padding: 4rem 1rem; color: var(--muted); }
.empty-state p { margin-bottom: 1rem; }

/* ── Footer ──────────────────────────────────────────────────────────────────── */
.site-footer { background: var(--primary); color: rgba(255,255,255,.85); margin-top: 4rem; }
.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2rem;
}
.footer-brand p { font-size: .9rem; opacity: .8; margin-top: .4rem; }
.footer-links h4, .footer-contact h4 { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: .6rem; color: var(--accent); }
.footer-links ul { list-style: none; }
.footer-links li { margin-bottom: .3rem; }
.footer-links a, .footer-contact a { color: rgba(255,255,255,.8); font-size: .88rem; }
.footer-links a:hover, .footer-contact a:hover { color: var(--accent); }
.footer-copy { text-align: center; padding: 1rem; border-top: 1px solid rgba(255,255,255,.15); font-size: .82rem; opacity: .7; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .browse-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .detail-layout { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .alpha-jump { display: none; }
  .country-list { columns: 1; }
}

@media (max-width: 700px) {
  .main-nav { display: none; }
  .main-nav.open { display: block; position: absolute; top: var(--nav-height); left: 0; right: 0; background: var(--primary); padding: 1rem; z-index: 200; }
  .main-nav.open ul { flex-direction: column; }
  .nav-toggle { display: block; }
  .header-inner { flex-wrap: wrap; height: auto; padding: .75rem 1rem; }
  .header-search { order: 3; flex: 1 1 100%; }
  .hero h1 { font-size: 1.8rem; }
  .hero-search { flex-direction: column; align-items: center; }
  .footer-inner { grid-template-columns: 1fr; }
}

/* ── Cart ──────────────────────────────────────────────────────────────────── */
.cart-icon {
  position: relative;
  font-size: 1.3rem;
  text-decoration: none;
  margin-left: .5rem;
  line-height: 1;
}
.cart-badge {
  position: absolute;
  top: -6px; right: -8px;
  background: var(--accent);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 5px;
  line-height: 1.4;
}
.cart-list { display: flex; flex-direction: column; gap: .75rem; margin-bottom: 1.5rem; }
.cart-item {
  display: flex; align-items: center; gap: 1rem;
  background: #fff; border: 1px solid #e0ddd4;
  border-radius: 8px; padding: .75rem 1rem;
}
.cart-item__img { width: 64px; height: 64px; flex-shrink: 0; }
.cart-item__img img { width: 100%; height: 100%; object-fit: contain; border-radius: 4px; }
.cart-item__info { flex: 1; display: flex; flex-direction: column; gap: .2rem; }
.cart-item__name { font-weight: 600; }
.cart-item__meta { font-size: .8rem; color: var(--muted, #888); }
.cart-item__price { font-size: 1.1rem; font-weight: 700; color: var(--primary); min-width: 70px; text-align: right; }
.cart-summary {
  display: flex; justify-content: flex-end; align-items: center; gap: 1rem;
  border-top: 2px solid var(--primary); padding-top: 1rem; margin-bottom: 1.5rem;
}
.cart-total-label { font-size: 1rem; color: var(--muted, #888); }
.cart-total-amount { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.cart-checkout-form { display: flex; gap: 1rem; align-items: center; }
.detail-price { font-size: 1.6rem; font-weight: 700; color: var(--primary); margin: .5rem 0 1rem; }
.flash-container { max-width: 900px; margin: 1rem auto; padding: 0 1.5rem; }
.flash {
  padding: .75rem 1rem; border-radius: 6px; margin-bottom: .5rem;
  font-size: .9rem; font-weight: 500;
}
.flash--success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash--error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.flash--warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.flash--info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

.col-price { white-space: nowrap; font-weight: 600; color: var(--primary); min-width: 70px; }
.col-buy   { white-space: nowrap; min-width: 70px; }
.col-buy form { margin: 0; }

/* ── Commerce fields (new API needed) ──────────────────────────────────────── */
.api-badge--purple { background:#e8d5f5; color:#5a2d82; border:1px solid #d4aaef; }
.commerce-section {
  margin-top: 2rem;
  border: 2px dashed #d4aaef;
  border-radius: 8px;
  padding: 1rem 1.25rem 1.25rem;
  background: #faf5ff;
}
.commerce-section h3 {
  margin: 0 0 .75rem;
  font-size: .9rem;
  color: #5a2d82;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.commerce-section .commerce-note {
  font-size: .75rem; color: #5a2d82; margin-bottom: .75rem;
  background: #e8d5f5; border-radius: 4px; padding: 4px 8px; display: inline-block;
}
.commerce-placeholder {
  color: #bbb; font-style: italic; font-size: .85rem;
}
.status-badge {
  display: inline-block; border-radius: 4px; padding: 2px 8px;
  font-size: .78rem; font-weight: 700;
}
.status--sale    { background:#d4edda; color:#155724; }
.status--sold    { background:#f8d7da; color:#721c24; }
.status--nosale  { background:#e2e3e5; color:#383d41; }
.col-status { min-width: 90px; }
.col-asking { min-width: 80px; font-weight:600; color:var(--primary); }
