/* Calix Self-Install & Self-Upgrade Savings Calculator
   Responsive stylesheet — mobile first, fluid up to 1200px. */

:root {
  --calix-blue: #0B38DB;
  --calix-orange: #FF7600;
  --calix-light-blue: #64B1E7;
  --calix-charcoal: #333333;
  --ink: #232323;
  --muted: #62656c;
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e1e6f2;
  --soft-blue: #eef5ff;
  --soft-orange: #fff4ea;
  --radius: 18px;
  --shadow: 0 8px 28px rgba(20, 22, 35, .08);
  --gutter: clamp(12px, 3vw, 20px);
  --maxw: 1200px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: Arial, "Segoe UI", Roboto, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  overflow-wrap: break-word;
}

h1, h2 { line-height: 1.15; }

.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;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: #fff;
  color: var(--calix-blue);
  padding: 10px 14px;
  border-radius: 0 0 10px 0;
  font-weight: 700;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */

.site-header {
  background: linear-gradient(120deg, var(--calix-blue), #214be0 58%, var(--calix-light-blue));
  color: #fff;
  padding: clamp(14px, 3vw, 20px) var(--gutter) clamp(18px, 3.2vw, 26px);
  position: relative;
  overflow: hidden;
}
.site-header::after {
  content: "";
  position: absolute;
  right: -70px; top: -90px;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: rgba(255, 118, 0, .22);
}

.hero-lockup {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2.4vw, 20px);
  position: relative;
  z-index: 1;
  text-align: center;
}

.hero-logo {
  height: clamp(46px, 9vw, 76px);
  width: auto;
  max-width: min(330px, 72vw);
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .14));
}

.site-header h1 {
  margin: 0;
  max-width: 22ch;
  font-size: clamp(21px, 4.4vw, 38px);
  letter-spacing: -.5px;
  font-weight: 900;
  color: #fff;
}

@media (min-width: 760px) {
  .hero-lockup { flex-wrap: nowrap; text-align: left; }
  .site-header h1 { max-width: 500px; letter-spacing: -.7px; }
}

/* ---------- Layout ---------- */

main {
  max-width: var(--maxw);
  margin: clamp(14px, 2.4vw, 22px) auto clamp(20px, 5vw, 34px);
  padding: 0 var(--gutter);
  position: relative;
  z-index: 2;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
}

@media (min-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(14px, 2.6vw, 20px);
}
.card h2 {
  margin: 0 0 10px;
  font-size: clamp(17px, 2.2vw, 19px);
  color: var(--calix-charcoal);
}
.card h2.section-gap { margin-top: clamp(16px, 3vw, 22px); }

.small { color: var(--muted); font-size: 13px; line-height: 1.4; }
.hint { margin: 12px 0 0; }

/* ---------- Inputs ---------- */

.inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.field-label {
  display: block;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--calix-charcoal);
}

.control {
  display: flex;
  align-items: stretch;
  border: 1px solid #cad3e4;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.control:focus-within {
  border-color: var(--calix-blue);
  box-shadow: 0 0 0 3px rgba(11, 56, 219, .14);
}

.control input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px; /* 16px avoids iOS zoom-on-focus */
  color: var(--ink);
  min-height: 44px;
}
.control input:focus { outline: none; }
/* Hide spinners: the fields accept decimals and steppers are unusable on mobile */
.control input::-webkit-outer-spin-button,
.control input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.control input[type=number] { -moz-appearance: textfield; appearance: textfield; }

.control .unit {
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  background: #f6f8fd;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}
.control .unit.prefix {
  border-left: 0;
  border-right: 1px solid var(--border);
  order: -1;
}

/* ---------- Buttons ---------- */

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  min-height: 44px;
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  background: var(--calix-blue);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(11, 56, 219, .22);
  transition: filter .12s ease, transform .06s ease;
}
button.secondary {
  background: #fff;
  color: var(--calix-blue);
  border: 1px solid rgba(11, 56, 219, .25);
  box-shadow: none;
}
button:hover { filter: brightness(.97); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 3px solid rgba(11, 56, 219, .45); outline-offset: 2px; }

@media (max-width: 420px) {
  .actions { flex-direction: column; align-items: stretch; }
  .actions button { width: 100%; }
}

/* ---------- KPIs & metrics ---------- */

.kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.kpi .box {
  padding: clamp(12px, 2.4vw, 16px);
  border-radius: 14px;
  background: var(--soft-blue);
  border: 1px solid #d6e8ff;
  position: relative;
  overflow: hidden;
}
.kpi .box:nth-child(even) { background: var(--soft-orange); border-color: #ffe1c9; }
.kpi .box::after {
  content: "";
  position: absolute;
  right: -28px; bottom: -28px;
  width: 86px; height: 86px;
  border-radius: 50%;
  background: rgba(255, 118, 0, .18);
}
.value {
  font-size: clamp(26px, 6vw, 38px);
  font-weight: 900;
  letter-spacing: -.8px;
  line-height: 1.05;
  color: var(--calix-blue);
  position: relative;
  z-index: 1;
}
.kpi .box:nth-child(even) .value { color: var(--calix-orange); }
.label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: 4px;
  font-weight: 700;
  position: relative;
  z-index: 1;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.metric {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  border-top: 4px solid var(--calix-orange);
}
.metric strong { font-size: 20px; color: var(--calix-blue); display: block; }

/* Two-by-two on the desktop side column so no tile is orphaned on its own row */
@media (min-width: 980px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Bars ---------- */

.bar-row { margin: 10px 0; }
.bar-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.bar-title strong { white-space: nowrap; }
/* Below this width some labels wrap and some don't — stack them all for an even rhythm */
@media (max-width: 430px) {
  .bar-title { flex-direction: column; align-items: flex-start; gap: 2px; }
}
.bar {
  height: 10px;
  background: #edf0f6;
  border-radius: 999px;
  overflow: hidden;
}
.fill {
  height: 100%;
  background: linear-gradient(90deg, var(--calix-blue), var(--calix-light-blue), var(--calix-orange));
  border-radius: 999px;
  transition: width .25s ease;
}

/* ---------- Disclaimer & summary panel ---------- */

.results-disclaimer {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 4px solid var(--calix-orange);
  background: #fff7ef;
  border-radius: 10px;
  color: var(--calix-charcoal);
  font-size: 12.5px;
  line-height: 1.4;
}

.summary-panel {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfcff;
  overflow: hidden;
}
.summary-panel[hidden] { display: none; }
.summary-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--calix-charcoal);
}
#generatedSummary {
  display: block;
  width: 100%;
  min-height: 150px;
  border: 0;
  resize: vertical;
  padding: 10px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
  background: #fff;
}
#generatedSummary:focus { outline: 2px solid rgba(11, 56, 219, .3); outline-offset: -2px; }
.mini { padding: 7px 12px; min-height: 34px; font-size: 12px; box-shadow: none; }

/* ---------- Details / table ---------- */

.calc-details { margin-top: 14px; }
.calc-details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  font-weight: 900;
  font-size: clamp(15px, 2vw, 17px);
  color: var(--calix-charcoal);
}
.calc-details > summary::-webkit-details-marker { display: none; }
.calc-details > summary::after {
  content: "Show details";
  flex: none;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: var(--calix-blue);
  border-radius: 999px;
  padding: 7px 12px;
}
.calc-details[open] > summary::after { content: "Hide details"; background: var(--calix-orange); }
.calc-details > summary:focus-visible { outline: 3px solid rgba(11, 56, 219, .45); outline-offset: 2px; }
.calc-details .card { margin-top: 8px; }

.table-wrap { width: 100%; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th, .table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}
.table thead th {
  color: var(--calix-charcoal);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.table tbody tr:last-child th { color: var(--calix-blue); font-size: 14px; }
.table .right { text-align: right; }
.table .formula { color: var(--muted); font-size: 13px; }

.footer { margin: 16px 0 0; color: var(--muted); font-size: 12px; }

/* Stacked table on small screens — no horizontal scrolling, no lost data */
@media (max-width: 720px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table th, .table td { display: block; width: 100%; }
  .table tr {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: #fff;
  }
  .table tr:last-child { background: var(--soft-blue); border-color: #d6e8ff; }
  .table th, .table td { border: 0; padding: 3px 0; }
  .table td[data-label]::before,
  .table th[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
  }
  .table .right { text-align: left; }
  .table .cat { font-weight: 800; color: var(--calix-charcoal); }
}

/* ---------- Sticky mobile total ---------- */

.sticky-total {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .97);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 20px rgba(20, 22, 35, .10);
  font-size: 13px;
}
.sticky-label {
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
  font-size: 11px;
  color: var(--muted);
}
.sticky-values { display: flex; align-items: baseline; gap: 8px; }
.sticky-values strong { font-size: 17px; color: var(--calix-blue); letter-spacing: -.4px; }
.sticky-sep { color: var(--border); }
.sticky-values > span { color: var(--muted); font-size: 12px; }

@media (max-width: 979px) {
  .sticky-total { display: flex; }
  body { padding-bottom: 68px; }
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  z-index: 40;
  max-width: min(92vw, 420px);
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--calix-charcoal);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 979px) {
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- Print ---------- */

@media print {
  body { background: #fff; padding: 0; }
  .site-header { background: none; color: var(--ink); padding: 0 0 12px; }
  .site-header::after { display: none; }
  .site-header h1 { color: var(--ink); }
  .actions, .skip-link, .sticky-total, .toast, .calc-details > summary::after { display: none !important; }
  main { margin: 0; padding: 0; }
  .layout { grid-template-columns: 1fr 1fr; }
  .card, .calc-details > summary { box-shadow: none; break-inside: avoid; }
  .table tr, .bar-row, .metric, .kpi .box { break-inside: avoid; }
}
