/* Home: page rules on top of ../shared/css/base.css (tokens, type, header, nav, buttons, chips,
   inputs, pills, cards, tables, tabs, dialog, login). Home sets only its accent and the kind colours. */

/* ---------- Accent and kind colours ---------- */
:root {
  --accent: #7A2E3B; --accent-soft: #F1E4E5;   /* white on the accent: 9.2:1 */
  --wine: #7A2E3B; --beer: #9A6A12; --spirit: #4E5F73;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #D98C99; --accent-soft: #35221F;  /* base --on-accent #0B1020 on the accent: 7.3:1 */
    --wine: #D98C99; --beer: #D9AE5A; --spirit: #9FB2C8;
  }
}
:root[data-theme="dark"] {
  --accent: #D98C99; --accent-soft: #35221F;
  --wine: #D98C99; --beer: #D9AE5A; --spirit: #9FB2C8;
}

#whoEmail { display: none; }  /* the address is the tooltip on Sign out; the header has no room for it next to the switch */

/* ---------- Text ---------- */
.empty { color: var(--muted); font-size: 14px; margin: 6px 0; }
.spaced { margin-top: 18px; }
.back { display: inline-block; margin-top: 18px; font-size: 14px; font-weight: 500; }
.prose { font-size: 14.5px; max-width: 62ch; overflow-wrap: anywhere; }

/* ---------- Filters ---------- */
.tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 18px 0 8px; }
.tools + .tools { margin-top: 8px; }
.tools input[type="search"] { flex: 1 1 220px; max-width: 320px; }
.tablewrap { margin-top: 14px; }

/* ---------- Tables and pills ---------- */
tbody tr[data-href] { cursor: pointer; }
td.name a { color: var(--ink); text-decoration: none; font-weight: 500; }
td.name a:hover { text-decoration: underline; }
td.name .by { display: block; font-size: 12.5px; color: var(--muted); }
.pill.bad { color: var(--bad); background: var(--bad-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.good { color: var(--good); background: var(--good-bg); }
.pill.acc { color: var(--accent); background: var(--accent-soft); }
.kdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.kdot.wine { background: var(--wine); }
.kdot.beer { background: var(--beer); }
.kdot.spirit { background: var(--spirit); }

/* ---------- Overview ---------- */
.stats { display: flex; flex-wrap: wrap; gap: 10px 32px; margin-top: 16px; }
.stat { display: grid; gap: 1px; }
.stat b { font: 600 22px/1.2 var(--display); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.cols { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 0 36px; }
.cols > * { min-width: 0; }
@media (max-width: 820px) { .cols { grid-template-columns: 1fr; } }
.list li a { color: var(--ink); text-decoration: none; font-weight: 500; }
.list li a:hover { text-decoration: underline; }
.list li .r { font-size: 12.5px; color: var(--muted); white-space: nowrap; text-align: right; }
.list li .r.mono { font-variant-numeric: tabular-nums; }
.list li .l { min-width: 0; }
.list li .l .m { display: block; font-size: 12.5px; color: var(--muted); }

/* ---------- Item page ---------- */
.acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.acts .qa { font-size: 13.5px; padding: 7px 14px; border-radius: var(--r-ctl); }
.qa.main { background: var(--accent); color: var(--on-accent); }
.qa.main:hover { filter: brightness(1.06); }
dl.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 18px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
/* Drinking window used: the fill width comes from a class w0 to w100 in steps of 5 */
.wbar { position: relative; height: 6px; border-radius: 3px; background: var(--fill); width: 140px; display: inline-block; vertical-align: middle; margin-left: 8px; overflow: hidden; }
.wbar i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); border-radius: 3px; }
.wbar.over i { background: var(--bad); }
.wbar .w5 { width: 5%; } .wbar .w10 { width: 10%; } .wbar .w15 { width: 15%; } .wbar .w20 { width: 20%; }
.wbar .w25 { width: 25%; } .wbar .w30 { width: 30%; } .wbar .w35 { width: 35%; } .wbar .w40 { width: 40%; }
.wbar .w45 { width: 45%; } .wbar .w50 { width: 50%; } .wbar .w55 { width: 55%; } .wbar .w60 { width: 60%; }
.wbar .w65 { width: 65%; } .wbar .w70 { width: 70%; } .wbar .w75 { width: 75%; } .wbar .w80 { width: 80%; }
.wbar .w85 { width: 85%; } .wbar .w90 { width: 90%; } .wbar .w95 { width: 95%; } .wbar .w100 { width: 100%; }

/* ---------- Storage ---------- */
.areas { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-top: 18px; align-items: start; }
.area {
  display: grid; gap: 6px; align-content: start; padding: 12px 14px; text-align: left; color: var(--ink); cursor: pointer;
  background: var(--surface); border: 1px solid var(--edge); border-radius: var(--r-card); box-shadow: var(--shadow);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.area:hover { box-shadow: 0 0 0 1px var(--edge), var(--shadow-hover); }
.area:active { transform: scale(.99); }
.area[aria-expanded="true"] { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.area .an { font: 600 18px/1.25 var(--display); letter-spacing: -0.01em; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.area .an span { font: 500 15px var(--mono); font-variant-numeric: tabular-nums; }
.area .ak { font-size: 12.5px; color: var(--muted); }
/* Fridge: 4 rows of 6 places */
.grid46 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 4px; }
.grid46 i { aspect-ratio: 1; border-radius: 50%; background: var(--fill); box-shadow: inset 0 0 0 1px var(--line); }
.grid46 i.on { background: var(--accent); box-shadow: none; }

/* ---------- Action dialog ---------- */
dialog#actDlg { width: min(460px, calc(100vw - 32px)); }
dialog#actDlg h3 { font: 600 20px/1.25 var(--display); letter-spacing: -0.01em; margin: 0 0 4px; }
.field { display: grid; gap: 5px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea { font-size: 15px; }
.field textarea { min-height: 70px; }
.score { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 2px; padding: 2px; background: var(--fill); border-radius: var(--r-ctl); }
.score button {
  font: 500 14px var(--mono); height: 34px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink); cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.score button:hover { background: var(--raised); }
.score button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow); }
.dactions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }

/* ---------- Meals ---------- */
.nights { display: grid; gap: 10px; margin-top: 14px; }
.night { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px 16px; align-items: start; padding: 12px 16px; }
.night .nday b { display: block; font: 600 15px/1.3 var(--display); letter-spacing: -0.01em; }
.night .nday span { font-size: 12.5px; color: var(--muted); }
.night .nmain { display: grid; gap: 10px; justify-items: start; min-width: 0; }
.night .nstate { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; width: 100%; }
.night .nstate .linkbtn { margin-left: auto; }
.night .nrec { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; font-size: 14.5px; font-weight: 500; overflow-wrap: anywhere; }
.night .nrec a { color: var(--ink); }
.night .nacts, .nacts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.night .nnote { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.ncooked { color: var(--good); font-weight: 500; }
/* Away: the card steps back (no surface, no shadow) and has no cook controls */
.night.away { background: transparent; box-shadow: none; border: 1px solid var(--line); }
.night.away .nday b { color: var(--muted); }
.score.s5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.sumtext { display: block; width: 100%; max-width: 72ch; margin-top: 14px; font-size: 14px; line-height: 1.5; field-sizing: content; }

/* Done planning: a bar at the bottom of the Plan page. Sticky, so at the end of the list it sits below
   the last evening instead of over it; it bleeds to the edges through the page's side padding. */
.planbar {
  position: sticky; bottom: 0; z-index: 4;
  display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap;
  margin: 18px calc(-1 * clamp(16px, 2.5vw, 40px)) 0;
  padding: 10px clamp(16px, 2.5vw, 40px) calc(10px + env(safe-area-inset-bottom, 0px));
  font-size: 14px; font-weight: 500;
  background: color-mix(in srgb, var(--ground) 72%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .planbar { background: var(--ground); } }
body:has(.planbar) .toast { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }  /* above the bar */

/* ---------- Sub-tabs: the section's segmented control under the page title ---------- */
.subtabs { position: relative; display: flex; width: fit-content; margin: 14px 0 6px; }
.subtabs a {
  flex: none; font: 500 13px/1.3 var(--sans); color: var(--muted); text-decoration: none;
  border-radius: 8px; padding: 5px 14px; white-space: nowrap;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.subtabs a:hover { color: var(--ink); text-decoration: none; }
.subtabs a[aria-current="page"] { color: var(--ink); background: var(--raised); box-shadow: 0 0 0 1px var(--edge), var(--shadow); }

/* ---------- Recipe cards (picker and Recipes list): 3 columns, 2 on a narrow window, 1 on a phone ---------- */
.rgrid { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1100px) { .rgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.rgrid li { display: flex; min-width: 0; }
.rcard {
  display: grid; gap: 6px; align-content: start; width: 100%; min-width: 0; padding: 12px 14px;
  text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.rcard:hover { box-shadow: 0 0 0 1px var(--edge), var(--shadow-hover); }
.rcard:active { transform: scale(.99); }
.rhead { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.rhead b { font-weight: 600; font-size: 15.5px; overflow-wrap: anywhere; }
.rhead .pe { flex: none; width: 24px; font-size: 20px; line-height: 1.2; text-align: center; }
.rhead .pe:empty { display: none; }
.rdesc { min-width: 0; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rpills { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; }
.rpills:empty { display: none; }
.rcard .m { font-size: 12.5px; color: var(--muted); }

/* ---------- Recipe page: ingredients left, steps right from 900px ---------- */
.rlead { margin: 14px 0 8px; font-size: 15px; }
.rcols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 0 40px; }
.rcols > * { min-width: 0; }
@media (max-width: 899px) { .rcols { grid-template-columns: 1fr; } }
.rsec { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.stepper .qa { width: 34px; padding-inline: 0; font-size: 16px; }
#rServ { min-width: 9ch; text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; }
.rgroup { margin: 16px 0 2px; font-size: 13px; font-weight: 600; color: var(--muted); }
.rings li .l { overflow-wrap: anywhere; }
.rsteps { margin: 0; padding-left: 1.7em; display: grid; gap: 10px; font-size: 15px; max-width: 70ch; }
.rsteps li { padding-left: 4px; overflow-wrap: anywhere; }
.rsteps li::marker { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.rnotes p, .rnotes ul { margin: 0 0 10px; }
.rnotes ul { padding-left: 1.3em; }

/* ---------- Preview sheet and the evening picker of "Plan this" ---------- */
.preview h4 { margin: 14px 0 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.preview .prose { margin: 8px 0; }
.preview .rpills { margin: 10px 0 0; }
.preview p.small { margin: 4px 0; font-size: 13.5px; }
.nightpick { display: grid; gap: 2px; margin-top: 12px; max-height: 46vh; overflow-y: auto; }
.nightpick label { display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: var(--r-ctl); cursor: pointer; }
.nightpick label:hover { background: var(--fill); }
.nightpick label:has(input:checked) { background: var(--accent-soft); }
.nightpick b { font-weight: 500; }
.nightpick .m { display: block; font-size: 12.5px; color: var(--muted); }
.nightpick .m.open { color: var(--good); }

/* ---------- Toast (Home uses the class .toast; base styles #toast) ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 50;
  max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: var(--r-pill);
  font: 500 14px/1.35 var(--sans); color: var(--ground);
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  animation: toast-in 220ms var(--ease);
}

/* ---------- Touch ---------- */
@media (hover: none) { tbody tr[data-href]:hover { background: none; } }
@media (pointer: coarse) {
  .acts .qa { padding: 10px 14px; }
  .subtabs a { padding: 7px 14px; }
  .stepper .qa { height: 38px; width: 40px; }
  .score button { height: 40px; }
}

/* ---------- Phones ---------- */
@media (max-width: 720px) {
  .wrap { padding-bottom: 48px; }
  /* iOS zooms into any field under 16px on focus */
  input, select, textarea { font-size: 16px !important; }

  /* Header: brand and sign out on one line, the nav as one swipeable strip below (as in the Cockpit) */
  header.top .wrap { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding-block: 8px 6px; }
  .brand { justify-self: start; }
  .appswitch a { font-size: 14px; }
  .who { grid-row: 1; grid-column: 2; }
  nav { grid-column: 1 / -1; flex-wrap: nowrap; gap: 2px; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding: 2px 16px; mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 24px), transparent 100%); }
  nav::-webkit-scrollbar, .chips::-webkit-scrollbar { display: none; }
  nav a { white-space: nowrap; padding-block: 8px; flex: none; }

  /* Filter tracks: one swipeable row */
  .tools .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .chips button { flex: none; }
  .tools input[type="search"] { flex: 1 1 100%; max-width: none; }

  h1 { margin-top: 18px; }
  h2 { margin-top: 26px; }
  .stats { gap: 10px 22px; }
  .stat b { font-size: 19px; }
  .list li { flex-wrap: wrap; row-gap: 2px; }
  .acts .qa { flex: 1 1 calc(50% - 8px); }
  .wbar { width: 90px; }

  /* Meals: the day sits above the night's controls; the cook control spans the card */
  .night { grid-template-columns: 1fr; padding: 12px 14px; }
  .night .nday { display: flex; align-items: baseline; gap: 8px; }
  .night .nmain > .chips { display: flex; width: 100%; }
  .night .nmain > .chips button { flex: 1 1 0; padding-block: 8px; }
  .night .nacts .qa { padding: 8px 12px; }

  /* Sub-tabs: one swipeable row; recipe cards in one column */
  .subtabs { max-width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .subtabs::-webkit-scrollbar { display: none; }
  .rgrid { grid-template-columns: 1fr; }

  /* Tables become one row card per record inside the rounded container; number cells carry their column name */
  .tablewrap { overflow: hidden; }
  .tablewrap table, .tablewrap tbody, .tablewrap tr, .tablewrap td { display: block; }
  .tablewrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .tablewrap tbody tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .tablewrap tbody tr:last-child { border-bottom: 0; }
  .tablewrap td, .tablewrap td:first-child, .tablewrap td:last-child { padding: 0; border: 0; }
  .tablewrap td:first-child { flex: 1 1 100%; }
  .tablewrap td:empty { display: none; }
  .tablewrap td.num { text-align: left; }
  .tablewrap td:not(:first-child) { font-size: 13px; }
  .tablewrap td.num[data-label]::before { content: attr(data-label) " "; font-family: var(--sans); color: var(--muted); }

  /* Action dialog: a sheet from the bottom */
  dialog#actDlg { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 16px 16px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
  dialog#actDlg[open] { animation: sheet-up 280ms var(--ease); }
  .dactions .btn { flex: 1 1 auto; }
  .score { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
