/* Camp Meal Planner: the Chiro theme on top of Bootstrap 5.3 (docs/DESIGN.md §8),
   plus the few rules Bootstrap's utilities can't express. */

:root {
  --chiro-red: #E1143C;
  --chiro-red-dark: #BF1133;
  --chiro-navy: #00124D;
  --chiro-navy-hover: #263668;
  --chiro-navy-soft: #EBECF1;
  --chiro-sand: #E4D096;
  --chiro-sand-soft: #F7F1E0;
  --chiro-sand-faint: #FBF8EF;

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-heading: "Myriad Pro Condensed", "Myriad Pro", "Arial Narrow", "Roboto Condensed",
    "sans-serif-condensed", "Helvetica Neue", Arial, sans-serif;

  --bs-primary: var(--chiro-navy);
  --bs-primary-rgb: 0, 18, 77;
  --bs-primary-text-emphasis: var(--chiro-navy);
  --bs-primary-bg-subtle: var(--chiro-navy-soft);
  --bs-primary-border-subtle: #B3B8CA;
  --bs-link-color: var(--chiro-navy);
  --bs-link-color-rgb: 0, 18, 77;
  --bs-link-hover-color: var(--chiro-navy-hover);
  --bs-link-hover-color-rgb: 38, 54, 104;
  --bs-focus-ring-color: rgba(0, 18, 77, 0.25);
  --bs-body-bg: var(--chiro-sand-faint);
  --bs-body-font-family: var(--font-body);
  /* Darker than Bootstrap's #6c757d, which drops under 4.5:1 on the sand tints. */
  --bs-secondary-color: #5c636a;
  /* Bootstrap's red-600: Bootstrap's own #dc3545 is 4.3:1 on sand-faint, under AA.
     The subtle background and text-emphasis variables are dark enough and stay. */
  --bs-danger: #B02A37;
  --bs-danger-rgb: 176, 42, 55;
  /* Field errors (invalid-feedback, is-invalid borders) have their own fixed red. */
  --bs-form-invalid-color: #B02A37;
  --bs-form-invalid-border-color: #B02A37;
}

.btn-primary {
  --bs-btn-bg: var(--chiro-navy);
  --bs-btn-border-color: var(--chiro-navy);
  --bs-btn-hover-bg: var(--chiro-navy-hover);
  --bs-btn-hover-border-color: var(--chiro-navy-hover);
  --bs-btn-active-bg: var(--chiro-navy-hover);
  --bs-btn-active-border-color: var(--chiro-navy-hover);
  --bs-btn-disabled-bg: var(--chiro-navy);
  --bs-btn-disabled-border-color: var(--chiro-navy);
  --bs-btn-focus-shadow-rgb: 0, 18, 77;
}

.btn-outline-primary {
  --bs-btn-color: var(--chiro-navy);
  --bs-btn-border-color: var(--chiro-navy);
  --bs-btn-hover-color: var(--chiro-navy);
  --bs-btn-hover-bg: var(--chiro-navy-soft);
  --bs-btn-hover-border-color: var(--chiro-navy);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--chiro-navy);
  --bs-btn-active-border-color: var(--chiro-navy);
  --bs-btn-disabled-color: var(--chiro-navy);
  --bs-btn-disabled-border-color: var(--chiro-navy);
  --bs-btn-focus-shadow-rgb: 0, 18, 77;
}

/* The danger buttons have Bootstrap's red compiled in; these follow --bs-danger. */
.btn-danger {
  --bs-btn-bg: #B02A37;
  --bs-btn-border-color: #B02A37;
  --bs-btn-hover-bg: #8E2230;
  --bs-btn-hover-border-color: #8E2230;
  --bs-btn-active-bg: #8E2230;
  --bs-btn-active-border-color: #842029;
  --bs-btn-disabled-bg: #B02A37;
  --bs-btn-disabled-border-color: #B02A37;
  --bs-btn-focus-shadow-rgb: 176, 42, 55;
}

.btn-outline-danger {
  --bs-btn-color: #B02A37;
  --bs-btn-border-color: #B02A37;
  --bs-btn-hover-bg: #B02A37;
  --bs-btn-hover-border-color: #B02A37;
  --bs-btn-active-bg: #8E2230;
  --bs-btn-active-border-color: #8E2230;
  --bs-btn-disabled-color: #B02A37;
  --bs-btn-disabled-border-color: #B02A37;
  --bs-btn-focus-shadow-rgb: 176, 42, 55;
}

/* Unchecked boxes: Bootstrap's #dee2e6 border is under 3:1 on white and sand. */
.form-check-input { border-color: #6C757D; }
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: var(--chiro-navy);
  box-shadow: 0 0 0 0.25rem rgba(0, 18, 77, 0.25);
}
.form-check-input:checked {
  background-color: var(--chiro-navy);
  border-color: var(--chiro-navy);
}

/* Badges fully rounded (DESIGN §6). */
.badge { --bs-badge-border-radius: var(--bs-border-radius-pill); }

.navbar-chiro { background-color: var(--chiro-red); }
.page-rule { width: 3rem; height: 3px; background: var(--chiro-red); border: 0; opacity: 1; }

/* ---------- Navbar (base.html) ---------- */

/* Bootstrap's dark navbar dims links to 55% white: too little contrast on primary. */
.navbar[data-bs-theme="dark"] {
  --bs-navbar-color: #fff;
  --bs-navbar-hover-color: #fff;
  --bs-navbar-active-color: #fff;
  /* The language, account and logout links sit outside .navbar-nav. */
  --bs-nav-link-color: #fff;
  --bs-nav-link-hover-color: #fff;
}
.navbar .nav-link:hover { text-decoration: underline; }
.navbar .nav-link[aria-current="page"] { background: var(--chiro-red-dark); border-radius: 0.5rem; }
.navbar-brand { font-family: var(--font-heading); font-weight: 700; font-stretch: condensed; }

/* Tap targets of at least 44px (docs/ui-guidelines.md). */
.navbar .nav-link,
.navbar-toggler,
.navbar-brand {
  min-height: 44px;
  display: flex;
  align-items: center;
}

/* ---------- Headings: the condensed Chiro font, in navy ---------- */

h1, h2, h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-stretch: condensed;
  color: var(--chiro-navy);
}
h1 { font-size: 1.75rem; letter-spacing: -0.01em; }
@media (min-width: 992px) { h1 { font-size: 2rem; } }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }

/* ---------- Tables, pills and focus rings ---------- */

/* Bootstrap tables (DESIGN §6): sand-soft header row with navy text. */
.table { --bs-table-hover-bg: var(--chiro-sand-faint); }
.table > thead > tr > th {
  --bs-table-bg: var(--chiro-sand-soft);
  --bs-table-color: var(--chiro-navy);
  font-weight: 600;
}

/* Active pill and list item navy, not Bootstrap blue (camp nav, runbook days, the
   help pages' list). */
.nav-pills { --bs-nav-pills-link-active-bg: var(--chiro-navy); }
.list-group {
  --bs-list-group-active-bg: var(--chiro-navy);
  --bs-list-group-active-border-color: var(--chiro-navy);
}

/* Focus rings (DESIGN §6): navy, red on danger buttons, white on the red navbar. */
.btn:focus-visible { outline: 0; box-shadow: 0 0 0 0.25rem rgba(0, 18, 77, 0.25); }
.btn-danger:focus-visible,
.btn-outline-danger:focus-visible { box-shadow: 0 0 0 0.25rem rgba(176, 42, 55, 0.25); }
main a:focus-visible { outline: 2px solid var(--chiro-navy); outline-offset: 2px; }
.navbar .nav-link:focus-visible,
.navbar-brand:focus-visible,
.navbar-toggler:focus { outline: 0; box-shadow: 0 0 0 0.25rem rgba(255, 255, 255, 0.6); }

/* Bootstrap 5.3 doesn't style <dialog> (the new-ingredient dialog). */
dialog { border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius-lg); width: min(32rem, calc(100vw - 2rem)); box-sizing: border-box; }
dialog::backdrop { background: rgb(0 0 0 / 0.4); }

/* ---------- Planner grid: chips Bootstrap's badges can't do (dashed, hover) ---------- */

.slot-chip {
  display: inline-block;
  background: var(--chiro-sand-soft);
  color: var(--bs-primary);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: 0.88rem;
  text-decoration: none;
}
.slot-chip:hover { background: var(--chiro-sand); color: var(--bs-primary); }
.slot-chip:focus-visible { outline: 3px solid var(--bs-primary); outline-offset: 2px; }

.slot-chip-empty {
  background: transparent;
  border: 1px dashed var(--bs-border-color);
  color: var(--bs-secondary-color);
  font-style: italic;
}
.slot-chip-empty:hover { background: transparent; border-color: var(--bs-primary); color: var(--bs-primary); }

.slot-chip-missing {
  background: var(--bs-danger-bg-subtle);
  border: 1px solid var(--bs-danger);
  /* Darker than --bs-danger: plain danger red drops under 4.5:1 on the pink. */
  color: var(--bs-danger-text-emphasis);
}
.slot-chip-missing:hover { background: var(--bs-danger-bg-subtle); border-color: var(--bs-danger-text-emphasis); color: var(--bs-danger-text-emphasis); }

/* ---------- Text ---------- */

/* Multi-line camp fields on the runbook keep their line breaks; Bootstrap has no
   pre-line utility. */
.prewrap { white-space: pre-line; margin: 0.2rem 0 0; }

/* Help pages and news posts: Markdown, at a readable line length. The Markdown
   renderer writes plain <table> and <h2>, so they get their look here. */
.prose { max-width: 42rem; line-height: 1.6; }
.prose h2 { margin-top: 1.75rem; }
.prose table { border-collapse: collapse; margin-bottom: 1rem; background: #fff; }
.prose th,
.prose td { border: 1px solid var(--bs-border-color); padding: 0.5rem 0.7rem; vertical-align: top; }
.prose thead th { background: var(--chiro-sand-soft); color: var(--chiro-navy); font-weight: 600; }

/* Runbook days stay clear of the sticky day pills when jumped to. */
.runbook-day { scroll-margin-top: 4rem; }

/* A visually-hidden table heading is absolutely positioned: without this it escapes
   the scrolling box and widens the whole page on a phone. */
.table-responsive { position: relative; }

/* ---------- Print (recipe one-pager) ---------- */

@media print {
  .navbar { display: none !important; }
  /* Side by side on paper too (the recipe page's ingredients and steps). */
  .print-columns { flex-wrap: nowrap; }
  .print-columns > [class*="col-"] { flex: 1 1 0; width: auto; }
  body { background: white; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; }
}

/* ---------- Bill review: a wide table, with the matching columns first ---------- */

main:has(.bill-review) { max-width: none; }
.bill-lines { table-layout: fixed; }
.bill-lines th, .bill-lines td { padding: 0.3rem 0.4rem; }
/* The header stays in view while scrolling through a long bill. */
.bill-lines thead th { position: sticky; top: 0; z-index: 1; background-color: var(--bs-body-bg); }
.bill-lines .col-description { width: 20%; }
.bill-lines .col-category { width: 9.5rem; }
.bill-lines .col-ingredient { width: 20%; }
.bill-lines .col-number { width: 6.5rem; }
.bill-lines .col-check { width: 4.5rem; text-align: center; }
.bill-lines .col-stock { width: 11%; }
/* Narrow screens scroll the table sideways; the header can't stick then. */
@media (max-width: 60rem) {
  .bill-lines-box { overflow-x: auto; }
  .bill-lines { min-width: 60rem; }
  .bill-lines thead th { position: static; }
}
