/* Emergency fund calculator: page layout on top of the shared /style.css.
   Kept in this folder so the shared stylesheet stays untouched. Same layout as the other
   calculators: graph and answer on the left, a short inputs panel on the right
   (stacked graph, inputs, stats on phones). Everything is scoped to body.bg. */

.bg .hero-head { display: block; padding-block: 26px 6px; }
.bg .hero-head h1 { font-size: var(--step-3); max-width: none; margin-top: 6px; }
.bg .workspace { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px 40px; align-items: start; padding-top: 18px; }
.bg .stage { position: sticky; top: 12px; display: grid; min-width: 0; }
.bg .answer { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px 18px; }
.bg .answer .label { flex-basis: 100%; }
.bg .answer .big { font-size: clamp(2.8rem, 2rem + 2.6vw, 4.2rem); }
.bg .answer .big.is-ahead { color: var(--slate); }
.bg .answer-line { padding-bottom: 6px; max-width: 46ch; }
.bg .landscape { padding-top: 14px; }
.bg .legend-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 24px; padding-top: 10px; }
.bg .legend { pointer-events: none; }
.bg .legend span { display: inline-flex; align-items: center; gap: 7px; }


/* Stats under the graph */
.bg .stats { margin-top: 22px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 640px) { .bg .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.bg .stat { align-content: start; }
.bg .stat .sub { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.bg .stat-gold .v { color: var(--gold); }
.bg .stat-rust .v { color: var(--rust); }

/* Inputs panel */
.bg .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 18px; display: grid; gap: 4px; min-width: 0; }
.bg .panel-head { display: grid; gap: 10px; padding-bottom: 12px; }
.bg .panel-head h2 { font-size: 1.45rem; }
.bg .panel-head .btn-row { flex-wrap: nowrap; }
.bg .panel-head .inline-field { flex: 1; min-width: 0; }
.bg .panel-head .inline-field select { width: 100%; }
.bg .simple { display: grid; grid-template-columns: minmax(0, 1fr); border-top: 1px solid var(--ink); }
.bg .simple .col { border: 0; margin: 0; padding: 14px 0; display: grid; gap: 12px; align-content: start; min-width: 0; }
.bg .simple .col + .col { border-top: 1px solid var(--line); }
.bg .simple .col:last-child { padding-bottom: 4px; }
.bg .simple legend { float: left; width: 100%; padding: 0; font-family: var(--font-display); font-size: 1.05rem; }
.bg .simple legend + * { clear: both; }
.bg .row2 { gap: 10px; }
.bg .row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.bg .idle-line { font-size: 0.88rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.bg .idle-line b { color: var(--ink); font-weight: 600; }
.bg .field-hint { font-size: 0.78rem; color: var(--muted); line-height: 1.4; }
.bg .presets .preset { min-width: 0; flex: 1; }
.bg .privacy { margin-top: 8px; }
.bg .errors { margin-top: 8px; }
.bg .errors:empty { display: none; }
.bg input[type="text"] { min-height: 42px; }

/* Guideline table */
.bg .yt-scroll { overflow-x: auto; }
.bg .yt { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.95rem; border-top: 1px solid var(--ink); }
.bg .yt th, .bg .yt td { padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.bg .yt th:first-child { text-align: left; }
.bg .yt th:last-child, .bg .yt td:last-child { padding-right: 0; }
.bg .yt thead th { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.bg .yt tbody th { font-weight: 600; }
.bg .yt td.short { color: var(--rust); }
.bg .yt td.ok { color: var(--gold); font-weight: 600; }

/* Reading: one content width, heading left and text right on wide screens */
.bg .prose, .bg .disclaimer { max-width: none; }
@media (min-width: 900px) {
  .bg .section.prose { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); column-gap: 48px; row-gap: 0; align-items: start; }
  .bg .section.prose > h2 { grid-column: 1; grid-row: 1 / span 30; }
  .bg .section.prose > :not(h2) { grid-column: 2; margin-bottom: 16px; }
}
.bg .sources { font-size: var(--step--1); color: var(--muted); }

@media (max-width: 1200px) and (min-width: 961px) { .bg .workspace { grid-template-columns: minmax(0, 1fr) 330px; gap: 28px; } }
@media (max-width: 960px) {
  .bg .workspace { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .bg .stage { display: contents; }
  .bg .stage .answer { order: 1; }
  .bg .stage .landscape { order: 2; }
  .bg .panel { order: 3; margin-top: 20px; }
  .bg .stage .stats { order: 4; margin-top: 28px; }
}
@media (max-width: 960px) and (min-width: 600px) {
  .bg .simple { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .bg .simple .col:nth-child(2) { border-top: 0; border-left: 1px solid var(--line); padding-left: 18px; grid-row: span 2; }
  .bg .simple .col:nth-child(1), .bg .simple .col:nth-child(3) { padding-right: 18px; }
}
@media (max-width: 600px) {
  .bg .hero-head { padding-block: 18px 0; }
  .bg .hero-head h1 { font-size: 1.6rem; }
  .bg .hero-head .eyebrow { display: none; }
  .bg .answer .big { font-size: 2.9rem; }
  .bg .answer-line { font-size: 0.85rem; flex-basis: 100%; padding-bottom: 0; }
  .bg .landscape { padding-top: 6px; }
  .bg .panel { padding: 14px 14px 16px; margin-inline: -4px; }
  .bg .legend-row { gap: 6px 14px; padding-top: 6px; }
  .bg .legend { gap: 2px 14px; font-size: 0.8rem; }
  .bg .panel { margin-top: 14px; }
  .bg .yt { font-size: 0.84rem; }
  .bg .yt th, .bg .yt td { padding-right: 8px; }
  .bg .yt .wide { display: none; }
}

/* While a number is invalid, keep the last result but fade it. */
.bg .is-stale .landscape, .bg .is-stale .stats { opacity: 0.35; transition: opacity 0.15s; }


/* Tighter panel on desktop, so all the inputs fit beside the chart on one screen. */
@media (min-width: 961px) {
  .bg .panel { padding-top: 12px; }
  .bg .panel-head { padding-bottom: 8px; gap: 8px; }
  .bg .simple .col { padding: 10px 0; gap: 9px; }
}

/* The flow chart */
.bg .chip { display: inline-block; width: 12px; height: 10px; border: 0; }
.bg .chip-needs { background: var(--slate); }
.bg .chip-wants { background: color-mix(in srgb, var(--ink) 45%, transparent); }
.bg .chip-save { background: var(--gold); }
.bg .chip-over { background: repeating-linear-gradient(135deg, var(--rust) 0 1.5px, transparent 1.5px 4px); outline: 1px solid var(--rust); outline-offset: -1px; }
.bg .chip-short { background: transparent; outline: 1.5px dashed var(--rust); outline-offset: -1.5px; }
.chart-box .flow { opacity: 0.3; transition: opacity 0.12s; }
.chart-box .flow.is-hot { opacity: 0.5; }
.chart-box .flow.f-wants { opacity: 0.16; }
.chart-box .flow.is-alt { opacity: 0.42; }
.chart-box .flow.f-wants.is-alt { opacity: 0.26; }
.chart-box .flow.is-planned { opacity: 0.1; }
.chart-box .flow.f-wants.is-hot { opacity: 0.3; }
.chart-box .n-pay { fill: var(--ink); }
.chart-box .n-needs, .chart-box .f-needs, .mix-box .n-needs { fill: var(--slate); }
.chart-box .n-wants, .mix-box .n-wants { fill: color-mix(in srgb, var(--ink) 45%, transparent); }
.chart-box .f-wants { fill: var(--ink); }
.chart-box .n-save, .chart-box .f-save, .mix-box .n-save { fill: var(--gold); }
.chart-box .f-over { fill: var(--rust); }
.chart-box .n-over, .mix-box .n-over { fill: url(#hb-hatch-loss); stroke: var(--rust); stroke-width: 1; }
.chart-box .n-short { fill: none; stroke: var(--rust); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart-box .n-cut { stroke: var(--paper); stroke-width: 1.5; }
.chart-box .guide-tick { stroke: var(--ink); stroke-width: 1.2; }
.chart-box .guide-l { font-size: 11px; fill: var(--muted); }
.chart-box .n-name { font-family: var(--font-body); font-size: 14px; font-weight: 600; fill: var(--ink); }
.chart-box .n-v { font-size: 13px; font-weight: 700; fill: var(--ink); font-variant-numeric: tabular-nums; }
.chart-box .n-s { font-size: 12px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart-box .n-s.bad { fill: var(--rust); font-weight: 600; }
.chart-box .n-s.good { fill: var(--gold); font-weight: 600; }
.chart-box .in-l { font-size: 11.5px; fill: var(--ink); }
.chart-box .pay-name { font-family: var(--font-body); font-size: 14px; font-weight: 600; fill: var(--ink); }
.chart-box .halo { paint-order: stroke; stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; }
.chart-box .pay-v { font-size: 13px; font-weight: 700; fill: var(--ink); }
.bg .stat.is-bad .v { color: var(--rust); }
.bg .stat.is-good .v { color: var(--gold); }

/* Second graph: yours next to the guideline */
.bg .compare { padding-top: 64px; display: grid; gap: 14px; }
.bg .compare-msg { font-size: 1.05rem; max-width: 70ch; }
.bg .compare-msg b { font-weight: 700; }
.bg .compare-msg .g { color: var(--gold); }
.bg .compare-msg .r { color: var(--rust); }
.bg .mix-box { border-top: 1px solid var(--ink); padding-top: 8px; }
.bg .mix-box svg { display: block; width: 100%; height: auto; overflow: visible; }
.bg .mix-box text { font-family: var(--font-body); font-size: 12px; font-variant-numeric: tabular-nums; }
.bg .mix-box .r-name { font-family: var(--font-body); font-size: 14px; font-weight: 600; fill: var(--ink); }
.bg .mix-box .seg-l { font-size: 12px; font-weight: 600; fill: var(--paper); }
.mix-box .seg-l.dark { fill: var(--ink); }
.mix-box .link { opacity: 0.14; }
.mix-box .sep { stroke: var(--paper); stroke-width: 2; }
.bg .yt td.bad { color: var(--rust); }
.bg .yt td.good { color: var(--gold); font-weight: 600; }
.bg .yt { margin-top: 10px; }

/* Your own costs: name, amount, need or want, remove */
.bg .costs { display: grid; gap: 8px; }
.bg .costs:empty { display: none; }
.bg .cost-row { display: grid; grid-template-columns: minmax(0, 1fr) 6rem 3.6rem 24px; gap: 6px; align-items: center; }
.bg .cost-row input[type="text"] { min-height: 38px; }
.bg .cost-row .c-name { width: 100%; min-width: 0; padding-left: 10px; padding-right: 6px; }
.bg .cost-row .c-kind { height: 38px; padding: 0; border: 1px solid color-mix(in srgb, var(--ink) 22%, transparent); background: transparent;
  font: inherit; font-size: 0.8rem; font-weight: 600; cursor: pointer; border-radius: var(--radius); }
.bg .cost-row .c-kind.is-need { color: var(--slate); box-shadow: inset 3px 0 0 var(--slate); }
.bg .cost-row .c-kind.is-want { color: var(--muted); box-shadow: inset 3px 0 0 color-mix(in srgb, var(--ink) 45%, transparent); }
.bg .cost-row .c-kind:hover { border-color: var(--ink); }
.bg .cost-row .c-del { width: 24px; height: 38px; border: 0; background: transparent; color: var(--muted); font-size: 1.25rem; line-height: 1; cursor: pointer; padding: 0; }
.bg .cost-row .c-del:hover { color: var(--rust); }
.bg .cost-row .field-err { grid-column: 1 / -1; }
.bg .cost-row .field-err:empty { display: none; }
.bg .add-cost { justify-self: start; font-size: 0.88rem; }
.bg .add-cost[hidden] { display: none; }
.bg .costs-full { font-size: 0.78rem; color: var(--muted); }
.chart-box path.flow.is-hot { opacity: 0.55; }
