/* ==========================================================================
   ABV Calculator — Craft Apothecary Light Theme (WCAG 2.1 AA)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,500;0,9..144,700;1,9..144,400&family=Outfit:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
  --bg:           #f8f4ed;
  --bg-warm:      #f3ede3;
  --bg-surface:   #ffffff;
  --bg-card:      #ffffff;
  --bg-input:     #ffffff;
  --border:       #e0d6c4;
  --border-strong:#c8bca6;
  --border-focus: #8b5a1b;
  --accent:       #8b5a1b;
  --accent-light: #a0681e;
  --accent-glow:  rgba(139, 90, 27, 0.08);
  --text:         #1c1710;
  --text-muted:   #4a4035;
  --text-dim:     #6b6052;
  --success:      #3d7a3a;
  --error:        #b83a2e;
  --radius:       12px;
  --font-heading: 'Fraunces', Georgia, serif;
  --font-body:    'Outfit', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', 'Consolas', monospace;
  --shadow-sm:    0 1px 3px rgba(28,23,16,0.04), 0 1px 2px rgba(28,23,16,0.06);
  --shadow-md:    0 4px 12px rgba(28,23,16,0.06), 0 2px 4px rgba(28,23,16,0.04);
}

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Skip link */
.skip-link { position: absolute; top: -100%; left: 16px; padding: 12px 24px; background: var(--accent); color: #fff; font-weight: 600; border-radius: 0 0 8px 8px; z-index: 1000; text-decoration: none; }
.skip-link:focus { top: 0; }

/* Focus ring */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Grain texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0.018;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 512px;
  pointer-events: none;
  z-index: 0;
}

a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent-light); text-decoration: underline; }

/* ==========================================================================
   Site Header
   ========================================================================== */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 960px;
  margin: 0 auto;
}

.site-header .logo {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
}

.site-header .logo:hover { color: var(--accent-light); text-decoration: none; }

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-link {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.15s;
}
.nav-link:hover { background: rgba(139,90,27,0.06); color: var(--text); text-decoration: none; }

.lang-icon { color: var(--accent); flex-shrink: 0; }

.lang-select {
  background: var(--bg-surface);
  color: var(--text);
  border: 1.5px solid var(--border-strong, var(--border));
  border-radius: 8px;
  padding: 6px 28px 6px 10px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' fill='none' stroke='%238b5a1b' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color 0.15s;
}
.lang-select:hover { border-color: var(--accent); }

/* ==========================================================================
   Article Layout
   ========================================================================== */
.article-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

.article-container h1 {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.article-meta {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

/* Article body typography */
.article-body h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin: 40px 0 16px;
}

.article-body h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin: 32px 0 12px;
}

.article-body h4 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 24px 0 8px;
}

.article-body p {
  margin-bottom: 16px;
  color: var(--text);
}

.article-body ul, .article-body ol {
  margin: 0 0 16px 24px;
  color: var(--text);
}

.article-body li { margin-bottom: 6px; }

.article-body blockquote {
  border-left: 3px solid var(--accent);
  margin: 20px 0;
  padding: 12px 20px;
  background: var(--bg-surface);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-muted);
  font-style: italic;
}

.article-body code {
  background: var(--bg-surface);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  color: var(--accent-light);
}

.article-body pre {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.article-body pre code {
  background: none;
  padding: 0;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.article-body th, .article-body td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left;
}

.article-body th {
  background: var(--bg-surface);
  font-weight: 600;
  color: var(--accent-light);
}

.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 16px 0;
}

/* ==========================================================================
   Calculator CTA (inline widget replacement)
   ========================================================================== */
.calculator-cta {
  display: block;
  background: var(--bg-surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 24px;
  margin: 24px 0;
  text-align: center;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.calculator-cta:hover {
  background: var(--bg-card);
  border-color: var(--accent-light);
  text-decoration: none;
  transform: translateY(-1px);
}

.calculator-cta .cta-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 8px;
}

.calculator-cta .cta-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent-light);
  display: block;
  margin-bottom: 4px;
}

.calculator-cta .cta-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Amazon Product Card
   ========================================================================== */
.product-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 20px 0;
  transition: border-color 0.2s;
}

.product-card:hover { border-color: var(--accent); }

.product-card .product-info { flex: 1; }

.product-card .product-name {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  display: block;
  margin-bottom: 8px;
}

.product-card .product-btn {
  display: inline-block;
  padding: 8px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: #c47014;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.2s;
  white-space: nowrap;
}

.product-card .product-btn:hover {
  background: #d4915f;
  text-decoration: none;
}

/* ==========================================================================
   Article Card Grid (homepage)
   ========================================================================== */
.articles-section {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

.articles-section h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
  text-align: center;
}

.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.article-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-decoration: none;
  transition: border-color 0.2s, transform 0.15s;
}

.article-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
}

.article-card .card-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-light);
  margin-bottom: 8px;
  line-height: 1.35;
}

.article-card .card-excerpt {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
}

.article-card .card-meta {
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* ==========================================================================
   Calculator page specifics
   ========================================================================== */
.calculator-wrapper {
  max-width: 520px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.calculator-wrapper header {
  text-align: center;
  padding: 32px 0 24px;
}

.calculator-wrapper header h1 {
  font-family: var(--font-heading);
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--accent-light);
  letter-spacing: -0.02em;
}

.calculator-wrapper header p {
  margin-top: 6px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Calculator card */
.calc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-bottom: 16px;
}

.calc-card-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }

input[type="number"],
select {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  -moz-appearance: textfield;
}

input[type="number"]:focus,
select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input[type="number"]::placeholder { color: var(--text-dim); }

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

select {
  min-width: 90px;
  flex-shrink: 0;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a8690' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.result-row:last-child { border-bottom: none; }

.result-label { font-size: 0.88rem; color: var(--text-muted); }

.result-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.result-primary .result-value { font-size: 1.15rem; color: var(--accent-light); }

.calc-placeholder, .calc-error {
  text-align: center;
  padding: 20px 0;
  font-size: 0.9rem;
}

.calc-placeholder { color: var(--text-dim); }
.calc-error { color: var(--error); }

.copy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  padding: 12px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.1s;
}

.copy-btn:hover { background: var(--accent); color: var(--bg); }
.copy-btn:active { transform: scale(0.98); }
.copy-btn.copied { background: var(--success); border-color: var(--success); color: #fff; }

/* ==========================================================================
   Site Footer
   ========================================================================== */
.site-footer {
  text-align: center;
  padding: 32px 20px;
  font-size: 0.82rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  max-width: 720px;
  margin: 0 auto;
}

.site-footer a { color: var(--accent); }

.site-footer .affiliate-disclosure {
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--text-dim);
  font-style: italic;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 480px) {
  .article-container h1 { font-size: 1.55rem; }
  .article-body h2 { font-size: 1.25rem; }
  .product-card { flex-direction: column; text-align: center; }
  .articles-grid { grid-template-columns: 1fr; }
}

@media (min-width: 480px) {
  .calculator-wrapper { padding: 32px 24px 64px; }
  .calc-card { padding: 28px 24px; }
}
