/* SPDX-License-Identifier: LGPL-3.0-only
 * Copyright (C) 2026 jjm.one
 */

/* Mobile-first: a portrait phone shows the bar header, the menu and the order total at once.
 * The menu scrolls between a fixed header and the total, so nothing is ever covered. */
:root {
  --bg: #101824;
  --surface: #1b2835;
  --surface-raised: #243440;
  --border: #30414e;
  --text: #f5f8f3;
  --muted: #aab7bf;
  --accent: #c9f274;
  --on-accent: #16231c;
  --danger: #b72d3b;
  --gutter: 12px;
  --target: 48px;
  font-family:
    Inter,
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--text);
  background: var(--bg);
  color-scheme: dark;
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  max-width: 1080px;
  margin: auto;
  background: var(--bg);
}

/* Header: bar name (or app name), connection status and language switch */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(6px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 6px
    max(var(--gutter), env(safe-area-inset-left));
  border-bottom: 1px solid #273442;
}

.brand-mark {
  display: block;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  flex: none;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.subtitle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.app-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-name:after {
  content: " ·";
  margin-left: 2px;
}

.bar-name {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection {
  font-weight: 500;
  white-space: nowrap;
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.connection:before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
}

.connection.offline:before {
  background: #9cabb2;
}

.connection.error:before {
  background: #e06c76;
}

.language {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--surface-raised);
  border: 1px solid #40515d;
  border-radius: 10px;
  flex: none;
}

.language-button {
  min-width: 38px;
  height: 34px;
  padding: 0 6px;
  border: 0;
  border-radius: 8px;
  color: #c0ccd1;
  background: transparent;
  font-size: 0.75rem;
  font-weight: 700;
}

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

/* Scrollable menu */
.content {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px max(var(--gutter), env(safe-area-inset-right)) 4px
    max(var(--gutter), env(safe-area-inset-left));
}

.section + .section {
  margin-top: 20px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 2px 8px;
}

h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 730;
  letter-spacing: -0.03em;
  line-height: 1.3;
}

.section-count {
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.item-list {
  display: grid;
  gap: 10px;
}

/* One row per item: name and price on the left, large steppers on the right */
.item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 5px 5px 5px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.item.selected {
  border-color: var(--accent);
  background: #1f3030;
}

.item-name {
  font-size: 1.0625rem;
  font-weight: 690;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.item-detail {
  margin-top: 3px;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.quantity-controls {
  display: grid;
  grid-template-columns: 52px 40px 64px;
  align-items: center;
  gap: 4px;
}

.quantity {
  text-align: center;
  font-size: 1.375rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.selected .quantity {
  color: var(--text);
}

.step {
  height: var(--target);
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #485a68;
  border-radius: 11px;
  background: #293a48;
  color: #fff;
  font-size: 1.75rem;
  font-weight: 400;
  line-height: 1;
}

.step.plus {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.step:active:not(:disabled) {
  transform: scale(0.94);
}

.step:disabled {
  opacity: 0.32;
}

.empty {
  border: 1px dashed #435360;
  border-radius: 14px;
  padding: 16px;
  color: #bcc7ca;
}

.error {
  margin: 0 0 10px;
  color: #ffc4bd;
  background: #462b31;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.875rem;
}

/* Order total: always visible below the menu */
.checkout {
  display: grid;
  gap: 8px;
  padding: 8px max(var(--gutter), env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom))
    max(var(--gutter), env(safe-area-inset-left));
  background: var(--surface-raised);
  border-top: 1px solid #425262;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 14px #090f1980;
}

.breakdown {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 16px;
  color: #bcc8cf;
  font-size: 0.8125rem;
}

.breakdown > span {
  display: flex;
  gap: 6px;
}

.breakdown strong {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #e5eceb;
  white-space: nowrap;
}

.total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.total {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #bcc8cf;
}

.total strong {
  font-size: 2rem;
  line-height: 1.1;
  letter-spacing: -0.04em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.clear {
  min-width: 112px;
  height: 52px;
  padding: 0 18px;
  border: 1px solid #d84e59;
  border-radius: 13px;
  background: var(--danger);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
}

.clear.undo {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent);
}

.clear:disabled {
  opacity: 0.45;
}

/* Footer at the end of the menu */
.attribution {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0 4px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
  text-align: center;
}

.attribution p {
  margin: 0;
}

.attribution a {
  color: inherit;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-underline-offset: 3px;
}

.author-logo {
  justify-content: center;
  min-width: 44px;
}

.author-logo img {
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 4px;
}

/* Very narrow phones */
@media (max-width: 359px) {
  :root {
    --gutter: 8px;
  }
  .item {
    padding-left: 10px;
    gap: 6px;
  }
  .quantity-controls {
    grid-template-columns: 48px 34px 56px;
  }
  .clear {
    min-width: 96px;
  }
}

/* Tablets, desktops and phones in landscape: menu on the left, total as a side panel */
@media (min-width: 720px), (orientation: landscape) and (min-width: 560px) {
  .app {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
    grid-template-rows: auto minmax(0, 1fr);
  }
  .topbar {
    grid-column: 1 / -1;
  }
  .checkout {
    align-self: start;
    max-height: calc(100% - 24px);
    overflow-y: auto;
    gap: 14px;
    margin: 12px max(var(--gutter), env(safe-area-inset-right)) 12px 0;
    padding: 18px;
    border: 1px solid #425262;
    border-radius: 18px;
    box-shadow: none;
  }
  .breakdown {
    flex-direction: column;
    padding-bottom: 12px;
    border-bottom: 1px solid #425464;
  }
  .breakdown > span {
    justify-content: space-between;
  }
  .total-row {
    flex-direction: column;
    align-items: stretch;
  }
  .total strong {
    font-size: 2.5rem;
  }
  .clear {
    width: 100%;
  }
}

@media (min-width: 720px) {
  :root {
    --gutter: 24px;
    --target: 56px;
  }
  body {
    background: #0b121c;
  }
  .app {
    box-shadow: 0 0 80px #050b13;
  }
  .item {
    min-height: 70px;
    padding-left: 18px;
  }
  .quantity-controls {
    grid-template-columns: 60px 48px 72px;
    gap: 6px;
  }
  .bar-name {
    font-size: 1.375rem;
  }
}

/* Short landscape phones: keep the header slim and the rows compact */
@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --target: 48px;
  }
  .item {
    min-height: 60px;
  }
  .quantity-controls {
    grid-template-columns: 52px 40px 64px;
    gap: 4px;
  }
  .bar-name {
    font-size: 1.125rem;
  }
  .topbar {
    padding-top: max(4px, env(safe-area-inset-top));
    padding-bottom: 4px;
  }
  .checkout {
    margin-top: 8px;
    margin-bottom: max(8px, env(safe-area-inset-bottom));
    padding: 12px;
    gap: 10px;
  }
  .total strong {
    font-size: 2rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .step {
    transition:
      transform 0.1s,
      background 0.12s;
  }
}
