/* Evergreen Gelateria – Allergens page */

/* Typeface */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* Palette & tokens */
:root {
  --brand: #00321C;
  --brand-600: #0A3E29;
  --cream: #FDF1D7;

  --bg: var(--cream);
  --card: #ffffff;
  --text: var(--brand);
  --muted: #4B6357;
  --ring: rgba(0, 50, 28, 0.35);
  --border: #E8DEC7;
  --shadow: 0 10px 25px rgba(0,0,0,0.07);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Layout shell */
.page {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* Header + logo */
.appbar {
  position: static;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 900;
  letter-spacing: .2px;
  color: var(--brand);
  font-size: 20px;
  width: 100%;
}

.logo {
  height: 250px;
  width: auto;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 50, 28, 0.15);
}

/* Main card */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.title {
  margin: 0 0 12px;
  font-size: 27px;
  color: var(--brand);
  text-align: center;
}

.stack {
  display: grid;
  gap: 12px;
}

/* Footer */
.footer {
  margin: auto 0 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* Accessibility focus */
:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 4px var(--ring);
  border-radius: 8px;
}

/* ---------- Table ---------- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

/* Desktop / tablet layout */
.table--stack th,
.table--stack td {
  padding: 8px 12px;
}

/* keep Flavour left, center other columns */
.table--stack th:first-child,
.table--stack td:first-child {
  text-align: left;
}

.table--stack th:nth-child(n + 2),
.table--stack td:nth-child(n + 2) {
  text-align: center;
}

/* extra spacing + soft separators */
.table thead th { padding: 14px 8px; }

.table tbody tr td {
  padding-top: 8px;
  padding-bottom: 8px;
}

.table tbody tr { border-bottom: 1px solid var(--border); }
.table thead tr { border-bottom: 4px solid var(--border); }

/* Zebra striping (desktop/tablet only) */
@media (min-width: 641px) {
  .table--stack tbody tr:nth-child(even) {
    background-color: rgba(0, 50, 28, 0.03);
  }
}

/* Search */
.flavour-search {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.flavour-search input {
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  min-width: 180px;
}

.flavour-search button {
  padding: 6px 12px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  background: #00321c;
  color: white;
  font-size: 14px;
}

/* Clear button (single source of truth) */
.flavour-search .clear-btn {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--brand);
}

.search-message {
  font-size: 12px;
  color: var(--muted);
}

.legend-icon { vertical-align: -4px; }

/* Row highlight base */
.table--stack tbody tr.highlight-row {
  background-color: rgba(0, 50, 28, 0.04);
  transition: background-color 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

/* Desktop highlight “full rectangle” */
@media (min-width: 641px) {
  .table--stack tbody tr.highlight-row td {
    border-top: 2px solid var(--brand);
    border-bottom: 2px solid var(--brand);
  }

  .table--stack tbody tr.highlight-row td:first-child {
    border-left: 2px solid var(--brand);
    border-radius: 12px 0 0 12px;
  }

  .table--stack tbody tr.highlight-row td:last-child {
    border-right: 2px solid var(--brand);
    border-radius: 0 12px 12px 0;
  }
}

/* ---------- Filters (base) ---------- */
.filters {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.filter-group {
  border: 1px solid var(--border);
  background: rgba(0, 50, 28, 0.02);
  border-radius: 12px;
  padding: 10px 12px;
  display: grid;
  gap: 8px;
}

.filter-title {
  font-weight: 750;
  color: var(--brand);
  font-size: 13px;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  user-select: none;
}

.filter-item input { width: 16px; height: 16px; }

.filters-clear {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--brand);
  background: transparent;
  color: var(--brand);
  cursor: pointer;
  font-weight: 650;
}

.filter-message {
  font-size: 12px;
  color: var(--muted);
  align-self: center;
}

/* Mobile filters */
@media (max-width: 640px) {
  .filters { gap: 8px; }
  .filter-group, .filters-clear { width: 100%; }
}

/* Desktop filters: rock-solid top-right stack (no overlap, no drifting) */
@media (min-width: 641px) {
  .filters {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 14px;
    align-items: start;
    margin-top: 10px;

    /* reserve space on the right for count + button */
    padding-right: 170px;
  }

  /* Filter groups left + middle */
  .filters .filter-group:nth-of-type(1) { grid-column: 1; }
  .filters .filter-group:nth-of-type(2) { grid-column: 2; }

  /* Compact group layout (2 columns) */
  .filters .filter-group {
    padding: 10px 14px;
    background: rgba(0, 50, 28, 0.01);
    border-radius: 14px;

    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 14px;
    row-gap: 6px;
  }

  .filters .filter-title {
    grid-column: 1 / -1;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
  }

  /* Top-right: count */
  #filterMessage {
    position: absolute;
    top: 8px;
    right: 36px;
    margin: 0 !important;
    white-space: nowrap;
    text-align: right;
    font-size: 12px;
    line-height: 1.2;
    color: var(--muted);
  }

  /* Top-right: button directly under count */
  #clearFiltersBtn,
  .filters-clear {
    position: absolute;
    top: 32px; /* sits under the count */
    right: 36px;
    margin: 0 !important;

    width: max-content;
    height: 38px;
    padding: 0 16px;
    border-radius: 999px;
    white-space: nowrap;
  }

  .filter-item:hover { color: var(--brand); }
}

/* ✅ Small desktop safety (prevents squeezing on narrow laptops) */
@media (min-width: 641px) and (max-width: 860px) {
  .filters {
    display: block;        /* stack naturally */
    padding-right: 0;      /* no reserved right area */
  }

  #filterMessage,
  #clearFiltersBtn,
  .filters-clear {
    position: static;      /* stop absolute positioning */
    display: block;
    margin-left: auto;     /* right align */
  }

  #filterMessage {
    text-align: right;
    margin-top: 6px;
    margin-bottom: 6px;
  }

  #clearFiltersBtn,
  .filters-clear {
    height: 38px;
    padding: 0 16px;
    border-radius: 999px;
  }
}
/* ---------- Mobile table layout (restore card rows) ---------- */
@media (max-width: 640px) {
  /* remove desktop-style row separators */
  .table tbody tr {
    border-bottom: none;
  }

  /* Search layout on mobile */
  .flavour-search {
    gap: 6px;
    align-items: center;
  }

  .flavour-search label {
    flex: 0 0 100%;
    font-weight: 600;
  }

  .flavour-search input {
    flex: 0 0 50%;
    min-width: 0;
    padding: 4px 10px;
    border-radius: 24px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    margin-right: 15px;
  }

  .flavour-search button {
    flex: 0 0 auto;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
  }

  /* turn table into stacked cards */
  .table--stack thead {
    display: none;
  }

  .table--stack tbody {
    display: block;
  }

  .table--stack tbody tr {
    display: block;
    margin: 10px 0;
    border-radius: 12px;
    background: var(--card);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border);
  }

  .table--stack tbody tr.highlight-row {
    border: 2px solid var(--brand);
    box-shadow: 0 10px 25px rgba(0,0,0,0.07);
  }

  .table--stack tbody tr td {
    display: block;
  }

  .table--stack tbody td.cell {
    position: relative;
    display: block;
    padding: 10px 5px 10px 175px;
    text-align: center;
  }

  .table--stack tbody td.cell::before {
    content: attr(data-label);
    position: absolute;
    left: 25px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 650;
    color: var(--muted);
    text-align: left;
    width: 145px;
    white-space: nowrap;
  }

  .table--stack tbody td.cell.cell--flavour {
    padding-left: 8px;
    text-align: center;
    font-weight: 800;
    font-size: 20px;
  }

  .table--stack tbody td.cell.cell--flavour::before {
    content: none;
  }

  .table--stack tbody td.cell.cell--allergen img,
  .table--stack tbody td.cell.cell--allergen svg {
    display: inline-block;
    vertical-align: middle;
  }
}

/* Ultra-small phones: slightly narrower label column */
@media (max-width: 360px) {
  .table--stack tbody td.cell::before {
    width: 120px;
  }

  .table--stack tbody td.cell {
    padding-left: 150px;
  }
}
