/* ── Fonts ─────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;600&display=swap');

@font-face {
  font-family: 'Glacial Indifference';
  src: url('/assets/fonts/GlacialIndifference-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Glacial Indifference';
  src: url('/assets/fonts/GlacialIndifference-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ── Variables ─────────────────────────────────────────────────────── */
:root {
  --color-primary:    #313130;
  --color-accent:     #125c10;
  --color-bg:         #f7f3ea;
  --color-bg-alt:     #ffffff;
  --color-text:       #000000;
  --color-muted:      #6B7280;
  --color-border:     #E5E7EB;
  --color-warning:    #FFD885;
  --color-error:      #E44D04;

  --font-heading: 'Cormorant Garamond', Georgia, serif;
  --font-body:    'Glacial Indifference', system-ui, sans-serif;

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

  --container-max: 1200px;
  --transition: 200ms ease-in-out;
}

/* ── Reset ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img, svg { display: block; max-width: 100%; }

/* ── Base ──────────────────────────────────────────────────────────── */
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-bg);
}

h1, h2, h3 {
  font-family: var(--font-heading);
  font-weight: 400;
  color: var(--color-primary);
}

h2 { font-size: 48px; line-height: 1.2; }
h3 { font-size: 36px; line-height: 1.3; }

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: opacity var(--transition);
}
a:hover { opacity: 0.75; text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; border-radius: 2px; }

.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  background: var(--color-accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  z-index: 9999;
  transition: top var(--transition);
}
.skip-link:focus { top: 16px; }

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

/* ── Header ────────────────────────────────────────────────────────── */
.site-header {
  background: var(--color-bg-alt);
  border-bottom: 1px solid var(--color-border);
  padding: 24px 0;
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 32px;
}

.logo-link { flex-shrink: 0; }
.logo { height: 40px; width: auto; }

.site-title {
  font-family: var(--font-heading);
  font-size: 36px;
  font-weight: 400;
  color: var(--color-primary);
  line-height: 1.1;
}

.tagline {
  font-size: 13px;
  color: var(--color-muted);
  letter-spacing: 0.05em;
  margin-top: 6px;
}

/* ── Section layout ────────────────────────────────────────────────── */
.prices-section {
  padding: 96px 0;
}

.chart-section {
  padding: 96px 0;
  background: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 48px;
}

.section-note {
  font-size: 13px;
  color: var(--color-muted);
  letter-spacing: 0.04em;
  margin-top: -32px;
  margin-bottom: 48px;
}

.last-updated {
  font-size: 13px;
  color: var(--color-muted);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* ── Commodity & state tabs ────────────────────────────────────────── */
.tabs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

.commodity-tabs,
.state-tabs {
  display: flex;
  gap: 8px;
}

.tab-btn {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 8px 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-alt);
  color: var(--color-primary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.tab-btn.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.tab-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* ── Latest prices grid ────────────────────────────────────────────── */
.prices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

.prices-grid.single {
  grid-template-columns: 1fr;
}

.commodity-card {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.commodity-card-header {
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--color-bg);
}

.commodity-card-header h3 {
  font-size: 36px;
}

.commodity-date {
  font-size: 13px;
  color: var(--color-muted);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* ── Price table ───────────────────────────────────────────────────── */
.price-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-family: var(--font-body);
}

.price-table th {
  text-align: left;
  padding: 10px 20px;
  color: var(--color-muted);
  font-weight: 400;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.price-table td {
  padding: 13px 20px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.price-table tbody tr:last-child td { border-bottom: none; }

.price-table tbody tr {
  transition: background var(--transition);
}
.price-table tbody tr:hover td { background: var(--color-bg); }

.modal-price {
  font-size: 13px;
  color: var(--color-muted);
  white-space: nowrap;
}

.modal-price.muted {
  font-weight: 400;
}

.price-range {
  font-weight: 700;
  font-size: 15px;
  color: var(--color-accent);
  white-space: nowrap;
}

.variety-tag {
  display: inline-block;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 12px;
  letter-spacing: 0.03em;
}

.grade-label {
  display: block;
  font-size: 11px;
  color: var(--color-muted);
  margin-top: 3px;
  letter-spacing: 0.03em;
}

/* ── Charts ────────────────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

.chart-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 28px;
}

.chart-card h3 {
  font-size: 28px;
  margin-bottom: 4px;
}

.chart-unit {
  font-size: 13px;
  color: var(--color-muted);
  letter-spacing: 0.04em;
  margin-bottom: 24px;
}

.chart-wrap {
  position: relative;
  height: 280px;
}

/* ── State messages ────────────────────────────────────────────────── */
.state-msg {
  font-size: 13px;
  color: var(--color-muted);
  letter-spacing: 0.04em;
  text-align: center;
  padding: 48px 0;
  grid-column: 1 / -1;
}

.state-msg.error { color: var(--color-error); }

.hidden { display: none !important; }

/* ── Card header actions ───────────────────────────────────────────── */
.card-header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.market-link {
  font-family: var(--font-body);
  font-size: inherit;
  background: none;
  border: none;
  color: var(--color-accent);
  cursor: pointer;
  padding: 0;
  text-align: left;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}

.market-link:hover { text-decoration-style: solid; }

/* ── Grade tooltip ─────────────────────────────────────────────────── */
.th-grade {
  position: relative;
}

.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--color-muted);
  background: none;
  color: var(--color-muted);
  font-size: 10px;
  font-family: var(--font-body);
  cursor: pointer;
  vertical-align: middle;
  margin-left: 4px;
  line-height: 1;
}

.info-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.grade-tooltip {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 100;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  min-width: 280px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.grade-tooltip dl { margin: 0; }
.grade-tooltip dt {
  font-weight: 700;
  font-size: 12px;
  color: var(--color-primary);
  margin-top: 8px;
}
.grade-tooltip dt:first-child { margin-top: 0; }
.grade-tooltip dd {
  font-size: 12px;
  color: var(--color-muted);
  margin: 2px 0 0 0;
  line-height: 1.4;
}

/* ── History modal ─────────────────────────────────────────────────── */
#history-modal {
  border: none;
  border-radius: var(--radius-md);
  padding: 32px;
  width: min(860px, 92vw);
  background: var(--color-bg-alt);
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}

#history-modal::backdrop {
  background: rgba(49,49,48,0.5);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.modal-header h3 {
  font-size: 28px;
  margin: 0 0 4px;
}

.modal-close {
  font-size: 20px;
  background: none;
  border: none;
  color: var(--color-muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  flex-shrink: 0;
}

.modal-close:hover { color: var(--color-primary); }

/* ── Contact form ──────────────────────────────────────────────────── */
.contact-section {
  padding: 80px 0;
  background: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
}

.contact-form {
  max-width: 560px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.form-row label {
  font-size: 13px;
  color: var(--color-muted);
  letter-spacing: 0.04em;
}

.form-row input,
.form-row textarea {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--color-primary);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s;
  resize: vertical;
}

.form-row input:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--color-accent);
}

.submit-btn {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 28px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: opacity 0.15s;
}

.submit-btn:hover { opacity: 0.85; }

/* ── Footer ────────────────────────────────────────────────────────── */
.site-footer {
  padding: 48px 0;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-alt);
}

.site-footer p {
  font-size: 13px;
  color: var(--color-muted);
  letter-spacing: 0.04em;
  text-align: center;
  line-height: 2;
}

.footer-brand {
  font-family: var(--font-heading);
  font-size: 20px;
  color: var(--color-primary) !important;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.footer-brand:hover {
  color: var(--color-accent) !important;
}

.site-footer a {
  color: var(--color-muted);
}
.site-footer a:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .prices-grid,
  .charts-grid {
    grid-template-columns: 1fr;
  }

  h2 { font-size: 32px; }
  h3 { font-size: 26px; }

  .prices-section,
  .chart-section {
    padding: 64px 0;
  }

  .site-header .container {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .section-header {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 32px;
  }
}

@media (max-width: 600px) {
  body { font-size: 16px; }

  .container { padding: 0 16px; }

  .commodity-card-header { padding: 16px; }

  .price-table th,
  .price-table td { padding: 10px 14px; }

  .chart-card { padding: 20px 16px; }

  .chart-wrap { height: 220px; }
}
