/* ==========================================================================
   The Ultimate Construction Conversion Matrix — styles.css
   Rugged, glove-friendly, high-contrast. One accent: safety orange.
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root,
[data-theme="light"] {
  --bg: #F2EFE9;
  --surface: #FFFFFF;
  --surface-2: #E9E4D9;
  --text: #191A1E;
  --muted: #565A63;
  --line: #D8D1C2;
  --line-strong: #A99F8B;
  --accent: #FF7A00;          /* safety-orange fill */
  --accent-ink: #1C1002;      /* text on accent fill */
  --accent-text: #B84A00;     /* accent used as text on light bg */
  --accent-soft: #FFE6CF;
  --danger: #B3261E;
  --shadow: 0 1px 2px rgba(25, 18, 6, .07), 0 5px 16px rgba(25, 18, 6, .06);
}

[data-theme="dark"] {
  --bg: #121417;
  --surface: #1B1F25;
  --surface-2: #242A32;
  --text: #F2F0EA;
  --muted: #9DA3AD;
  --line: #32383F;
  --line-strong: #4C5561;
  --accent: #FF8A2A;          /* brighter orange for dark bg */
  --accent-ink: #201202;
  --accent-text: #FFA45C;
  --accent-soft: #3A2A17;
  --danger: #FF8A7E;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 6px 20px rgba(0, 0, 0, .35);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
a { color: var(--accent-text); }

.container { max-width: 1140px; margin-inline: auto; padding-inline: 16px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 800; padding: 12px 18px; border-radius: 0 0 12px 0;
  text-decoration: none;
}
.skip-link:focus { left: 0; }

/* Global focus ring (keyboard navigability) */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--accent-text);
  outline-offset: 2px;
}

.noscript-note {
  background: var(--accent-soft);
  border: 2px solid var(--accent-text);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
  margin: 16px 0;
  font-weight: 600;
}

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 3px solid var(--accent);
}
.header-inner {
  display: flex; align-items: center; gap: 14px;
  padding-block: 14px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 46px; height: 46px; flex: none;
  border-radius: 12px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
}
.brand-mark svg { width: 28px; height: 28px; }
.brand-text { min-width: 0; }
.site-header h1 {
  margin: 0;
  font-size: clamp(1rem, 2.6vw, 1.45rem);
  line-height: 1.15;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.tagline { margin: 2px 0 0; color: var(--muted); font-size: .85rem; font-weight: 600; }

#theme-toggle {
  margin-left: auto; flex: none;
  min-width: 52px; min-height: 52px;
  border-radius: 14px;
  border: 2px solid var(--line-strong);
  background: var(--surface);
  display: grid; place-items: center;
  cursor: pointer;
}
#theme-toggle svg { width: 24px; height: 24px; }
[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"]  .icon-sun  { display: none; }

/* Simple header variant for legal pages */
.site-header.simple .header-inner { padding-block: 12px; }
.site-header.simple a.brand-link {
  display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text);
}
.site-header.simple .site-name { font-weight: 800; text-transform: uppercase; letter-spacing: .03em; font-size: .95rem; }

/* ---------- Quick-tap preset dashboard (sticky) ---------- */
.preset-bar {
  position: sticky; top: 0; z-index: 60;
  background: var(--bg);
  border-bottom: 2px solid var(--line);
}
.preset-row {
  display: flex; gap: 10px;
  padding-block: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.preset {
  flex: none;
  min-height: 56px; min-width: 112px;
  padding: 6px 18px;
  border-radius: 14px;
  border: 2px solid var(--line-strong);
  background: var(--surface);
  font-weight: 800; font-size: 1rem; letter-spacing: .01em;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.preset:hover { border-color: var(--accent-text); }
.preset.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
@media (min-width: 980px) {
  .preset-row { flex-wrap: wrap; overflow: visible; justify-content: center; }
}

/* ---------- Advertisement placeholder slots ----------
   Replace each .ad-slot's contents with a Google AdSense unit.
   Kept away from input controls; no pop-ups; no auto-refresh. */
.ad-slot {
  margin: 18px 0;
  border: 2px dashed var(--line-strong);
  border-radius: 14px;
  min-height: 110px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
  color: var(--muted);
  text-align: center;
  padding: 16px;
}
.ad-tag {
  font-size: .72rem; font-weight: 800;
  letter-spacing: .3em; text-transform: uppercase;
}
.ad-note { font-size: .75rem; }

/* ---------- Converter section ---------- */
.converter { padding-top: 6px; }
.trust-note {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: .92rem;
  color: var(--muted);
  margin: 14px 0 4px;
}
.trust-note svg { width: 20px; height: 20px; flex: none; color: var(--accent-text); }
.trust-note.small { font-size: .8rem; font-weight: 600; }

/* Tabs */
.tabs {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 12px 0 14px;
}
.tab {
  flex: none;
  min-height: 48px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 2px solid var(--line-strong);
  background: var(--surface);
  font-weight: 800; font-size: .95rem;
  cursor: pointer;
  white-space: nowrap;
}
.tab[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* Panels: mobile = swipeable single column, desktop = 2-col grid (all visible) */
.panels {
  position: relative;
  display: flex; gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 10px;
  scrollbar-width: thin;
}
.panel {
  flex: 0 0 100%;
  min-width: 100%;
  scroll-snap-align: start;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
}
@media (min-width: 980px) {
  .panels {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    overflow: visible;
    padding-bottom: 0;
  }
  .panel { min-width: 0; scroll-margin-top: 96px; }
}

.panel-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 6px; }
.panel-icon {
  width: 44px; height: 44px; flex: none;
  border-radius: 12px;
  background: var(--accent-soft); color: var(--accent-text);
  display: grid; place-items: center;
}
.panel-icon svg { width: 24px; height: 24px; }
.panel-head h2 {
  margin: 0;
  font-size: 1rem; line-height: 1.25;
  text-transform: uppercase; letter-spacing: .05em;
}
.panel-sub { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }
.reset-btn { margin-left: auto; flex: none; }

/* Material density row */
.material-row {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 10px 14px;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  margin: 14px 0 18px;
}
.material-row label {
  font-weight: 800; text-transform: uppercase;
  font-size: .8rem; letter-spacing: .08em;
}
.material-row select {
  min-height: 48px;
  border-radius: 12px;
  border: 2px solid var(--line-strong);
  background: var(--surface); color: var(--text);
  font-size: 1.02rem; font-weight: 700;
  padding: 0 12px;
  max-width: 100%;
}
.density-readout {
  margin: 0; width: 100%;
  font-weight: 800;
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
}
@media (min-width: 640px) {
  .density-readout { width: auto; margin-left: auto; }
}

/* Conversion groups */
.conv-group { padding-top: 16px; margin-top: 16px; border-top: 2px solid var(--line); }
.group-title {
  margin: 0 0 12px;
  font-size: .93rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.field-row { display: flex; flex-wrap: wrap; gap: 12px; }
.result-row { margin-top: 12px; }
.field {
  flex: 1 1 150px;
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0;
}
.field label {
  font-size: .78rem; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
}
.field input,
.field select {
  width: 100%;
  min-height: 56px;
  border: 2px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface); color: var(--text);
  font-size: 1.3rem; font-weight: 700;
  padding: 0 14px;
  font-variant-numeric: tabular-nums;
}
.field select { font-size: 1.05rem; }
.field input::placeholder { color: var(--line-strong); font-weight: 600; }
.field input[readonly] {
  background: var(--surface-2);
  border-left: 6px solid var(--accent);
}
.field.has-error input { border-color: var(--danger); }
.field-error {
  margin: 0;
  color: var(--danger);
  font-size: .83rem; font-weight: 700;
}
.group-note { margin: 10px 0 0; color: var(--muted); font-size: .8rem; }

/* Buttons */
.btn {
  min-height: 48px;
  padding: 10px 20px;
  border-radius: 12px;
  border: 2px solid var(--line-strong);
  background: var(--surface);
  font-weight: 800;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent-text); }
.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.reset-btn { font-size: .9rem; padding: 8px 16px; }

/* ---------- Supporting content ---------- */
.content-section { margin-top: 52px; }
.content-section h2 {
  font-size: 1.3rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 0 0 10px;
}
.table-card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  margin-top: 14px;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td {
  padding: 12px 14px;
  border-bottom: 2px solid var(--line);
  text-align: left;
  font-size: .95rem;
  white-space: nowrap;
}
thead th {
  background: var(--surface-2);
  text-transform: uppercase;
  font-size: .78rem; letter-spacing: .07em;
}
tbody tr:nth-child(even) { background: var(--surface-2); }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: none; }

.tip-list { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 10px; }
.tip-list li {
  background: var(--surface);
  border: 2px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: .95rem;
}

/* FAQ */
.faq details {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 14px;
  margin-top: 12px;
}
.faq summary {
  cursor: pointer;
  padding: 16px 48px 16px 18px;
  font-weight: 800; font-size: 1.02rem;
  list-style: none;
  position: relative;
  min-height: 48px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "";
  position: absolute; right: 18px; top: 50%;
  width: 10px; height: 10px;
  border-right: 3px solid var(--accent-text);
  border-bottom: 3px solid var(--accent-text);
  transform: translateY(-70%) rotate(45deg);
  transition: transform .15s ease;
}
.faq details[open] summary::after { transform: translateY(-30%) rotate(225deg); }
.faq .faq-body { padding: 0 18px 16px; color: var(--muted); }
.faq .faq-body p { margin: 0 0 10px; }
.faq .faq-body p:last-child { margin-bottom: 0; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 56px;
  background: var(--surface);
  border-top: 8px solid transparent;
  border-image: repeating-linear-gradient(-45deg, var(--accent) 0 14px, var(--text) 14px 28px) 8;
}
.footer-grid {
  display: grid; gap: 24px;
  grid-template-columns: 1fr;
  padding-block: 32px;
}
@media (min-width: 700px) {
  .footer-grid { grid-template-columns: 1.6fr 1fr; }
}
.footer-logo {
  margin: 0 0 8px;
  font-weight: 800; text-transform: uppercase; letter-spacing: .03em;
}
.footer-brand p { margin: 0 0 10px; color: var(--muted); font-size: .92rem; }
.footer-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.footer-nav a {
  color: var(--text); font-weight: 700; text-decoration: none;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 1px;
}
.footer-nav a:hover { color: var(--accent-text); }
.footer-bottom {
  border-top: 2px solid var(--line);
  padding-block: 16px;
  color: var(--muted);
  font-size: .85rem;
}
.footer-bottom p { margin: 0; }

/* ---------- Cookie consent bar ---------- */
#cookie-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  background: var(--surface);
  border-top: 4px solid var(--accent);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .25);
}
.cookie-inner {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center;
  padding-block: 14px;
}
.cookie-inner p { margin: 0; flex: 1 1 320px; font-size: .92rem; }

/* ---------- Prose pages (About / Privacy / Terms / Contact / Disclaimer) ---------- */
.prose { max-width: 780px; padding-top: 30px; padding-bottom: 64px; }
.prose h1 { font-size: 1.7rem; margin: 0 0 4px; text-transform: uppercase; letter-spacing: .03em; }
.prose .updated { color: var(--muted); margin: 0 0 24px; font-size: .9rem; }
.prose h2 { margin-top: 30px; font-size: 1.12rem; }
.prose p, .prose li { font-size: 1rem; }
.prose ul { padding-left: 22px; }
.prose a { font-weight: 700; }
.prose .contact-card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: 12px;
  padding: 16px;
  margin: 18px 0;
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
