/* ═══════════════════════════════════════════
   Räckviddskartan 2026 – Responsive Styles
   ═══════════════════════════════════════════ */

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

html, body {
  width: 100%; height: 100%;
  background: linear-gradient(77deg, rgba(253,249,206,1) 0%, rgba(239,220,232,1) 100%);
  
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ── App container ── */

#app {
  width: 100%; height: 100%;
  position: relative; overflow: hidden;
  background: url('../assets/betong_2x.jpg') center/cover;
  font-family: 'Roboto', sans-serif;
  color: #1A1A1A;
}

/* ── Landing page ── */

#landing {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  background: url('../assets/kartanbak.jpg') center/cover;
  padding: 24px;
}

#landing::before {
  content: ''; position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

#landing::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

#landing > * { position: relative; z-index: 1; }

#landing h1 {
  font-family: Georgia, Times, "Times New Roman", serif;
  font-weight: 400; font-size: clamp(36px, 8vw, 72px);
  color: #fff; margin-bottom: 12px;
  letter-spacing: -1px; text-align: center;
}

#landing .subtitle {
  font-family: 'Montserrat', sans-serif;
  font-weight: 500; font-size: clamp(11px, 2vw, 16px);
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 3px; margin-bottom: 48px;
  text-align: center;
}

.btn-valj {
  font-family: 'Montserrat', sans-serif;
  font-weight: 600; font-size: 15px;
  color: #1A1A1A; background: #fff;
  border: none; border-radius: 30px;
  padding: 14px 48px; cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  transition: transform .15s, box-shadow .15s;
}

.btn-valj:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

#landing.hidden { display: none; }

/* ── Mobile: both in normal flex flow, pushed to bottom ── */
.landing-footnote {
  position: relative; z-index: 1;
  font-family: 'Montserrat', sans-serif;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.6;
  white-space: pre-line;
  text-align: left;
  margin-top: auto;       /* pushes footnote + logos to bottom */
  padding-bottom: 12px;
}

.landing-logos {
  position: relative; z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-bottom: 20px;
}

/* ── Desktop: pin each to its corner ── */
@media (min-width: 1024px) {
  #landing > .landing-footnote {
    position: absolute;
    margin-top: 0;
    padding-bottom: 0;
    bottom: 30px;
    left: 30px;
    right: auto;
    text-align: left;
    max-width: 520px;
  }

  #landing > .landing-logos {
    position: absolute;
    flex-direction: row;
    align-items: center;
    gap: 24px;
    padding-bottom: 0;
    bottom: 30px;
    right: 30px;
  }
}

.landing-logos a {
  display: inline-flex;
  line-height: 0;
}

.landing-logos img {
  width: auto;
  opacity: 0.9;
  transition: opacity .15s;
}

/* Individual heights tuned to visual balance across different aspect ratios */
.landing-logos :nth-child(1) img { height: 34px; } /* BNS  – tall stacked wordmark */
.landing-logos :nth-child(2) img { height: 22px; } /* Gota – wide single-line      */
.landing-logos :nth-child(3) img { height: 32px; } /* ERNA – wide single-line      */
.landing-logos :nth-child(4) img { height: 40px; } /* Miti                         */

.landing-logos img:hover { opacity: 1; }

/* ── Main view ── */

#main-view {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

#main-view.active { display: flex; }

/* ── Bottom bar  ── */

#bottom-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px 8px;
  flex-shrink: 0;
}


#back-btn {
  font-family: 'Montserrat', sans-serif;
  font-weight: 600; font-size: 12px;
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 20px;
  padding: 7px 18px; cursor: pointer;
  transition: background .15s;
  display: none;
  position: absolute;
  bottom: 14px; left: 20px;
  z-index: 2;
}

#back-btn:hover { background: rgba(255, 255, 255, 0.28); }
#back-btn.visible { display: inline-block; }

/* ── Region list ── */

#region-list {
  display: flex;
  gap: 6px;
  padding: 8px 20px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}

#region-list::-webkit-scrollbar { height: 4px; }
#region-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
}

.region-group-label {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #000;
  padding: 8px 4px 3px;
  white-space: nowrap;
  flex-shrink: 0;
  display: block; /* stack vertically on mobile */
}

/* First group label needs no top padding */
.region-group-label:first-child { padding-top: 2px; }

.region-btn {
  font-family: 'Montserrat', sans-serif;
  font-weight: 600; font-size: 12px;
  color: #1A1A1A;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 5px;
  padding: 7px 12px; cursor: pointer;
  text-align: left;
  transition: background .12s, box-shadow .12s;
  white-space: nowrap; flex-shrink: 0;
}

.region-btn:hover {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.region-btn.active {
  background: #fff;
  border-color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
}

/* ── Map ── */

#map-container {
  display: none; /* Hidden on mobile by default */
}

#map-container svg {
  width: 100%; max-width: 200px; height: auto;
  opacity: 0.85;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.25));
  display: block;
}

/* County paths in the SVG map */
#map-container svg path {
  transition: fill 0.25s ease;
}

.svg-active   { fill: #efdce8 !important; }
.svg-dimmed   { fill: #b0b8b6 !important; }

/* ── Data card ── */

#data-card {
  background: rgba(255, 255, 255, 0.96);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  display: flex; flex-direction: column;
  margin: 0 12px 16px;
  flex: 1;
  min-height: 0;
}

/* ── Tabs ── */

#tabs-bar {
  display: flex;
  min-height: 42px;
  background: #D8DDE4;
  flex-shrink: 0;
}

.tab-btn {
  font-family: 'Montserrat', sans-serif;
  font-weight: 600; font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 11px 16px; cursor: pointer;
  border: none; background: #D8DDE4;
  color: #777;
  transition: background .12s, color .12s;
  border-right: 1px solid #c5cad0;
  flex: 1; text-align: center;
}

.tab-btn:last-child { border-right: none; }
.tab-btn.active { background: #fff; color: #1A1A1A; }
.tab-btn:hover:not(.active) { background: #e3e6ea; }

/* ── Data content ── */

#data-content {
  flex: 1;
  padding: 16px 16px 8px;
  overflow-y: auto;
  min-height: 0;
}

#data-content::-webkit-scrollbar { width: 5px; }
#data-content::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

.area-name {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700; font-size: 16px;
  color: #1A1A1A; margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Metric header ── */

.metric-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px; margin-bottom: 2px;
  padding-bottom: 6px;
  border-bottom: 2px solid #e0e0e0;
}

.metric-header span {
  font-family: 'Montserrat', sans-serif;
  font-weight: 600; font-size: 10px;
  color: #999; text-transform: uppercase;
  letter-spacing: 1px; text-align: center;
}

/* Hide the empty first column header on mobile */
.metric-header span.col-label { display: none; }

/* ── Metric row ── */

.metric-row {
  display: flex;
  flex-direction: column;
  padding: 10px 0;
  border-bottom: 1px solid #ececec;
}

.metric-row:last-child { border-bottom: none; }

.metric-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.metric-values {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
}

.metric-cell { text-align: center; }

.metric-pct {
  font-family: 'Roboto', sans-serif;
  font-weight: 700; font-size: 26px;
  color: #1A1A1A; line-height: 1.15;
}

.metric-abs {
  font-family: 'Roboto', sans-serif;
  font-weight: 400; font-size: 11px;
  color: #999; margin-top: 1px;
}

/* ── Icons ── */

.bn-icon {
  width: 26px; height: 26px;
  border-radius: 50%; background: #000;
  color: #fff;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700; font-size: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}

.paper-icon {
  width: 26px; height: 26px;
  border-radius: 50%; overflow: hidden;
  flex-shrink: 0; display: inline-flex;
}

.paper-icon img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.label-text {
  font-family: 'Montserrat', sans-serif;
  font-weight: 600; font-size: 12px;
  color: #555; text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ── Municipality selector ── */

#muni-bar {
  padding: 10px 16px 14px;
  border-top: 1px solid #e0e0e0;
  display: none; align-items: center; gap: 10px;
  flex-shrink: 0;
}

#muni-bar.active { display: flex; }

#muni-bar label {
  font-family: 'Montserrat', sans-serif;
  font-weight: 600; font-size: 10px;
  color: #999; text-transform: uppercase;
  letter-spacing: 1px; white-space: nowrap;
}

#muni-select {
  flex: 1; min-width: 0;
  padding: 7px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-family: 'Roboto', sans-serif;
  font-size: 16px;
  background: #F7F7F7; color: #1A1A1A;
  cursor: pointer; outline: none;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Animations ── */

.fade-in { animation: fadeIn .2s ease-out; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}


/* ═══════════════════════════════════════════
   Tablet (≥ 600px)
   ═══════════════════════════════════════════ */

@media (min-width: 600px) {
  .metric-pct { font-size: 30px; }
  .area-name { font-size: 18px; }

  #data-content { padding: 20px 24px 12px; }
  #muni-bar { padding: 10px 24px 14px; }
  #data-card { margin: 0 20px 20px; }
}


/* ═══════════════════════════════════════════
   Desktop (≥ 1024px) — side-by-side layout
   ═══════════════════════════════════════════ */

@media (min-width: 1024px) {
  html, body { overflow: hidden; }

  body {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  #app {
    width: 1280px; height: 720px;
  }

  /* Main view becomes positioned layout */
  #main-view {
    overflow: hidden;
  }

  #main-view.active {
    display: block;
  }

  /* ── Left panel ── */
  #bottom-bar {
    position: absolute; left: 0; bottom: 0;
    width: 460px;
    padding: 28px 20px 0 32px;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  #back-btn {
    left: 32px;
  }

  /* Region list: vertical sidebar on desktop */
  #region-list {
    position: absolute;
    left: 232px; top: 24px;
    width: 220px;
    bottom: 24px;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0 4px 0 0;
    gap: 3px;
  }

  #region-list::-webkit-scrollbar { width: 4px; height: 0; }

  /* Group labels take full width in vertical sidebar */
  .region-group-label {
    width: 100%;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding-top: 10px;
    margin-top: 4px;
  }
  .region-group-label:first-child {
    border-top: none;
    margin-top: 0;
    padding-top: 2px;
  }

  /* Map visible on desktop */
  #map-container {
    display: flex;
    position: absolute;
    left: 32px; top: 96px;
    width: 200px;
    align-items: flex-start;
    justify-content: center;
    padding-top: 8px;
  }

  #map-container svg {
    width: 300px;
  }

  /* ── Right panel ── */
  #data-card {
    position: absolute;
    right: 28px; top: 24px;
    bottom: 24px;
    left: 468px;
    margin: 0;
    border-radius: 14px;
  }

  #data-content { padding: 20px 28px 12px; }
  #muni-bar { padding: 10px 28px 14px; }

  /* Metric grid: add label column on desktop */
  .metric-header {
    grid-template-columns: 200px 1fr 1fr 1fr;
  }

  .metric-header span.col-label { display: block; }

  .metric-row {
    flex-direction: row;
    display: grid;
    grid-template-columns: 200px 1fr 1fr 1fr;
    gap: 4px;
    align-items: center;
  }

  .metric-label { margin-bottom: 0; }
  .metric-values {
    display: contents;
  }

  .metric-pct { font-size: 32px; }
  .area-name { font-size: 18px; margin-bottom: 16px; }

  #muni-select { font-size: 13px; }
}


/* ═══════════════════════════════════════════
   Large desktop (≥ 1400px)
   ═══════════════════════════════════════════ */

@media (min-width: 1400px) {
  #app {
    width: 1280px; height: 720px;
  }
}
