:root {
  --bg: #fbf8f3;
  --surface: #ffffff;
  --text: #231c17;
  --muted: #6d625a;
  --accent: #a32b1f;
  --on-accent: #ffffff;
  --line: #e6dccd;
  --field-line: #8a7d70; /* 3:1 or better against --bg */
  --veg: #2f6b35;

  --column: 1120px;
  --reading: 640px; /* single dish and bottom bar stay this narrow */
  --gutter: 20px;
  --nav-height: 112px; /* search box + category links */
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17120f;
    --surface: #221b17;
    --text: #f4ede4;
    --muted: #b3a598;
    --accent: #e8695a;
    --on-accent: #1b0d0a;
    --line: #382e27;
    --field-line: #7d6e62;
    --veg: #86c98c;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans KR", sans-serif;
}

/* One column: everything shares the same left and right edge. */
.top, main, .notice, .search, .cat-row, .empty, .detail, .foot {
  width: 100%;
  max-width: var(--column);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

h2 {
  margin: 0;
  font: 700 1.4rem/1.25 Georgia, "Times New Roman", serif;
}

/* Header */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 16px 12px;
}

.brand {
  margin: 0;
  font: 700 1.75rem/1 Georgia, "Times New Roman", serif;
  color: var(--accent);
}

.langs {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 2px;
}

.lang {
  min-width: 44px;
  min-height: 40px;
  padding: 0 8px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.lang[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

.notice {
  margin-block: 0 8px;
  color: var(--muted);
  font-size: 0.8125rem;
}

/* Search and category links */

.bar {
  position: sticky;
  top: 0;
  z-index: 3; /* above an enlarged photo scrolling under it */
  height: var(--nav-height);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.search { display: flex; gap: 8px; padding-top: 8px; margin-block: 0; }

.search input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--field-line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit; /* 16px or more stops iPhones zooming in on focus */
}

.cat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 59px;
}

.icon-button {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--field-line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.icon-button:disabled { opacity: 0.4; }

.cats {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 4px;
  height: 44px;
  overflow-x: auto;
  scrollbar-width: none;
}

.cat {
  flex: none;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--text);
  font-size: 0.9375rem;
  text-decoration: none;
  white-space: nowrap;
}

.cat[aria-current] {
  background: var(--accent);
  color: var(--on-accent);
}

/* Menu list: name on the left, price lined up on the right */

.category { scroll-margin-top: var(--nav-height); }

.category h2 {
  padding-block: 32px 8px;
  border-bottom: 2px solid var(--accent);
}

/* One column on phones, two or more when there is room. */
.dishes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr));
  column-gap: 40px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dish {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 52px;
  padding-block: 14px;
  border-bottom: 1px solid var(--line);
}

.dish:active { background: var(--surface); }

.dish-body {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 16px;
  align-content: start;
  overflow-wrap: break-word;
}

.dish-body > * { grid-column: 1; margin: 0; }
.dish-body > .dish-name { grid-row: 1; font-size: 1rem; font-weight: 500; }
.dish-body > .dish-desc, .dish-body > .tags { margin-top: 4px; }

/* Two lines in the list; the dish page has the full text. */
.dish-body > .dish-desc {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.dish-body > .dish-meta {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: start;
  text-align: right;
}

.price {
  display: block;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dish-desc, .dish-original, .weight { color: var(--muted); font-size: 0.875rem; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }

.tag {
  padding: 1px 8px;
  border: 1px solid currentColor;
  border-radius: 6px;
  font-size: 0.75rem;
}

.spicy { color: var(--accent); }
.veg { color: var(--veg); }
.out { color: var(--muted); }

.photo {
  position: relative;
  flex: none;
  width: 72px;
  height: 72px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--line) url("favicon.svg?v=6854ff99") center / 32px no-repeat;
}

.photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--surface);
}

/* Mouse users can look closer at a real photo. Touch screens are left alone: there
   a tap opens the dish page, which shows the photo large. */
@media (hover: hover) and (pointer: fine) {
  .dish .photo:has(img) {
    z-index: 1;
    cursor: pointer;
    transform-origin: left center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .dish .photo:has(img):hover {
    z-index: 2;
    transform: scale(3);
    box-shadow: 0 4px 12px rgb(0 0 0 / 0.45);
    transition-delay: 0.15s; /* not while the pointer is just passing over */
  }
}

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

/* The link stretches over the row, so the whole row can be tapped. */
.dish-link { color: inherit; text-decoration: none; }
.dish-link::after { content: ""; position: absolute; inset: 0; }
.dish-link:focus-visible { outline: none; }
.dish-link:focus-visible::after { outline: 3px solid var(--accent); outline-offset: -3px; }

.sold-out .photo { opacity: 0.4; }
.sold-out .dish-name, .sold-out .price { color: var(--muted); }
.sold-out .price { text-decoration: line-through; }

/* My choice. Buttons sit above the stretched row link. */

.add {
  position: relative;
  z-index: 0;
  min-width: 44px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--field-line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1.125rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.add.chosen {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}

.chooser { display: flex; justify-content: flex-end; gap: 4px; }
.dish-meta .chooser { margin-top: 8px; }
.dish-meta .add { min-width: 40px; padding: 0 8px; }
.detail-card .chooser { margin-top: 16px; gap: 8px; }
.detail-card .remove { flex: none; width: 56px; }
.detail-card .add-wide { flex: 1; font-size: 1rem; }

.choice-open {
  display: flex;
  flex: none;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

/* Phones: icon and number only; the name is still read out by screen readers. */
@media (max-width: 599px), (max-height: 500px) { .choice-label { display: none; } }

.choice-hint { margin: 4px 0 8px; color: var(--muted); font-size: 0.875rem; }
.choice-row { display: flex; align-items: center; gap: 12px; padding-block: 12px; border-bottom: 1px solid var(--line); }
.choice-names { flex: 1; min-width: 0; display: grid; overflow-wrap: break-word; }
.choice-name { font-size: 1.0625rem; font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 8px; }
.qty { min-width: 2ch; text-align: center; font-weight: 700; }
.choice-total { margin: 12px 0 0; font-weight: 700; }
.choice-total:empty { margin: 0; }
.choice-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice-actions .back { width: 100%; margin: 12px 0 0; }

/* Single dish */

.detail-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.detail-top .choice-open { margin-bottom: 8px; }

.back {
  min-height: 44px;
  margin-block: 8px 16px;
  padding: 0 16px;
  border: 1px solid var(--field-line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.detail { max-width: var(--reading); }
.detail-card { overflow-wrap: break-word; }
.detail-card p { margin: 8px 0 0; }
.detail-card h2 { padding-top: 4px; font-size: 1.75rem; }
.detail-card h2:focus { outline: none; }
.detail-card .photo { width: 100%; height: auto; aspect-ratio: 4 / 3; max-height: 40vh; margin-bottom: 16px; background-size: 96px; }
.detail-card .credit { margin: -8px 0 16px; color: var(--muted); font-size: 0.75rem; }
.credit a { color: inherit; }
.detail-card .detail-category { margin: 0; color: var(--muted); font-size: 0.875rem; }
.detail-card .dish-original { font-size: 1rem; }

.detail-card .dish-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.detail-card .price { font-size: 1.5rem; }
.detail-card .warning { margin-top: 8px; padding: 10px 12px; border: 1px solid var(--accent); border-radius: 10px; font-size: 0.875rem; }
.detail-card .ingredients-title { margin: 24px 0 0; font-size: 1rem; }

/* Overlays and footer */

/* Floats at the lower right, labelled and filled, so it is easy to find. */
.to-top {
  position: fixed;
  right: max(var(--gutter), (100% - var(--column)) / 2 + var(--gutter));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 22px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.35);
  cursor: pointer;
}

.sheet {
  width: min(100% - 32px, 420px);
  max-height: 85dvh;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
}

.sheet::backdrop { background: rgb(0 0 0 / 0.5); }
.sheet h2 { padding-bottom: 8px; }
.sheet ul { margin: 0; padding: 0; list-style: none; }
.sheet .cat { min-height: 44px; white-space: normal; }
.sheet .back { width: 100%; margin: 12px 0 0; }

.empty { margin-block: 24px; color: var(--muted); text-align: center; }
.empty:empty { margin: 0; }

.foot {
  padding-block: 24px calc(76px + env(safe-area-inset-bottom)); /* clears the up button */
  color: var(--muted);
  font-size: 0.8125rem;
  text-align: center;
}

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Phones: names and descriptions get the full width; price and buttons go underneath. */
@media (max-width: 479px) {
  .dish-body { grid-template-columns: minmax(0, 1fr); }
  .dish-body > .dish-meta {
    grid-column: 1;
    grid-row: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    margin-top: 8px;
    text-align: left;
  }
  .dish-meta .chooser { margin: 0 0 0 auto; }
}

/* Very narrow phones */
@media (max-width: 359px) {
  :root { --gutter: 12px; }
  .photo { width: 56px; height: 56px; background-size: 28px; }
  .choice-row { flex-wrap: wrap; }
  .choice-names { flex-basis: 100%; }
  .stepper { margin-left: auto; }
  .detail-card .photo { max-height: 28vh; }
}

/* Phones held sideways: little height, so the fixed bars must be small. */
@media (max-height: 500px) and (min-width: 560px) {
  :root { --nav-height: 61px; }
  .bar { display: flex; justify-content: center; }
  .search { flex: none; width: 260px; margin: 0; padding: 8px 0 0 var(--gutter); }
  .cat-row { flex: 1; min-width: 0; max-width: calc(var(--column) - 260px); margin: 0; padding-left: 8px; height: 60px; }
}
