/* True cost of car ownership: page styles on top of the shared style.css.
   Everything here is prefixed "cc-" so it never changes another page.
   Colours: the costs of owning (value lost, interest) in rust; running costs in gold and slate. */

:root {
  --cc-dep: #bd3c1c; --cc-int: #d58b74; --cc-fuel: #b8862a; --cc-ins: #4d6079; --cc-up: #9aa9be; --cc-fee: #b5ab95;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --cc-dep: #d4735b; --cc-int: #a65a45; --cc-fuel: #c9a159; --cc-ins: #93a5bc; --cc-up: #5f6f88; --cc-fee: #77705f; }
}
:root[data-theme="dark"] { --cc-dep: #d4735b; --cc-int: #a65a45; --cc-fuel: #c9a159; --cc-ins: #93a5bc; --cc-up: #5f6f88; --cc-fee: #77705f; }

.cc-head { padding-block: 24px 4px; }
.cc-head h1 { font-size: var(--step-3); margin-top: 6px; }

.cc-work { display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 28px 40px; align-items: start; padding-top: 16px; }
.cc-stage { display: grid; min-width: 0; }

.cc-answer { display: grid; gap: 2px; justify-items: start; }
.cc-answer .label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.cc-answer .big { font-size: clamp(2.6rem, 2rem + 2.4vw, 4rem); }
.cc-answer .big small { font-size: 0.3em; margin-left: 6px; }
.cc-answer-line { color: var(--muted); font-size: 0.93rem; max-width: 62ch; margin-top: 6px; }
.cc-answer-line strong { color: var(--ink); font-weight: 600; }

.cc-figure { margin: 0; padding-top: 12px; }
.cc-legend-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 24px; padding-top: 8px; }
.cc-legend-row .hint { font-size: 0.8rem; }
.cc-legend-row .legend { gap: 4px 14px; }
.cc-key { display: inline-flex; align-items: center; gap: 6px; }
.cc-sw { width: 11px; height: 11px; border-radius: 2px; display: inline-block; flex: none; }
.c-dep { --c: var(--cc-dep); } .c-int { --c: var(--cc-int); } .c-fuel { --c: var(--cc-fuel); }
.c-ins { --c: var(--cc-ins); } .c-up { --c: var(--cc-up); } .c-fee { --c: var(--cc-fee); }
.cc-sw, .cc-bar-fill { background: var(--c); }

/* chart marks */
.chart-box .cc-seg-r { fill: var(--c); stroke: var(--paper); stroke-width: 1; }
.chart-box .cc-total { font-size: 11px; font-weight: 600; fill: var(--muted); }
.chart-box .cc-avg { stroke: var(--ink); stroke-width: 1.2; stroke-dasharray: 4 4; }
.chart-box .cc-avg-label { font-family: var(--font-body); font-style: normal; font-size: 12.5px; font-weight: 600; fill: var(--ink); }
.chart-box .cc-lab-v { font-size: 12px; font-weight: 700; fill: var(--ink); }
.chart-box .cc-lab-s { font-size: 11px; fill: var(--muted); }
.chart-box .cc-lab-tick { stroke: var(--muted); stroke-width: 1; }
.chart-box .cc-hi { fill: var(--ink); fill-opacity: 0.06; }
.chart-box .cc-halo { paint-order: stroke; stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; }
.tip .t-sw { display: inline-flex; align-items: center; gap: 6px; }
.tip .t-total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 5px; font-weight: 600; }
.tip .t-total span:first-child { color: var(--ink); }

/* stats */
.cc-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 22px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); }
.cc-stat { padding: 12px 16px 14px 0; display: grid; gap: 2px; align-content: start; min-width: 0; }
.cc-stat + .cc-stat { padding-left: 16px; border-left: 1px solid var(--line); }
.cc-stat .label { font-size: 0.76rem; font-weight: 600; color: var(--muted); }
.cc-stat .v { font-family: var(--font-display); font-weight: 500; font-size: 1.5rem; font-variant-numeric: lining-nums tabular-nums; line-height: 1.2; overflow-wrap: anywhere; }
.cc-stat .sub { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.cc-stat .sub.is-warn { color: var(--rust); font-weight: 600; }

/* inputs */
.cc-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 4px; min-width: 0; position: sticky; top: 12px; }
.cc-panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-bottom: 12px; }
.cc-panel-head h2 { flex: none; font-size: 1.3rem; white-space: nowrap; }
.cc-panel-head .btn-row { flex: 0 1 auto; flex-wrap: nowrap; gap: 4px; min-width: 0; justify-content: flex-end; }
.cc-panel-head .inline-field { min-width: 0; flex: 0 1 auto; }
.cc-panel-head .inline-field select { max-width: 10rem; width: 100%; min-width: 0; }
.cc-panel-head .btn-ghost { padding-inline: 6px; }
.cc-form { display: grid; border-top: 1px solid var(--ink); }
.cc-group { border: 0; margin: 0; padding: 12px 0; display: grid; gap: 8px; min-width: 0; align-content: start; }
.cc-group + .cc-group { border-top: 1px solid var(--line); }
.cc-group:last-child { padding-bottom: 6px; }
.cc-group legend { float: left; padding: 0; font-family: var(--font-display); font-size: 1.05rem; }
.cc-group > legend { width: 100%; }
.cc-group legend + * { clear: both; }
.cc-legend-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cc-legend-line legend { float: none; width: auto; }
.cc-seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cc-seg button { border: 0; background: var(--paper); color: var(--muted); font-weight: 600; font-size: 0.78rem; cursor: pointer; padding: 5px 9px; white-space: nowrap; }
.cc-seg button + button { border-left: 1px solid var(--line); }
.cc-seg button:hover { color: var(--ink); }
.cc-seg button[aria-pressed="true"] { background: var(--gold-soft); color: var(--gold); }
.cc-seg button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.cc-row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; }
.cc-row3 .field label { font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-group .hint { font-size: 0.8rem; }
.cc-panel .privacy { margin-top: 6px; }
.cc-panel input[type="text"] { min-height: 40px; }
.cc-panel .pct input { padding-right: 46px; }
.cc-panel .pct span { font-size: 0.85rem; }
.cc-errs:empty { display: none; }
.cc-errs { display: grid; }

/* sections */
.cc-section { padding-top: 64px; }
.cc-section-head { display: grid; gap: 8px; margin-bottom: 14px; }
.cc-msg { font-size: 1.05rem; max-width: 70ch; }
.cc-msg b { font-weight: 700; }
.cc-msg .c-own { color: var(--rust); }

/* where each km goes */
.cc-ledger { display: grid; border-top: 1px solid var(--ink); max-width: 900px; font-variant-numeric: tabular-nums; }
.cc-lr { display: grid; grid-template-columns: minmax(9rem, 13rem) minmax(0, 1fr) 6.5rem 7.5rem; gap: 6px 16px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.cc-lr.cc-lr-head { padding: 7px 0; font-size: 0.76rem; font-weight: 600; color: var(--muted); }
.cc-lr .n { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.cc-lr .r { text-align: right; white-space: nowrap; }
.cc-lr .pk { font-family: var(--font-display); font-size: 1.08rem; }
.cc-bar { height: 12px; background: var(--grid); border-radius: 2px; overflow: hidden; display: flex; align-items: center; }
.cc-bar-fill { height: 100%; border-radius: 2px; }
.cc-bar-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cc-bar-cell .cc-bar { flex: 1; }
.cc-bar-cell .pc { font-size: 0.8rem; color: var(--muted); width: 2.6rem; text-align: right; flex: none; }
.cc-lr.cc-lr-total { border-bottom: 1px solid var(--ink); font-weight: 700; }
.cc-lr.cc-lr-total .pk { font-weight: 600; }

/* year by year */
.cc-yt-scroll { overflow-x: auto; margin-top: 8px; }
.cc-yt { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.93rem; border-top: 1px solid var(--ink); }
.cc-yt th, .cc-yt td { padding: 7px 12px 7px 0; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.cc-yt th:first-child, .cc-yt td:first-child { text-align: left; }
.cc-yt thead th { font-size: 0.76rem; color: var(--muted); font-weight: 600; }
.cc-yt tbody th { font-weight: 600; }
.cc-yt td.z { color: var(--muted); }
.cc-yt td.t { font-weight: 600; }
.cc-yt tfoot th, .cc-yt tfoot td { font-weight: 700; border-bottom: 1px solid var(--ink); }
.cc-yt-note { margin-top: 10px; }

@media (max-width: 1200px) and (min-width: 961px) { .cc-work { grid-template-columns: minmax(0, 1fr) 350px; gap: 28px; } }
@media (max-width: 960px) {
  .cc-work { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .cc-stage { display: contents; }
  .cc-answer { order: 1; }
  .cc-stage .cc-figure { order: 2; }
  .cc-panel { order: 3; margin-top: 18px; position: static; }
  .cc-stats { order: 4; margin-top: 28px; }
}
@media (max-width: 960px) and (min-width: 700px) {
  .cc-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 20px; }
  .cc-form .cc-group:first-child { grid-row: span 2; }
  .cc-form .cc-group:nth-child(2) { border-top: 0; }
  .cc-form .cc-group:nth-child(n+2) { border-left: 1px solid var(--line); padding-left: 20px; }
}
@media (max-width: 640px) {
  .cc-stats { grid-template-columns: minmax(0, 1fr); }
  .cc-stat + .cc-stat { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); }
  .cc-stat { grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; column-gap: 12px; padding-right: 0; }
  .cc-stat .label { grid-column: 1; }
  .cc-stat .v { grid-column: 2; grid-row: 1 / span 2; text-align: right; font-size: 1.3rem; }
  .cc-stat .sub { grid-column: 1; grid-row: 2; }
  .cc-lr { grid-template-columns: minmax(0, 1fr) 5rem 5.6rem; grid-template-areas: "n pk tot" "bar bar bar"; gap: 6px 10px; }
  .cc-lr .n { grid-area: n; } .cc-lr .pk { grid-area: pk; } .cc-lr .tot { grid-area: tot; } .cc-lr .cc-bar-cell { grid-area: bar; }
  .cc-lr.cc-lr-head { grid-template-areas: "n pk tot"; }
  .cc-lr.cc-lr-head .cc-bar-cell, .cc-lr.cc-lr-total .cc-bar-cell { display: none; }
  .cc-lr.cc-lr-total { grid-template-areas: "n pk tot"; }
}
@media (max-width: 600px) {
  .cc-head { padding-block: 16px 0; }
  .cc-head .eyebrow { display: none; }
  .cc-head h1 { font-size: 1.4rem; }
  .cc-answer .label { font-size: 0.76rem; }
  .cc-answer .big { font-size: 2.3rem; }
  .cc-answer .big small { font-size: 0.4em; }
  .cc-answer-line { font-size: 0.86rem; }
  .cc-answer-line .cc-more { display: none; }
  .cc-figure { padding-top: 6px; }
  .cc-hover-hint { display: none; }
  .cc-panel { padding: 14px; margin-inline: -4px; }
  .cc-panel-head h2 { font-size: 1.2rem; }
  .cc-panel-head { padding-bottom: 10px; }
  .cc-section { padding-top: 52px; }
  .cc-yt { font-size: 0.84rem; }
  .cc-yt th, .cc-yt td { padding-right: 9px; }
  .cc-seg button { padding: 5px 7px; }
}
.cc-yt tr.cc-yt-sum th, .cc-yt tr.cc-yt-sum td { font-weight: 700; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
body.cc-has-errors .cc-answer, body.cc-has-errors .cc-figure, body.cc-has-errors .cc-stats, body.cc-has-errors #where, body.cc-has-errors #years { opacity: 0.4; transition: opacity 0.15s; }

/* Tighter panel on desktop, so all the inputs fit beside the chart on one screen. */
@media (min-width: 961px) {
  .cc-panel { padding-top: 12px; }
  .cc-panel-head { padding-bottom: 8px; }
  .cc-group { padding: 9px 0; gap: 6px; }
  .cc-group .hint { font-size: 0.76rem; line-height: 1.4; }
}

/* Keep the currency picker readable: it used to shrink to an empty box once Share joined Reset.
   When "Your numbers" and the buttons don't fit on one line, the buttons move under the title. */
.cc-panel-head { flex-wrap: wrap; row-gap: 8px; }
.cc-panel-head .btn-row { flex: 0 0 auto; max-width: 100%; flex-wrap: wrap; row-gap: 6px; }
.cc-panel-head .inline-field { flex: 0 0 auto; }
.cc-panel-head .inline-field select { width: 8rem; min-width: 8rem; max-width: 8rem; }
