/* Rent or buy calculator — palette "Sky and sunset" (light theme only for v1). */

:root {
  --ink: #023047;
  --ink2: #2A4A5E;
  --muted: #4F6878;
  --ground: #EEF6FA;
  --surface: #FFFFFF;
  --soft: #E4F2F9;
  --line: #CFE3EE;
  --grid: #E1EEF5;
  --border: #B4D0DF;
  --axis: #8FA9B8;
  --buy: #219EBC;
  --buy-text: #12708A;
  --rent: #FB8500;
  --rent-text: #A35400;
  --accent: #FFB703;
  --light: #8ECAE6;
  --error: #B42318;

  --font: Archivo, 'Helvetica Neue', Helvetica, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3, p { margin: 0; }

button, input { font: inherit; color: inherit; }

.num, input { font-variant-numeric: tabular-nums; }

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

.buy-text { color: var(--buy-text); }
.rent-text { color: var(--rent-text); }

/* Focus */
input:focus { outline: none; }
button:focus-visible { outline: 3px solid var(--buy); outline-offset: 3px; }
.field:focus-within { outline: 3px solid var(--buy); outline-offset: 2px; }
.verdict:focus { outline: none; }

/* Page layout */
.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 64px 80px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.intro {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 48px;
  max-width: 760px;
}

h1 {
  font-size: 76px;
  line-height: 0.95;
  font-weight: 800;
  font-stretch: 72%;
  letter-spacing: -0.01em;
}

.intro p { font-size: 19px; line-height: 1.5; color: var(--ink2); }

.layout {
  display: grid;
  grid-template-columns: 392px minmax(0, 1fr);
  gap: 56px;
  align-items: start;
}

/* Inputs sheet */
.sheet {
  background: var(--surface);
  border-radius: 16px;
  padding: 28px 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sheet h2 { font-size: 22px; line-height: 1.2; font-weight: 700; }

.stack { display: flex; flex-direction: column; gap: 22px; }

.pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.input-block { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.input-block label { font-size: 15px; font-weight: 600; }

.field {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: text;
}

.field input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  border: 0;
  padding: 0;
  font-size: 17px;
  color: var(--ink);
  background: transparent;
}

.field .prefix { font-size: 17px; color: var(--muted); }
.field .suffix { font-size: 15px; color: var(--muted); white-space: nowrap; }

.input-block.invalid .field { border-color: var(--error); }

.help { font-size: 13px; line-height: 1.4; color: var(--muted); }
.error { font-size: 13px; line-height: 1.4; color: var(--error); }

/* Compact fields inside the assumption groups */
.input-block.compact label { font-size: 14px; }
.input-block.compact .field { height: 44px; padding: 0 12px; }
.input-block.compact .field input { font-size: 16px; }
.input-block.compact .field .suffix { font-size: 14px; }
.input-block.compact .help,
.input-block.compact .error { font-size: 12px; }

/* Calculated box */
.calc {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px;
  background: var(--soft);
  border-radius: 12px;
}
.calc-row { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; }
.calc-row span { color: var(--ink2); }
.calc-row strong { font-weight: 700; }

/* Assumptions */
.assumptions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--grid);
}

.disclosure {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 17px;
  font-weight: 700;
  text-align: left;
}

.chevron { transition: transform 160ms ease; }
.chevron path { fill: none; stroke: var(--ink); stroke-width: 2px; stroke-linecap: round; stroke-linejoin: round; }
.disclosure[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.summary { font-size: 14px; line-height: 1.5; color: var(--ink2); }

.groups { display: flex; flex-direction: column; gap: 24px; padding-top: 4px; }
.groups[hidden] { display: none; }

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
legend { padding: 0; margin-bottom: 4px; font-size: 15px; font-weight: 700; }
/* Extra savings */
.extra { display: flex; flex-direction: column; gap: 12px; }
.choice legend { font-size: 14px; font-weight: 600; }
.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: var(--soft);
  border-radius: 12px;
}
.segmented label { position: relative; display: flex; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 6px 10px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  color: var(--ink2);
}
.segmented input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(2, 48, 71, 0.15); }
.segmented input:focus-visible + span { outline: 3px solid #219EBC; outline-offset: 1px; }

fieldset .grid3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
fieldset .grid2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.reset {
  align-self: flex-start;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--buy-text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Share */
.share-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.share {
  min-height: 44px;
  padding: 0 18px;
  border: 1.5px solid var(--buy-text);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  color: var(--buy-text);
}
.share:hover { background: var(--soft); }
.share-status { font-size: 14px; color: var(--ink2); overflow-wrap: anywhere; min-width: 0; }

/* Results */
.results { min-width: 0; display: flex; flex-direction: column; gap: 56px; }

.verdict-block { display: flex; flex-direction: column; gap: 20px; }

.verdict {
  max-width: 820px;
  font-size: 64px;
  line-height: 1.02;
  font-weight: 800;
  font-stretch: 75%;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.verdict.buy { color: var(--buy-text); }
.verdict.rent { color: var(--rent-text); }
.verdict.even { color: var(--ink); }

.totals { display: flex; flex-wrap: wrap; gap: 16px 48px; }
.totals div { display: flex; flex-direction: column; gap: 2px; }
.totals span { font-size: 15px; color: var(--ink2); }
.totals strong { font-size: 30px; line-height: 1.2; font-weight: 700; font-stretch: 85%; }

.break-even {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 32px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.break-even p { font-size: 17px; line-height: 1.45; }

.block { display: flex; flex-direction: column; gap: 16px; }
.block h2 { font-size: 24px; line-height: 1.2; font-weight: 700; }
.lede { max-width: 680px; font-size: 15px; line-height: 1.5; color: var(--ink2); }
.note { max-width: 720px; font-size: 15px; line-height: 1.5; }

/* Chart */
.chart-panel {
  position: relative;
  width: 100%;
  max-width: 864px;
  background: var(--surface);
  border-radius: 16px;
  overflow: hidden;
}
.chart-panel svg { display: block; width: 100%; height: auto; }
.chart-panel text { font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart-panel .tick { font-size: 13px; fill: var(--muted); }
.chart-panel .horizon-label {
  font-size: 13px; font-weight: 600; fill: var(--ink);
  stroke: var(--surface); stroke-width: 6px; stroke-linejoin: round; paint-order: stroke;
}
.chart-panel .end-label { font-size: 14px; font-weight: 700; }
.chart-panel .end-label.buy { fill: var(--buy-text); }
.chart-panel .end-label.rent { fill: var(--rent-text); }

/* Bars */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: flex; align-items: center; gap: 16px; }
.bar-name { width: 48px; flex-shrink: 0; font-size: 15px; font-weight: 700; }
.bar-track { flex: 1 1 auto; min-width: 0; display: flex; height: 36px; }
.bar-part { flex-shrink: 0; height: 100%; }
.bar-total { width: 108px; flex-shrink: 0; text-align: right; font-size: 17px; font-weight: 700; }

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 32px;
}
.legend li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.swatch { width: 12px; height: 12px; flex-shrink: 0; border-radius: 3px; }
.legend .label { flex: 1 1 auto; color: var(--ink2); }
.legend .amount { font-weight: 600; }

/* Breakdown */
.breakdown {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px 48px;
  align-items: start;
}
.breakdown h3 { margin: 0 0 8px; font-size: 17px; font-weight: 700; }
.breakdown dl { margin: 0; display: flex; flex-direction: column; }
.breakdown .row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.breakdown dt { color: var(--ink2); }
.breakdown dd { margin: 0; }
.breakdown .row.total { padding-top: 12px; border-bottom: 0; font-size: 17px; font-weight: 700; }
.breakdown .row.total dt { color: var(--ink); }

/* How this works */
.how { padding-top: 32px; border-top: 1px solid var(--line); }
.how-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 48px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink2);
}
.how-grid strong { color: var(--ink); }

/* Phone sticky bar (shown only below 640px) */
.sticky { display: none; }

/* Below 1024px: one column */
@media (max-width: 1023.98px) {
  .page { padding: 0 16px 48px; gap: 24px; }
  .intro { padding-top: 32px; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .verdict { font-size: clamp(40px, 7vw, 64px); }
}

/* Phones */
@media (max-width: 639.98px) {
  .page { padding-bottom: 120px; }
  .intro { padding: 28px 4px 0; gap: 10px; }
  h1 { font-size: 52px; }
  .intro p { font-size: 16px; }
  .sheet { padding: 20px; gap: 18px; }
  .sheet h2 { font-size: 20px; }
  .stack { gap: 18px; }
  .pair { gap: 12px; }
  .calc { padding: 14px 16px; }
  .results { gap: 44px; }
  .break-even, .breakdown, .how-grid { grid-template-columns: minmax(0, 1fr); }
  .legend { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .bar-row { gap: 10px; }
  .bar-name { width: 40px; }
  .bar-total { width: 84px; font-size: 16px; }

  .sticky:not([hidden]) {
    display: flex;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 10;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 14px 14px 18px;
    background: var(--ink);
    border-radius: 16px;
    color: #FFFFFF;
    box-shadow: 0 8px 24px rgba(2, 48, 71, 0.25);
  }
  .sticky-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .sticky-label { font-size: 13px; line-height: 1.3; color: var(--light); }
  .sticky-value { font-size: clamp(17px, 5vw, 24px); line-height: 1.1; font-weight: 800; font-stretch: 70%; }
  .sticky button {
    flex-shrink: 0;
    min-height: 44px;
    padding: 0 16px;
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: var(--ink);
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
  }
  .sticky button:focus-visible { outline-color: var(--accent); }
}

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