/* Wines of Texas — Three aesthetic themes */

:root {
  --viewport-pad: 0px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'kern' 1, 'liga' 1;
}

img { max-width: 100%; display: block; }
a { color: inherit; }
button { font-family: inherit; }

/* ======================================================================
   THEME 1 — EDITORIAL MAGAZINE
   Serif-forward, cream + ink, NYT-flavored but original
   ====================================================================== */
[data-theme="editorial"] {
  --page-bg: #f6f2ea;
  --paper: #fbf8f2;
  --ink: #1a1612;
  --ink-soft: #4a423a;
  --ink-mute: #8a7f72;
  --rule: #d9cfbd;
  --accent: #7a1a1a;     /* oxblood */
  --accent-2: #3e5c3a;   /* vine green */
  --chip: #ebe3d4;
  --font-display: 'Playfair Display', 'Didot', 'Bodoni MT', Georgia, serif;
  --font-body: 'Source Serif Pro', 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-ui: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --radius: 2px;
  --radius-lg: 4px;
}

/* ======================================================================
   THEME 2 — RUSTIC HERITAGE
   Warm ochre, oxblood, sand; textured and ranch-y
   ====================================================================== */
[data-theme="rustic"] {
  --page-bg: #ede4d3;
  --paper: #f5ecda;
  --ink: #231712;
  --ink-soft: #4e382a;
  --ink-mute: #8b6b55;
  --rule: #c9b693;
  --accent: #a6451f;      /* terracotta */
  --accent-2: #5b6330;    /* sage */
  --chip: #dccdae;
  --font-display: 'DM Serif Display', 'Playfair Display', Georgia, serif;
  --font-body: 'Lora', Georgia, serif;
  --font-ui: 'Work Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --radius: 4px;
  --radius-lg: 10px;
}

/* Rustic adds a subtle paper texture */
[data-theme="rustic"] body {
  background-image:
    radial-gradient(rgba(120,90,60,0.06) 1px, transparent 1px),
    radial-gradient(rgba(120,90,60,0.04) 1px, transparent 1px);
  background-size: 3px 3px, 7px 7px;
  background-position: 0 0, 1px 2px;
}

/* ======================================================================
   THEME 3 — TERROIR ALMANAC
   Field guide / data-forward; off-white, ink, chart green
   ====================================================================== */
[data-theme="almanac"] {
  --page-bg: #f3f1ec;
  --paper: #ffffff;
  --ink: #0e1a14;
  --ink-soft: #2f3e36;
  --ink-mute: #6c7a71;
  --rule: #c4cac2;
  --accent: #1f4d3a;   /* deep green */
  --accent-2: #8a3b12; /* burnt rust for data highlight */
  --chip: #e4e5df;
  --font-display: 'Fraunces', 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-ui: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 0px;
  --radius-lg: 0px;
}

/* Almanac: grid lines in background */
[data-theme="almanac"] body {
  background-image:
    linear-gradient(to right, rgba(20,40,30,0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(20,40,30,0.04) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* ======================================================================
   SHARED UTILITIES
   ====================================================================== */

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 32px;
}

.container-narrow {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 32px;
}

.kicker {
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
}

.rule { border: 0; border-top: 1px solid var(--rule); margin: 0; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 22px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}
.btn:hover { background: var(--accent); border-color: var(--accent); }
.btn-ghost {
  background: transparent; color: var(--ink);
}
.btn-ghost:hover { background: var(--ink); color: var(--paper); }

[data-theme="rustic"] .btn { text-transform: none; letter-spacing: 0.02em; font-weight: 500; font-size: 14px; }
[data-theme="almanac"] .btn { text-transform: uppercase; letter-spacing: 0.1em; font-size: 11px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--chip);
  color: var(--ink-soft);
  border-radius: 99px;
}

[data-theme="almanac"] .chip {
  border-radius: 0;
  border: 1px solid var(--ink-soft);
  background: transparent;
  font-family: var(--font-mono);
}

/* Placeholder image — striped, never fake imagery */
.ph {
  position: relative;
  background: var(--chip);
  background-image: repeating-linear-gradient(
    135deg,
    rgba(0,0,0,0.04) 0px, rgba(0,0,0,0.04) 1px,
    transparent 1px, transparent 14px
  );
  color: var(--ink-mute);
  font-family: var(--font-mono);
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  letter-spacing: 0.1em;
  overflow: hidden;
}
.ph::before {
  content: '';
  position: absolute; inset: 8px;
  border: 1px dashed rgba(0,0,0,0.15);
  pointer-events: none;
}
.ph span {
  position: relative;
  padding: 6px 10px;
  background: var(--paper);
  border: 1px solid var(--rule);
  text-transform: uppercase;
}

/* Photo placeholder — seeded image from picsum */
.ph-photo {
  background-color: var(--chip);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  overflow: hidden;
}

/* Initial card — for unclaimed wineries; deterministic tint + first letter */
.ph-initial {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: rgba(255,255,255,0.92);
}
.ph-initial::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(135deg, rgba(255,255,255,0.04) 0 2px, transparent 2px 18px);
  pointer-events: none;
}
.ph-initial span {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(48px, 18cqw, 120px);
  line-height: 1;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 12px rgba(0,0,0,0.18);
  container-type: inline-size;
}

/* Top navigation */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--page-bg);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(8px);
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 32px;
  max-width: 1440px; margin: 0 auto;
}
.nav-logo {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  display: flex; align-items: baseline; gap: 8px;
}
.nav-logo small {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.nav-links {
  display: flex; gap: 28px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
}
.nav-links a {
  color: var(--ink-soft);
  text-decoration: none;
  cursor: pointer;
  padding: 6px 0;
  border-bottom: 1.5px solid transparent;
  transition: border-color 0.15s;
}
.nav-links a:hover, .nav-links a.active { border-color: var(--accent); color: var(--ink); }
.nav-actions { display: flex; gap: 10px; align-items: center; }
.nav-search {
  background: transparent; border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 8px 12px; font-size: 12px; width: 180px;
  font-family: var(--font-ui);
  color: var(--ink);
}
.nav-search::placeholder { color: var(--ink-mute); }

/* Footer */
.footer {
  margin-top: 120px;
  background: var(--ink);
  color: var(--paper);
  padding: 64px 32px 40px;
}
[data-theme="rustic"] .footer { background: #2c1e17; }
[data-theme="almanac"] .footer { background: #0e1a14; }

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  gap: 48px;
  max-width: 1280px; margin: 0 auto;
}
.footer h4 {
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  margin: 0 0 16px;
  font-weight: 600;
}
.footer ul { list-style: none; padding: 0; margin: 0; }
.footer li { margin-bottom: 10px; font-size: 14px; opacity: 0.85; }
.footer-brand {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1.15;
  margin-bottom: 12px;
}
.footer-brand small {
  display: block;
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.5;
  margin-top: 8px;
}
.footer-fine {
  max-width: 1280px; margin: 48px auto 0;
  padding-top: 24px;
  border-top: 1px solid rgba(255,255,255,0.12);
  display: flex; justify-content: space-between;
  font-family: var(--font-ui);
  font-size: 12px;
  opacity: 0.5;
}

/* Theme switcher chip (not the Tweaks panel — the in-page switcher shown
   in the nav for editorial/rustic/almanac demo. Stays visible.) */
.theme-pill {
  display: inline-flex; align-items: center;
  gap: 0;
  border: 1px solid var(--rule);
  border-radius: 99px;
  overflow: hidden;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.theme-pill button {
  background: transparent;
  border: 0;
  padding: 6px 12px;
  color: var(--ink-mute);
  cursor: pointer;
}
.theme-pill button.on {
  background: var(--ink);
  color: var(--paper);
}

/* Tweaks panel */
.tweaks {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 100;
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: var(--radius-lg);
  padding: 18px;
  width: 300px;
  font-family: var(--font-ui);
  font-size: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.18);
}
.tweaks h5 {
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin: 0 0 14px;
  display: flex; justify-content: space-between;
}
.tweaks label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 14px 0 6px;
  font-weight: 600;
}
.tweaks .opts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.tweaks .opt {
  padding: 8px 6px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 11px;
  border-radius: var(--radius);
  text-align: center;
  font-weight: 500;
}
.tweaks .opt.on {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.tweaks .check {
  display: flex; align-items: center; justify-content: space-between;
  margin: 10px 0;
  cursor: pointer;
}
.tweaks .check span { font-size: 12px; color: var(--ink-soft); }
.tweaks .check input { accent-color: var(--accent); }

/* Headline scales */
.h-display {
  font-family: var(--font-display);
  font-size: clamp(48px, 7vw, 108px);
  line-height: 0.92;
  letter-spacing: -0.025em;
  font-weight: 700;
  margin: 0;
  text-wrap: balance;
}
[data-theme="almanac"] .h-display { font-weight: 500; }
[data-theme="rustic"] .h-display { font-weight: 400; }

.h1 {
  font-family: var(--font-display);
  font-size: clamp(36px, 4.5vw, 64px);
  line-height: 1.02;
  letter-spacing: -0.02em;
  margin: 0;
  text-wrap: balance;
  font-weight: 700;
}
[data-theme="almanac"] .h1 { font-weight: 500; }

.h2 {
  font-family: var(--font-display);
  font-size: clamp(26px, 2.6vw, 38px);
  line-height: 1.1;
  margin: 0;
  letter-spacing: -0.015em;
  font-weight: 600;
}

.lede {
  font-family: var(--font-body);
  font-size: clamp(17px, 1.4vw, 20px);
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 60ch;
}

.section-label {
  display: flex; align-items: center; gap: 16px;
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
  margin-bottom: 24px;
}
.section-label::before {
  content: ''; width: 40px; height: 1.5px; background: var(--accent);
  display: inline-block;
}

/* ======================================================================
   MOBILE — collapse multi-column layouts, scale type, reduce padding.
   Many grids in the React components use inline styles, so we need
   high specificity + targeted !important to override them.
   ====================================================================== */

/* Tablet and below */
@media (max-width: 900px) {
  .container, .container-narrow {
    padding: 0 20px !important;
  }

  /* Nav — let it scroll horizontally rather than overflow */
  .nav-inner {
    padding: 12px 20px !important;
    gap: 12px;
  }
  .nav-actions { display: none !important; }
  .nav-links {
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 20px !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links a { white-space: nowrap; }
  .nav-logo { font-size: 18px !important; }
  .nav-logo small { display: none; }

  /* Footer */
  .footer { padding: 48px 20px 32px !important; margin-top: 64px !important; }
  .footer-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 32px !important;
  }
  .footer-fine {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}

/* Phone — single column everywhere */
@media (max-width: 700px) {
  /* Headlines — scale further */
  .h-display { font-size: clamp(38px, 9vw, 60px) !important; }
  .h1 { font-size: clamp(28px, 7vw, 42px) !important; }
  .h2 { font-size: clamp(22px, 5.5vw, 30px) !important; }
  .lede { font-size: 16px !important; }

  .container, .container-narrow {
    padding: 0 16px !important;
  }

  /* Tighten vertical rhythm on tall hero sections */
  main > section,
  main > div > section {
    padding-top: 32px !important;
    padding-bottom: 32px !important;
  }

  /* Stack ALL inline grid layouts to single column.
     The selector matches every element with an inline grid-template-columns. */
  [style*="grid-template-columns"],
  [style*="gridTemplateColumns"] {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }

  /* Footer back to 1 col on phones */
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
  }

  /* Tables — let them scroll horizontally rather than crush */
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  /* Tweaks panel — full-width drawer on mobile, doesn't cover content */
  .tweaks {
    left: 12px !important;
    right: 12px !important;
    bottom: 12px !important;
    width: auto !important;
    max-height: 60vh;
    overflow-y: auto;
  }

  /* Inputs — bigger tap targets, full width */
  input, textarea, select, button {
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  /* Hero block: remove huge top padding (React serializes to kebab-case) */
  [style*="padding-top: 64"],
  [style*="padding-bottom: 64"] {
    padding-top: 24px !important;
    padding-bottom: 24px !important;
  }
}

/* Very small phones */
@media (max-width: 380px) {
  .h-display { font-size: 36px !important; }
  .h1 { font-size: 26px !important; }
  .container { padding: 0 12px !important; }
}

[data-theme="almanac"] .section-label { font-family: var(--font-mono); }
