/* Self-hosted fonts (SIL Open Font License, see fonts/LICENSE-*). No third-party requests. */
@font-face { font-family: "Bricolage Grotesque"; src: url("fonts/bricolage-grotesque-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Bricolage Grotesque"; src: url("fonts/bricolage-grotesque-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Sans 3"; src: url("fonts/source-sans-3-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Sans 3"; src: url("fonts/source-sans-3-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Source Sans 3"; src: url("fonts/source-sans-3-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Sans 3"; src: url("fonts/source-sans-3-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

/* BakeCost: blueberry ink on cool kitchen grey, with one butter-yellow price tag. */
:root {
  --bg: #EDEFF3;
  --paper: #FFFFFF;
  --ink: #1D2433;
  --muted: #586174;
  --line: #D3D8E1;
  --line-soft: #E6E9EF;
  --berry: #2B3A67;
  --berry-ink: #FFFFFF;
  --berry-soft: #E3E8F6;
  --butter: #F5CD47;
  --butter-ink: #2A2206;
  --ok: #24714A;
  --ok-soft: #E2F2E8;
  --warn: #8A5300;
  --warn-soft: #FCF0D9;
  --bad: #A2353A;
  --bad-soft: #F8E3E4;
  --radius-s: 6px;
  --radius-m: 10px;
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131722;
    --paper: #1C2231;
    --ink: #E5E8EF;
    --muted: #9AA3B6;
    --line: #2F374A;
    --line-soft: #262D3D;
    --berry: #A9BAF2;
    --berry-ink: #131722;
    --berry-soft: #262F4C;
    --ok: #7FD1A2;
    --ok-soft: #1D3428;
    --warn: #F2BF6B;
    --warn-soft: #3A2D16;
    --bad: #F0A0A4;
    --bad-soft: #3D2124;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.5 var(--body);
}
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.15; margin: 0 0 .5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; max-width: 70ch; }
a { color: var(--berry); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--butter); outline-offset: 2px; border-radius: 3px; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.hint { display: block; color: var(--muted); font-size: .875rem; font-weight: 400; margin-top: .2rem; }
.lede { color: var(--muted); font-size: 1.05rem; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 1.25rem;
  padding: .7rem clamp(1rem, 3vw, 2rem);
  background: var(--paper); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: inline-flex; align-items: center; gap: .5rem; font: 700 1.2rem/1 var(--display); color: var(--ink); text-decoration: none; margin: 0; }
.brand-lg { font-size: 1.5rem; margin-bottom: 1.25rem; }
.brand-mark { width: 1.1em; height: 1.1em; background: var(--butter); border-radius: 3px 50% 50% 3px; position: relative; }
.brand-mark::after { content: ""; position: absolute; left: .22em; top: 50%; width: .22em; height: .22em; margin-top: -.11em; border-radius: 50%; background: var(--paper); }
.nav { display: flex; gap: .15rem; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav a { padding: .45rem .7rem; border-radius: var(--radius-s); color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap; }
.nav a:hover { color: var(--ink); background: var(--line-soft); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--berry-soft); }
.signout { margin: 0 0 0 auto; }
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: .5rem; }
  .nav { order: 3; flex-basis: 100%; }
}

.wrap { max-width: 1240px; margin: 0 auto; padding: clamp(1rem, 3vw, 2rem); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-head h1 { margin: 0; }
.page-head p { margin: .35rem 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.actions form { margin: 0; }

/* ---------- Surfaces ---------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); padding: clamp(1rem, 2.5vw, 1.5rem); margin-bottom: 1.25rem; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.panel-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.25rem; }
.cost-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.5rem; align-items: start; }
.cost-layout aside { position: sticky; top: 5rem; }
@media (max-width: 980px) {
  .cost-layout { grid-template-columns: 1fr; }
  .cost-layout aside { position: static; order: -1; }
}

/* ---------- The price tag (the one loud element) ---------- */
.tag {
  position: relative;
  background: var(--butter); color: var(--butter-ink);
  padding: 1.4rem 1.4rem 1.3rem 2.6rem;
  clip-path: polygon(1.4rem 0, 100% 0, 100% 100%, 1.4rem 100%, 0 50%);
  border-radius: 0 var(--radius-m) var(--radius-m) 0;
  margin-bottom: 1rem;
}
.tag::before { /* the punched hole */
  content: ""; position: absolute; left: 1.05rem; top: 50%;
  width: .7rem; height: .7rem; margin-top: -.35rem; border-radius: 50%;
  background: var(--bg); box-shadow: inset 0 1px 2px rgba(0,0,0,.25);
}
.tag-label { font-weight: 600; font-size: .95rem; margin: 0; }
.tag-value { font: 700 clamp(2.4rem, 2rem + 2vw, 3.2rem)/1 var(--display); font-variant-numeric: tabular-nums; margin: .15rem 0 .5rem; letter-spacing: -0.02em; }
.tag-sub { margin: 0; font-size: .95rem; }
.tag-sub strong { font-size: 1.15rem; }
.tag.is-incomplete { background: repeating-linear-gradient(-45deg, var(--butter), var(--butter) 10px, #EFC33A 10px, #EFC33A 20px); }

.ledger { width: 100%; border-collapse: collapse; }
.ledger td { padding: .45rem 0; border-bottom: 1px solid var(--line-soft); }
.ledger td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: .75rem; }
.ledger tr.total td { border-bottom: 0; border-top: 2px solid var(--ink); font-weight: 700; padding-top: .6rem; }
.ledger .sub td { color: var(--muted); font-size: .9rem; padding-top: 0; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -.25rem; padding: 0 .25rem; }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.data th { text-align: left; font-weight: 600; color: var(--muted); font-size: .85rem; padding: .5rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: .6rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.data tr.section-row td { background: var(--line-soft); font-weight: 700; font-family: var(--display); padding: .35rem .6rem; }
table.data tfoot td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; }
table.data .math { display: block; color: var(--muted); font-size: .82rem; margin-top: .15rem; white-space: normal; }
tr.row-problem td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
tr.row-excluded { color: var(--muted); }

/* ---------- Badges ---------- */
.badge { display: inline-block; font-size: .78rem; font-weight: 600; padding: .1rem .45rem; border-radius: 999px; background: var(--line-soft); color: var(--muted); white-space: nowrap; margin: .1rem .15rem .1rem 0; }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-info { background: var(--berry-soft); color: var(--berry); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .95rem; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: .5rem .6rem; width: 100%; margin-top: .3rem; min-height: 2.5rem;
}
input:focus, select:focus, textarea:focus { border-color: var(--berry); outline: 2px solid var(--berry-soft); outline-offset: 0; }
textarea { min-height: 14rem; line-height: 1.45; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; margin: 0 .45rem 0 0; accent-color: var(--berry); }
.check { display: flex; align-items: center; font-weight: 400; margin: .5rem 0; }
.stack > * + * { margin-top: 1rem; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .9rem 1rem; }
.fields .wide { grid-column: 1 / -1; }
fieldset { border: 0; padding: 0; margin: 0 0 1.25rem; }
legend { font: 700 1.05rem var(--display); margin-bottom: .6rem; padding: 0; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 3rem; }
.input-suffix span { position: absolute; right: .65rem; bottom: .62rem; color: var(--muted); font-size: .9rem; pointer-events: none; }

/* compact inputs inside the review table */
table.edit td { padding: .35rem .3rem; vertical-align: middle; }
table.edit input, table.edit select { margin: 0; min-height: 2.25rem; padding: .35rem .45rem; font-size: .93rem; }
table.edit .w-qty { width: 5.5rem; }
table.edit .w-unit { width: 6.5rem; }
table.edit .w-sec { width: 7.5rem; }
table.edit .raw { display: block; color: var(--muted); font-size: .8rem; margin-top: .2rem; max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: 600 .95rem var(--body); text-decoration: none; cursor: pointer;
  padding: .55rem 1rem; min-height: 2.5rem; border-radius: var(--radius-s);
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--berry); color: var(--berry-ink); border-color: var(--berry); }
.btn-primary:hover { filter: brightness(1.12); border-color: var(--berry); }
.btn-danger { color: var(--bad); }
.btn-small { padding: .3rem .6rem; min-height: 2rem; font-size: .85rem; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--berry); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Tabs (recipe input) ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: .6rem .9rem; font: 600 1rem var(--body); color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--berry); }
[role="tabpanel"][hidden] { display: none; }

/* ---------- Notices ---------- */
.flash, .notice { padding: .75rem 1rem; border-radius: var(--radius-s); margin-bottom: 1.25rem; border: 1px solid transparent; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-error, .notice-bad { background: var(--bad-soft); color: var(--bad); }
.notice-warn { background: var(--warn-soft); color: var(--warn); }
.notice-info { background: var(--berry-soft); color: var(--ink); }
.notice ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.notice p:last-child { margin-bottom: 0; }

/* ---------- Dashboard ---------- */
.questions { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.question { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1rem 1.1rem; }
.question p { margin: 0; }
.question .q { color: var(--muted); font-size: .95rem; }
.question .a { font: 700 1.6rem/1.2 var(--display); margin-top: .3rem; font-variant-numeric: tabular-nums; }
.recipe-list { list-style: none; margin: 0; padding: 0; }
.recipe-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .75rem 0; border-bottom: 1px solid var(--line-soft); }
.recipe-list li:last-child { border-bottom: 0; }
.recipe-list .title { font-weight: 600; }
.empty { text-align: center; padding: 2.5rem 1rem; }
.empty p { margin-left: auto; margin-right: auto; }

details.explain summary { cursor: pointer; color: var(--berry); font-weight: 600; }
details.explain[open] summary { margin-bottom: .5rem; }

.auth { min-height: 80vh; display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 26rem; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 2rem; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
.mt { margin-top: 1rem; }
tr.flag-row td { border-top: 0; padding-top: 0; font-size: .88rem; }
textarea.short { min-height: 5rem; }

table.review { min-width: 1180px; }
table.edit .w-qty { width: 4.75rem; }
table.edit .w-sec { width: 6.5rem; }
table.edit .w-name { min-width: 12rem; }
table.edit .w-note { min-width: 7.5rem; }
table.edit .w-pantry { min-width: 11rem; }
table.edit .w-mode { min-width: 8.5rem; }
table.edit .check { white-space: nowrap; margin: 0; }
.ledger tr.sub td:last-child { white-space: normal; }
