/* ---------- COLORS AND FONTS (change the look here) ---------- */
:root {
  --counter:  #d9e2d5;   /* page ground, pale sage */
  --panel:    #f3f6ef;   /* item list, nutrition, prices */
  --ink:      #1b2a21;   /* text */
  --muted:    #5d6e63;   /* secondary text */
  --line:     #b8c6b6;   /* hairlines */
  --shak:     #2e5e3e;   /* spinach green: wordmark, kitchen */
  --shak-ink: #eef5e9;   /* text on spinach green */
  --yolk:     #f0b429;   /* accent: Add buttons, order code */
  --yolk-dk:  #d9a01b;
  --paper:    #fffdf4;   /* receipt paper */

  --font-ui:      "Bricolage Grotesque", "Noto Sans Bengali", system-ui, sans-serif;
  --font-receipt: "Courier Prime", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

/* ---------- PAGE ---------- */
body {
  margin: 0;
  padding: 10px;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  background: var(--counter);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.4;
}

h1 {
  margin: 0;
  padding: 2px 8px 0;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--shak);
}

h2 {
  margin: 0;
  padding: 14px 16px 10px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

h4 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
}

#main {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) minmax(0, 2.6fr) minmax(250px, 1fr);
  gap: 10px;
  min-height: 0;
}

#foot {
  border-top: 1px solid var(--line);
  text-align: center;
}

#foot h2 {
  padding: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
}

/* ---------- BUTTONS ---------- */
button {
  font: inherit;
  cursor: pointer;
  transition: background-color 120ms, color 120ms;
}

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

.inc,
.dec {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  line-height: 1;
}

.inc:hover,
.dec:hover {
  background: var(--ink);
  color: var(--panel);
}

.add {
  padding: 6px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--yolk);
  color: var(--ink);
  font-weight: 700;
}

.add:hover {
  background: var(--yolk-dk);
}

.add:active {
  transform: translateY(1px);
}

/* ---------- ITEMS (left) ---------- */
#input {
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 8px;
  background: var(--panel);
  border-radius: 12px;
}

.icard {
  margin: 0 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px 10px;
}

.icard .name {
  grid-column: 1 / -1;
}

.count {
  display: flex;
  align-items: center;
  gap: 6px;
}

.count .value {
  min-width: 3ch;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.count .unit {
  margin-left: 2px;
}

/* ---------- MIDDLE: kitchen and nutrition ---------- */
#mid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 15fr) minmax(0, 25fr);
  gap: 10px;
}

#kitchen {
  overflow-y: auto;
  background: var(--shak);
  color: var(--shak-ink);
  border-radius: 12px;
}

#kitchen h2 {
  color: var(--shak-ink);
}

#kitchen button:focus-visible {
  outline-color: var(--yolk);
}

#kitchen-list {
  padding: 0 16px 14px;
}

.k-row {
  margin: 0;
  padding: 7px 0;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  border-top: 1px dashed rgba(238, 245, 233, 0.35);
}

.k-name {
  font-weight: 600;
  text-transform: capitalize;
}

.k-qty {
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

.rm {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(238, 245, 233, 0.18);
  color: var(--shak-ink);
  line-height: 1;
}

.rm:hover {
  background: var(--yolk);
  color: var(--ink);
}

.empty {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

#kitchen .empty {
  padding-top: 4px;
  color: rgba(238, 245, 233, 0.7);
}

/* title on the top row, macros left, micronutrients right */
#values {
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--panel);
  border-radius: 12px;
}

#values h2 {
  grid-column: 1 / -1;
}

.ncard {
  padding: 0 16px 16px;
  display: grid;
  align-content: start;
  gap: 2px;
}

.ncard + .ncard {
  border-left: 1px solid var(--line);
}

.ncard h3 {
  padding-bottom: 6px;
  color: var(--shak);
}

.ncard p {
  margin: 0;
  padding: 4px 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px dotted var(--line);
  font-variant-numeric: tabular-nums;
}

.ncard p.kcal {
  margin-top: 6px;
  font-weight: 700;
}

.ncard p.empty {
  border-bottom: 0;
}

/* ---------- RIGHT: receipt, code, prices ---------- */
#output {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* the receipt is the one loud thing on the page: paper, typewriter type, torn bottom edge */
#cost {
  flex: 0 1 auto;
  min-height: 140px;
  overflow-y: auto;
  padding: 0 16px 24px;
  background: var(--paper);
  color: #26241f;
  font-family: var(--font-receipt);
  clip-path: polygon(
    0 0, 100% 0,
    100% 100%, 95% calc(100% - 8px), 90% 100%, 85% calc(100% - 8px), 80% 100%,
    75% calc(100% - 8px), 70% 100%, 65% calc(100% - 8px), 60% 100%, 55% calc(100% - 8px),
    50% 100%, 45% calc(100% - 8px), 40% 100%, 35% calc(100% - 8px), 30% 100%,
    25% calc(100% - 8px), 20% 100%, 15% calc(100% - 8px), 10% 100%, 5% calc(100% - 8px),
    0 100%
  );
}

#cost h2 {
  margin-bottom: 8px;
  padding: 14px 0 8px;
  border-bottom: 2px dashed #26241f;
  text-align: center;
  font-family: var(--font-receipt);
  font-size: 1.05rem;
  font-weight: 700;
}

#cost .empty {
  color: #6b675d;
}

.r-row {
  padding: 4px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9rem;
}

.r-name {
  text-transform: capitalize;
}

.r-name small {
  display: block;
  font-size: 0.78rem;
  color: #6b675d;
  text-transform: none;
}

.r-amt {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.r-rule {
  margin: 8px 0;
  border-top: 1px dashed #8a8678;
}

.r-total {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 2px dashed #26241f;
  font-size: 1.1rem;
  font-weight: 700;
}

/* order code, styled as a claim ticket */
#ocode {
  flex: none;
  padding: 10px 14px;
  background: var(--yolk);
  border: 2px dashed var(--ink);
  border-radius: 10px;
}

#ocode h3:first-child {
  font-size: 0.85rem;
}

#order-code {
  margin-top: 4px;
  font-family: var(--font-receipt);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.25;
  word-break: break-all;
}

/* static menu prices, with dotted leaders */
#prices {
  flex: none;
  padding-bottom: 12px;
  background: var(--panel);
  border-radius: 12px;
}

.p-row {
  padding: 3px 16px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.p-name {
  text-transform: capitalize;
}

.p-lead {
  flex: 1;
  border-bottom: 1px dotted var(--muted);
  transform: translateY(-3px);
}

.p-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.p-val small {
  font-weight: 400;
  color: var(--muted);
}

/* ---------- SMALL SCREENS: stack everything and let the page scroll ---------- */
@media (max-width: 900px) {
  body {
    height: auto;
    min-height: 100vh;
    grid-template-rows: auto auto auto;
  }

  #main {
    grid-template-columns: minmax(0, 1fr);
  }

  #mid {
    grid-template-rows: auto auto;
  }

  #input,
  #kitchen,
  #values,
  #output,
  #cost {
    overflow: visible;
  }

  #cost {
    min-height: 0;
  }

  #values {
    grid-template-columns: 1fr;
  }

  .ncard + .ncard {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-top: 12px;
  }
}

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