/* ==========================================================================
   CalculatorLuv — Shared Component Library
   Base reset + every reusable UI piece (header, cards, inputs, accordion,
   tabs, table, badges, footer). Calculator-specific layout lives in each
   calculator's own style.css, which imports this file.
   ========================================================================== */

/* ---- Reset ---- */
*, *::before, *::after{ box-sizing: border-box; }
html, body{ margin: 0; padding: 0; }
body{
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
h1,h2,h3,h4,p,figure{ margin: 0; }
img{ max-width: 100%; display: block; }
a{ color: inherit; text-decoration: none; }
button{ font-family: inherit; }
ul{ margin: 0; padding: 0; list-style: none; }

/* Respect reduced-motion preference everywhere */
@media (prefers-reduced-motion: reduce){
  *{ transition: none !important; animation: none !important; }
}

/* ---- Layout ---- */
.container{
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 var(--space-5);
}

/* ---- Header ---- */
.site-header{
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .container{
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.logo{
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.2px;
}
.logo .mark{
  width: 26px; height: 26px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--text-on-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.logo .love{ color: var(--primary); }
.header-actions{ display: flex; align-items: center; gap: var(--space-3); }

.breadcrumb{
  display: flex; align-items: center; gap: var(--space-2);
  font-size: 13px; color: var(--text-tertiary);
}
.breadcrumb a:hover{ color: var(--text-secondary); }

/* ---- Theme toggle ---- */
.theme-toggle{
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.theme-toggle:hover{ background: var(--surface-hover); }
.theme-toggle svg{ width: 17px; height: 17px; }
.theme-toggle .icon-moon{ display: none; }
[data-theme="dark"] .theme-toggle .icon-sun{ display: none; }
[data-theme="dark"] .theme-toggle .icon-moon{ display: block; }

/* ---- Buttons ---- */
.btn{
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  padding: 9px 16px;
  font-size: 14px; font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease), color var(--duration) var(--ease);
}
.btn-primary{ background: var(--primary); color: var(--text-on-primary); }
.btn-primary:hover{ background: var(--primary-hover); }
.btn-ghost{ background: transparent; border-color: var(--border); color: var(--text-primary); }
.btn-ghost:hover{ background: var(--surface-hover); }

/* ---- Cards ---- */
.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad{ padding: var(--space-5); }

/* ---- Form fields ---- */
.field{ margin-bottom: var(--space-4); }
.field-label{
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  margin-bottom: var(--space-2);
}
.field-label .field-value{
  font-family: var(--font-mono); font-size: 12.5px; color: var(--text-primary);
}
.input-group{
  display: flex; align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-3);
  transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}
.input-group:focus-within{
  border-color: var(--primary);
  background: var(--surface);
}
.input-group .affix{ font-size: 14px; color: var(--text-tertiary); }
.input-group input, .input-group select{
  flex: 1;
  border: none; outline: none; background: transparent;
  font-family: var(--font-mono); font-size: 15px; color: var(--text-primary);
  padding: 10px 6px;
  width: 100%;
  -moz-appearance: textfield;
}
.input-group input::-webkit-outer-spin-button,
.input-group input::-webkit-inner-spin-button{ -webkit-appearance: none; margin: 0; }
.input-group select{ appearance: none; cursor: pointer; }
/* The closed <select> box picks up our CSS fine, but the dropdown popup
   list is drawn by the OS/browser and only respects dark mode when colors
   are set directly on <select>/<option> rather than just inherited. */
select, select option{
  background-color: var(--surface);
  color: var(--text-primary);
}
.field-row{ display: flex; gap: var(--space-4); }
.field-row .field{ flex: 1; min-width: 0; }

/* Range slider */
input[type="range"]{
  -webkit-appearance: none;
  width: 100%; height: 4px;
  background: var(--border);
  border-radius: var(--radius-full);
  margin-top: var(--space-2);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--primary);
}
input[type="range"]::-moz-range-thumb{
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--primary); cursor: pointer;
  border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--primary);
}

.section-title{ font-size: 15px; font-weight: 700; margin-bottom: var(--space-1); }
.section-sub{ font-size: 13px; color: var(--text-tertiary); margin-bottom: var(--space-5); }

/* ---- Accordion (used for taxes/fees toggle, amortization, FAQ) ---- */
.accordion-item{ border-top: 1px solid var(--border); }
.accordion-item:last-child{ border-bottom: 1px solid var(--border); }
.accordion-trigger{
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  background: none; border: none; cursor: pointer;
  padding: var(--space-4) 0;
  font-size: 14px; font-weight: 600; color: var(--text-primary);
  text-align: left;
}
.accordion-trigger .chevron{
  width: 18px; height: 18px; color: var(--text-tertiary); flex-shrink: 0;
  transition: transform var(--duration) var(--ease);
}
.accordion-item[data-open="true"] .chevron{ transform: rotate(180deg); }
.accordion-panel{
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--duration) var(--ease);
}
.accordion-item[data-open="true"] .accordion-panel{ grid-template-rows: 1fr; }
.accordion-panel-inner{ overflow: hidden; }
.accordion-panel-content{ padding-bottom: var(--space-5); }

/* ---- Tabs ---- */
.tabs{ display: inline-flex; background: var(--bg-secondary); border-radius: var(--radius-sm); padding: 3px; border: 1px solid var(--border); }
.tab{
  border: none; background: transparent; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  padding: 6px 14px; border-radius: 6px;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
.tab[aria-selected="true"]{ background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.tab-panel{ display: none; }
.tab-panel[data-active="true"]{ display: block; }

/* ---- Table ---- */
.table-scroll{ max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table{ width: 100%; border-collapse: collapse; font-size: 13px; }
thead th{
  position: sticky; top: 0;
  background: var(--bg-secondary);
  text-align: right;
  font-size: 11px; letter-spacing: 0.4px; text-transform: uppercase;
  color: var(--text-tertiary); font-weight: 700;
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
}
thead th:first-child, tbody td:first-child{ text-align: left; }
tbody td{
  text-align: right; padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono); color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}
tbody tr:last-child td{ border-bottom: none; }

/* ---- Badges ---- */
.badge{
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
  padding: 3px 9px; border-radius: var(--radius-full);
  background: var(--primary-soft); color: var(--primary);
  text-transform: uppercase;
}
.badge-muted{ background: var(--bg-secondary); color: var(--text-tertiary); }

/* ---- Result rows ---- */
.result-row{
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-2) 0;
  font-size: 14px;
}
.result-row .label{ color: var(--text-secondary); display: flex; align-items: center; gap: var(--space-2); }
.result-row .value{ font-family: var(--font-mono); font-weight: 600; }
.result-row .swatch{ width: 8px; height: 8px; border-radius: 2px; }

/* ---- Insight callouts ---- */
.insight{
  display: flex; gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
}
.insight strong{ color: var(--text-primary); }
.insight + .insight{ margin-top: var(--space-2); }

/* ---- Calculator grid card links (homepage) ---- */
.calc-card{
  display: block;
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color var(--duration) var(--ease), transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.calc-card:hover{ border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.calc-card.disabled{ cursor: default; opacity: 0.55; }
.calc-card.disabled:hover{ transform: none; box-shadow: var(--shadow-sm); border-color: var(--border); }
.calc-card .icon{
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--space-3);
}
.calc-card .icon svg{ width: 20px; height: 20px; }
.calc-card h3{ font-size: 15px; font-weight: 700; margin-bottom: var(--space-1); }
.calc-card p{ font-size: 13px; color: var(--text-tertiary); }
.calc-grid{ display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }

/* ---- Footer ---- */
.site-footer{
  border-top: 1px solid var(--border);
  padding: var(--space-6) 0;
  margin-top: var(--space-8);
}
.site-footer .container{
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-3);
}
.site-footer p{ font-size: 13px; color: var(--text-tertiary); }
.footer-links{ display: flex; gap: var(--space-4); font-size: 13px; color: var(--text-tertiary); }
.footer-links a:hover{ color: var(--text-primary); }

/* ---- Formula / reference boxes (shared across calculators) ---- */
.formula-box{
  font-family: var(--font-mono);
  font-size: 13.5px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  line-height: 1.8;
  overflow-x: auto;
}
.formula-box .comment{ color: var(--text-tertiary); }
.related-grid{ display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-3); }

/* ---- Utility ---- */
.visually-hidden{
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap;
}
:focus-visible{ outline: 2px solid var(--primary); outline-offset: 2px; }
