/* Haybird fee calculators. Page layout and charts for the four fee pages.
   Builds on ../style.css (tokens, masthead, inputs, buttons, reading sections) and uses
   its own class names (fd-*) so changes to the other calculator's layout don't move this one. */

/* Question */
.fd-head { padding-block: 26px 4px; }
.fd-head h1 { font-size: var(--step-3); margin-top: 6px; max-width: 30ch; }

/* Graph left, inputs right; on phones: answer, graph, inputs, numbers */
.fd-work { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px 40px; align-items: start; padding-top: 16px; }
.fd-stage { display: grid; min-width: 0; }
@media (max-width: 1200px) and (min-width: 961px) { .fd-work { grid-template-columns: minmax(0, 1fr) 330px; column-gap: 28px; } }
@media (max-width: 960px) {
  .fd-work { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .fd-stage { display: contents; }
  .fd-answer { order: 1; }
  .fd-figure { order: 2; }
  .fd-panel { order: 3; margin-top: 18px; }
  .fd-stats { order: 4; }
}

/* Answer */
.fd-answer { display: grid; gap: 2px; justify-items: start; }
.fd-answer .label { font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.fd-big { font-family: var(--font-display); font-weight: 500; font-size: clamp(2.6rem, 1.9rem + 2.4vw, 4rem); letter-spacing: -0.04em; line-height: 0.98; font-variant-numeric: lining-nums tabular-nums; color: var(--rust); overflow-wrap: anywhere; }
.fd-big.is-good { color: var(--gold); }
.fd-big.is-even { color: var(--ink); }
.fd-line { color: var(--muted); max-width: 60ch; font-size: 0.95rem; margin-top: 4px; }
.fd-line strong { color: var(--ink); font-weight: 600; }

/* Main graph */
.fd-figure { margin: 0; padding-top: 12px; min-width: 0; }
.fd-cap { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 22px; padding-top: 8px; font-size: 0.84rem; color: var(--muted); }
.fd-key { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.fd-key span { display: inline-flex; align-items: center; gap: 7px; }
.fd-cap .hint { font-size: 0.8rem; }
.k-line { width: 16px; height: 0; border-top: 2.4px solid var(--gold); display: inline-block; }
.k-line.k-mine { border-color: var(--ink); border-top-width: 2px; }
.k-line.k-put { border-color: var(--muted); border-top: 1.5px dashed; }
.k-sq { width: 11px; height: 11px; border-radius: 2px; display: inline-block; background: var(--rust); opacity: 0.3; }
.k-sq.k-fee { opacity: 0.85; }
.k-sq.k-lost { opacity: 0.32; }
.chart-box .l-other { fill: none; stroke: var(--gold); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.chart-box .l-mine { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-box .l-put { fill: none; stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 3 4; }
.chart-box .gap-bad { fill: var(--rust); fill-opacity: 0.15; }
.chart-box .gap-good { fill: var(--gold-area); fill-opacity: 0.2; }
.chart-box .bracket { stroke: var(--rust); stroke-width: 1.5; fill: none; }
.chart-box .bracket.is-good { stroke: var(--gold); }
.chart-box .gap-note { font-family: var(--font-body); font-style: normal; font-size: 12.5px; font-weight: 600; fill: var(--rust); }
.chart-box .gap-note.is-good { fill: var(--gold); }
.chart-box .gap-num { font-family: var(--font-body); font-style: normal; font-weight: 700; }
.chart-box .dot-other { fill: var(--gold); stroke: var(--paper); stroke-width: 2; }
.chart-box .dot-mine { fill: var(--ink); stroke: var(--paper); stroke-width: 2; }
.chart-box .halo { paint-order: stroke; stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; }

/* Numbers under the graph */
.fd-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 22px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); }
.fd-stats .stat { padding: 11px 14px 13px 0; display: grid; gap: 2px; align-content: start; min-width: 0; }
.fd-stats .stat + .stat { padding-left: 14px; border-left: 1px solid var(--line); }
.fd-stats .label { font-size: 0.76rem; font-weight: 600; color: var(--muted); }
.fd-stats .v { font-family: var(--font-display); font-weight: 500; font-size: 1.4rem; font-variant-numeric: lining-nums tabular-nums; overflow-wrap: anywhere; line-height: 1.2; }
.fd-stats .sub { font-size: 0.78rem; color: var(--muted); }
.fd-stats .v.is-other { color: var(--gold); }
.fd-stats .v.is-bad { color: var(--rust); }
@media (max-width: 960px) { .fd-stats { margin-top: 26px; } }
@media (max-width: 640px) {
  .fd-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fd-stats .stat:nth-child(3) { border-left: 0; padding-left: 0; }
  .fd-stats .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* Inputs */
.fd-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; min-width: 0; }
.fd-panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding-bottom: 12px; }
.fd-panel-head h2 { font-size: 1.4rem; }
.fd-panel-head .btn-row { flex-wrap: nowrap; }
.fd-panel-head select { width: auto; max-width: 11rem; padding-block: 6px; font-size: 0.88rem; }
.fd-form { display: grid; border-top: 1px solid var(--ink); }
.fd-form fieldset { border: 0; margin: 0; padding: 13px 0; display: grid; gap: 11px; min-width: 0; }
.fd-form fieldset + fieldset { border-top: 1px solid var(--line); }
.fd-form legend { float: left; width: 100%; padding: 0; font-family: var(--font-display); font-size: 1.05rem; }
.fd-form legend + * { clear: both; }
.fd-form .row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.fd-form .pct input { padding-right: 30px; }
.fd-form .presets { gap: 4px; flex-wrap: nowrap; }
.fd-form .preset { padding: 5px 7px; font-size: 0.78rem; white-space: nowrap; }
.fd-fee { display: grid; grid-template-columns: 4.9rem minmax(0, 1fr); gap: 4px 10px; align-items: center; }
.fd-fee .pct input { padding-right: 24px; }
.fd-fee .pct span { right: 9px; }
.fd-fee > label, .fd-fee > .label { grid-column: 1 / -1; }
.fd-fee .k-line { margin-right: 6px; vertical-align: 3px; }
.fd-fee.has-flat { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.fd-fee.has-flat .presets { grid-column: 1 / -1; }
.fd-unit { font-size: 0.72rem; color: var(--muted); font-weight: 600; }
.fd-panel .field-err { display: block; }
.fd-panel .privacy { margin-top: 6px; font-size: 0.8rem; }
.fd-panel .errors { margin-top: 8px; font-size: 0.9rem; }
.money input { padding-left: calc(14px + var(--sym-w, 0.7em)); }
@media (max-width: 960px) and (min-width: 600px) {
  .fd-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 20px; }
  .fd-form fieldset:first-child { grid-column: 1 / -1; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 20px; }
  .fd-form fieldset:first-child legend { grid-column: 1 / -1; }
  .fd-form fieldset:nth-child(3) { border-left: 1px solid var(--line); padding-left: 20px; }
  .fd-form fieldset:nth-child(2) { border-top: 1px solid var(--line); }
}
@media (max-width: 600px) {
  .fd-head { padding-block: 16px 0; }
  .fd-head h1 { font-size: 1.55rem; }
  .fd-head .eyebrow { display: none; }
  .fd-big { font-size: 2.7rem; }
  .fd-line { font-size: 0.86rem; }
  .fd-line .more { display: none; }
  .fd-answer .label { font-size: 0.74rem; }
  .fd-figure { padding-top: 6px; }
  .fd-cap .hint { display: none; }
  .fd-panel { padding: 12px 14px 14px; margin-inline: -4px; }
  .fd-panel-head { flex-wrap: nowrap; padding-bottom: 10px; }
  .fd-panel-head h2 { font-size: 1.2rem; white-space: nowrap; }
  .fd-panel-head select { max-width: 8.2rem; }
  .fd-panel-head .btn-row { gap: 4px; min-width: 0; }
  .fd-panel-head .btn-ghost { padding-inline: 4px; }
  .fd-cap { font-size: 0.8rem; }
  .fd-key { gap: 2px 14px; }
}

/* Sections below */
.fd-sec { padding-top: 64px; display: grid; gap: 12px; }
.fd-sec h2 { margin-bottom: 2px; }
.fd-msg { font-size: 1.05rem; max-width: 72ch; }
.fd-msg b { font-weight: 700; color: var(--rust); }
.fd-msg b.g { color: var(--gold); }
.fd-msg .muted { color: var(--muted); }
.chart-box .b-fee { fill: var(--rust); fill-opacity: 0.85; }
.chart-box .b-lost { fill: var(--rust); fill-opacity: 0.32; }
.chart-box .b-good { fill: var(--gold-area); fill-opacity: 0.6; }
.chart-box .bar-g { transition: opacity 0.12s; }
.chart-box .bar-g.is-dim { opacity: 0.35; }
.chart-box .tip-line { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.55; }
.chart-box .note { fill: var(--muted); font-size: 11.5px; }
.chart-box .note-strong { fill: var(--ink); font-weight: 700; }

/* Fee ladder */
.ladder { display: grid; gap: 0; border-top: 1px solid var(--ink); }
.lad { display: grid; grid-template-columns: 4.6rem minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.lad .fee { font-weight: 600; font-size: 0.95rem; }
.lad .tag { display: block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); line-height: 1.2; }
.lad .track { height: 14px; position: relative; }
.lad .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--muted); opacity: 0.32; border-radius: 0 3px 3px 0; }
.lad .lost { position: absolute; top: 0; bottom: 0; border: 1px dashed var(--rust); border-left: 0; border-radius: 0 3px 3px 0; opacity: 0.6; }
.lad.is-mine .fill { background: var(--ink); opacity: 1; }
.lad.is-other .fill { background: var(--gold); opacity: 1; }
.lad .val { text-align: right; min-width: 7.5rem; }
.lad .val b { font-family: var(--font-display); font-weight: 500; font-size: 1.1rem; display: block; line-height: 1.2; }
.lad .val span { font-size: 0.8rem; color: var(--rust); }
.lad .val span.zero { color: var(--muted); }
@media (max-width: 560px) {
  .lad { grid-template-columns: 3.6rem minmax(0, 1fr) auto; gap: 10px; }
  .lad .val { min-width: 6.2rem; }
  .lad .val b { font-size: 1rem; }
}

/* Year by year */
.fd-years summary { cursor: pointer; font-weight: 600; color: var(--muted); font-size: 0.95rem; }
.fd-years[open] summary { margin-bottom: 12px; }
.yt-scroll { overflow-x: auto; }
.fd-yt { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.92rem; border-top: 1px solid var(--ink); }
.fd-yt th, .fd-yt td { padding: 7px 12px 7px 0; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.fd-yt th:first-child { text-align: left; }
.fd-yt th:last-child, .fd-yt td:last-child { padding-right: 0; }
.fd-yt thead th { font-size: 0.76rem; color: var(--muted); font-weight: 600; vertical-align: bottom; }
.fd-yt td.bad { color: var(--rust); }
.fd-yt td.good { color: var(--gold); }
@media (max-width: 520px) { .fd-yt { font-size: 0.8rem; } .fd-yt th, .fd-yt td { padding-right: 7px; } .fd-yt .wide { display: none; } }

/* Reading: same full width as the tool, heading left, text right on wide screens */
.fd-read { padding-top: 72px; display: grid; gap: 14px; }
.fd-read ul, .fd-read ol { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.fd-read > p, .fd-read > ul, .fd-read > ol, .fd-read > .faq, .fd-read > .formula, .fd-read > .example-table { max-width: 72ch; }
@media (min-width: 900px) {
  .fd-read { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); column-gap: 48px; row-gap: 0; align-items: start; }
  .fd-read > h2 { grid-column: 1; grid-row: 1 / span 8; }
  .fd-read > :not(h2) { grid-column: 2; margin-bottom: 14px; }
  .fd-read > :last-child { margin-bottom: 0; }
}
.fd-read .sources { font-size: 0.85rem; color: var(--muted); }
.fd-related { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 0.95rem; }
.fd-related a { font-weight: 600; }
.fd-related a[aria-current="page"] { color: var(--muted); text-decoration: none; pointer-events: none; }
.disclaimer { max-width: none; }
.fd-fee .field-err, .fd-fee .hint { grid-column: 1 / -1; }
.fd-form .hint { font-size: 0.8rem; }
.fd-fee.has-flat .field label { font-size: 0.74rem; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chart-box .gap-bad { fill-opacity: 0.22; } }
:root[data-theme="dark"] .chart-box .gap-bad { fill-opacity: 0.22; }
.fd-stale .fd-figure, .fd-stale .fd-stats, .fd-stale #parts-sec, .fd-stale #ladder-sec, .fd-stale #pot-sec, .fd-stale #years { opacity: 0.3; pointer-events: none; transition: opacity 0.15s; }

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

/* Very narrow phones: let the panel heading wrap. */
@media (max-width: 380px) { .fd-panel-head { flex-wrap: wrap; } }
@media (max-width: 400px) { .fd-form .presets { flex-wrap: wrap; } }
/* The narrower panel (961-1200px) has no room for the currency menu and both buttons, or every preset, on one line. */
@media (max-width: 1200px) and (min-width: 961px) { .fd-panel-head .btn-row, .fd-form .presets { flex-wrap: wrap; } }
