/* JUMECHU — design d1 "한 그릇 (One Bowl)" (docs/design/d1/NOTES.md).
   One display face, one stage colour per menu category, a rice-white sheet for everything you act on.
   Shared system only; each screen group adds static/css/<group>.css through {% block styles %}. */

@font-face {
  font-family: "Bagel Fat One";
  src: url("/static/fonts/BagelFatOne-sub.woff2") format("woff2");
  font-display: swap;
}

/* Registered so the stage colour can glide from one dish to the next. */
@property --stage {
  syntax: "<color>";
  inherits: true;
  initial-value: #C8231A;
}

:root {
  --kimchi: #C8231A;   /* 김치 — brand red, 찌개 stage */
  --soy: #2A1712;      /* 간장 — ink, 16.7:1 on rice */
  --rice: #FFFCF7;     /* 쌀밥 — the sheet */
  --sesame: #FFC53D;   /* 참기름 — "on" state, recruit tint; never text */
  --minari: #1E7A4C;   /* 미나리 — open now, success */
  --muted: #6F5E56;    /* 보리차 — secondary text, 6.0:1 on rice */
  --line: #EDE3DA;
  --danger: #A61B12;
  --glass: rgba(24, 4, 0, 0.26);
  --stage: var(--kimchi);
  --display: "Bagel Fat One", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --body: "Apple SD Gothic Neo", "Noto Sans KR", "Noto Sans CJK KR", "Malgun Gothic", system-ui, sans-serif;
  --col: 440px;
  --nav-h: 74px;
  --dock: calc(var(--nav-h) + 10px + env(safe-area-inset-bottom));
}

/* Stage colour per menu category (white text ≥ 5.4:1 on each). */
.cat-jjigae  { --stage: #C8231A; } /* 찌개·전골 — 김치 */
.cat-gukbap  { --stage: #23565A; } /* 국밥·탕 — 대파 */
.cat-noodle  { --stage: #9C5A00; } /* 면 — 밀 */
.cat-bap     { --stage: #2E6B4E; } /* 밥·정식 — 나물 */
.cat-deopbap { --stage: #B0410C; } /* 덮밥·볶음 — 제육 */
.cat-meat    { --stage: #8E1B3B; } /* 고기 */
.cat-bunsik  { --stage: #C21C57; } /* 분식 — 떡볶이 */
.cat-western { --stage: #2D5A8E; } /* 양식 */
.cat-asian   { --stage: #6A3FA0; } /* 아시안·기타 */
.cat-empty   { --stage: #5B4A42; } /* 빈 그릇 */

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--stage); }
body {
  margin: 0;
  min-height: 100dvh;
  font: 16px/1.5 var(--body);
  color: var(--soy);
  background: linear-gradient(180deg, var(--stage) 0, color-mix(in srgb, var(--stage) 72%, #000) 100%) fixed;
  transition: --stage 0.6s ease;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
main { max-width: var(--col); margin: 0 auto; display: flow-root; }   /* banner margins stay inside main */
/* Phones: the rice sheet runs to the bottom even when the page is short (.sheet alone stops at 40vh). */
@media (max-width: 719px) {
  main { display: flex; flex-direction: column; min-height: 100dvh; }
  .sheet { flex: 1 0 auto; }
}
/* A [hidden] element must stay hidden (`button { display: inline-flex }` beats the browser's own rule). */
[hidden] { display: none !important; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.25; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--soy); outline-offset: 3px; }
.stage :focus-visible, .page-hero :focus-visible { outline-color: #fff; }

/* ───────── Frame: a coloured stage on top, the rice sheet below ───────── */

.page-hero {
  position: relative;
  padding: 18px 20px 46px;
  color: #fff;
  text-align: center;
}
.page-hero.is-slim { padding: 14px 20px 38px; }
.hero-icon { width: 84px; height: 84px; margin: 4px auto 6px; filter: drop-shadow(0 10px 10px rgba(40, 0, 0, 0.3)); }
.hero-title { margin: 0; font: 34px/1.15 var(--display); font-weight: 400; text-shadow: 0 3px 0 rgba(40, 0, 0, 0.2); text-wrap: balance; }
.hero-sub { margin: 8px auto 0; max-width: 320px; font-size: 15px; font-weight: 600; opacity: 0.92; }

.sheet {
  position: relative;
  margin-top: -24px;
  padding: 22px 18px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom));
  border-radius: 32px 32px 0 0;
  background: var(--rice);
  min-height: 40vh;
}
.sheet > :first-child { margin-top: 0; }
.sheet h1 { margin: 0 0 14px; font: 30px/1.15 var(--display); font-weight: 400; }
.sheet h2 { margin: 28px 0 10px; font-size: 17px; font-weight: 800; }
.sheet h3 { margin: 18px 0 6px; font-size: 15px; font-weight: 800; }
.sheet p { margin: 8px 0; }

/* Things on the stage (install card, check-in) sit on dark glass. */
.on-stage { color: #fff; }

/* ───────── Buttons ───────── */

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: var(--stage);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
  line-height: 1.2;
}
button:active, .button:active { transform: translateY(1px); }
button.secondary, .button.secondary {
  background: color-mix(in srgb, var(--stage) 10%, var(--rice));
  color: var(--soy);
}
button.link, .link-button {
  min-height: 44px;
  padding: 0 6px;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: underline;
}
button.danger, .button.danger { background: var(--danger); color: #fff; }
button:disabled { opacity: 0.45; cursor: default; }

/* ───────── Toggle, chips, segmented links ───────── */

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 8px;
  border: 0;
  border-radius: 999px;
  background: var(--glass);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}
.toggle img { width: 30px; height: 30px; }
.switch { position: relative; width: 38px; height: 24px; border-radius: 999px; background: rgba(255, 255, 255, 0.3); }
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}
.toggle[aria-pressed="true"] { background: var(--sesame); color: var(--soy); }
.toggle[aria-pressed="true"] .switch { background: var(--soy); }
.toggle[aria-pressed="true"] .switch::after { transform: translateX(14px); background: var(--sesame); }

/* A chip is a label around a checkbox/radio (old markup: text directly, new markup: <span>). On the rice sheet. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; padding: 0; border: 0; }
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.chip input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.chip:has(input:checked), .chip[aria-pressed="true"] { border-color: var(--stage); background: var(--stage); color: #fff; }
.chip:has(input:focus-visible) { outline: 3px solid var(--soy); outline-offset: 3px; }
a.chip { text-decoration: none; }
a.chip[aria-pressed="true"], a.chip[aria-current] { border-color: var(--soy); background: var(--soy); color: #fff; }

.seg { display: inline-flex; padding: 4px; border-radius: 999px; background: color-mix(in srgb, var(--soy) 7%, var(--rice)); }
.seg a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}
.seg a[aria-current], .seg a[aria-pressed="true"] { background: var(--soy); color: #fff; }

/* ───────── Lists, badges, text ───────── */

ul.places, ul.list { margin: 0; padding: 0; list-style: none; }
ul.places > li, ul.list > li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  padding: 14px 4px;
  border-top: 1px solid var(--line);
}
ul.places > li:first-child, ul.list > li:first-child { border-top: 0; }
ul.places a, ul.list a { font-weight: 700; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--soy) 8%, var(--rice));
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.badge.open { background: none; padding: 0; color: var(--minari); }
.badge.open::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(30, 122, 76, 0.18);
}

.muted { color: var(--muted); }
.empty {
  margin: 18px 0;
  padding: 22px 18px;
  border-radius: 22px;
  background: color-mix(in srgb, var(--soy) 5%, var(--rice));
  color: var(--muted);
  text-align: center;
  font-weight: 600;
}
.error {
  padding: 12px 16px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--danger) 10%, var(--rice));
  color: var(--danger);
  font-weight: 700;
}
.notice {
  white-space: pre-wrap;
  padding: 16px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--soy) 5%, var(--rice));
  font: 14px/1.7 var(--body);
}

/* ───────── Forms ───────── */

.stack { display: grid; gap: 12px; }
.stack label { display: grid; gap: 6px; font-weight: 700; }
/* Zero specificity: any screen's own label layout (e.g. [오늘] restaurant rows) wins. */
:where(.stack, fieldset) :where(label:has(> input[type="checkbox"]), label:has(> input[type="radio"])) {
  display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 700;
}
input[type="text"], input[type="url"], input[type="number"], input[type="time"], input[type="search"],
input[type="email"], input:not([type]), select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--soy);
  font-size: 16px;
  font-weight: 500;
}
textarea { min-height: 96px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--soy); outline-offset: 1px; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; font-weight: 800; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; accent-color: var(--stage); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 10px 6px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.table-wrap { overflow-x: auto; }

/* ───────── 식대 확장 받기 ([나] 식대 제출, /submit): the download, the steps folded, the update line small ───────── */

.ext-get { display: grid; justify-items: start; gap: 2px; }
.me-sec .ext-get { margin-top: 14px; }
.ext-get + form { margin-top: 16px; }
.ext-get p { margin: 0; }
.ext-new { display: none; }
/* /submit with an older extension: a quiet card, so [제출] stays the one loud thing. Updating is the line under
   the button, so the install steps fold away. */
.ext-get.outdated { padding: 14px 16px; border-radius: 18px; background: color-mix(in srgb, var(--sesame) 22%, var(--rice)); }
.ext-get.outdated .ext-new { display: block; margin-bottom: 8px; font-size: 16px; font-weight: 800; }
.ext-get.outdated .ext-download { min-height: 44px; padding: 0 18px; background: #fff; color: var(--soy); font-size: 15px; }
.ext-get.outdated .ext-steps { display: none; }
.ext-get.outdated .ext-update { margin-top: 8px; }
#submit-ext:not(.outdated) .ext-update { display: none; }   /* /submit without the extension: nothing to update yet */
.me-sec .ext-get .muted { margin-bottom: 8px; }
/* Phones can't use it: the download stays, but quiet, so it doesn't look like [저장]. */
@media (pointer: coarse) {
  .me-sec .ext-download { background: color-mix(in srgb, var(--stage) 10%, var(--rice)); color: var(--soy); }
}
.ext-steps { width: 100%; margin-top: 4px; }
.ext-steps summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}
.ext-steps summary::-webkit-details-marker { display: none; }
.ext-steps summary::after {
  content: "";
  width: 7px; height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px);
}
.ext-steps[open] summary::after { transform: rotate(225deg); }
.ext-steps ol { margin: 0 0 8px; padding-left: 22px; font-size: 15px; line-height: 1.7; }
.ext-update { color: var(--muted); font-size: 14px; line-height: 1.6; }
.ext-get code {
  padding: 1px 6px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--soy) 7%, var(--rice));
  color: var(--soy);
  font-size: 13.5px;
  user-select: all;   /* chrome:// can't be a link from a web page: one tap selects it to copy */
}

/* ───────── Install bar: phones in the browser (app.js shows it). It floats over the top while you scroll, but
   at the top of the page it takes its own room, so it never sits on a page's first controls. ───────── */

.install-bar {
  position: sticky;
  z-index: 20;
  top: calc(8px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 16px);
  max-width: var(--col);
  margin: calc(8px + env(safe-area-inset-top)) auto 0;
  padding: 4px 4px 4px 10px;
  border-radius: 22px;
  background: var(--rice);
  color: var(--soy);
  box-shadow: 0 10px 26px rgba(30, 0, 0, 0.28);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}
.install-bar img { flex: none; width: 28px; height: 28px; border-radius: 8px; }
.install-bar p { flex: 1; margin: 0; text-wrap: balance; }
.install-bar .button { flex: none; min-height: 44px; padding: 0 16px; font-size: 15px; }
.install-close { flex: none; width: 44px; min-height: 44px; padding: 0; background: none; color: var(--muted); font-size: 18px; }

/* ───────── On the stage: check-in banner ───────── */

.standalone-only { display: none; }
@media (display-mode: standalone) {
  .standalone-only { display: revert; }
}

.checkin-banner {
  margin: 12px 16px 0;
  padding: 16px;
  border-radius: 24px;
  background: var(--rice);
  color: var(--soy);
  box-shadow: 0 14px 30px rgba(30, 0, 0, 0.25);
}
.checkin-banner .q { margin: 0 0 8px; font: 22px/1.25 var(--display); }
.checkin-banner .q-place { font-family: var(--body); font-weight: 900; }   /* typed by people: not the display face */
.checkin-banner form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.checkin-banner form > p { flex-basis: 100%; margin: 4px 0 0; font-size: 14px; color: var(--muted); }

/* ───────── Bottom tabs ───────── */

.tabs {
  position: fixed;
  z-index: 10;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  border-radius: 26px 26px 0 0;
  background: rgba(255, 252, 247, 0.94);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 -6px 28px rgba(42, 23, 18, 0.14);
}
.tabs a {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  min-height: 62px;
  border-radius: 18px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
}
.tabs img {
  width: 34px;
  height: 34px;
  filter: grayscale(1) opacity(0.55);
  transition: transform 0.25s cubic-bezier(.3, 1.6, .5, 1), filter 0.2s;
}
.tabs a:hover img { filter: grayscale(0.4) opacity(0.85); }
.tabs a[aria-current="page"] { color: var(--soy); }
.tabs a[aria-current="page"] img { filter: none; transform: scale(1.14) translateY(-2px); }
.tabs .rail-mark { display: none; }   /* the left rail's logo: PC only, below */

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

/* ───────── Wider screens: the phone column sits on the stage ───────── */

@media (min-width: 720px) {
  :root { --dock: calc(var(--nav-h) + 30px); }
  main { padding-top: 24px; }
  .sheet {
    border-radius: 32px;
    margin-bottom: calc(var(--nav-h) + 46px);   /* clear of the floating tabs: 18px + 74px, then 28px */
    padding-bottom: 28px;
    box-shadow: 0 30px 60px rgba(30, 0, 0, 0.25);
  }
  .tabs {
    left: 50%;
    right: auto;
    bottom: 18px;
    width: var(--col);
    transform: translateX(-50%);
    border-radius: 28px;
    padding-bottom: 6px;
  }
}

/* ───────── PC (≥1024px): the tabs become a fixed left rail, the content gets the rest ─────────
   Same <nav> markup. Defaults here use plain selectors (main, .sheet, .page-hero) so a screen's own
   css/<group>.css, loaded later, overrides them at equal or higher specificity. */

@media (min-width: 1024px) {
  :root {
    --rail: 104px;    /* the rail's width; body keeps this much free on the left */
    --wide: 1120px;   /* the content area's max width (main) */
    --read: 640px;    /* a single reading column, for screens that want one */
    --nav-h: 0px;     /* no bottom tabs: every "room for the tabs" padding collapses (--dock becomes 30px) */
  }
  body:has(> .tabs) { padding-left: var(--rail); }
  main { max-width: var(--wide); padding: 32px 40px 0; }
  .sheet { margin-bottom: 48px; padding: 28px 36px 36px; min-height: 0; }   /* a card: it ends with its content */
  /* The check-in question: one reading-width card above any screen, not a full-width strip. */
  .checkin-banner { width: 100%; max-width: var(--read); margin-inline: auto; }

  .tabs {
    top: 0; bottom: 0; left: 0;
    width: var(--rail);
    transform: none;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    gap: 6px;
    padding: 22px 10px;
    border-radius: 0;
    background: var(--rice);
    box-shadow: 6px 0 28px rgba(42, 23, 18, 0.14);
  }
  .tabs .rail-mark { display: block; justify-self: center; width: 52px; height: 52px; margin-bottom: 18px; filter: none; }
  .tabs a { gap: 6px; min-height: 86px; font-size: 14px; }
  .tabs a img { width: 40px; height: 40px; }
  .tabs a:hover { background: color-mix(in srgb, var(--soy) 5%, var(--rice)); }
  .tabs a[aria-current="page"] { background: color-mix(in srgb, var(--stage) 12%, var(--rice)); }
  .tabs a[aria-current="page"] img { transform: scale(1.08); }
}

/* ───────── Touch screens held sideways, at any width, and iPhone Duo's outer display: a right rail ─────────
   /static/layout.js puts .rail-right on <html> (touch only; on iPhone Duo Apple moves tab bars to the right edge
   everywhere but the inner display upright), and .wide when there's room for the PC layouts beside it (≥720×500:
   an iPad, an open Fold, iPhone Duo's inner display), whose media blocks it switches on. Without .wide the content
   keeps its phone/tablet column. The rail's colour runs into the right safe area (iOS
   puts its status column there) while its icons and labels stay inside it. No logo, to save height: the five rows
   share the height there is, 84px each when it's free and never under a 44px target, so a 390px tall phone shows
   all five without scrolling; icons and labels shrink with it. Over the PC left rail where both apply. */

.rail-right {
  --nav-h: 0px;
  --rail: 80px;
  --dock: calc(16px + env(safe-area-inset-bottom));   /* sticky bars sit just above the bottom edge */
}
.rail-right body:has(> .tabs) { padding-left: 0; padding-right: calc(var(--rail) + env(safe-area-inset-right)); }
/* The 좋음/보통/별로 and 저장 fades reach the sheet's sides and run down over --dock: keep them inside its corners. */
.rail-right .sheet:has(.rate-bar, .save-bar) { overflow: clip; }
.rail-right .tabs {
  top: 0; bottom: 0; left: auto; right: 0;
  width: calc(var(--rail) + env(safe-area-inset-right));
  transform: none;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: repeat(5, minmax(44px, 84px));
  align-content: center;
  gap: 4px;
  padding: calc(8px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right))
           calc(8px + env(safe-area-inset-bottom)) 8px;
  border-radius: 0;
  background: var(--rice);
  box-shadow: -6px 0 28px rgba(42, 23, 18, 0.14);
}
.rail-right .tabs .rail-mark { display: none; }
.rail-right .tabs a { gap: 2px; min-height: 0; font-size: clamp(12px, 2dvh, 14px); }
.rail-right .tabs a img { width: clamp(24px, 7.5dvh, 36px); height: clamp(24px, 7.5dvh, 36px); }
.rail-right .tabs a:hover { background: color-mix(in srgb, var(--soy) 5%, var(--rice)); }
.rail-right .tabs a[aria-current="page"] { background: color-mix(in srgb, var(--stage) 12%, var(--rice)); }
.rail-right .tabs a[aria-current="page"] img { transform: scale(1.08); }
/* Upright (iPhone Duo's outer display: 382px less the system's column): a slimmer rail leaves the column more. */
@media (orientation: portrait) {
  .rail-right { --rail: 60px; }
  .rail-right .tabs { padding-left: 6px; padding-right: calc(6px + env(safe-area-inset-right)); }
}

/* Beside the right rail under 1024px (an open Fold, iPhone Duo's inner display; 720px at the least): the PC layouts
   with a narrower side column (the sheet beside the bowl or the map) and less air at the sides. */
@media (max-width: 1023px) {
  .wide { --col: min(440px, 46vw); }
  .wide main { padding-inline: 24px; }
  .wide .sheet { padding-inline: 24px; }
}
