/* ==========================================================================
   Glycemic Load Calculator — Design Tokens
   Palette: deep teal + sage, warm amber for medium, clay-red for high
   Type: Fraunces (display) / Inter (body + data)
   ========================================================================== */

:root {
  --bg: #F5F6F1;
  --surface: #FFFFFF;
  --surface-sunken: #EEF1EA;
  --ink: #172623;
  --ink-soft: #4B5D58;
  --ink-faint: #7C8C86;
  --border: #DFE4DC;

  --brand: #1F6F5C;
  --brand-dark: #124337;
  --brand-tint: #E4F1EA;

  --gold: #B7841F;
  --gold-tint: #FBF1DD;

  --low: #2E7D46;
  --low-tint: #E4F3E7;
  --medium: #B7841F;
  --medium-tint: #FBF1DD;
  --high: #B84A22;
  --high-tint: #FBE7DD;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;

  --shadow-sm: 0 1px 3px rgba(23, 38, 35, 0.08);
  --shadow-md: 0 8px 24px rgba(23, 38, 35, 0.10);
  --shadow-lg: 0 20px 48px rgba(23, 38, 35, 0.14);

  --container: 1080px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  line-height: 1.15;
  margin: 0 0 0.5em;
  font-weight: 600;
}

h1 { font-size: clamp(2rem, 4vw, 2.75rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -0.01em; }
h3 { font-size: 1.2rem; }

p { margin: 0 0 1em; color: var(--ink-soft); }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 10px;
}

/* Visually-hidden utility for accessible labels */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--brand);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 1000;
}
.skip-link:focus {
  left: 0;
}

/* Focus visibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* ==========================================================================
   Manual-codes placeholder strip (analytics / GSC / AdSense / ads.txt note)
   ========================================================================== */
.manual-codes-strip {
  background: #0F1E1B;
  color: #9FB6AF;
  font-size: 0.72rem;
  text-align: center;
  padding: 4px 10px;
  font-family: var(--font-body);
}

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 14px;
  gap: 16px;
}
.logo {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--ink);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.logo span { color: var(--brand); }

.site-nav ul {
  list-style: none;
  display: flex;
  gap: 28px;
  margin: 0;
  padding: 0;
}
.site-nav a {
  color: var(--ink-soft);
  font-size: 0.94rem;
  font-weight: 500;
}
.site-nav a:hover { color: var(--brand); text-decoration: none; }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 1.1rem;
  cursor: pointer;
}

/* ==========================================================================
   Hero / Tool section
   ========================================================================== */
.hero {
  padding: 56px 0 32px;
}
.hero-intro {
  max-width: 680px;
  margin-bottom: 40px;
}
.hero-intro p.lead {
  font-size: 1.1rem;
  color: var(--ink-soft);
}

.tool-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 32px;
}
@media (max-width: 860px) {
  .tool-panel { grid-template-columns: 1fr; padding: 24px; }
}

/* Mode switch */
.mode-switch {
  display: inline-flex;
  background: var(--surface-sunken);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 24px;
}
.mode-switch button {
  border: none;
  background: transparent;
  padding: 9px 18px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.mode-switch button.active {
  background: var(--brand);
  color: #fff;
}

.calc-mode { display: none; }
.calc-mode.active { display: block; }

.form-group {
  margin-bottom: 20px;
  position: relative;
}
.form-group label {
  display: block;
  margin-bottom: 7px;
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--ink);
}
.hint {
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-top: 6px;
}

.field-row {
  display: flex;
  gap: 10px;
}
.field-row .form-group { flex: 1; margin-bottom: 0; }

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.98rem;
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input[type="text"]:focus,
input[type="number"]:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
  outline: none;
}

/* Unit toggle (grams / oz) */
.unit-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}
.unit-toggle button {
  border: none;
  background: var(--surface);
  padding: 0 16px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--ink-soft);
  cursor: pointer;
}
.unit-toggle button.active {
  background: var(--brand);
  color: #fff;
}

.suggestions {
  border: 1px solid var(--border);
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface);
  margin-top: 4px;
  display: none;
  position: absolute;
  width: 100%;
  z-index: 100;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}
.suggestions div {
  padding: 11px 14px;
  cursor: pointer;
  font-size: 0.92rem;
  border-bottom: 1px solid var(--surface-sunken);
  color: var(--ink);
}
.suggestions div:last-child { border-bottom: none; }
.suggestions div:hover,
.suggestions div.active-suggestion {
  background-color: var(--brand-tint);
  color: var(--brand-dark);
}
.suggestions .no-match {
  color: var(--ink-faint);
  cursor: default;
}
.suggestions .no-match:hover { background: none; }

.calc-btn {
  width: 100%;
  padding: 14px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-body);
  transition: background 0.2s ease, transform 0.1s ease;
  margin-top: 6px;
}
.calc-btn:hover { background: var(--brand-dark); }
.calc-btn:active { transform: translateY(1px); }

/* ---- Result column ---- */
.result-col {
  display: flex;
  flex-direction: column;
}
.result-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--ink-faint);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 32px 20px;
  font-size: 0.92rem;
}

.result-box { display: none; }
.result-box.visible { display: block; animation: fadeIn 0.35s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.gl-badge {
  border-radius: var(--radius-md);
  padding: 28px 20px;
  text-align: center;
  color: #fff;
  transition: background 0.35s ease;
}
.gl-badge .gl-caption {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
  margin-bottom: 6px;
}
.gl-badge .gl-number {
  font-family: var(--font-display);
  font-size: 3.4rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.gl-badge .gl-status {
  margin-top: 8px;
  font-weight: 700;
  font-size: 1.05rem;
}

.gl-badge.low    { background: linear-gradient(155deg, #2E7D46, #1F6F5C); }
.gl-badge.medium { background: linear-gradient(155deg, #C6871A, #B7841F); }
.gl-badge.high   { background: linear-gradient(155deg, #C1440E, #B84A22); }

/* Scale strip under the badge */
.gl-scale {
  display: flex;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  margin: 16px 0 4px;
}
.gl-scale span { flex: 1; }
.gl-scale .s-low { background: var(--low); }
.gl-scale .s-medium { background: var(--medium); }
.gl-scale .s-high { background: var(--high); }
.gl-scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--ink-faint);
  margin-bottom: 18px;
}

.result-detail {
  background: var(--surface-sunken);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  font-size: 0.92rem;
  color: var(--ink);
  margin-bottom: 16px;
}
.result-detail div { padding: 3px 0; }
.result-detail strong { color: var(--ink); }

.suggestion-box {
  background: var(--brand-tint);
  border-left: 4px solid var(--brand);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 16px;
  font-size: 0.88rem;
  color: var(--brand-dark);
  margin-bottom: 16px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.action-btn:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.action-btn svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ==========================================================================
   Content sections
   ========================================================================== */
.content-section {
  padding: 56px 0;
  border-top: 1px solid var(--border);
}
.content-section.alt { background: var(--surface); }

.two-col {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 40px;
}
@media (max-width: 760px) {
  .two-col { grid-template-columns: 1fr; }
}

.ref-list {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  gap: 12px;
}
.ref-list li {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.ref-list a { font-weight: 600; }

/* FAQ accordion */
.faq-item {
  border-bottom: 1px solid var(--border);
}
.faq-item:first-child { border-top: 1px solid var(--border); }
.faq-question {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 18px 4px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.faq-question .icon {
  flex-shrink: 0;
  width: 20px; height: 20px;
  border: 1.5px solid var(--brand);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--brand);
  font-size: 0.85rem;
  transition: transform 0.2s ease;
}
.faq-item.open .icon { transform: rotate(45deg); }
.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.faq-item.open .faq-answer { max-height: 400px; }
.faq-answer p { padding: 0 4px 18px; margin: 0; }

/* Disclaimer callout */
.callout {
  background: var(--gold-tint);
  border-left: 4px solid var(--gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 16px 20px;
  font-size: 0.9rem;
  color: #6B4E14;
}
.callout p { color: #6B4E14; margin: 0; }

/* Ad slots (clearly marked placeholders) */
.ad-slot {
  max-width: var(--container);
  margin: 24px auto;
  padding: 0 24px;
}
.ad-slot .ad-slot-inner {
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-faint);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  background: var(--brand-dark);
  color: #CFE0D9;
  padding: 44px 0 24px;
  margin-top: 40px;
}
.site-footer h4 { color: #fff; font-family: var(--font-body); font-size: 0.85rem; letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 14px; }
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}
@media (max-width: 700px) {
  .footer-grid { grid-template-columns: 1fr; }
}
.footer-grid p { color: #A9C2B8; font-size: 0.88rem; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.footer-grid a { color: #CFE0D9; font-size: 0.88rem; }
.footer-grid a:hover { color: #fff; }
.footer-logo { font-family: var(--font-display); font-size: 1.15rem; color: #fff; margin-bottom: 10px; }
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.12);
  padding-top: 18px;
  font-size: 0.78rem;
  color: #8FAA9F;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* Simple content pages (about/privacy/disclaimer/contact) */
.page-body {
  padding: 48px 0 64px;
  max-width: 760px;
}
.page-body h2 { margin-top: 1.4em; }

/* Responsive nav for small screens */
@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .site-nav {
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
  }
  .site-nav.open { display: block; }
  .site-nav ul { flex-direction: column; gap: 0; padding: 8px 24px 16px; }
  .site-nav li { border-bottom: 1px solid var(--surface-sunken); }
  .site-nav a { display: block; padding: 12px 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
