/* Meni restorana, tamna tema: jelo pod toplim svetlom na tamnom stolnjaku.
   Boje i fontovi su u tokens.css (zajednički sa početnom stranom). */
@import url(tokens.css);

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 var(--text-base)/1.55 var(--text);
  padding-bottom: calc(var(--tray-h) + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 400; }
p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }

:root {
  --tray-h: 84px;
  --stage-h: clamp(240px, 40svh, 430px);
  --nav-h: 52px;
}

/* ---------------------------------------------------------------- zaglavlje */
.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 22px var(--gutter) 16px;
}
.masthead h1 {
  font-family: var(--display);
  font-size: clamp(34px, 9vw, 52px);
  line-height: 1.02;
  letter-spacing: -0.01em;
}
.tagline { margin-top: 8px; color: var(--muted); font-size: 16px; }
.masthead-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.lang-switch { display: flex; gap: 2px; }
.lang-option {
  min-width: 40px;
  min-height: 36px;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
}
.lang-option[aria-pressed='true'] { color: var(--ink); box-shadow: inset 0 -1px 0 var(--accent); border-radius: 0; }
.table-no { color: var(--muted); font-size: 14px; white-space: nowrap; }
.table-no strong {
  margin-left: 2px;
  color: var(--ink);
  font-family: var(--display);
  font-size: 30px;
  font-weight: 400;
}

/* ---------------------------------------------------------------- sto */
.stage {
  position: sticky;
  top: 0;
  z-index: 5;
  height: var(--stage-h);
  overflow: hidden;
  background: var(--page);
}
.stage model-viewer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-color: var(--page);
  --poster-color: transparent;
}
/* Ivice stola se utapaju u stranicu. */
.stage model-viewer {
  -webkit-mask-image: radial-gradient(closest-side, #000 76%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 76%, transparent 100%);
}
.stage-note {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(86%, 400px);
  padding: 9px 14px;
  border-radius: 12px;
  background: rgba(14, 13, 12, 0.72);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  pointer-events: none;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.stage-busy { display: flex; align-items: center; gap: 10px; padding-bottom: 14px; color: var(--ink); }
.spinner {
  width: 15px;
  height: 15px;
  flex: none;
  border: 1.5px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Koliko je modela preuzeto: tanka linija na dnu poruke (--part od 0 do 1). */
.load-bar {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 6px;
  height: 2px;
  border-radius: 1px;
  background: var(--line);
}
.load-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(var(--part, 1));
  transition: transform 0.25s linear;
}
/* U dijalogu se poruka pojavi tek ako učitavanje potraje, da ne trepne. */
.viewer-loading:not([hidden]) { animation: appear 0.25s 0.35s both; }
@keyframes appear { from { opacity: 0; } }

.phone-card {
  position: absolute;
  z-index: 2;
  top: 18px;
  left: 18px;
  display: flex;
  gap: 14px;
  align-items: center;
  max-width: 330px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(23, 21, 19, 0.88);
  box-shadow: 0 0 0 1px var(--line);
  transition: box-shadow 0.3s;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.phone-card.attention { box-shadow: 0 0 0 2px var(--accent); }
/* QR mora biti taman na svetlom da bi ga kamera pročitala. */
.phone-card .qr { width: 104px; height: 104px; flex: none; padding: 8px; border-radius: 8px; background: var(--ink); color: var(--page); }
.phone-card .qr svg { width: 100%; height: 100%; display: block; }
.phone-card h2 { font-family: var(--display); font-size: 20px; line-height: 1.2; }
.phone-card p { margin-top: 4px; color: var(--muted); font-size: 14px; line-height: 1.4; }
.phone-card .phone-warning { color: var(--warn); }

/* ---------------------------------------------------------------- kategorije */
.category-nav {
  position: sticky;
  top: var(--stage-h);
  z-index: 4;
  display: flex;
  gap: 4px;
  height: var(--nav-h);
  padding: 0 calc(var(--gutter) - 10px);
  overflow-x: auto;
  background: var(--page);
  box-shadow: 0 1px 0 var(--line);
  scrollbar-width: none;
}
.category-nav::-webkit-scrollbar { display: none; }
.category-link {
  display: flex;
  align-items: center;
  flex: none;
  padding: 0 10px;
  color: var(--muted);
  font-size: 16px;
  text-decoration: none;
  white-space: nowrap;
}
.category-link:hover { color: var(--ink); }
.category-link.current { color: var(--ink); box-shadow: inset 0 -1px 0 var(--accent); }

/* ---------------------------------------------------------------- meni */
.menu { padding: 0 var(--gutter) 40px; }
.price-note { padding-top: 18px; color: var(--muted); font-size: 14px; }
.menu-section { padding-top: 34px; scroll-margin-top: calc(var(--stage-h) + var(--nav-h)); }
.menu-heading {
  color: var(--ink);
  font-family: var(--display);
  font-size: 30px;
  line-height: 1.15;
}
.dish-list { list-style: none; margin: 10px 0 0; padding: 0; }
.dish { padding: 18px 0; border-bottom: 1px solid var(--line); }
.dish:last-child { border-bottom: 0; }
.dish-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.dish-name { font-family: var(--display); font-size: 22px; line-height: 1.22; }
.dish-open {
  appearance: none;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
}
.dish-open:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; text-decoration-color: var(--accent); }
.dish-price {
  color: var(--ink);
  font-size: 16px;
  font-variant-numeric: tabular-nums lining-nums;
  white-space: nowrap;
}
.dish-description { max-width: 58ch; margin-top: 6px; color: var(--muted); font-size: 16px; }
.dish-status { margin-top: 6px; color: var(--muted); font-size: 14px; }
.dish-status:empty { display: none; }
.dish.missing .dish-status { color: var(--warn); }
.dish.missing .dish-name { color: var(--muted); }
.dish-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }

/* ---------------------------------------------------------------- dugmad */
.cta {
  appearance: none;
  min-height: 50px;
  padding: 12px 24px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--page);
  font-size: 16px;
  font-weight: 600;
}
.cta:hover:not(:disabled) { background: #fff8ec; }
.cta:disabled { background: var(--raised); color: var(--faint); }

.view-btn, .ghost {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 2px;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
}
.view-btn:hover:not(:disabled) span, .ghost:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 4px; }
.view-btn:disabled, .ghost:disabled { color: var(--faint); }

.add-btn {
  appearance: none;
  min-height: 44px;
  padding: 8px 22px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: none;
  font-weight: 600;
}
.add-btn:hover:not(:disabled) { border-color: var(--ink); }
.add-btn:disabled { color: var(--faint); }

.stepper {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--ink);
  color: var(--page);
}
.stepper button {
  width: 46px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: inherit;
  font-size: 22px;
  line-height: 1;
}
.stepper-count { min-width: 22px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- donja traka */
.tray {
  position: fixed;
  inset: auto 0 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px var(--gutter) calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(14, 13, 12, 0.9);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}
/* Traka se pojavi tek kad je nešto na stolu. */
body:not(.has-dishes) .tray { transform: translateY(calc(100% + 2px)); }
.tray-summary { display: flex; flex-direction: column; line-height: 1.3; }
#tray-count { font-weight: 600; transform-origin: left center; }
.tray-total { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.bump { animation: bump 0.32s ease-out; }
@keyframes bump { 45% { transform: scale(1.06); } }

/* ---------------------------------------------------------------- dijalog jela */
.dish-dialog {
  width: min(560px, calc(100vw - 20px));
  max-width: none;
  max-height: calc(100svh - 20px);
  padding: 0;
  border: 0;
  border-radius: 20px;
  overflow: hidden;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line), 0 30px 80px rgba(0, 0, 0, 0.6);
}
.dish-dialog[open] { display: flex; flex-direction: column; }
.dish-dialog::backdrop { background: rgba(5, 5, 4, 0.72); }
.dish-dialog model-viewer {
  display: block;
  position: relative; /* poruka "Učitavam…" ostaje u prikazu i pre nego što <model-viewer> stigne */
  flex: none;
  width: 100%;
  height: min(46svh, 400px);
  background-color: var(--page);
  --poster-color: transparent;
}
.dialog-close-form { position: absolute; top: 12px; right: 12px; z-index: 2; margin: 0; }
.dialog-close {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(14, 13, 12, 0.7);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.dialog-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 20px 22px 0; }
.dialog-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.dialog-head h2 { font-family: var(--display); font-size: 28px; line-height: 1.15; }
.dialog-head h2:focus { outline: none; }
.dialog-price { font-size: 17px; font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.dialog-description { margin-top: 8px; color: var(--muted); }
.dialog-size { margin-top: 10px; color: var(--accent); font-size: 14px; }
.dialog-size:empty { display: none; }
.dialog-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px 18px;
  margin-top: 16px;
  padding: 14px 0 calc(18px + env(safe-area-inset-bottom));
  background: var(--surface);
}

/* sastav i alergeni */
.dialog-facts { margin-top: 8px; }
.facts-heading {
  margin: 20px 0 12px;
  color: var(--muted);
  font-family: var(--text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.fact-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 14px 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.fact { display: flex; flex-direction: column; align-items: center; gap: 7px; text-align: center; }
.fact-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--raised);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
}
.fact-icon svg { width: 28px; height: 28px; }
.fact-icon-empty::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.fact-label { font-size: 14px; line-height: 1.3; }
.allergen-list .fact-icon { box-shadow: inset 0 0 0 1.5px var(--allergen); color: var(--allergen); }
.allergen-list .fact-label { color: var(--allergen); font-weight: 600; }
.facts-note { margin-top: 12px; color: var(--muted); font-size: 14px; }
.dialog-note { margin-top: 14px; color: var(--accent); font-size: 15px; }
.dialog-note:empty { display: none; }

/* ---------------------------------------------------------------- obaveštenja */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tray-h) + 16px + env(safe-area-inset-bottom));
  z-index: 30;
  width: max-content;
  max-width: min(92vw, 460px);
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--page);
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- telefon: dijalog odozdo */
@media (max-width: 599px) {
  .dish-dialog {
    width: 100vw;
    max-height: calc(100svh - 12px);
    margin: auto 0 0;
    border-radius: 20px 20px 0 0;
  }
}

/* ---------------------------------------------------------------- računar */
@media (min-width: 900px) {
  :root { --stage-h: calc(100svh - var(--tray-h) - 32px); }
  /* Sto levo preko cele visine, naziv restorana i meni desno. */
  .layout {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(380px, 1fr);
    grid-template-rows: auto auto 1fr;
    grid-template-areas: 'stage head' 'stage nav' 'stage menu';
    gap: 0 44px;
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 32px;
  }
  .masthead { grid-area: head; padding: 34px 0 14px; }
  .stage {
    grid-area: stage;
    top: 16px;
    align-self: start;
    height: var(--stage-h);
    min-height: 460px;
    margin-top: 16px;
  }
  .category-nav { grid-area: nav; top: 0; padding: 0; }
  .category-link:first-child { padding-left: 0; }
  .menu { grid-area: menu; padding: 0 0 40px; }
  .menu-section { scroll-margin-top: var(--nav-h); }
  .tray { padding-left: max(32px, calc((100vw - 1320px) / 2 + 32px)); padding-right: max(32px, calc((100vw - 1320px) / 2 + 32px)); }
}

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