@import url("./variables.css");

/* ========================================
   1) Reset & Base
======================================== */
html,
body {
  height: 100%;
}

img {
  max-width: 100%;
  display: block;
}
:focus-visible {
  outline: 2px solid #1a4b84;
  outline-offset: 2px;
}

/* Handy brand fallback */
:root {
  --brand-navy: #0f335c;
}

/* ========================================
   2) Layout
======================================== */
.container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 120px 20px; /* plass til sticky navbar */
  display: grid;
  grid-template-columns: 260px 1fr; /* sidebar | innhold */
  gap: 20px;
}
main {
  min-width: 0;
} /* hindrer overflow i grid */

/* ========================================
   3) Sidebar (Filtre)
======================================== */
.sidebar {
  align-self: start;
  position: static;
  top: auto;
  height: auto;
  max-height: none;
  overflow: visible;
  background: var(--secondary-color);
  border-radius: 12px;
  padding: 16px;
}

.facet-title,
.facet-subtitle {
  color: #5e5e5e;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  margin: 14px 0 10px;
  position: relative;
}
.facet-title::after,
.facet-subtitle::after {
  content: "";
  display: block;
  width: 28px;
  height: 2px;
  background: var(--border-color);
  margin-top: 6px;
}

.facet-list {
  list-style: none;
  margin: 0 0 4px 0;
  padding: 0;
  border-top: 1px solid var(--border-color);
}
.facet-list > li {
  border-bottom: 1px solid var(--border-color);
}

/* Subcategory list: show separators, but no line under the last item */
.subcat li {
  border-bottom: 1px solid var(--border-color);
}
.subcat li:last-child {
  border-bottom: none;
}

/* Kategori-knapp (tekst klikker inn / resten toggler via JS) */
.cat-link {
  background: none;
  border: 0;
  font: inherit;
  color: var(--link-color, #000);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 12px 2px;
  cursor: pointer;
  text-align: left;
  font-size: 1.1rem;
  font-weight: 300;
}
.cat-link .chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid #8a8a8a;
  border-bottom: 2px solid #8a8a8a;
  transform: rotate(-45deg);
  transition: transform 200ms ease;
  margin-left: 8px;
  pointer-events: auto; /* tillat klikking på pilen */
  cursor: pointer;
}
.cat-link.has-children[aria-expanded="true"] .chevron {
  transform: rotate(45deg);
}

/* Subcat-accordion */
.subcat {
  list-style: none;
  display: grid;
  gap: 8px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  transition: max-height 280ms ease, opacity 220ms ease, transform 220ms ease,
    padding 220ms ease;
  padding: 0 0;
  will-change: max-height, opacity, transform;
}
.cat-link[aria-expanded="true"] + .subcat {
  max-height: 600px;
  opacity: 1;
  transform: translateY(0);
  padding: 6px 0 12px 12px;
}

.subcat-link {
  background: none;
  border: 0;
  font: inherit;
  cursor: pointer;
  color: var(--text-color);
  font-size: 1rem;
  padding: 2px 0;
  text-align: left;
}
.subcat-link:hover {
  color: var(--link-color, #1a4b84);
}

/* --- Subcategory count aligned right (no parentheses) --- */
.subcat-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.subcat-link .subcat-label {
  flex: 1 1 auto;
  padding-right: 8px;
}
.subcat-link .subcat-count {
  flex: 0 0 auto;
  min-width: 1.5ch; /* keep numbers aligned */
  text-align: right;
  color: #000000;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}
/* Limit hover color change to the label only */
.subcat-link:hover {
  color: inherit;
}
.subcat-link:hover .subcat-label {
  color: var(--link-color, #1a4b84);
}
/* Active state: bold label; keep count muted */
.subcat-link.active .subcat-count {
  color: inherit;
  font-weight: 800;
}
.subcat-link.active .subcat-label {
  color: #000000;
}
.subcat-link.active .subcat-count {
  color: #000000;
  opacity: 1;
}

/* Active tilstander */
.cat-link.active,
.subcat-link.active {
  color: #000000;
  font-weight: 800;
}
.cat-link.active:hover,
.subcat-link.active:hover {
  text-decoration: none;
}
.subcat-link.active::before {
  margin-right: 6px;
  color: #0f335c;
}

/* ========================================
   4) Headings
======================================== */
#shopTitle {
  font-size: 1.8rem;
  margin-bottom: 18px;
  font-weight: 800;
  text-align: center;
}

.series-title {
  font-size: 1.2rem;
  line-height: 1.2;
  font-weight: 400;
  margin: 0 0 6px;
}

/* ========================================
   5) Grids
======================================== */
.categories-grid,
.subcategories-grid,
.product-grid {
  display: grid;
  gap: 36px 32px;
  align-items: start; /* don't stretch tall rows; fit to content */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: auto; /* product rows size to content */
}

/* Family grid (landingseksjoner) */
.family-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

/* ========================================
   6) Kort-komponenter
   (category-card & subcategory-card deler mye)
======================================== */

.product-subtitle {
  text-align: center;
}
.category-card,
.subcategory-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-color);
  transition: transform 0.2s ease, box-shadow 0.25s ease,
    border-color 0.25s ease, background 0.25s ease;
  border-radius: 12px;
  padding: 8px;
}
.category-card {
  background: var(--secondary-color);
}
.subcategory-card {
  background: rgb(255, 255, 255);
}

.category-card img,
.subcategory-card img {
  width: 100%;
  aspect-ratio: 3 / 3;
  object-fit: cover;
  background: rgb(255, 255, 255);
  border-radius: 10px;
}

.category-card h3,
.subcategory-card h3 {
  margin-top: 14px;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
}
.subcategory-card small {
  margin-top: 6px;
  color: #1a4b84;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.category-card:hover,
.subcategory-card:hover {
  transform: translateY(-4px);
}

/* Produktkort */
.product-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.product-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
}
.product-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 12px 0 4px;
  line-height: 1.35;
  text-align: center;
}

/* Product link inside card */
.product-link {
  text-decoration: none;
  color: inherit;
  display: block;
  transition: box-shadow 0.25s ease, transform 0.2s ease;
}

.product-link:hover {
  transform: translateY(-4px);
}

/* Actions row under each product card */
.product-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}
.product-card .product-info {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-decoration: none;
}
.product-card .variant-note {
  margin-top: 4px;
  font-size: 0.92rem;
  color: #425466;
  line-height: 1.35;
}

.product-card .product-card-line {
  margin-top: 0.25rem;
  font-size: 0.85rem;
  line-height: 1.3;
  color: #67748e; /* eller var(--muted-foreground) hvis du bruker CSS-variabler */
  text-align: center;
  display: -webkit-box;
  -webkit-box-orient: vertical;

  overflow: hidden;
}

.product-actions .addcart,
.product-actions .themability_quickview-button {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 10px;
  width: 100%;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #262626;
  color: #fff;
  transition: filter 0.2s ease, transform 0.1s ease;
}
.product-actions .themability_quickview-button {
  background: #324a60;
}
.product-actions .addcart:hover,
.product-actions .themability_quickview-button:hover {
  filter: brightness(1.2);
}
.product-actions img {
  width: 18px;
  height: 18px;
}

/* ========================================
   7) Intro-blokker (kategori/serie) + tabeller
======================================== */
.category-intro,
.series-intro {
  background: #ffffff;
}
.category-intro h2 {
  margin: 0 0 6px;
  font-size: 1.25rem;
}
.category-intro .subtitle {
  color: #334155;
  margin: 0 0 10px;
}
.category-intro .intro-html p {
  margin: 0.5rem 0;
}
.category-intro .intro-html ul,
.series-intro ul {
  margin: 0.5rem 0 0.75rem 1.25rem;
}
.category-intro .intro-html li,
.series-intro li {
  margin: 0.25rem 0;
}

.intro-html p,
.intro-html h2 {
  text-align: left;
}

.series-intro .series-banner {
  background: var(--brand-navy);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 800;
  border-radius: 10px;
  padding: 16px 18px;
  text-align: center;
  margin-bottom: 12px;
}
.series-subtitle {
  display: block;
  color: #000000;
  margin: 6px 0 16px;
  font-weight: 600;
  line-height: 1.35;
  font-size: 1.4rem;
}

/* Tabeller (brukes i intro-HTML når det finnes) */
.category-intro .intro-html table,
.series-intro table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}
.category-intro .intro-html th,
.category-intro .intro-html td,
.series-intro th,
.series-intro td {
  border-bottom: 1px solid #e5e7eb;
  padding: 8px 10px;
  text-align: left;
}

/* ========================================
   8) Landings-seksjoner (familier/serier)
======================================== */
.category-section + .category-section {
  padding-top: 24px;
}

.family-banner {
  background: var(--brand-navy);
  color: #ffffff;
  padding: 18px 20px;
  text-align: center;
  margin: 0 0 16px 0;
  border-bottom: 1px solid #e5e7eb;
  border-radius: 12px;
  grid-column: 1 / -1;
}
.family-banner h2 {
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.4rem;
  text-align: center;
}
.family-banner .family-subtitle {
  margin: 6px 0 0;
  opacity: 0.92;
  font-size: 0.95rem;
}

.family-grid .product-card {
  padding: 12px;
}
.family-grid .product-card h3 {
  min-height: 0;
  margin-bottom: 6px;
}

/* Subtle divider between product groups */
.section-divider {
  grid-column: 1 / -1;
  height: 12px;
  background: #eef1f4;
  border-radius: 10px;
  margin: 16px 0;
}

/* ========================================
   9) Pagination
======================================== */
.pagination {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-top: 18px;
}
.pagination button {
  min-width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: #fff;
  cursor: pointer;
  font-weight: 700;
}
.pagination button.active {
  background: #1a4b84;
  color: #fff;
  border-color: #1a4b84;
}
.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========================================
   10) Responsive
======================================== */
@media (max-width: 1100px) {
  .container {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
  }
  .categories-grid,
  .subcategories-grid,
  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .family-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 720px) {
  .categories-grid,
  .subcategories-grid,
  .product-grid {
    grid-template-columns: 1fr;
  }
  .family-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ========================================
   11) Utilities
======================================== */
.hidden {
  display: none !important;
}

/* ========================================
   12) Grouped (series/family) blocks -> stack as rows
   Ensure each grouped block takes the full row inside .product-grid
======================================== */
.product-grid .category-section,
.product-grid .series-block,
.product-grid .family-section {
  grid-column: 1 / -1; /* span all grid columns -> one per row */
  width: 100%;
}

/* Optional spacing between stacked groups */
.product-grid .category-section + .category-section,
.product-grid .series-block + .series-block,
.product-grid .family-section + .family-section {
  margin-top: 24px;
}

/* If your JS renders a dedicated grid for products inside a series block,
   this utility gives you a clean 3-column layout that collapses responsively. */
.products-grid {
  display: grid;
  gap: 36px 32px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 1100px) {
  .products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 720px) {
  .products-grid {
    grid-template-columns: 1fr;
  }
}
