/* FenceCalculate.com — Styles
   Mobile-first, system font, green theme */

/* ─── Design tokens ──────────────────────────────────────────────────────── */
:root {
  --green-900: #0f3d26;
  --green-800: #155233;
  --green-700: #1e6b45;
  --green-600: #2d8a5e;
  --green-500: #3da872;
  --green-400: #5abf8a;
  --green-200: #a8dfc0;
  --green-100: #d4f0e2;
  --green-50:  #edf9f3;

  --brown-700: #5a3a1a;
  --brown-500: #8b6230;
  --brown-300: #c4a060;
  --brown-100: #f5ede0;

  --gray-900: #111827;
  --gray-700: #374151;
  --gray-500: #6b7280;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-50:  #f9fafb;
  --white:    #ffffff;

  --primary:        var(--green-700);
  --primary-dark:   var(--green-800);
  --primary-light:  var(--green-500);
  --primary-bg:     var(--green-50);
  --primary-border: var(--green-200);

  --text:           var(--gray-900);
  --text-secondary: var(--gray-700);
  --text-muted:     var(--gray-500);
  --border:         var(--gray-300);
  --surface:        var(--gray-50);
  --bg:             var(--white);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow:    0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.08);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;

  --max-width: 1100px;
  --tool-width: 780px;
}

/* ─── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.6; font-size: 16px; }
img, svg { display: block; max-width: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, select { font-family: inherit; font-size: inherit; }

/* ─── Cookie banner ──────────────────────────────────────────────────────── */
#cookieBanner {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 999;
  background: var(--gray-900); color: var(--white);
  padding: 14px 20px; display: flex; align-items: center;
  gap: 16px; flex-wrap: wrap; font-size: 14px;
  box-shadow: 0 -2px 12px rgba(0,0,0,.2);
}
#cookieBanner p { flex: 1; min-width: 200px; }
#cookieBanner a { color: var(--green-400); }
#btnAcceptConsent {
  background: var(--primary); color: var(--white); border: none;
  padding: 8px 20px; border-radius: var(--radius-sm); font-weight: 600;
  white-space: nowrap; font-size: 14px;
}
#btnAcceptConsent:hover { background: var(--primary-dark); }

/* ─── Site header ────────────────────────────────────────────────────────── */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
}
.site-logo {
  font-size: 1.25rem; font-weight: 800; color: var(--primary);
  display: flex; align-items: center; gap: 8px; text-decoration: none;
}
.site-logo svg { color: var(--primary); flex-shrink: 0; }
.site-logo:hover { text-decoration: none; opacity: .9; }
.logo-tag { color: var(--green-500); font-size: .75rem; font-weight: 600; letter-spacing: .04em; }

.site-nav { display: flex; align-items: center; gap: 4px; }
.site-nav a {
  color: var(--text-secondary); font-size: .9rem; font-weight: 500;
  padding: 6px 12px; border-radius: var(--radius-sm); transition: background .15s, color .15s;
}
.site-nav a:hover { background: var(--primary-bg); color: var(--primary); text-decoration: none; }

/* ─── Hero ───────────────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--green-900) 0%, var(--green-700) 60%, var(--green-600) 100%);
  color: var(--white); text-align: center;
  padding: 48px 20px 36px;
}
.hero h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); font-weight: 800; line-height: 1.2; margin-bottom: 10px; }
.hero p { font-size: 1.05rem; opacity: .88; max-width: 580px; margin: 0 auto 20px; }
.hero-badges { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.badge {
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.3);
  color: var(--white); padding: 5px 14px; border-radius: 99px; font-size: .8rem; font-weight: 600;
}

/* ─── Main layout ────────────────────────────────────────────────────────── */
.page-main { max-width: var(--max-width); margin: 0 auto; padding: 32px 20px 60px; }

.tool-layout { display: grid; grid-template-columns: 1fr; gap: 28px; }
@media (min-width: 900px) {
  .tool-layout { grid-template-columns: 340px 1fr; align-items: start; }
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden;
}
.card-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h2, .card-header h3 {
  font-size: 1rem; font-weight: 700; color: var(--gray-900);
  display: flex; align-items: center; gap: 8px;
}
.card-header .card-icon { font-size: 1.1rem; }
.card-body { padding: 20px; }

/* ─── Unit toggle ────────────────────────────────────────────────────────── */
.unit-toggle {
  display: flex; background: var(--gray-100); border-radius: var(--radius-sm);
  padding: 3px; gap: 2px; margin-bottom: 20px;
}
.unit-btn {
  flex: 1; padding: 6px 12px; border: none; border-radius: 5px; font-size: .85rem;
  font-weight: 600; background: transparent; color: var(--text-muted); transition: all .15s;
}
.unit-btn.active { background: var(--white); color: var(--primary); box-shadow: var(--shadow-sm); }

/* ─── Form elements ──────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: .85rem; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 5px; letter-spacing: .01em;
}
.form-select, .form-input {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--white); color: var(--text);
  font-size: .95rem; transition: border-color .15s, box-shadow .15s; appearance: none;
}
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 18px;
  padding-right: 36px; cursor: pointer;
}
.form-select:focus, .form-input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,107,69,.12);
}
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }

/* ─── Segments ───────────────────────────────────────────────────────────── */
.segments-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.total-length-display { font-size: .82rem; font-weight: 700; color: var(--primary); }
.segment-row {
  display: grid; grid-template-columns: 80px 1fr 32px;
  align-items: center; gap: 8px; margin-bottom: 8px;
}
.segment-label { font-size: .82rem; color: var(--text-muted); font-weight: 600; }
.segment-input-group { display: flex; align-items: center; gap: 0; }
.segment-input {
  flex: 1; padding: 8px 10px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm); font-size: .95rem;
  background: var(--white); color: var(--text); transition: border-color .15s;
}
.segment-input:focus { outline: none; border-color: var(--primary); }
.unit-label {
  padding: 8px 10px; background: var(--gray-100); border: 1.5px solid var(--border);
  border-left: none; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .85rem; color: var(--text-muted); font-weight: 600; white-space: nowrap;
}
.btn-remove-segment {
  width: 28px; height: 28px; border: none; background: var(--gray-100);
  color: var(--gray-500); border-radius: 50%; font-size: 12px; line-height: 1;
  transition: background .15s, color .15s;
}
.btn-remove-segment:hover { background: #fee2e2; color: #dc2626; }

.btn-add-segment {
  display: flex; align-items: center; gap: 6px;
  background: none; border: 1.5px dashed var(--primary-border);
  color: var(--primary); padding: 7px 14px; border-radius: var(--radius-sm);
  font-size: .85rem; font-weight: 600; width: 100%; justify-content: center;
  transition: background .15s, border-color .15s; margin-top: 4px;
}
.btn-add-segment:hover { background: var(--primary-bg); border-color: var(--primary); }

/* ─── Style description ──────────────────────────────────────────────────── */
.style-description {
  font-size: .83rem; color: var(--text-muted); margin-top: 5px;
  padding: 8px 10px; background: var(--primary-bg); border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
}

/* ─── Gates ──────────────────────────────────────────────────────────────── */
.gates-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.gate-label-small { font-size: .76rem; color: var(--text-muted); display: block; }

/* ─── Custom height ──────────────────────────────────────────────────────── */
.custom-height-row { margin-top: 8px; }
.hidden { display: none !important; }

/* ─── Results panel ──────────────────────────────────────────────────────── */
.results-panel { display: flex; flex-direction: column; gap: 20px; }

.results-empty {
  text-align: center; padding: 40px 20px; color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.results-summary {
  font-size: .88rem; color: var(--text-secondary); margin-bottom: 14px;
  padding: 8px 12px; background: var(--green-50); border-radius: var(--radius-sm);
  border: 1px solid var(--green-100);
}

.result-cards {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-bottom: 12px;
}
@media (min-width: 600px) { .result-cards { grid-template-columns: repeat(4, 1fr); } }

.result-card {
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 16px 12px;
  text-align: center; transition: border-color .15s, box-shadow .15s;
}
.result-card:hover { border-color: var(--primary-border); box-shadow: var(--shadow-sm); }
.result-icon { font-size: 1.4rem; margin-bottom: 6px; display: block; }
.result-value { font-size: 1.75rem; font-weight: 800; color: var(--primary); line-height: 1; margin-bottom: 4px; }
.result-label { font-size: .8rem; color: var(--text-muted); font-weight: 500; }
.result-label small { display: block; font-size: .72rem; margin-top: 2px; }

.results-note {
  font-size: .83rem; color: var(--text-secondary);
  background: var(--brown-100); border: 1px solid #e8d9c0;
  border-radius: var(--radius-sm); padding: 10px 14px; line-height: 1.5;
}

/* ─── Diagram ────────────────────────────────────────────────────────────── */
.diagram-wrap {
  border-radius: var(--radius); overflow: hidden;
  border: 1.5px solid var(--primary-border); background: var(--white);
}
.diagram-wrap svg { width: 100%; height: auto; }

/* ─── Actions bar ────────────────────────────────────────────────────────── */
.actions-bar { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-primary, .btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-size: .88rem; font-weight: 600; border: none; transition: all .15s;
}
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
  background: var(--white); color: var(--text-secondary);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-500); color: var(--text); }

/* ─── Collapsible sections ───────────────────────────────────────────────── */
.collapsible-trigger {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; background: none; border: none; padding: 14px 20px;
  font-size: .95rem; font-weight: 700; color: var(--text);
  border-top: 1px solid var(--gray-200); cursor: pointer; transition: background .15s;
}
.collapsible-trigger:hover { background: var(--gray-50); }
.toggle-icon {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--gray-200); display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--gray-500); transition: transform .2s; flex-shrink: 0;
}
.toggle-icon.rotated { transform: rotate(180deg); }
.collapsible-body { padding: 20px; border-top: 1px solid var(--gray-200); }
.collapsible-body.collapsed { display: none; }

/* ─── Cost estimator ─────────────────────────────────────────────────────── */
.price-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.price-row { display: flex; flex-direction: column; gap: 4px; }
.price-label { font-size: .8rem; font-weight: 600; color: var(--text-secondary); }
.price-input-wrap { display: flex; align-items: center; }
.price-prefix {
  padding: 8px 10px; background: var(--gray-100); border: 1.5px solid var(--border);
  border-right: none; border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  font-size: .88rem; color: var(--text-muted); font-weight: 600;
}
.price-input {
  flex: 1; padding: 8px 10px; border: 1.5px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .88rem; transition: border-color .15s;
}
.price-input:focus { outline: none; border-color: var(--primary); }
.cost-table {
  width: 100%; border-collapse: collapse; font-size: .88rem; margin-top: 16px;
}
.cost-table th, .cost-table td {
  padding: 9px 12px; border-bottom: 1px solid var(--gray-200); text-align: left;
}
.cost-table th { background: var(--gray-50); font-weight: 700; color: var(--text-secondary); font-size: .8rem; }
.cost-table td:not(:first-child) { text-align: right; }
.cost-table th:not(:first-child) { text-align: right; }
.subtotal-row td { border-top: 2px solid var(--gray-300); font-weight: 600; }
.total-row td { background: var(--primary-bg); font-size: 1rem; }
.cost-note { font-size: .78rem; color: var(--text-muted); margin-top: 10px; font-style: italic; }

/* ─── Formula section ────────────────────────────────────────────────────── */
.formula-section { margin-bottom: 16px; }
.formula-section h4 { font-size: .88rem; font-weight: 700; color: var(--primary); margin-bottom: 6px; }
.formula-section p { font-size: .85rem; color: var(--text-secondary); margin-bottom: 4px; }
.formula-section code {
  font-family: var(--font-mono); font-size: .82rem;
  background: var(--gray-100); padding: 2px 6px; border-radius: 4px; color: var(--gray-900);
  display: inline-block;
}
.formula-note { font-size: .78rem; color: var(--text-muted) !important; font-style: italic; }

/* ─── FAQ ────────────────────────────────────────────────────────────────── */
.faq-section { max-width: var(--tool-width); margin: 40px auto 0; }
.faq-section h2 { font-size: 1.4rem; font-weight: 800; margin-bottom: 20px; }
.faq-item { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.faq-trigger {
  width: 100%; text-align: left; background: none; border: none;
  padding: 14px 18px; font-size: .95rem; font-weight: 600; color: var(--text);
  cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  transition: background .15s;
}
.faq-trigger:hover { background: var(--gray-50); }
.faq-answer { padding: 4px 18px 16px; font-size: .9rem; color: var(--text-secondary); line-height: 1.7; }
.faq-answer p { margin-bottom: 8px; }
.faq-answer ul { padding-left: 18px; }
.faq-answer ul li { margin-bottom: 4px; }
.faq-answer.collapsed { display: none; }
.faq-chevron { font-size: .75rem; color: var(--text-muted); transition: transform .2s; }
.faq-chevron.open { transform: rotate(180deg); }

/* ─── Related tools ──────────────────────────────────────────────────────── */
.related-section { max-width: var(--tool-width); margin: 40px auto 0; }
.related-section h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 14px; }
.related-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 600px) { .related-grid { grid-template-columns: repeat(3, 1fr); } }
.related-card {
  border: 1.5px solid var(--border); border-radius: var(--radius); padding: 14px;
  transition: border-color .15s, box-shadow .15s; text-decoration: none; display: block;
  background: var(--white); color: var(--text);
}
.related-card:hover { border-color: var(--primary-border); box-shadow: var(--shadow-sm); text-decoration: none; color: var(--primary); }
.related-card-icon { font-size: 1.3rem; margin-bottom: 6px; }
.related-card-name { font-size: .85rem; font-weight: 700; display: block; margin-bottom: 2px; }
.related-card-desc { font-size: .75rem; color: var(--text-muted); }
.related-card.coming-soon { opacity: .55; pointer-events: none; }

/* ─── Trust strip ────────────────────────────────────────────────────────── */
.trust-strip {
  text-align: center; padding: 28px 20px;
  background: var(--primary-bg); border-top: 1px solid var(--primary-border);
  border-bottom: 1px solid var(--primary-border); margin: 40px 0;
}
.trust-strip p { font-size: .85rem; color: var(--text-muted); max-width: 600px; margin: 0 auto; }
.trust-strip strong { color: var(--text-secondary); }

/* ─── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--gray-900); color: var(--gray-300); padding: 32px 20px;
}
.footer-inner { max-width: var(--max-width); margin: 0 auto; }
.footer-top { display: flex; flex-wrap: wrap; gap: 24px; justify-content: space-between; margin-bottom: 24px; }
.footer-brand { font-size: .95rem; }
.footer-brand strong { color: var(--white); font-size: 1.05rem; }
.footer-brand p { margin-top: 6px; font-size: .82rem; color: var(--gray-500); max-width: 280px; }
.footer-links { display: flex; flex-direction: column; gap: 6px; }
.footer-links a { color: var(--gray-400); font-size: .85rem; transition: color .15s; }
.footer-links a:hover { color: var(--green-400); text-decoration: none; }
.footer-bottom { border-top: 1px solid #374151; padding-top: 16px; font-size: .78rem; color: var(--gray-500); }

/* ─── Print styles ───────────────────────────────────────────────────────── */
@media print {
  .site-header, .hero, .faq-section, .related-section, .trust-strip,
  .site-footer, .actions-bar, .btn-add-segment, #cookieBanner,
  .collapsible-trigger, [id="costSection"], [id="formulaSection"] { display: none !important; }
  .page-main { padding: 0; }
  .tool-layout { display: block; }
  .card { border: 1px solid #ccc; box-shadow: none; page-break-inside: avoid; margin-bottom: 16px; }
  .result-cards { grid-template-columns: repeat(4, 1fr); }
  .result-value { font-size: 1.3rem; }
  body { font-size: 13px; }
  .print-header { display: block !important; font-size: 11px; color: #666; margin-bottom: 8px; }
}
.print-header { display: none; }

/* ─── Responsive nav ─────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .site-nav { display: none; }
  .hero { padding: 32px 16px 28px; }
  .result-cards { grid-template-columns: 1fr 1fr; }
  .price-grid { grid-template-columns: 1fr; }
  .gates-grid { grid-template-columns: 1fr 1fr; }
  .footer-top { flex-direction: column; }
}

/* ─── Utilities ──────────────────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.text-muted { color: var(--text-muted); font-size: .85rem; }
