/* App shell and page layouts. Component styles live in momo.css (from the design system). */

html, body { margin: 0; min-height: 100%; background: var(--surface-000); }
body { overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
a { color: var(--pink-text); }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 3px; }
/* Blazor focuses the page heading after navigation (FocusOnNavigate) for screen readers; headings are not controls, so no ring. */
h1:focus, h1:focus-visible { outline: none; }

/* ---------- Shell ---------- */
.app {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "header" "main" "nav";
}
.app__header {
  grid-area: header;
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px;
  background: color-mix(in srgb, var(--surface-000) 88%, transparent);
  backdrop-filter: blur(10px);
}
.app__brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 700; font-size: 20px; color: var(--ink); text-decoration: none; }
.app__brand-dot { width: 28px; height: 28px; border-radius: 50%; background: var(--pink-500); box-shadow: inset -4px -4px 0 var(--pink-edge); position: relative; }
.app__brand-dot::after { content: ""; position: absolute; top: -5px; left: 10px; width: 9px; height: 7px; border-radius: 9px 0; background: var(--green-500); }
.app__header-actions { display: flex; align-items: center; gap: 8px; }
.app__member { display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border: 0; border-radius: var(--radius-pill); background: var(--surface-100); box-shadow: var(--shadow-card); color: var(--ink); font-weight: 800; cursor: pointer; min-height: 44px; }
.app__main { grid-area: main; width: 100%; max-width: 1280px; margin: 0 auto; padding: 8px 16px 32px; box-sizing: border-box; min-width: 0; }
.app__nav { grid-area: nav; position: sticky; bottom: 0; z-index: 20; }
.app__timers { position: fixed; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); z-index: 30; display: grid; gap: 8px; justify-items: end; }
.app__timers .mo-timer-pill { border: 0; cursor: pointer; font-family: var(--font-body); }

@media (min-width: 768px) {
  .app {
    grid-template-columns: 112px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas: "nav header" "nav main";
  }
  .app__nav { position: sticky; top: 0; height: 100dvh; padding: 16px 0 16px 16px; box-sizing: border-box; }
  .app__nav .mo-rail { height: 100%; }
  .app__main { padding: 8px 24px 40px; }
  .app__header { padding: 16px 24px 8px; }
  .app__timers { bottom: 24px; right: 24px; }
}

/* Focus mode (cooking): no chrome, full screen. */
.app--focus { grid-template-columns: 1fr !important; grid-template-rows: 1fr !important; grid-template-areas: "main" !important; }
.app--focus .app__header, .app--focus .app__nav, .app--focus .app__timers { display: none; }
.app--focus .app__main { max-width: none; padding: 0; }

/* ---------- Page scaffolding ---------- */
.page { display: grid; gap: 24px; }
.page__hero { display: flex; align-items: center; gap: 16px; }
.page__hero-text { display: grid; gap: 4px; min-width: 0; }
.page__title { font-family: var(--font-display); font-size: 26px; line-height: 32px; font-weight: 700; }
.page__greeting { font-family: var(--font-display); font-size: 34px; line-height: 38px; font-weight: 700; }
.page__sub { color: var(--ink-muted); font-weight: 600; }
.page__actions { display: flex; gap: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid--2 { grid-template-columns: 1fr; }
@media (min-width: 1024px) { .grid--2 { grid-template-columns: 1fr 1fr; } }
.split { display: grid; gap: 24px; }
@media (min-width: 1024px) { .split { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; } }
.stack-sm { display: grid; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.form-grid { display: grid; gap: 16px; }
@media (min-width: 640px) { .form-grid--2 { grid-template-columns: 1fr 1fr; } .form-grid--3 { grid-template-columns: repeat(3, 1fr); } }
.sticky-actions { position: sticky; bottom: 0; padding: 12px 0 4px; background: linear-gradient(to top, var(--surface-000) 70%, transparent); }
.link-plain { color: inherit; text-decoration: none; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- Empty / loading ---------- */
.empty { display: grid; justify-items: center; text-align: center; gap: 12px; padding: 32px 16px; }
.empty__title { font-family: var(--font-display); font-size: 20px; line-height: 26px; font-weight: 600; }
.empty__text { color: var(--ink-muted); max-width: 36ch; }
.loading { display: grid; place-items: center; padding: 48px; color: var(--ink-muted); font-weight: 700; }
.loading__dots { display: flex; gap: 6px; }
.loading__dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--pink-500); animation: momo-bounce 900ms infinite var(--ease-bounce); }
.loading__dots span:nth-child(2) { animation-delay: 150ms; background: var(--green-500); }
.loading__dots span:nth-child(3) { animation-delay: 300ms; background: var(--butter-300); }
@keyframes momo-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ---------- Home ---------- */
.home-hero { display: flex; align-items: center; gap: 16px; }
.home-hero .mo-bubble { max-width: 32ch; }
@media (max-width: 520px) { .home-hero { flex-direction: column; text-align: center; } .home-hero .mo-bubble::after { display: none; } }
.dash-grid { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 768px) { .dash-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1200px) { .dash-grid { grid-template-columns: repeat(3, 1fr); } }
.dash-grid .span-2 { grid-column: span 1; }
@media (min-width: 768px) { .dash-grid .span-2 { grid-column: span 2; } }

/* ---------- Recipes ---------- */
.recipe-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .recipe-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .recipe-grid { grid-template-columns: repeat(3, 1fr); } }
.recipe-card { display: flex; gap: 14px; align-items: center; color: var(--ink); text-decoration: none; }
.recipe-card__body { flex: 1; min-width: 0; display: grid; gap: 6px; }
.recipe-card__title { font-family: var(--font-display); font-size: 20px; line-height: 24px; font-weight: 700; }
.recipe-card__desc { color: var(--ink-muted); font-size: 13px; line-height: 18px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.recipe-thumb { width: 96px; height: 96px; flex: none; border-radius: var(--radius-md); background: var(--pink-100); display: grid; place-items: center; overflow: hidden; color: var(--pink-text); font-size: 40px; }
.recipe-thumb img { width: 100%; height: 100%; object-fit: cover; }
.recipe-thumb--lg { width: 100%; height: 220px; border-radius: var(--radius-lg); font-size: 72px; }
.fav { border: 0; background: none; color: var(--ink-muted); font-size: 24px; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.fav.is-on { color: var(--pink-text); }
.ingredient { display: flex; align-items: baseline; gap: 12px; padding: 10px 0; }
.ingredient + .ingredient { border-top: 1px solid var(--line); }
.ingredient__qty { min-width: 88px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ingredient__name { flex: 1; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; counter-reset: step; }
.steps li { display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: start; counter-increment: step; }
.steps li::before { content: counter(step); width: 36px; height: 36px; border-radius: 50%; background: var(--green-100); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; }
.editor-row { display: grid; gap: 8px; grid-template-columns: 80px 80px 1fr 44px; align-items: center; }
.editor-row--step { grid-template-columns: 1fr 44px; }
.editor-row .mo-input, .editor-row .mo-select { min-height: 44px; padding: 8px 12px; font-size: 15px; }
@media (max-width: 560px) { .editor-row { grid-template-columns: 64px 64px 1fr 44px; } }
.ingredient-aisle { display: flex; align-items: center; gap: 8px; }
.ingredient-aisle .mo-select { flex: 1; min-height: 40px; padding: 6px 12px; font-size: 14px; }
.time-total { display: flex; align-items: center; background: var(--surface-200); font-weight: 800; }
.tiktok-link { justify-self: start; }

/* Photo upload in the recipe editor */
.photo-picker { display: flex; gap: 16px; align-items: center; }
.photo-picker__preview { width: 120px; height: 120px; }
.photo-picker__link summary { cursor: pointer; margin-top: 4px; }
.photo-picker__link .mo-input { margin-top: 8px; }
label.mo-btn { cursor: pointer; justify-self: start; }
label.mo-btn.is-disabled { opacity: .5; pointer-events: none; }
input.mo-sr:focus-visible + label.mo-btn { outline: 3px solid var(--focus-ring); outline-offset: 3px; }

/* Tag picker: chips + "+" button with a searchable suggestion list */
.tag-picker { display: grid; gap: 8px; }
.tag-picker__chip { padding-right: 4px; }
.tag-picker__remove { border: 0; background: none; color: inherit; cursor: pointer; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; }
.tag-picker__remove:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.tag-picker__add { border: 2px dashed var(--line); background: var(--surface-100); }
.tag-picker__panel { display: grid; gap: 8px; padding: 12px; }
.tag-picker__list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; display: grid; gap: 2px; }
.tag-picker__option { width: 100%; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 10px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink); font-weight: 700; text-align: left; cursor: pointer; }
.tag-picker__option:hover, .tag-picker__option:focus-visible { background: var(--green-100); }
.tag-picker__option i { color: var(--green-text, var(--ink-muted)); }
.tag-picker__option--new { color: var(--pink-text); }
.tag-picker__empty { padding: 8px 10px; color: var(--ink-muted); font-weight: 600; }

/* ---------- Cooking mode ---------- */
.cook { min-height: 100dvh; display: grid; grid-template-rows: auto auto 1fr auto; gap: 16px; padding: calc(12px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px)); box-sizing: border-box; max-width: 1280px; margin: 0 auto; }
.cook__top { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; }
.cook__title { font-family: var(--font-display); font-size: 20px; line-height: 26px; font-weight: 600; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cook__body { display: grid; gap: 24px; align-content: start; }
@media (min-width: 900px) and (orientation: landscape) { .cook__body { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: center; align-content: center; } }
.cook__step-no { font-family: var(--font-display); font-weight: 600; color: var(--pink-text); font-size: 17px; }
.cook__text { font-family: var(--font-body); font-size: clamp(22px, 3.2vw, 32px); line-height: 1.45; font-weight: 700; }
.cook__timer { display: grid; justify-items: center; gap: 16px; }
.cook__timer .mo-timer { width: min(280px, 70vw); }
.cook__controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cook__done { display: grid; justify-items: center; gap: 16px; text-align: center; padding: 24px 0; }

/* ---------- Groceries ---------- */
.aisle { display: grid; gap: 4px; }
.aisle__title { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 600; font-size: 17px; margin: 8px 0 4px; }
.qty-inline { display: grid; grid-template-columns: 1fr 90px minmax(150px, 200px); gap: 8px; }
@media (max-width: 560px) { .qty-inline { grid-template-columns: 1fr 90px; } .qty-inline .mo-select { grid-column: 1 / -1; } }
.aisle--done { opacity: .6; }
.pick-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.pick-row + .pick-row { border-top: 1px solid var(--line); }

/* ---------- Chores ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.week__day { display: grid; justify-items: center; gap: 4px; padding: 8px 2px; border-radius: var(--radius-md); border: 0; background: var(--surface-100); color: var(--ink); cursor: pointer; box-shadow: var(--shadow-card); font-family: var(--font-body); }
.week__day.is-today .week__num { background: var(--butter-300); color: var(--ink-on-fill); }
.week__day.is-selected { background: var(--pink-500); color: var(--ink-on-fill); box-shadow: 0 3px 0 var(--pink-edge); }
.week__day.is-selected .week__letter { color: var(--ink-on-fill); }
.week__letter { font-size: 11px; line-height: 14px; font-weight: 800; color: var(--ink-muted); }
.week__num { font-family: var(--font-display); font-size: 18px; font-weight: 700; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; }
.week__dots { display: flex; gap: 3px; min-height: 8px; flex-wrap: wrap; justify-content: center; }
.week__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-muted); }
.week__dot--pink { background: var(--pink-edge); }
.week__dot--green { background: var(--green-edge); }
.week__dot--butter { background: var(--butter-300); box-shadow: inset 0 0 0 1px var(--ink-muted); }
.week__dot--lilac { background: var(--lilac-300); box-shadow: inset 0 0 0 1px var(--ink-muted); }
.week__dot--sky { background: var(--sky-300); box-shadow: inset 0 0 0 1px var(--ink-muted); }
.week__dot--anyone { background: var(--ink-muted); }
.week__dot.is-done { opacity: .35; }
.member-cols { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .member-cols { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); } }
.day-picker { display: flex; gap: 6px; flex-wrap: wrap; }
/* Icon Momo picked automatically for a chore */
.mo-chip.is-suggested { box-shadow: inset 0 0 0 2px var(--pink-edge); background: var(--pink-100); }
.day-picker button { width: 44px; height: 44px; border-radius: 50%; }

/* ---------- Money ---------- */
.money-hero { display: grid; gap: 16px; align-items: center; grid-template-columns: 1fr; }
@media (min-width: 640px) { .money-hero { grid-template-columns: auto 1fr; } }
.money-stats { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .money-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.money-flow { display: grid; gap: 8px; }
.money-flow__row { display: flex; justify-content: space-between; gap: 12px; font-weight: 700; }
.money-flow__row--total { border-top: 2px dashed var(--line); padding-top: 8px; font-family: var(--font-display); font-size: 18px; }
.amount-input { font-family: var(--font-display); font-size: 32px !important; line-height: 40px !important; text-align: center; }
.cat-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.cat-picker button { display: grid; justify-items: center; gap: 6px; padding: 10px 6px; border-radius: var(--radius-md); border: 2px solid transparent; background: var(--surface-200); color: var(--ink); font-weight: 800; font-size: 13px; cursor: pointer; }
.cat-picker button[aria-pressed="true"] { background: var(--pink-100); border-color: var(--pink-edge); }

/* ---------- Settings ---------- */
.color-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.color-picker button { border: 0; padding: 0; background: none; cursor: pointer; border-radius: 50%; }

/* ---------- Who's here ---------- */
.who { min-height: 80dvh; display: grid; place-content: center; justify-items: center; gap: 24px; text-align: center; }
.who__grid { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; }
.who__member { display: grid; justify-items: center; gap: 8px; padding: 16px; min-width: 120px; border: 0; border-radius: var(--radius-lg); background: var(--surface-100); box-shadow: var(--shadow-card); cursor: pointer; font-weight: 800; color: var(--ink); font-family: var(--font-body); }

/* Blazor error UI */
#blazor-error-ui { display: none; position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; margin-left: auto; }

/* Nav: tab bar on phones, rail on tablets */
.nav-tablet { display: none; height: 100%; }
@media (min-width: 768px) { .nav-phone { display: none; } .nav-tablet { display: block; } }

.spin { display: inline-block; animation: momo-spin 900ms linear infinite; }
@keyframes momo-spin { to { transform: rotate(360deg); } }

/* Phone refinements */
.app__brand { white-space: nowrap; }
.mo-stat__value { white-space: nowrap; }
@media (max-width: 899px) { .money-stats > :first-child { grid-column: 1 / -1; } }
@media (max-width: 480px) {
  .app__member span:last-child { display: none; }
  .app__member { padding: 4px; }
  .app__header-actions { gap: 6px; }
}
