@import url('_tokens-colors.css');
@import url('_tokens-typography.css');
@import url('_tokens-spacing.css');
@import url('_tokens-radii.css');

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

body {
  margin: 0;
  background: var(--surface-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
}

a { color: var(--text-link); }
a:hover { color: var(--text-link-hover); }

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

.container {
  max-width: var(--container-wide);
  margin: 0 auto;
  padding: 0 var(--space-8);
}

/* ---- Site header / footer ---- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 48px;
  border-bottom: var(--border-width-hairline) solid var(--border-subtle);
  background: var(--surface-card);
}

.site-header .brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--text-primary);
}

.site-header .brand span {
  font-weight: 700;
  font-size: var(--text-md);
  letter-spacing: var(--tracking-tight);
}

.site-nav {
  display: flex;
  gap: var(--space-8);
}

.site-nav a {
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  color: var(--text-tertiary);
  border-bottom: 2px solid transparent;
  padding-bottom: 4px;
}

.site-nav a.active,
.site-nav a:hover {
  color: var(--text-primary);
  border-bottom-color: var(--accent-primary);
}

.site-footer {
  padding: var(--space-10) 48px;
  border-top: var(--border-width-hairline) solid var(--border-subtle);
  background: var(--surface-sunken);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-footer .brand {
  font-weight: 700;
  font-size: var(--text-md);
}

.site-footer .tagline {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

/* ---- Eyebrow / section label ---- */

.eyebrow {
  font-size: var(--text-eyebrow);
  font-weight: 700;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* ---- Buttons ---- */

.btn {
  font: inherit;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease-standard),
              transform var(--duration-fast) var(--ease-standard);
}

.btn-primary { background: var(--accent-primary); color: var(--text-on-red); }
.btn-primary:hover { background: var(--accent-primary-hover); color: var(--text-on-red); }
.btn-primary:active { background: var(--accent-primary-active); transform: translateY(1px); }

.btn-secondary { background: var(--surface-card); color: var(--text-primary); border: var(--border-width-default) solid var(--border-default); }
.btn-secondary:hover { background: var(--surface-sunken); color: var(--text-primary); }

.btn-ghost { background: transparent; color: var(--text-primary); }
.btn-ghost:hover { background: var(--surface-sunken); color: var(--text-primary); }
.btn-ghost.on-dark { color: var(--text-on-inverse); }
.btn-ghost.on-dark:hover { background: rgba(255, 255, 255, 0.12); color: var(--text-on-inverse); }

.btn-white { background: var(--wine-white); color: var(--text-on-jasmine); }
.btn-white:hover { background: var(--wine-white-strong); color: var(--text-on-jasmine); }

.btn-danger { background: var(--surface-tint-red); color: var(--wine-red); border: var(--border-width-default) solid var(--border-red); }
.btn-danger:hover { background: var(--wine-red); color: var(--text-on-red); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { font-size: var(--text-xs); padding: 6px 14px; }
.btn-lg { font-size: var(--text-base); padding: 14px 24px; }

/* ---- Card ---- */

.card {
  position: relative;
  background: var(--surface-card);
  border: var(--border-width-hairline) solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-6);
}

.card.compact { padding: var(--space-4); }

.card.interactive {
  cursor: pointer;
  transition: box-shadow var(--duration-fast) var(--ease-standard);
  text-decoration: none;
  color: inherit;
  display: block;
}

.card.interactive:hover { box-shadow: var(--shadow-sm); }

.card.is-popular {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-xs);
}

.badge-popular {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  background: var(--accent-primary);
  color: var(--text-on-red);
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
}

/* ---- Badge / Tag ---- */

.badge {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-2xs);
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}

.badge-red { background: var(--surface-tint-red); color: var(--wine-red); }
.badge-neutral { background: var(--surface-sunken); color: var(--text-secondary); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  text-decoration: none;
}

.tag img { width: 12px; height: 12px; }

.tag-red { background: var(--surface-tint-red); color: var(--wine-red); border: var(--border-width-hairline) solid var(--border-red); }
.tag-white { background: var(--surface-tint-white); color: var(--text-on-jasmine); border: var(--border-width-hairline) solid var(--border-jasmine); }
.tag-neutral { background: var(--surface-sunken); color: var(--text-secondary); border: var(--border-width-hairline) solid var(--border-subtle); }

/* ---- Tabs ---- */

.tabs {
  display: flex;
  gap: var(--space-8);
  border-bottom: var(--border-width-hairline) solid var(--border-subtle);
}

.tabs a {
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  color: var(--text-tertiary);
  padding-bottom: 10px;
  border-bottom: 2px solid transparent;
}

.tabs a.active { color: var(--text-primary); border-bottom-color: var(--accent-primary); }

/* ---- Wine-card grid ---- */

.wine-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
}

.wine-card-swatch {
  height: 90px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
}

.wine-card-swatch.red { background: linear-gradient(160deg, #6f0601, var(--hue-blood)); }
.wine-card-swatch.white,
.wine-card-swatch.pink_gris { background: linear-gradient(160deg, #f7e3ab, var(--hue-jasmine)); }

.wine-card-name { font-weight: 700; font-size: var(--text-lg); margin-bottom: var(--space-1); }
.wine-card-note { font-size: var(--text-sm); color: var(--text-secondary); margin-bottom: var(--space-3); }
.wine-card-tags { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ---- Hero (home) ---- */

.hero {
  padding: var(--space-20) 48px;
  background: var(--surface-inverse);
  color: var(--text-on-inverse);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  align-items: flex-start;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: var(--text-5xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  margin: 0;
  max-width: 620px;
  line-height: var(--leading-tight);
}

.hero p {
  font-size: var(--text-md);
  color: rgba(255, 255, 255, 0.75);
  max-width: 520px;
  line-height: var(--leading-relaxed);
  margin: 0;
}

.hero .actions { display: flex; gap: var(--space-3); margin-top: var(--space-2); }

.hero.has-image { position: relative; overflow: hidden; }

.hero-bg { position: absolute; inset: 0; z-index: 0; }
.hero-bg-img { width: 100%; height: 100%; object-fit: cover; }

.hero.has-image::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(160deg, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0.35));
}

.hero.has-image > :not(.hero-bg) { position: relative; z-index: 2; }

section.page-section { padding: var(--space-14, 56px) 48px; }

/* ---- Article hero banner ---- */

.article-hero-banner {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 420px;
  overflow: hidden;
}

.article-hero-img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---- Detail hero (grape / place) ---- */

.detail-hero {
  padding: 56px 48px 40px;
}

.detail-hero.red { background: linear-gradient(160deg, #6f0601, var(--hue-blood)); color: var(--text-on-red); }
.detail-hero.white,
.detail-hero.pink_gris { background: linear-gradient(160deg, #f7e3ab, var(--hue-jasmine)); color: var(--text-on-jasmine); }
.detail-hero.neutral { background: var(--surface-inverse); color: var(--text-on-inverse); }

.detail-hero .back-link {
  font-size: var(--text-sm);
  font-weight: 600;
  color: inherit;
  opacity: 0.8;
  text-decoration: none;
}

.detail-hero h1 {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 700;
  margin: 14px 0 8px;
  letter-spacing: var(--tracking-tight);
}

.detail-hero .tag-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.detail-body { padding: var(--space-8) 48px 64px; max-width: 680px; }
.detail-body p { font-size: var(--text-lg); line-height: var(--leading-relaxed); }

.stat-pair { display: flex; gap: var(--space-10); }
.stat-pair .stat-label { font-size: var(--text-xs); font-weight: 700; color: var(--text-tertiary); letter-spacing: var(--tracking-wider); text-transform: uppercase; }
.stat-pair .stat-value { font-size: var(--text-xl); font-weight: 700; margin-top: 4px; }

.range-bar { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--space-4); }
.range-bar .range-track { position: relative; height: 6px; border-radius: var(--radius-pill); background: var(--surface-sunken); }
.range-bar .range-fill { position: absolute; top: 0; bottom: 0; border-radius: var(--radius-pill); background: var(--accent-primary); }
.range-bar .range-label { display: flex; justify-content: space-between; font-size: var(--text-xs); color: var(--text-tertiary); }

/* ---- Article ---- */

.article-wrap { padding: 56px 48px 80px; display: flex; justify-content: center; }
.article-wrap .article-inner { max-width: 640px; width: 100%; }
.article-inner .back-link { font-size: var(--text-sm); font-weight: 600; text-decoration: none; }
.article-inner h1 {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  margin: 10px 0 16px;
  line-height: var(--leading-tight);
}
.article-inner .dek {
  font-family: var(--font-serif-accent);
  font-style: italic;
  font-size: var(--text-lg);
  color: var(--text-secondary);
  line-height: var(--leading-snug);
  margin: 0 0 32px;
}
.article-inner p { font-size: var(--text-lg); line-height: var(--leading-relaxed); margin-bottom: var(--space-5); }

.article-card { padding: 0; overflow: hidden; }
.article-card-image { width: 100%; aspect-ratio: 16 / 9; overflow: hidden; }
.article-card-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.article-card-body { padding: var(--space-5); }
.article-card-title { font-weight: 700; font-size: var(--text-lg); margin-bottom: var(--space-1); }
.article-card-dek { font-size: var(--text-sm); color: var(--text-secondary); }

/* ---- Article index — sidebar filters ---- */

.article-page-layout { display: flex; align-items: flex-start; gap: var(--space-10); }

.article-sidebar {
  flex: 0 0 220px;
  position: sticky;
  top: var(--space-8);
  max-height: calc(100vh - var(--space-8) * 2);
  overflow-y: auto;
}

.sidebar-clear {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-link);
  text-decoration: none;
  margin-bottom: var(--space-5);
}

.sidebar-group { margin-bottom: var(--space-6); }
.sidebar-group-label {
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
}

.sidebar-filter-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.sidebar-filter-list a {
  display: block;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
}
.sidebar-filter-list a:hover { background: var(--surface-sunken); color: var(--text-primary); }
.sidebar-filter-list a.active { background: var(--surface-tint-red); color: var(--wine-red); font-weight: 600; }

.article-page-content { flex: 1; min-width: 0; }

/* ---- Pairing tool ---- */

.pairing-tool { padding: 56px 48px; max-width: 720px; }
.pairing-tool h1 { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 700; margin: 10px 0 var(--space-6); letter-spacing: var(--tracking-tight); }
.pairing-matches { margin-top: var(--space-8); display: flex; flex-direction: column; gap: var(--space-3); }
.pairing-matches .match-row { display: flex; align-items: center; justify-content: space-between; }
.pairing-matches .match-name { font-weight: 700; font-size: var(--text-base); }
.pairing-matches .match-note { font-size: var(--text-sm); color: var(--text-secondary); margin-top: 2px; }

/* ---- Place / breadcrumbs ---- */

.breadcrumbs { font-size: var(--text-sm); color: var(--text-tertiary); margin-bottom: var(--space-4); }
.breadcrumbs a { color: var(--text-tertiary); text-decoration: none; }
.breadcrumbs a:hover { color: var(--text-link); }

.child-grid, .list-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
}

/* ---- Forms (shared by public pairing tool + admin) ---- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-5); }
.field label { font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary); }
.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field input[type="password"],
.field textarea,
.field select {
  font: inherit;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  padding: 10px 12px;
  border: var(--border-width-default) solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--text-primary);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent-focus-ring);
  box-shadow: var(--shadow-focus);
}
.field textarea { resize: vertical; min-height: 100px; }
.field .help { font-size: var(--text-xs); color: var(--text-tertiary); }
.field-row { display: flex; gap: var(--space-4); }
.field-row .field { flex: 1; }

.checkbox-row, .radio-row { display: flex; align-items: center; gap: var(--space-2); }
.checkbox-row input, .radio-row input { accent-color: var(--accent-primary); width: 16px; height: 16px; }
.checkbox-row label, .radio-row label { font-size: var(--text-sm); }

/* ---- Empty / misc ---- */

.empty-state { font-size: var(--text-sm); color: var(--text-tertiary); padding: var(--space-6) 0; }

.flash {
  background: var(--surface-tint-teal);
  border: var(--border-width-hairline) solid var(--accent-secondary);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  margin: var(--space-4) 48px 0;
}

abbr[title] {
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
  cursor: help;
}
