@import url('https://fonts.googleapis.com/css2?family=Alegreya:ital,wght@0,500;0,700;0,800;1,500&family=Alegreya+Sans:ital,wght@0,400;0,500;0,700;1,400&display=swap');

/* "Tasca de azulejos": whitewashed walls, cobalt glaze and a touch of yellow ochre.
   The tiles are pure CSS — a diagonal lattice with rings at its crossings and an ochre
   dot in every diamond — used sparingly: a band under the header, ornaments either side
   of a family name, a strip along the top of the order sheet and the order card. */
:root {
  --bg: #fdfcf8;
  --card-bg: #ffffff;
  --border: #d3dbea;
  --text: #17223a;
  --text-muted: #556079;
  --accent: #1f4fa3;
  --accent-hover: #173d80;
  --accent-wash: #edf2fb;
  --accent-line: rgba(31, 79, 163, 0.22);
  --ochre: #e0a526;
  --ochre-deep: #7d5300;
  --danger: #b3261e;
  --danger-wash: #fcefee;

  --font-display: 'Alegreya', 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --font-body: 'Alegreya Sans', 'Gill Sans', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif;

  --tap: 2.75rem;
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* One visible focus ring everywhere, offset so it reads on white and on cobalt alike. */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

button {
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Header and the tile band under it ---------- */

header {
  position: relative;
  padding: calc(1.6rem + env(safe-area-inset-top)) 1rem 1.1rem;
  margin-bottom: calc(1.25rem + 22px);
  text-align: center;
  background: var(--card-bg);
}

header::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 22px;
  --tile-size: 22px;
  border-top: 3px solid var(--accent);
  border-bottom: 3px solid var(--accent);
  box-sizing: content-box;
}

header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--accent);
}

/* The staff screens carry a long title ("Micaela — Menú del día"); it stays on one or
   two calm lines instead of shouting across the phone. */
header:has(.main-nav) h1 {
  font-size: 1.9rem;
  line-height: 1.1;
}

/* A short ochre rule with a cobalt lozenge, like the cartouche on a tiled shop sign. */
header h1::after {
  content: '';
  display: block;
  width: 7rem;
  height: 10px;
  margin: 0.55rem auto 0;
  background:
    radial-gradient(circle, var(--ochre) 0 2px, var(--accent) 2.5px 5px, transparent 5.5px) center / 12px 12px no-repeat,
    linear-gradient(var(--ochre), var(--ochre)) left center / calc(50% - 9px) 2px no-repeat,
    linear-gradient(var(--ochre), var(--ochre)) right center / calc(50% - 9px) 2px no-repeat;
}

.subtitle {
  margin: 0.45rem 0 0;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.1rem;
}

.main-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  margin-top: 0.6rem;
  font-size: 0.95rem;
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 3px solid transparent;
}

.main-nav a:hover {
  color: var(--accent);
}

.main-nav a.current {
  color: var(--accent);
  font-weight: 700;
  border-bottom-color: var(--ochre);
}

/* ---------- Page and cards ---------- */

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 1rem calc(3rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 1px 0 rgba(31, 79, 163, 0.05);
}

.card h2 {
  margin-top: 0;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}

/* ---------- Forms (staff screens) ---------- */

.field-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  flex: 2;
}

.field-small {
  flex: 1;
  min-width: 90px;
}

input,
textarea {
  min-height: var(--tap);
  padding: 0.55rem 0.7rem;
  border: 1px solid #b9c5dc;
  border-radius: var(--radius);
  background: #fff;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.closed-message-field {
  margin-top: 1rem;
}

.field-help {
  margin: 0.3rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* A day with no service reads as such from across the room. */
.day-closed {
  border-color: var(--danger);
}

.day-closed textarea {
  border-color: var(--danger);
}

.notice {
  margin: 0;
  padding: 1rem 1.1rem;
  border: 1px solid var(--accent);
  border-left-width: 5px;
  border-radius: var(--radius);
  background: var(--accent-wash);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.sides-section {
  margin-top: 1rem;
  border-top: 1px dashed var(--accent-line);
  padding-top: 0.75rem;
}

.sides-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.sides-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text);
}

#add-side,
#add-time {
  min-height: var(--tap);
  background: none;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
}

#add-side:hover,
#add-time:hover {
  background: var(--accent-wash);
}

.side-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
  align-items: center;
}

/* A flex item will not shrink below the width its content wants unless it is told to,
   which is what pushed this row — and the card around it — off the side of a phone. */
.side-row input {
  flex: 2;
  min-width: 0;
}

.side-row .field-small {
  flex: 1;
  min-width: 0;
}

/* On a phone the description takes the whole width and the unit, the price and the
   remove button share the line below it. */
@media (max-width: 719px) {
  .side-row .side-description {
    flex: 1 1 100%;
  }
}

.remove-side {
  flex: none;
  width: var(--tap);
  height: var(--tap);
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--danger);
  font-size: 1.05rem;
  cursor: pointer;
  padding: 0;
}

.remove-side:hover {
  background: var(--danger-wash);
}

.form-actions {
  margin-top: 1.25rem;
  display: flex;
  gap: 0.5rem;
}

button.primary {
  flex: 1;
  min-height: 3rem;
  padding: 0.7rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
}

button.primary:hover {
  background: var(--accent-hover);
}

button.secondary {
  min-height: 3rem;
  padding: 0.65rem 1.1rem;
  background: none;
  color: var(--text-muted);
  border: 1px solid #b9c5dc;
  border-radius: 999px;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
}

button.secondary:hover {
  background: var(--accent-wash);
}

/* Beats any display a component sets for itself (the chip bar is a flex box). */
.hidden {
  display: none !important;
}

.edit-item {
  min-height: var(--tap);
  padding: 0 0.4rem;
  background: none;
  border: none;
  border-radius: var(--radius);
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
}

.edit-item:hover {
  background: var(--accent-wash);
}

.empty-state {
  color: var(--text-muted);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.1rem;
}

.menu-hint {
  margin: 1rem 0 0;
  padding: 0.6rem 0.75rem;
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--accent-wash);
  color: var(--text);
  font-size: 0.9rem;
}

/* ---------- Dish lists ---------- */

.dishes-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.dish-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  background: var(--card-bg);
}

.dish-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.dish-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.12rem;
  line-height: 1.2;
  color: var(--text);
}

.dish-extra {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.9rem;
}

.dish-price {
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.delete-dish {
  min-height: var(--tap);
  padding: 0 0.4rem;
  background: none;
  border: none;
  border-radius: var(--radius);
  color: var(--danger);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
}

.delete-dish:hover {
  background: var(--danger-wash);
}

.side-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  padding-left: 0.75rem;
}

.time-row .time-value {
  flex: 1;
}

.daily-dishes {
  margin-top: 1rem;
}

/* The card is the wrapper, not the row: a button cannot hold a number field, so the box
   sits beside the row inside one border and reads as part of the same item. */
.daily-dish-holder {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--card-bg);
}

.daily-dish,
.daily-line {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  user-select: none;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  text-align: left;
}

/* One dish and its combinados, with a handle to drag the whole dish at once. */
.daily-dish-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Lifted out of the flow and following the finger. */
.daily-dish-group.dragging {
  box-shadow: 0 10px 26px rgba(23, 34, 58, 0.25);
  border-radius: var(--radius);
  background: var(--card-bg);
}

/* The gap the dragged dish will drop into. */
.daily-drag-placeholder {
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--accent-wash);
}

.daily-dish-lines {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.daily-group-label {
  margin: 0 0 0.1rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Combinados collapse under a toggle so a dish is one short, easy-to-drag row. */
.daily-combos-toggle {
  align-self: flex-start;
  min-height: var(--tap);
  background: none;
  border: none;
  padding: 0 0.25rem;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.92rem;
  cursor: pointer;
}

.daily-combos-toggle-active {
  color: var(--accent);
  font-weight: 700;
}

.daily-combos-caret {
  display: inline-block;
  width: 1em;
}

.daily-combos-count {
  color: var(--accent);
  font-weight: 700;
}

.daily-combos {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--accent-line);
}

.daily-combos.hidden {
  display: none;
}

.daily-dish-holder:active {
  background: var(--accent-wash);
}

.daily-dish-holder:has(.daily-dish-chosen) {
  border-color: var(--accent);
  background: var(--accent-wash);
  box-shadow: inset 4px 0 0 var(--accent);
}

.daily-dish-title {
  flex: 1;
}

.daily-dish-mark {
  visibility: hidden;
  color: var(--accent);
  font-weight: 700;
}

.daily-dish-chosen .daily-dish-mark {
  visibility: visible;
}

button.primary:disabled {
  background: #c6cfdf;
  color: #3d4760;
  cursor: default;
}

.order-line {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.order-line-title {
  flex: 1;
  min-width: 0;
}

/* The carta row on a phone: the name and, under it, the price on the left; the stepper on
   the right, spanning both; allergens and ingredients across the full width below. */
.carta-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'title step'
    'price step'
    'details details';
  align-items: center;
  align-content: start;
  column-gap: 0.75rem;
  row-gap: 0.15rem;
}

.carta-line > .order-line-title {
  grid-area: title;
}

.carta-line > .dish-price {
  grid-area: price;
  font-size: 1.05rem;
}

.carta-line > .order-stepper {
  grid-area: step;
}

.carta-line > .order-line-details {
  grid-area: details;
}

.order-line-chosen {
  border-color: var(--accent);
}

.order-line:active {
  background: var(--accent-wash);
}

.order-line-amount {
  min-width: 1.6rem;
  text-align: right;
  font-weight: 700;
  color: var(--accent);
}

.order-line-remove {
  position: absolute;
  top: -0.55rem;
  right: -0.55rem;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
}

.order-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-top: 1.25rem;
  border-top: 1px dashed var(--accent-line);
  padding-top: 0.9rem;
}

.time-options-label {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.time-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.time-option {
  min-height: var(--tap);
  padding: 0.45rem 0.9rem;
  border: 1px solid #b9c5dc;
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
}

.time-option.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 700;
}

.order-total {
  margin: 0;
  font-weight: 700;
}

.order-summary {
  margin-top: 1rem;
}

.order-summary .side-item {
  margin-top: 0.5rem;
  font-size: 1rem;
  color: var(--text);
  padding-left: 0;
}

.order-summary-total {
  display: flex;
  justify-content: space-between;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--accent-line);
  font-size: 1.05rem;
}

.order-total span:last-child {
  color: var(--accent);
}

.drop-point-slug {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.drop-point-slug:hover {
  color: var(--accent);
}

.time-option.closed {
  color: var(--text-muted);
  background: var(--bg);
  text-decoration: line-through;
  cursor: not-allowed;
}

.kitchen-status {
  margin-left: 0.5rem;
  font-size: 0.8rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.kitchen-status-live {
  color: var(--accent);
  border-color: var(--accent);
}

.kitchen-status-down {
  color: var(--danger);
  border-color: var(--danger);
}

.kitchen-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.kitchen-group-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.kitchen-group-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.kitchen-chip {
  font-size: 0.8rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
}

.kitchen-group-ready {
  border-color: var(--accent);
}

.kitchen-group-ready .kitchen-group-count {
  color: var(--accent);
}

.kitchen-line {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.kitchen-line:active {
  background: var(--accent-wash);
}

.kitchen-line-title {
  flex: 1;
}

.kitchen-count {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.kitchen-line-done {
  border-color: var(--accent);
  background: var(--accent-wash);
}

.kitchen-line-done .kitchen-count {
  font-size: 1.4rem;
}

.kitchen-undo {
  position: absolute;
  top: -0.55rem;
  right: -0.55rem;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--text-muted);
  color: white;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  cursor: pointer;
}

.kitchen-undo.hidden {
  display: none;
}

/* Desktop only: the phone layout below 720px stays exactly as it is. */
@media (min-width: 720px) {
  main {
    max-width: 1080px;
  }

  .dishes-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    column-gap: 0.75rem;
  }

  #daily-dishes,
  #order-lines,
  .kitchen-group .dishes-list {
    grid-auto-rows: 1fr;
  }

  .kitchen-group .dishes-list {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  }

  header h1 {
    font-size: 3.2rem;
  }

  header:has(.main-nav) h1 {
    font-size: 2.4rem;
  }
}

.day-picker {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.day-picker input {
  flex: 1;
  min-width: 0;
}

.day-picker button {
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0.5rem 0.7rem;
  border: 1px solid #b9c5dc;
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--accent);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

.day-picker button:hover {
  border-color: var(--accent);
  background: var(--accent-wash);
}

/* A family's name, centred between two short tile strips — the ornament a tasca paints
   above each section of its wall menu. It spans the whole grid on desktop so the family
   below starts on a fresh row. */
.line-group-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 1.8rem 0 0.4rem;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.15;
  color: var(--accent);
  text-align: center;
  letter-spacing: 0.04em;
}

.line-group-heading::before,
.line-group-heading::after {
  content: '';
  flex: 1 1 0;
  min-width: 1.5rem;
  max-width: 11rem;
  height: 16px;
  --tile-size: 16px;
  border-top: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  box-sizing: content-box;
}

.line-group-heading:first-child {
  margin-top: 0.25rem;
}

@media (min-width: 720px) {
  .line-group-heading {
    grid-column: 1 / -1;
  }
}

/* A dish with no price is a group; the list says so where the price would be. */
.dish-group-tag {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

@keyframes kitchen-arrived {
  from {
    background: #d9e4f7;
    border-color: var(--accent);
  }
  to {
    background: var(--card-bg);
    border-color: var(--border);
  }
}

.kitchen-line-new {
  animation: kitchen-arrived 2.5s ease-out;
}

/* The list above these can run to ninety lines, so the action stays on screen instead of
   waiting at the bottom of it. Sticky rather than fixed: the bar keeps its place in the
   flow, so it never covers the last row, and it stops sticking at the end of its own card. */
.form-actions,
.sticky-actions {
  position: sticky;
  bottom: 0;
  background: var(--card-bg);
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
}

.sticky-actions {
  padding-top: 0.1rem;
}

.sticky-actions .form-actions {
  position: static;
  padding-bottom: 0;
}

/* A line scrolling underneath must not read through the bar. */
.form-actions::before,
.sticky-actions::before {
  content: '';
  display: block;
  border-top: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.form-actions {
  flex-wrap: wrap;
}

.form-actions::before {
  flex: 1 1 100%;
  margin-bottom: 0.25rem;
}

.sticky-actions .form-actions::before {
  content: none;
}

#summary-card .form-actions {
  position: static;
}

#summary-card .form-actions::before {
  content: none;
}

/* Small and fixed: stretched to the row's height it dwarfed everything next to a name
   that wrapped over four lines. */
.daily-dish-stock {
  width: 4rem;
  height: 2rem;
  min-height: 0;
  flex: none;
  padding: 0.25rem 0.4rem;
  font-size: 0.9rem;
  text-align: right;
}

.order-line-left {
  position: absolute;
  left: 0.9rem;
  bottom: 0.1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.order-line:has(.order-line-left:not(:empty)) {
  padding-bottom: 1.4rem;
}

.order-line-sold-out {
  background: var(--bg);
  cursor: not-allowed;
}

.order-line-sold-out .dish-title,
.order-line-sold-out .dish-price {
  color: var(--text-muted);
}

.order-line-sold-out .order-line-left {
  color: var(--danger);
}

.counter-line {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  padding-right: 2.6rem;
}

.counter-line:active {
  background: var(--accent-wash);
}

.counter-line-title {
  flex: 1;
  min-width: 0;
}

.counter-breakdown {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.counter-count {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.counter-line-empty {
  background: var(--bg);
}

.counter-line-empty .counter-count {
  color: var(--text-muted);
}

.counter-line-short {
  border-color: var(--danger);
}

.counter-short {
  color: var(--danger);
  font-weight: 600;
}

.counter-add {
  position: absolute;
  bottom: -0.55rem;
  right: -0.55rem;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  cursor: pointer;
}

/* Allergens and ingredients under the name, always visible: nobody with an allergy should
   have to open dishes one at a time to find out. */
.order-line-details {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.35rem;
  margin-top: 0.35rem;
  min-width: 0;
}

.allergen-tag {
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: #fff;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.5;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.order-line-ingredients {
  flex-basis: 100%;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.order-line {
  flex-wrap: wrap;
}

/* The multiselect in Gestión: a chip has the shape of the tag it becomes on the carta,
   so what is marked is what will be seen. */
.allergen-field {
  margin-top: 1rem;
}

.allergen-label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.allergen-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.allergen-chip {
  min-height: 2.25rem;
  padding: 0.25rem 0.7rem;
  border: 1px solid #b9c5dc;
  border-radius: 3px;
  background: var(--card-bg);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.allergen-chip-on {
  border-color: var(--accent);
  background: var(--accent-wash);
  color: var(--accent);
  font-weight: 700;
}

.details-field {
  margin-top: 0.75rem;
}

.side-row .side-ingredients,
.side-row .allergen-chips {
  flex: 1 1 100%;
  min-width: 0;
}

.chime-button {
  margin-left: 0.4rem;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  vertical-align: middle;
}

.chime-button-muted {
  color: var(--text-muted);
}

.chime-button-blocked {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Carta: the category bar ---------- */

/* Chips scroll sideways and the bar sticks to the top, so the families stay one tap away
   however far down the dishes you are. It runs edge to edge across main's gutter. */
.carta-categories {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  margin: 0 -1rem 0.25rem;
  padding: 0.55rem 1rem;
  background: rgba(253, 252, 248, 0.96);
  border-bottom: 2px solid var(--accent);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.carta-categories::-webkit-scrollbar {
  display: none;
}

.carta-chip {
  flex: 0 0 auto;
  min-height: var(--tap);
  padding: 0 1rem;
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--accent);
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s;
}

.carta-chip:hover {
  background: var(--accent-wash);
}

.carta-chip-on,
.carta-chip-on:hover {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.carta-chip:focus-visible {
  outline-offset: -5px;
  outline-color: var(--ochre);
}

/* Gestión: the single free-text category field on the dish form. */
#tag-input {
  width: 100%;
}

/* Menú del día: the per-day ordering list. */
.daily-order {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.daily-order-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* The grab handle: touch-action none so dragging it never scrolls the page. */
.drag-handle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  min-height: var(--tap);
  cursor: grab;
  touch-action: none;
  color: var(--accent);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.2rem 0.3rem;
  user-select: none;
}

.daily-order-row.dragging {
  opacity: 0.6;
  border-color: var(--accent);
  cursor: grabbing;
}

/* ---------- Carta: the list itself ---------- */

/* The carta reads like a menu painted on a white wall: one card, dishes separated by thin
   cobalt rules rather than boxed one by one. */
@media (min-width: 720px) {
  body:has(#carta-lines) main {
    max-width: 920px;
  }
}

#carta-lines {
  gap: 0;
  column-gap: 2rem;
}

#carta-lines .carta-line {
  padding: 0.85rem 0.1rem;
  border: none;
  border-bottom: 1px solid var(--accent-line);
  border-radius: 0;
  background: transparent;
}

/* ---------- Carta: ordering (order.js) ---------- */

.order-stepper {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.order-stepper button {
  flex: none;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--card-bg);
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 1.45rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.1s;
}

.order-stepper .order-add,
.order-stepper .order-plus {
  background: var(--accent);
  color: #fff;
}

.order-stepper .order-add:hover,
.order-stepper .order-plus:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.order-stepper .order-minus:hover {
  background: var(--accent-wash);
}

.order-stepper button:active {
  transform: scale(0.92);
}

.order-quantity {
  min-width: 1.5rem;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Leave room under the last line so the bar never covers it. */
body:has(.order-bar:not(.hidden)) main {
  padding-bottom: calc(7rem + env(safe-area-inset-bottom));
}

.order-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 1.25rem calc(1rem + env(safe-area-inset-right)) calc(0.85rem + env(safe-area-inset-bottom))
    calc(1rem + env(safe-area-inset-left));
  background: linear-gradient(to top, var(--bg) 55%, rgba(253, 252, 248, 0));
  pointer-events: none;
  animation: order-rise 0.25s ease-out;
}

.order-bar-button,
.order-send {
  pointer-events: auto;
  display: block;
  width: 100%;
  max-width: 32rem;
  min-height: 3.25rem;
  margin: 0 auto;
  padding: 0.85rem 1rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(31, 79, 163, 0.32), inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}

.order-bar-button:hover,
.order-send:hover {
  background: var(--accent-hover);
}

.order-bar-button:focus-visible,
.order-send:focus-visible {
  outline-color: var(--ochre-deep);
  outline-offset: 3px;
}

.order-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(15, 30, 62, 0.45);
  animation: order-fade 0.2s ease-out;
}

.order-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  max-width: 36rem;
  max-height: 88vh;
  margin: 0 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 calc(1.1rem + env(safe-area-inset-right)) calc(1.1rem + env(safe-area-inset-bottom))
    calc(1.1rem + env(safe-area-inset-left));
  border-radius: 14px 14px 0 0;
  background: var(--card-bg);
  box-shadow: 0 -10px 30px rgba(15, 30, 62, 0.25);
  animation: order-rise 0.28s cubic-bezier(0.2, 0.8, 0.25, 1);
}

/* The tile strip along the sheet's top edge, bled out past its padding. */
.order-sheet::before {
  content: '';
  display: block;
  height: 18px;
  margin: 0 calc(-1.1rem - env(safe-area-inset-right)) 0.9rem calc(-1.1rem - env(safe-area-inset-left));
  --tile-size: 18px;
  border-bottom: 3px solid var(--accent);
}

@keyframes order-rise {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes order-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.order-sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.order-sheet-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
}

.order-close {
  flex: none;
  width: var(--tap);
  height: var(--tap);
  margin-right: -0.4rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  font-size: 1.9rem;
  line-height: 1;
  cursor: pointer;
}

.order-close:hover {
  background: var(--accent-wash);
  color: var(--accent);
}

.order-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.6rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--accent-line);
}

.order-item-name {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.2;
}

.order-item-name small {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
}

.order-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.85rem 0;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
}

.order-field-label {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.order-times {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.1rem;
}

.order-time {
  flex: 1;
  min-height: 3rem;
  padding: 0.6rem;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--accent);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.order-time:hover {
  background: var(--accent-wash);
}

.order-time-on,
.order-time-on:hover {
  background: var(--accent);
  color: #fff;
  box-shadow: inset 0 -4px 0 var(--ochre);
}

.order-error {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.75rem;
  border-left: 4px solid var(--danger);
  background: var(--danger-wash);
  color: var(--danger);
  font-weight: 700;
}

.order-hint {
  margin: 0.75rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

/* ---------- Carta: "Tu pedido de hoy" ---------- */

.order-summary {
  position: relative;
  margin-bottom: 0.5rem;
  padding-top: calc(1.25rem + 14px);
  border: 2px solid var(--accent);
  overflow: hidden;
}

.order-summary::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 12px;
  --tile-size: 12px;
  border-bottom: 2px solid var(--accent);
}

.order-summary h2 {
  margin: 0 0 0.5rem;
  font-size: 1.45rem;
}

.order-summary-line {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0;
  border-bottom: 1px dotted var(--accent-line);
}

.order-summary-line span:last-child {
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.order-summary .order-total {
  border-top: 2px solid var(--accent);
  margin-top: 0.3rem;
}

.order-summary-time {
  display: inline-block;
  margin: 0 0 0.9rem;
  padding: 0.25rem 0.7rem;
  border-radius: 3px;
  background: #fbf0d4;
  font-weight: 700;
  color: var(--ochre-deep);
}

.order-summary-edit,
.order-discard {
  display: block;
  width: 100%;
  min-height: 3rem;
  padding: 0.7rem 1rem;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--accent);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}

.order-summary-edit:hover {
  background: var(--accent-wash);
}

.order-discard {
  max-width: 32rem;
  margin: 0.6rem auto 0;
  border: 1px solid #b9c5dc;
  color: var(--text-muted);
  font-weight: 500;
}

.order-discard:hover {
  background: var(--accent-wash);
}

.order-cancel-note {
  margin: 0.5rem 0 0.25rem;
  padding: 0.55rem 0.75rem;
  border-left: 4px solid var(--danger);
  background: var(--danger-wash);
  color: var(--danger);
  font-weight: 700;
}

.order-items-cancelled .order-item-name {
  text-decoration: line-through;
  color: var(--text-muted);
}

.order-items-cancelled .order-item-name small {
  color: var(--text-muted);
}

.order-items-cancelled {
  margin-bottom: 1rem;
}

/* One azulejo, painted top layer first: a cobalt ring in the middle of each tile, an ochre
   dot at its corners, and a pale cobalt lattice joining them. Each band sets its own
   --tile-size (the tile is as tall as the band), so the rings always sit whole. */
header::after,
.line-group-heading::before,
.line-group-heading::after,
.order-sheet::before,
.order-summary::before {
  background:
    radial-gradient(circle, #fff 0 calc(var(--tile-size) * 0.09), var(--accent) calc(var(--tile-size) * 0.11) calc(var(--tile-size) * 0.24), transparent calc(var(--tile-size) * 0.26))
      0 0 / var(--tile-size) var(--tile-size),
    radial-gradient(circle, var(--ochre) 0 calc(var(--tile-size) * 0.11), transparent calc(var(--tile-size) * 0.13))
      calc(var(--tile-size) / 2) calc(var(--tile-size) / 2) / var(--tile-size) var(--tile-size),
    linear-gradient(45deg, transparent calc(50% - 1px), #7d9ad3 calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px))
      0 0 / var(--tile-size) var(--tile-size),
    linear-gradient(-45deg, transparent calc(50% - 1px), #7d9ad3 calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px))
      0 0 / var(--tile-size) var(--tile-size),
    #fff;
}

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .kitchen-line-new {
    animation: none;
    border-color: var(--accent);
  }
}

/* Gestión: the category field sat flush against the ingredients input above it. */
.details-field + label {
  margin-top: 0.75rem;
}
