/* Brandon Valley brand: cardinal red #A8181A, charcoal #343536 */
:root {
  --bv-red: #A8181A;
  --bv-red-dark: #7d1012;
  --bv-red-bright: #c22527;
  --bv-red-soft: #fbeeee;
  --bv-gold: #f4c95d;
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f3efe8;
  --text: #2b2a28;
  --text-soft: #77736d;
  --border: #e8e2d8;
  --today-ring: #A8181A;
  --shadow: 0 1px 2px rgba(70,50,30,.06), 0 6px 18px rgba(70,50,30,.07);
  --shadow-lift: 0 2px 4px rgba(70,50,30,.08), 0 12px 28px rgba(70,50,30,.12);
  --sheet-shadow: 0 -8px 40px rgba(0,0,0,.2);
  --scratch-blue: #2b7ba1;
  --display: "Fredoka", -apple-system, "Segoe UI", Roboto, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bv-red: #d4494b;
    --bv-red-dark: #641012;
    --bv-red-bright: #e05a5c;
    --bv-red-soft: #3b2425;
    --bg: #171514;
    --surface: #242220;
    --surface-2: #2e2b28;
    --text: #f2efeb;
    --text-soft: #a8a39c;
    --border: #3b3733;
    --today-ring: #e05a5c;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.3);
    --shadow-lift: 0 2px 4px rgba(0,0,0,.5), 0 12px 28px rgba(0,0,0,.45);
    --sheet-shadow: 0 -8px 40px rgba(0,0,0,.65);
    --scratch-blue: #5ab4d6;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }

/* ---------- Header ---------- */
.app-header {
  background:
    radial-gradient(120% 140% at 85% -20%, rgba(255,255,255,.14), transparent 45%),
    linear-gradient(160deg, var(--bv-red-dark), #A8181A 55%, var(--bv-red-bright));
  color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 20px 16px;
  box-shadow: 0 2px 14px rgba(90,10,12,.35);
}
.header-inner {
  max-width: 960px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.brand h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.3rem, 4.5vw, 1.7rem);
  letter-spacing: .01em;
  line-height: 1.1;
}
.brand h1 span { color: var(--bv-gold); }

.school-picker {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px;
  padding: 12px 16px;
  min-height: 44px;
  cursor: pointer;
  max-width: 100%;
}
.picker-label {
  font-size: clamp(.82rem, 2.8vw, .95rem);
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.picker-caret { width: 11px; height: 8px; flex: none; opacity: .85; }
.school-picker select {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; font-size: 16px; /* 16px stops iOS zoom */
}

/* ---------- Layout ---------- */
main { flex: 1; width: 100%; max-width: 960px; margin: 0 auto; padding: clamp(14px, 3vw, 26px) clamp(10px, 3vw, 24px) 8px; }

/* ---------- Today hero ---------- */
.hero { margin-bottom: clamp(16px, 3vw, 26px); }
.hero-card {
  display: block; width: 100%; text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: clamp(16px, 3.5vw, 26px) clamp(18px, 4vw, 30px);
  box-shadow: var(--shadow);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform .12s ease, box-shadow .12s ease;
}
.hero-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 6px;
  background: linear-gradient(var(--bv-red), var(--bv-red-bright));
}
.hero-card:active { transform: scale(.985); }
@media (hover: hover) {
  .hero-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
}
.hero-kicker {
  font-size: clamp(.72rem, 2.4vw, .82rem);
  font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: var(--bv-red); margin-bottom: 8px;
}
.hero-entree {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.45rem, 5.5vw, 2.1rem);
  line-height: 1.15;
}
.hero-sides { margin-top: 6px; font-size: clamp(.88rem, 3vw, 1rem); color: var(--text-soft); }
.hero-sides:empty, .hero-alt:empty { display: none; }
.hero-alt { margin-top: 4px; font-size: clamp(.8rem, 2.8vw, .9rem); color: var(--text-soft); }
.hero-alt b { color: var(--text); font-weight: 600; }
.hero-tomorrow {
  margin: 10px 4px 0;
  font-size: clamp(.8rem, 2.8vw, .9rem);
  color: var(--text-soft);
}
.hero-tomorrow b { color: var(--text); font-weight: 600; }

/* ---------- Month nav ---------- */
.month-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.nav-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  width: clamp(46px, 8vw, 52px); height: clamp(42px, 7vw, 48px);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  color: var(--bv-red);
  transition: transform .1s ease;
}
.nav-btn svg { width: 9px; height: 14px; }
.nav-btn:active { transform: scale(.94); }
@media (hover: hover) { .nav-btn:hover { box-shadow: var(--shadow-lift); } }
.month-label {
  background: none; border: none;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.15rem, 4vw, 1.5rem);
  cursor: pointer;
  padding: 10px 16px; min-height: 44px; border-radius: 12px;
}
.month-label:active { background: var(--surface-2); }

/* ---------- Calendar ---------- */
.weekday-row {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: clamp(6px, 1.2vw, 10px);
  margin-bottom: 6px;
}
.weekday-row span {
  text-align: center;
  font-size: clamp(.68rem, 2vw, .78rem);
  font-weight: 800; color: var(--text-soft);
  text-transform: uppercase; letter-spacing: .08em;
}
.calendar {
  display: grid; grid-template-columns: repeat(5, 1fr);
  grid-auto-rows: clamp(104px, 16vw, 132px); /* every cell the same height */
  gap: clamp(6px, 1.2vw, 10px);
}
.day-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  height: 100%;
  padding: clamp(7px, 1.4vw, 12px) clamp(6px, 1.2vw, 12px) clamp(8px, 1.4vw, 12px);
  display: flex; flex-direction: column; gap: 5px;
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
  border-bottom-width: 2px;
  transition: transform .1s ease, box-shadow .1s ease;
}
.day-cell:active { transform: scale(.96); }
@media (hover: hover) {
  .day-cell:not(.empty):not(.no-school):hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
}
.day-cell.empty { background: transparent; border: none; box-shadow: none; cursor: default; }
.day-cell.no-school {
  background: none; box-shadow: none; cursor: default;
  border-style: dashed; border-width: 1px;
}
.day-top { display: flex; align-items: center; justify-content: space-between; }
.day-num {
  font-family: var(--display);
  font-size: clamp(.8rem, 2.2vw, .95rem); font-weight: 600; color: var(--text-soft);
  min-width: 26px; height: 26px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
}
.day-cell.past { opacity: .45; box-shadow: none; }
@media (hover: hover) { .day-cell.past:hover { opacity: .8; } }
.day-cell.today { border-color: var(--today-ring); border-width: 2px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--today-ring) 22%, transparent), var(--shadow); }
.day-cell.today .day-num { background: var(--bv-red); color: #fff; }
.day-entree {
  font-size: clamp(.76rem, 2.1vw, .92rem);
  font-weight: 600; line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.day-cell.no-school .day-note { font-size: clamp(.72rem, 2vw, .82rem); color: var(--text-soft); font-weight: 600; }
.day-dow { display: none; }

/* ---------- Phone: month as a day list (whole words, uniform rows) ---------- */
@media (max-width: 599px) {
  .weekday-row { display: none; }
  .calendar {
    display: flex; flex-direction: column;
    gap: 8px;
  }
  .day-cell {
    flex-direction: row; align-items: center;
    gap: 12px;
    height: 56px;
    padding: 0 14px;
  }
  .day-cell.empty, .day-cell.no-school.out-of-session { display: none; }
  .day-cell[data-dow="5"]:not(:last-child) { margin-bottom: 14px; } /* week break after Friday */
  .day-top { display: flex; align-items: center; gap: 8px; width: 76px; flex: none; }
  .day-dow {
    display: inline;
    font-size: .72rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-soft);
  }
  .day-entree {
    font-size: .95rem;
    flex: 1;
    -webkit-line-clamp: 2;
  }
  .day-cell.no-school .day-note { font-size: .82rem; }
}

/* ---------- Status / empty month ---------- */
.status-area {
  margin: 30px auto; text-align: center; max-width: 460px;
  padding: 34px 26px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; box-shadow: var(--shadow);
}
.status-area h2 { font-family: var(--display); font-weight: 600; font-size: 1.2rem; margin-bottom: 6px; }
.status-area p { font-size: .9rem; color: var(--text-soft); line-height: 1.5; }
.status-area button {
  margin-top: 18px; background: var(--bv-red); color: #fff; border: none;
  padding: 13px 26px; border-radius: 999px;
  font-family: var(--display); font-size: 1rem; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow);
}
.status-area button:active { transform: scale(.96); }

.updated-note {
  text-align: center; font-size: .74rem; color: var(--text-soft);
  margin: 16px 0 4px; min-height: 1em;
}
.updated-note.stale { color: var(--bv-red); }

/* ---------- Footer ---------- */
.app-footer {
  text-align: center; font-size: .78rem; color: var(--text-soft);
  padding: 12px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
}
.app-footer a { color: var(--bv-red); font-weight: 600; display: inline-block; padding: 13px 4px; }
.footer-credit { margin-top: 6px; font-size: .85rem; }
.footer-credit a {
  color: var(--scratch-blue);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--scratch-blue) 45%, transparent);
  text-underline-offset: 3px;
  padding-top: 4px;
}

/* ---------- Detail sheet ---------- */
.day-sheet[hidden], .sheet-backdrop[hidden] { display: none; }
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(20,8,8,.5);
  z-index: 40; opacity: 0; transition: opacity .2s ease;
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.sheet-backdrop.show { opacity: 1; }
.day-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  box-shadow: var(--sheet-shadow);
  max-height: 84dvh;
  display: flex; flex-direction: column;
  transform: translateY(102%);
  transition: transform .28s cubic-bezier(.3,1,.4,1);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.day-sheet.show { transform: translateY(0); }
@media (min-width: 700px) {
  .day-sheet {
    max-width: 560px; margin: 0 auto;
    border-radius: 24px; bottom: 6vh;
    transform: translateY(calc(100% + 8vh));
  }
  .sheet-handle { visibility: hidden; }
}
.sheet-handle {
  width: 44px; height: 5px; border-radius: 3px;
  background: var(--border); margin: 10px auto 2px; flex: none;
}
.sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 22px 12px; flex: none;
  border-bottom: 1px solid var(--border);
}
.sheet-header h2 { font-family: var(--display); font-size: 1.15rem; font-weight: 600; }
.sheet-close {
  background: var(--surface-2); border: none; color: var(--text-soft);
  width: 40px; height: 40px; border-radius: 50%;
  font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.sheet-body { overflow-y: auto; padding: 16px 22px 24px; }
.menu-section { margin-bottom: 18px; }
.menu-section h3 {
  font-size: .72rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .09em; color: var(--bv-red); margin-bottom: 7px;
}
.menu-section ul { list-style: none; }
.menu-section li {
  font-size: .95rem; padding: 9px 13px; margin-bottom: 6px;
  background: var(--surface-2); border-radius: 11px; line-height: 1.35;
}
.menu-section li.hero-item {
  background: var(--bv-red-soft);
  border: 1px solid color-mix(in srgb, var(--bv-red) 25%, transparent);
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
