/* ============================================================
   The Hidden Shelf — Systembolaget Explorer
   Light mode — warm, editorial, refined
   ============================================================ */

:root {
  --bg-page: #f6f3ee;
  --bg-card: #ffffff;
  --bg-card-hover: #ffffff;
  --bg-surface: #f0ece5;
  --bg-sidebar: #faf8f4;
  --bg-image: #f0ece5;
  --border: #e2ddd4;
  --border-hover: #ccc5b8;

  --text-primary: #2c2825;
  --text-secondary: #6b6560;
  --text-muted: #9e9890;

  --gold: #a07d45;
  --gold-light: #c9a96e;
  --gold-bg: rgba(160, 125, 69, 0.08);
  --green: #3d6b4a;
  --green-light: #4a8a5c;
  --green-bg: rgba(61, 107, 74, 0.07);
  --brown: #8b5e3c;
  --brown-bg: rgba(139, 94, 60, 0.08);
  --red-muted: #9e4a4a;

  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'Outfit', system-ui, sans-serif;
  --font-mono: 'Space Mono', 'Courier New', monospace;

  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;

  --header-h: 64px;
  --sidebar-w: 300px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.05);
  --shadow-card-hover: 0 8px 28px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 24px 64px rgba(0, 0, 0, 0.12), 0 8px 24px rgba(0, 0, 0, 0.06);
}

/* --- Reset & Base ------------------------------------------ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 10% 0%, rgba(61, 107, 74, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 90% 100%, rgba(160, 125, 69, 0.03) 0%, transparent 50%),
    var(--bg-page);
}

::selection {
  background: var(--gold-light);
  color: #fff;
}

/* --- App Layout -------------------------------------------- */

.app {
  min-height: 100vh;
}

.app-body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
}

@media (max-width: 768px) {
  .app-body {
    grid-template-columns: 1fr;
  }
}

/* --- Header ------------------------------------------------ */

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(246, 243, 238, 0.88);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.app-header__inner {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 28px;
  gap: 20px;
  max-width: 2000px;
  margin: 0 auto;
}

.app-header__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  font-style: italic;
  color: var(--green);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.app-header__search {
  flex: 0 1 420px;
  margin-left: auto;
}

.header-search-input {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 300;
  color: var(--text-primary);
  background: var(--bg-card);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.header-search-input::placeholder {
  color: var(--text-muted);
}

.header-search-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-bg);
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color 0.15s;
}

.sidebar-toggle:hover {
  color: var(--text-primary);
}

@media (max-width: 768px) {
  .app-header__inner {
    padding: 0 16px;
  }

  .app-header__title {
    font-size: 1.2rem;
  }

  .app-header__search {
    flex: 1 1 0;
  }

  .sidebar-toggle {
    display: block;
  }
}

/* --- Filter Sidebar ---------------------------------------- */

.filter-sidebar {
  padding: 24px 20px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  height: calc(100vh - var(--header-h));
  position: sticky;
  top: var(--header-h);
}

.filter-sidebar::-webkit-scrollbar {
  width: 4px;
}

.filter-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.filter-sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.filter-sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

@media (max-width: 768px) {
  .filter-sidebar {
    display: none;
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    height: auto;
    border-right: none;
    overflow-y: auto;
  }

  .sidebar-open .filter-sidebar {
    display: block;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(0, 0, 0, 0.2);
  }
}

.filter-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.filter-header h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--green);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
}

.btn-reset {
  margin-left: auto;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.15s;
}

.btn-reset:hover {
  border-color: var(--border-hover);
  color: var(--text-secondary);
}

/* Filter sections */

.filter-section {
  margin-bottom: 6px;
}

.filter-search {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 300;
  color: var(--text-primary);
  background: var(--bg-card);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-search::placeholder {
  color: var(--text-muted);
}

.filter-search:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-bg);
}

.filter-section-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.section-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 0;
  border: none;
  background: none;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  text-align: left;
  transition: color 0.15s;
}

.section-toggle:hover {
  color: var(--text-secondary);
}

.toggle-icon {
  font-size: 0.55rem;
  color: var(--text-muted);
  opacity: 0.6;
}

.section-body {
  padding: 4px 0 10px;
}

.filter-subsection {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.filter-subsection strong {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Segment buttons */

.segment-group {
  display: flex;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.segment-btn {
  flex: 1;
  padding: 7px 6px;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 0.73rem;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
}

.segment-btn:not(:last-child) {
  border-right: 1px solid var(--border);
}

.segment-btn:hover:not(.segment-btn--active) {
  color: var(--text-secondary);
  background: var(--bg-surface);
}

.segment-btn--active {
  background: var(--green);
  color: #fff;
  font-weight: 600;
}

/* Checkbox lists */

.checkbox-list {
  display: flex;
  flex-direction: column;
}

.checkbox-list--scrollable {
  max-height: 200px;
  overflow-y: auto;
}

.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.82rem;
  font-weight: 300;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.15s;
}

.filter-checkbox:hover {
  color: var(--text-primary);
}

.filter-checkbox input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  min-width: 16px;
  border: 1.5px solid var(--border-hover);
  border-radius: 3px;
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.filter-checkbox input[type="checkbox"]:hover {
  border-color: var(--green);
}

.filter-checkbox input[type="checkbox"]:checked {
  background: var(--green);
  border-color: var(--green);
}

.filter-checkbox input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

.filter-checkbox input[type="checkbox"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.filter-checkbox--strong {
  font-weight: 500;
  color: var(--text-primary);
}

/* Range inputs */

.range-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.range-inputs input[type="number"] {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-primary);
  background: var(--bg-card);
  outline: none;
  min-width: 0;
  transition: border-color 0.2s;
}

.range-inputs input[type="number"]::placeholder {
  color: var(--text-muted);
  font-family: var(--font-body);
}

.range-inputs input[type="number"]:focus {
  border-color: var(--gold);
}

.range-sep {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Select */

.filter-select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.82rem;
  color: var(--text-primary);
  background: var(--bg-card);
  outline: none;
}

.filter-select:focus {
  border-color: var(--gold);
}

/* --- Main Content Area ------------------------------------- */

.app-main {
  padding: 24px;
  min-height: calc(100vh - var(--header-h));
}

@media (max-width: 768px) {
  .app-main {
    padding: 16px;
  }
}

/* --- Product Grid ------------------------------------------ */

.product-grid-wrapper {
  max-width: 1600px;
}

.product-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  letter-spacing: 0.02em;
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 300;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

/* --- Product Card ------------------------------------------ */

.product-card {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s ease;
  outline: none;
  box-shadow: var(--shadow-card);
}

.product-card:hover,
.product-card:focus-visible {
  border-color: var(--border-hover);
  transform: translateY(-3px);
  box-shadow: var(--shadow-card-hover);
}

.product-card__image-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  background: var(--bg-image);
  padding: 16px;
  overflow: hidden;
}

.product-card__image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.08));
}

.product-card__body {
  padding: 14px 14px 16px;
}

.product-card__name-bold {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.3;
}

.product-card__name-thin {
  font-size: 0.78rem;
  font-weight: 300;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.3;
}

.product-card__price {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 10px;
  letter-spacing: -0.02em;
}

.product-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.product-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

.product-card__country {
  font-size: 0.72rem;
  font-weight: 300;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* --- Badges ------------------------------------------------ */

.badge {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 3px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge--hidden {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--gold);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 3px;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(160, 125, 69, 0.25);
}

.badge--unavailable {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--brown);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 3px;
  z-index: 2;
}

.badge--category {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(61, 107, 74, 0.15);
}

.badge--secondary {
  background: var(--gold-bg);
  color: var(--gold);
  border: 1px solid rgba(160, 125, 69, 0.15);
}

/* --- Load More --------------------------------------------- */

.load-more {
  padding: 32px 0;
  text-align: center;
}

.btn--load-more {
  padding: 14px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.01em;
}

.btn--load-more:hover {
  border-color: var(--green);
  color: var(--green);
}

/* --- Modal ------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}

.modal {
  position: relative;
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  animation: slideUp 0.25s ease;
}

.modal::-webkit-scrollbar {
  width: 4px;
}

.modal::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s;
}

.modal__close:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.modal__content {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 28px;
  padding: 32px;
}

@media (max-width: 640px) {
  .modal__content {
    grid-template-columns: 1fr;
    padding: 24px 16px;
  }
}

.modal__image-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: var(--bg-image);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border);
}

.modal__image {
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
  filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.08));
}

.modal__info {
  min-width: 0;
}

.modal__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.2;
}

.modal__subtitle {
  font-size: 0.88rem;
  font-weight: 300;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.modal__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.modal__badges .badge--hidden {
  position: static;
  box-shadow: none;
}

.modal__details {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.detail-row {
  display: flex;
  gap: 12px;
  font-size: 0.85rem;
}

.detail-row dt {
  font-weight: 500;
  color: var(--text-muted);
  min-width: 100px;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  padding-top: 2px;
}

.detail-row dd {
  color: var(--text-primary);
  font-weight: 300;
}

.modal__loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.modal__error {
  padding: 10px 14px;
  background: var(--brown-bg);
  border: 1px solid rgba(139, 94, 60, 0.15);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--brown);
}

/* Extra detail sections */

.modal__extra {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.detail-section {
  margin-bottom: 18px;
}

.detail-section h3 {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.detail-section p {
  font-size: 0.85rem;
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Taste profile */

.taste-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.taste-item {
  display: grid;
  grid-template-columns: 75px 1fr 36px;
  align-items: center;
  gap: 10px;
}

.taste-label {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-secondary);
}

.taste-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.taste-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--gold-light));
  border-radius: 2px;
  transition: width 0.4s ease;
}

.taste-value {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: right;
}

/* Systembolaget link */

.modal__sb-link {
  display: inline-flex;
  align-items: center;
  margin-top: 20px;
  padding: 10px 20px;
  border: 1px solid var(--green);
  border-radius: var(--radius);
  background: transparent;
  color: var(--green);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: all 0.2s;
}

.modal__sb-link:hover {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

/* --- Buttons ----------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.btn--icon {
  padding: 6px;
  border: none;
  background: none;
}

/* --- Loading State ----------------------------------------- */

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 300;
  letter-spacing: 0.02em;
}

.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 16px;
  color: var(--red-muted);
  font-size: 0.9rem;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner--small {
  width: 18px;
  height: 18px;
  border-width: 1.5px;
}

/* --- Animations -------------------------------------------- */

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
