/* =========================================================================
 * Flagler Ward Meals - shared visual system
 * Single source of truth for all pages. Loaded by every HTML file via
 *   <link rel="stylesheet" href="/assets/css/app.css">
 *
 * IMPORTANT: All existing mmc-* class names are preserved here so the JS
 * (which targets these classes for innerHTML rendering and event binding)
 * continues to work without modification. Visual styling has been refreshed
 * to a warmer, more polished palette while keeping the same component
 * vocabulary.
 * ========================================================================= */

/* ---- Color & shape tokens (v0 design system port, OKLCH) ----
 * Palette and tokens matched to the v0-generated design spec
 * (flagler-ward-meals-design-system.md). OKLCH gives us perceptually-uniform
 * warmth control. Supported by Safari 15.4+, Chrome 111+, Firefox 113+.
 */
:root {
  /* Brand */
  --mmc-primary:        oklch(0.30 0.06 255);    /* navy - buttons, headers, key UI */
  --mmc-primary-dark:   oklch(0.24 0.06 255);    /* deeper navy for hover */
  --mmc-accent:         oklch(0.72 0.14 85);     /* gold - highlights, badges */
  --mmc-accent-soft:    oklch(0.72 0.14 85);     /* alias - same gold */

  /* Surfaces */
  --mmc-bg:             oklch(0.98 0.008 85);    /* warm cream/parchment */
  --mmc-card:           oklch(0.995 0.003 85);   /* off-white with warmth */
  --mmc-card-soft:      oklch(0.94 0.01 85);     /* subtle backgrounds (--muted) */

  /* Borders */
  --mmc-border:         oklch(0.88 0.015 85);    /* warm border */
  --mmc-border-soft:    oklch(0.92 0.012 85);    /* subtler */

  /* Text */
  --mmc-text:           oklch(0.15 0.02 255);    /* near-black with navy tint */
  --mmc-text-soft:      oklch(0.45 0.02 255);    /* secondary text */
  --mmc-muted:          oklch(0.45 0.02 255);    /* alias */
  --mmc-muted-soft:     oklch(0.55 0.02 255);    /* tertiary */

  /* Semantic (kept hex for predictable badge colors) */
  --mmc-success-bg:     #DCFCE7;
  --mmc-success-fg:     #14532D;
  --mmc-warn-bg:        #FEF3C7;
  --mmc-warn-fg:        #78350F;
  --mmc-error-bg:       #FEE2E2;
  --mmc-error-fg:       #991B1B;
  --mmc-destructive:    oklch(0.55 0.2 25);

  /* Shadows - softer, navy-tinted per v0 spec */
  --mmc-shadow-sm:      0 2px 8px -2px oklch(0.30 0.06 255 / 0.08);
  --mmc-shadow-md:      0 4px 12px -4px oklch(0.30 0.06 255 / 0.10);
  --mmc-shadow-lg:      0 12px 32px -8px oklch(0.30 0.06 255 / 0.18);

  /* Radius scale (v0 spec) */
  --mmc-radius-card:    16px;   /* rounded-2xl */
  --mmc-radius-btn:     12px;   /* rounded-xl */
  --mmc-radius-sm:      8px;    /* rounded-lg */
}

/* ---- Body ---- */
body {
  background: var(--mmc-bg);
  color: var(--mmc-text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- Topbar + tabs (overrides per-page inline nav styles to use new tokens) ---- */
.mmc-topbar {
  background: var(--mmc-primary) !important;
  padding: 0.85rem 1rem !important;
  box-shadow: var(--mmc-shadow-sm) !important;
}
.mmc-role {
  font-family: 'Newsreader', Georgia, serif !important;
  font-weight: 500 !important;
  font-size: 1.05rem !important;
  letter-spacing: -0.01em;
}
.mmc-tabs {
  background: var(--mmc-card) !important;
  border-bottom: 1px solid var(--mmc-border) !important;
  padding: 0.55rem 0.75rem !important;
  gap: 0.4rem !important;
}
.mmc-tab {
  padding: 0.55rem 1rem !important;
  font-size: 0.92rem !important;
  font-weight: 500 !important;
  color: var(--mmc-text) !important;
  background: var(--mmc-muted) !important;
  border-radius: 999px !important;
  min-height: 36px;
  transition: all 0.2s ease-out !important;
}
.mmc-tab:hover { background: var(--mmc-border) !important; }
.mmc-tab.active {
  background: var(--mmc-primary) !important;
  color: #fff !important;
  box-shadow: var(--mmc-shadow-sm);
}

/* ---- App container ---- */
#mmc-app {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 1rem 6rem;
}

/* =========================================================================
 * CARDS
 * ========================================================================= */
.mmc-card {
  background: var(--mmc-card);
  border: 1px solid var(--mmc-border);
  border-radius: var(--mmc-radius-card);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--mmc-shadow-sm);
}
.mmc-card h2 {
  font-family: 'Newsreader', Georgia, serif;
  font-weight: 500;             /* v0: medium weight for warmer feel */
  font-size: 1.5rem;            /* text-2xl per v0 */
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--mmc-foreground, var(--mmc-text));
  margin: 0 0 .5rem;
  text-wrap: balance;
}
.mmc-card .mmc-sub {
  color: var(--mmc-muted);
  font-size: 1rem;              /* 16px per v0 - body minimum */
  line-height: 1.5;
  margin: 0 0 1rem;
}

/* Subtle gradient hero variant - apply with class="mmc-card mmc-card-hero" */
.mmc-card-hero {
  background: linear-gradient(135deg, #FFFFFF 0%, var(--mmc-card-soft) 100%);
  position: relative;
  overflow: hidden;
}
.mmc-card-hero::before {
  content: "";
  position: absolute;
  right: -40px; top: -40px;
  width: 140px; height: 140px;
  background: radial-gradient(circle, rgba(201,162,74,.15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.mmc-card-hero > * { position: relative; z-index: 1; }

/* =========================================================================
 * TYPOGRAPHY HELPERS
 * ========================================================================= */
.mmc-eyebrow {
  font: 600 .68rem 'Inter', sans-serif;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--mmc-muted-soft);
  margin: 0 0 .4rem;
}

/* =========================================================================
 * FORM FIELDS
 * ========================================================================= */
.mmc-field {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: .9rem;
}
.mmc-field label {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--mmc-text-soft);
}
.mmc-field input,
.mmc-field select,
.mmc-field textarea {
  width: 100%;
  padding: .75rem 1rem;
  min-height: 44px;             /* v0: 44px tap target */
  border: 1.5px solid var(--mmc-border);
  border-radius: var(--mmc-radius-btn);
  font-size: 1rem;              /* 16px per v0 - prevents iOS zoom-on-focus */
  background: var(--mmc-card);
  color: var(--mmc-text);
  transition: all .2s ease-out;
  font-family: inherit;
}
.mmc-field input:focus,
.mmc-field select:focus,
.mmc-field textarea:focus {
  outline: none;
  border-color: var(--mmc-primary);
  box-shadow: 0 0 0 3px oklch(0.30 0.06 255 / 0.12);
}
.mmc-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
@media (max-width: 480px) {
  .mmc-row { grid-template-columns: 1fr; }
}

/* =========================================================================
 * BUTTONS
 * ========================================================================= */
.mmc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .75rem 1.5rem;          /* py-3 px-6 per v0 spec */
  min-height: 44px;                /* WCAG touch target */
  background: var(--mmc-primary);
  color: #fff;
  border: none;
  border-radius: var(--mmc-radius-btn);
  font-weight: 500;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  transition: all .2s ease-out;
  box-shadow: var(--mmc-shadow-sm);
  font-family: inherit;
}
.mmc-btn:hover {
  background: oklch(0.27 0.06 255);   /* primary at 90% per v0 */
  box-shadow: var(--mmc-shadow-md);
}
.mmc-btn:active { transform: scale(0.98); }
.mmc-btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; }

/* Secondary (outlined per v0) */
.mmc-btn-secondary {
  background: transparent;
  color: var(--mmc-primary);
  border: 2px solid var(--mmc-primary);
  box-shadow: none;
}
.mmc-btn-secondary:hover {
  background: oklch(0.30 0.06 255 / 0.05);
  color: var(--mmc-primary);
  box-shadow: none;
}
.mmc-btn-danger {
  background: var(--mmc-destructive);
  box-shadow: var(--mmc-shadow-sm);
}
.mmc-btn-danger:hover { background: oklch(0.50 0.2 25); }

/* Ghost (no border, hover tint) */
.mmc-btn-ghost {
  background: transparent;
  color: var(--mmc-primary);
  border: 1px solid transparent;
  box-shadow: none;
}
.mmc-btn-ghost:hover {
  background: var(--mmc-card-soft);
  box-shadow: none;
}

/* Accent (gold) - v0's "special action" variant */
.mmc-btn-accent {
  background: var(--mmc-accent);
  color: oklch(0.15 0.02 255);
  box-shadow: var(--mmc-shadow-sm);
}
.mmc-btn-accent:hover {
  background: oklch(0.65 0.14 85);
  box-shadow: var(--mmc-shadow-md);
}

/* =========================================================================
 * PILLS / BADGES
 * ========================================================================= */
.mmc-pill {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .25rem .65rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .01em;
}
.mmc-pill-ok    { background: var(--mmc-success-bg); color: var(--mmc-success-fg); }
.mmc-pill-warn  { background: var(--mmc-warn-bg);    color: var(--mmc-warn-fg); }
.mmc-pill-error { background: var(--mmc-error-bg);   color: var(--mmc-error-fg); }
.mmc-pill-info  { background: oklch(0.94 0.04 255);  color: var(--mmc-primary); }

/* =========================================================================
 * LISTS / ITEMS  (MealCard pattern per v0)
 * ========================================================================= */
.mmc-list {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.mmc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .85rem;
  padding: 1rem 1.1rem;
  background: var(--mmc-card);
  border: 1px solid var(--mmc-border);
  border-radius: var(--mmc-radius-card);
  box-shadow: var(--mmc-shadow-sm);
  transition: all .2s ease-out;
}
.mmc-item h3 {
  margin: 0;
  font-size: 1.05rem;            /* card titles per v0 (text-lg) */
  font-weight: 500;
  color: var(--mmc-text);
  font-family: 'Newsreader', Georgia, serif;
  letter-spacing: -0.01em;
}
.mmc-item p {
  margin: .2rem 0 0;
  font-size: .9rem;
  color: var(--mmc-muted);
  line-height: 1.45;
}

/* =========================================================================
 * EMPTY STATES (friendly per v0)
 * ========================================================================= */
.mmc-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--mmc-muted);
  font-size: 1rem;
  line-height: 1.5;
  border: 1.5px dashed var(--mmc-border);
  border-radius: var(--mmc-radius-card);
  background: var(--mmc-card);
}

/* =========================================================================
 * GRID UTILS
 * ========================================================================= */
.mmc-grid { display: grid; gap: .55rem; }
.mmc-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.mmc-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.mmc-grid.cols-7 { grid-template-columns: repeat(7, 1fr); }

/* =========================================================================
 * CALENDAR (day cells)
 * ========================================================================= */
.mmc-cal-day {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--mmc-border);
  background: #fff;
  user-select: none;
  transition: background .15s, transform .08s;
  color: var(--mmc-text);
}
.mmc-cal-day:hover { background: var(--mmc-card-soft); }
.mmc-cal-day:active { transform: translateY(1px); }
.mmc-cal-day.blocked {
  background: var(--mmc-error-bg);
  color: var(--mmc-error-fg);
  border-color: #FCA5A5;
  text-decoration: line-through;
}
.mmc-cal-day.has-meal {
  background: var(--mmc-success-bg);
  color: var(--mmc-success-fg);
  border-color: #86EFAC;
}
.mmc-cal-day.muted {
  color: #CBD5E1;
  cursor: default;
  background: #F8FAFC;
}
.mmc-cal-day.today {
  outline: 2px solid var(--mmc-accent-soft);
  outline-offset: -2px;
}
.mmc-cal-headers {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: .35rem;
  margin-bottom: .4rem;
}
.mmc-cal-headers div {
  text-align: center;
  font-size: .7rem;
  font-weight: 600;
  color: var(--mmc-muted-soft);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* =========================================================================
 * STATS TILES
 * ========================================================================= */
.mmc-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .65rem;
}
.mmc-stat {
  background: #fff;
  border: 1px solid var(--mmc-border-soft);
  border-radius: 16px;
  padding: 1rem .9rem;
  box-shadow: var(--mmc-shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform .08s, box-shadow .15s;
}
.mmc-stat .label {
  font-size: .68rem;
  color: var(--mmc-muted-soft);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 600;
}
.mmc-stat .value {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 1.9rem;
  font-weight: 600;
  color: var(--mmc-primary);
  margin-top: .35rem;
  line-height: 1;
}

/* Hero tile variant: navy gradient (apply alongside .mmc-stat) */
.mmc-stat-hero {
  background: linear-gradient(135deg, var(--mmc-primary) 0%, var(--mmc-primary-dark) 100%);
  border-color: var(--mmc-primary-dark);
  box-shadow: var(--mmc-shadow-md);
}
.mmc-stat-hero .label { color: rgba(255,255,255,.7); }
.mmc-stat-hero .value { color: #fff; }

/* Linkable variant (used on dashboard tiles) */
.mmc-stat-link {
  text-decoration: none;
  color: inherit;
  display: block;
}
.mmc-stat-link:hover {
  transform: translateY(-1px);
  box-shadow: var(--mmc-shadow-md);
}

/* =========================================================================
 * RADIOS / BIG-BUTTONS
 * ========================================================================= */
.mmc-radios {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .55rem;
}
.mmc-radio {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .75rem;
  background: #fff;
  border: 1.5px solid var(--mmc-border);
  border-radius: 12px;
  font-size: .92rem;
  cursor: pointer;
  user-select: none;
  transition: all .15s;
  color: var(--mmc-text);
}
.mmc-radio:hover { border-color: var(--mmc-accent-soft); background: var(--mmc-card-soft); }
.mmc-radio.selected {
  border-color: var(--mmc-primary);
  background: #EEF4FB;
  color: var(--mmc-primary);
  font-weight: 600;
}

/* =========================================================================
 * MISC
 * ========================================================================= */
.mmc-loading {
  text-align: center;
  padding: 2rem;
  color: var(--mmc-text-soft);
  font-size: .9rem;
}
.mmc-checkbox-row {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-bottom: .4rem;
}
.mmc-checkbox-row input[type=checkbox] {
  width: 18px; height: 18px;
  accent-color: var(--mmc-primary);
}

/* =========================================================================
 * AVATAR / PHOTO TILES
 * ========================================================================= */
.mmc-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #C5BFA8 0%, #8E8266 100%);
  color: #fff;
  font: 700 .85rem 'Inter', sans-serif;
  letter-spacing: .03em;
  overflow: hidden;
}
.mmc-avatar img { width: 100%; height: 100%; object-fit: cover; }
.mmc-avatar-sm { width: 36px; height: 36px; border-radius: 11px; font-size: .68rem; }
.mmc-avatar-md { width: 48px; height: 48px; border-radius: 14px; font-size: .82rem; }
.mmc-avatar-lg { width: 64px; height: 64px; border-radius: 18px; font-size: 1.05rem; }

/* =========================================================================
 * SECTION HEADERS (between cards)
 * ========================================================================= */
.mmc-section-eyebrow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: .25rem .25rem .65rem;
}
.mmc-section-eyebrow .title {
  font: 600 1rem 'Newsreader', Georgia, serif;
  color: var(--mmc-primary);
}
.mmc-section-eyebrow .meta {
  font: 500 .76rem 'Inter', sans-serif;
  color: var(--mmc-muted-soft);
}

/* =========================================================================
 * ANNOUNCEMENT (v0: card with gold left border for important)
 * ========================================================================= */
.mmc-announce {
  background: var(--mmc-card);
  border: 1px solid var(--mmc-border);
  border-left: 4px solid var(--mmc-accent);
  border-radius: var(--mmc-radius-card);
  padding: 1rem 1.1rem;
  display: flex;
  gap: .85rem;
  margin: 1rem 0;
  box-shadow: var(--mmc-shadow-sm);
}
.mmc-announce-icon {
  flex-shrink: 0;
  width: 40px; height: 40px;
  background: var(--mmc-accent);
  border-radius: var(--mmc-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: oklch(0.15 0.02 255);
  box-shadow: var(--mmc-shadow-sm);
}
.mmc-announce-body .label {
  font: 600 .7rem 'Inter', sans-serif;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--mmc-muted);
  margin: 0 0 .25rem;
}
.mmc-announce-body .msg {
  font: 400 1rem/1.5 'Inter', sans-serif;
  color: var(--mmc-text);
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* =========================================================================
 * RESPONSIVE
 * ========================================================================= */
@media (max-width: 460px) {
  #mmc-app { padding: .85rem .8rem 5rem; }
  .mmc-card { padding: 1.1rem 1rem; border-radius: 18px; }
  .mmc-card h2 { font-size: 1.15rem; }
}

/* =========================================================================
 * MOTION & POLISH LAYER
 * Subtle, fast, professional. Every rule below degrades gracefully and is
 * fully disabled for users who prefer reduced motion.
 * ========================================================================= */

/* Page content eases in once per load — content feels composed, not dumped */
@keyframes mmc-page-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
#mmc-app { animation: mmc-page-in .32s ease-out both; }

/* Cards lift faintly on hover where a pointer exists (never on touch) */
@media (hover: hover) and (pointer: fine) {
  .mmc-item:hover {
    border-color: var(--mmc-border);
    box-shadow: var(--mmc-shadow-md);
    transform: translateY(-1px);
  }
}

/* Consistent, accessible keyboard focus everywhere */
:focus-visible {
  outline: 2px solid var(--mmc-primary);
  outline-offset: 2px;
  border-radius: 4px;
}
.mmc-btn:focus-visible,
.mmc-tab:focus-visible,
.mmc-cal-day:focus-visible {
  outline: 2px solid var(--mmc-accent);
  outline-offset: 2px;
}

/* Loading: quiet skeleton shimmer instead of a bare "Loading…" string */
.mmc-loading {
  position: relative;
  color: var(--mmc-muted-soft);
}
.mmc-loading::after {
  content: "";
  display: block;
  height: 4px;
  width: 120px;
  margin: .8rem auto 0;
  border-radius: 999px;
  background: linear-gradient(90deg,
    var(--mmc-border-soft) 25%,
    var(--mmc-border) 50%,
    var(--mmc-border-soft) 75%);
  background-size: 200% 100%;
  animation: mmc-shimmer 1.2s linear infinite;
}
@keyframes mmc-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* Buttons: tactile press, smooth release */
.mmc-btn { will-change: transform; }
.mmc-btn:active { transform: scale(.97); transition-duration: .06s; }

/* Inputs: gentle settle on focus */
.mmc-field input:focus,
.mmc-field select:focus,
.mmc-field textarea:focus { transform: translateY(-1px); }

/* Calendar day cells: snappy feedback */
.mmc-cal-day { transition: background .15s, transform .1s, box-shadow .15s; }
.mmc-cal-day:hover:not(.muted) { box-shadow: var(--mmc-shadow-sm); }

/* Pills get a soft entrance when injected after async loads */
@keyframes mmc-pop-in {
  from { opacity: 0; transform: scale(.92); }
  to   { opacity: 1; transform: none; }
}
.mmc-pill { animation: mmc-pop-in .2s ease-out both; }

/* Section anchors scroll smoothly */
html { scroll-behavior: smooth; }

/* Tasteful text selection + slim scrollbars */
::selection { background: oklch(0.72 0.14 85 / .35); }
* { scrollbar-width: thin; scrollbar-color: var(--mmc-border) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--mmc-border); border-radius: 999px; }
*::-webkit-scrollbar-track { background: transparent; }

/* Images never overflow their cards */
.mmc-card img, .mmc-item img { max-width: 100%; }

/* Tap highlight: none (we provide our own pressed states) */
.mmc-btn, .mmc-tab, .mmc-cal-day, .mmc-radio, .mmc-bigbtn, a {
  -webkit-tap-highlight-color: transparent;
}

/* Honor reduced-motion users completely */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  html { scroll-behavior: auto; }
}
