/* ── Peter Hoff Design AB — Main Frontend ─────────────────────────────────── */
/* Inspired by peterpeterdesign.se: pure white, Scandinavian minimal,          */
/* centred logo header, text-link nav, image-forward product grid.              */

:root {
  --bg:         #ffffff;
  --text:       #111111;
  --muted:      #888888;
  --border:     #e4e4e4;
  --hover-bg:   #f5f5f5;
  --thumb-ratio: 1/1;
  --logo-h:     64px;   /* base logo height (tablet) — overridden by CMS appearance setting */
  --page-pad:   20px;   /* horizontal page padding — shared by header, filter bar, grid */
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.site-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
  padding: 0 var(--page-pad);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo-link {
  display: block;
  line-height: 0;
}

.logo {
  width: auto;
  height: calc(var(--logo-h) * 0.75);  /* mobile: scales with CMS setting */
  display: block;
}

/* ── Site nav ────────────────────────────────────────────────────────────── */
.site-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-shrink: 0;
  padding-left: 16px;
}

.site-nav a {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s;
}
.site-nav a:hover { color: var(--muted); }

/* ── Language picker ─────────────────────────────────────────────────────────── */
.lang-picker-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.lang-picker-wrap::after {
  content: '▾';
  font-size: 8px;
  color: var(--muted);
  pointer-events: none;
}
.lang-picker {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  line-height: 1;
}
.lang-picker:focus { outline: none; }

/* ── Filter nav (right-aligned, horizontally scrollable) ─────────────────────── */
.filter-nav {
  margin-left: auto;   /* pushes filter-nav + site-nav to the far right */
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.filter-nav::-webkit-scrollbar { display: none; }
.filter-nav .filter-btn:first-child { padding-left: 4px; }

.filter-btn {
  flex-shrink: 0;
  padding: 14px 20px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  margin-bottom: -1px; /* sit on top of nav border */
}

.filter-btn:hover { color: var(--text); }
.filter-btn.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

/* ── Ratio menu (trigger + dropdown) ─────────────────────────────────────────── */
.ratio-menu {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

/* Trigger button — shows active ratio icon */
.ratio-trigger {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 3px;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.ratio-trigger:hover {
  border-color: var(--text);
  background: var(--hover-bg);
}
.ratio-trigger svg {
  display: block;
  overflow: visible;
  pointer-events: none;
}
.ratio-trigger rect {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
  transition: stroke 0.15s;
}
.ratio-trigger:hover rect { stroke: var(--text); }
.ratio-trigger.active rect { stroke: var(--text); }

/* Floating dropdown panel */
.ratio-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 80px;
}
.ratio-dropdown[hidden] { display: none; }

/* Individual ratio options inside the dropdown */
.ratio-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.03em;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  white-space: nowrap;
}
.ratio-btn svg {
  display: block;
  overflow: visible;
  flex-shrink: 0;
}
.ratio-btn rect {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
  transition: stroke 0.12s;
}
.ratio-btn:hover {
  background: var(--hover-bg);
  color: var(--text);
}
.ratio-btn:hover rect  { stroke: var(--text); }
.ratio-btn.active {
  background: var(--hover-bg);
  border-color: var(--text);
  color: var(--text);
}
.ratio-btn.active rect { stroke: var(--text); }

/* ── Projects grid ───────────────────────────────────────────────────────────── */
.projects-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 32px var(--page-pad) 48px;
  background: var(--bg);
  min-height: 60vh;
}

.project-card {
  flex: 0 0 calc(50% - 8px);   /* mobile default: 2 cols, gap 16px → 16/2=8 */
  background: var(--bg);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}

/* Thumb + overlay wrapper */
.card-thumb {
  aspect-ratio: var(--thumb-ratio); /* controlled by ratio picker, default 1/1 */
  overflow: hidden;
  background: var(--hover-bg);
  flex-shrink: 0;
  position: relative;
  width: 100%;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.55s ease, opacity 0.2s;
}

/* ── Thumbnail slideshow slides ──────────────────────────────────────────── */
.card-thumb .thumb-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 3s ease, transform 0.55s ease;
}
.card-thumb .thumb-slide.active { opacity: 1; }

/* Hover overlay — white wash + title, like peterpeterdesign */
.card-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.card-overlay-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text);
  text-align: center;
  line-height: 1.4;
}

.card-overlay-cat {
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.project-card:hover .card-overlay { opacity: 1; }
.project-card:hover .card-thumb img { transform: scale(1.04); }
.project-card:active .card-thumb img { opacity: 0.85; }

/* Label below (shown on mobile / always for accessibility) */
.card-label {
  padding: 7px 0 0;
  text-align: left;
}

.project-name {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text);
  line-height: 1.4;
}

.project-cat {
  font-size: 11px;
  letter-spacing: 0.01em;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Detail overlay ──────────────────────────────────────────────────────────── */
.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.detail-overlay[hidden] { display: none; }

.detail-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  overflow: visible; /* let ratio dropdown overflow below the sticky bar */
}

.detail-back {
  flex-shrink: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.detail-back:hover { color: var(--text); }

.detail-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.detail-name {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-cat {
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--muted);
  flex-shrink: 0;
}

.detail-brand {
  flex-shrink: 0;
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--muted);
  white-space: nowrap;
}
@media (max-width: 420px) { .detail-brand { display: none; } }

/* ── Map section ──────────────────────────────────────────────────────────────── */
.detail-map {
  padding: 40px var(--page-pad) 0;
  max-width: 900px;
}

.detail-map[hidden] { display: none; }

.map-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--muted);
  margin-bottom: 12px;
}

.map-label svg { flex-shrink: 0; opacity: 0.6; }

.map-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  border: 1px solid var(--border);
  overflow: hidden;
}

.map-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ── Detail footer ───────────────────────────────────────────────────────────── */
.detail-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 5;
  padding: 10px 24px;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* ── Gallery ─────────────────────────────────────────────────────────────────── */
.detail-gallery {
  padding: 32px var(--page-pad) 48px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  background: var(--bg);
  align-items: start;
}

.gallery-img-wrap {
  background: var(--bg);
  overflow: hidden;
  aspect-ratio: var(--thumb-ratio);
}

.gallery-img-wrap img,
.gallery-img-wrap video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  cursor: zoom-in;
  transition: opacity 0.15s;
}
.gallery-img-wrap img:hover { opacity: 0.9; }

.gallery-caption {
  padding: 5px 10px 6px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.01em;
  background: var(--bg);
  line-height: 1.4;
}

.detail-gallery.is-single {
  padding: 40px var(--page-pad);
  background: var(--bg);
  justify-items: center;
  gap: 0;
}
.detail-gallery.is-single .gallery-img-wrap {
  aspect-ratio: unset;
  overflow: visible;
}
.detail-gallery.is-single .gallery-img-wrap img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 120px);
  object-fit: unset;
}

/* ── Lightbox ─────────────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox[hidden] { display: none; }

.lb-img {
  max-width: 94vw;
  max-height: 94vh;
  max-height: 94svh; /* safe area aware on mobile */
  object-fit: contain;
}

.lb-close, .lb-prev, .lb-next {
  position: absolute;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-close:hover, .lb-prev:hover, .lb-next:hover { opacity: 1; }
.lb-close { top: 16px; right: 16px; font-size: 18px; }
.lb-prev  { left: 0; top: 50%; transform: translateY(-50%); font-size: 22px; padding: 20px; }
.lb-next  { right: 0; top: 50%; transform: translateY(-50%); font-size: 22px; padding: 20px; }

.lb-caption {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.55);
  font-size: 13px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  pointer-events: none;
}

/* ── Site footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  padding: 40px 32px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.contact-bio {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  max-width: 560px;
  text-align: center;
}

.contact-company {
  font-size: 13px;
  letter-spacing: 0.01em;
  color: var(--text);
}

.contact-details {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.contact-details a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
  transition: color 0.15s, border-color 0.15s;
}
.contact-details a:hover {
  color: var(--text);
  border-bottom-color: var(--text);
}

/* ── Misc ─────────────────────────────────────────────────────────────────────── */
.loading {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.01em;
  padding: 80px;
  text-align: center;
  width: 100%;
}

/* ── Tablet ──────────────────────────────────────────────────────────────────── */
@media (min-width: 540px) {
  :root { --page-pad: 48px; }
  .site-header { padding: 0 var(--page-pad); }
  .logo { height: var(--logo-h); }
  .site-nav { gap: 40px; }
  .projects-grid { gap: 24px; padding: 40px var(--page-pad) 60px; }
  .projects-grid .project-card { flex: 0 0 calc(33.333% - 16px); } /* 3 cols: (100% - 24*2)/3 */
  .detail-gallery { gap: 24px; padding: 40px var(--page-pad) 60px; }
  .contact-details {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }
  .contact-details span { padding: 0 12px; }
  .contact-details span + span { border-left: 1px solid var(--border); }
}

/* ── Desktop ─────────────────────────────────────────────────────────────────── */
@media (min-width: 900px) {
  :root { --page-pad: 64px; }
  .logo { height: calc(var(--logo-h) * 1.25); }
  .projects-grid { gap: 28px; padding: 48px var(--page-pad) 72px; }
  .projects-grid .project-card { flex: 0 0 calc(25% - 21px); } /* 4 cols: (100% - 28*3)/4 */
  .detail-header { padding: 16px var(--page-pad); }
  .detail-gallery { gap: 28px; padding: 48px var(--page-pad) 72px; }
}

@media (min-width: 1200px) {
  :root { --page-pad: 80px; }
}

/* ── Hamburger button (hidden on desktop) ─────────────────────────────────────── */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px;
  margin-left: auto;
  flex-shrink: 0;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.hbg-bar {
  display: block;
  width: 22px;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.22s ease, opacity 0.22s ease;
  transform-origin: center;
}
/* Animate to × when open */
.nav-hamburger[aria-expanded="true"] .hbg-bar:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-hamburger[aria-expanded="true"] .hbg-bar:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-hamburger[aria-expanded="true"] .hbg-bar:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* ── Mobile slide-in menu ─────────────────────────────────────────────────────── */
.mobile-menu {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(300px, 88vw);
  background: var(--bg);
  border-left: 1px solid var(--border);
  z-index: 400;
  display: flex;
  flex-direction: column;
  padding: 80px 32px 48px;
  gap: 0;
  transform: translateX(100%);
  /* delay visibility: hidden until slide-out is done */
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0s linear 0.28s;
  visibility: hidden;
  overflow-y: auto;
}
.mobile-menu.is-open {
  transform: translateX(0);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0s linear 0s;
  visibility: visible;
}

/* Category buttons inside mobile menu */
.mobile-menu-cats {
  display: flex;
  flex-direction: column;
}
.mobile-filter-btn {
  display: block;
  padding: 15px 0;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 0.01em;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.mobile-filter-btn:first-child { border-top: 1px solid var(--border); }
.mobile-filter-btn:hover,
.mobile-filter-btn.active { color: var(--text); }

.mobile-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 20px 0 4px;
}

.mobile-menu-link {
  display: block;
  padding: 15px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  letter-spacing: 0.01em;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}
.mobile-menu-link:hover { color: var(--text); }

.mobile-menu-lang {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 0;
  border-bottom: 1px solid var(--border);
}
.mobile-menu-lang-label {
  font-size: 15px;
  letter-spacing: 0.01em;
  color: var(--muted);
}
.mobile-menu-lang .lang-picker {
  font-size: 13px;
  color: var(--text);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.mobile-menu-lang .lang-picker:focus { outline: none; }

/* Semi-transparent backdrop */
.mobile-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  z-index: 399;
  transition: background 0.28s, visibility 0s linear 0.28s;
  visibility: hidden;
  pointer-events: none;
}
.mobile-menu-backdrop.is-open {
  background: rgba(0,0,0,0.25);
  visibility: visible;
  pointer-events: all;
  transition: background 0.28s, visibility 0s linear 0s;
}

/* ── Mobile overrides (< 640px — portrait phones) ──────────────────────────────── */
@media (max-width: 639px) {
  :root { --page-pad: 16px; }
  .site-header { padding: 0 16px 0 var(--page-pad); }
  .logo { height: calc(var(--logo-h) * 0.75); }
  /* Hide desktop nav; show hamburger instead */
  .site-nav { display: none !important; }
  .filter-nav { display: none !important; }
  .nav-hamburger { display: flex; }
  /* Grid: 2 columns */
  .projects-grid { gap: 12px; }
  .projects-grid .project-card { flex: 0 0 calc(50% - 6px); }
  /* Detail gallery */
  .detail-gallery { gap: 12px; grid-template-columns: 1fr 1fr !important; }
  .detail-gallery.is-single { grid-template-columns: 1fr !important; padding: 24px var(--page-pad); }
  .detail-gallery.is-single .gallery-img-wrap img { max-height: calc(100vh - 100px); }
}

/* ── Tablet overrides (540–639px) ──────────────────────────────────────────────── */
/* (already handled by the main 540px+ breakpoint above — no extra rules needed) */
