/* ============================================================
   Samhällsbyggarkartan — designsystem
   Palett: petrol + varm sand + bränd ockra. Typsnitt: Fraunces + Inter.
   ============================================================ */

:root {
  --bg: #F7F4EE;
  --panel: #FFFFFF;
  --ink: #14262C;
  --ink-soft: #3D5158;
  --muted: #5A6B71;  /* mörkare än ursprungliga #6B7C82 — klarar WCAG AA på vit/sand */
  --brand: #0E5B63;
  --brand-deep: #093C42;
  --brand-ghost: #E3EEEF;
  --accent: #C8722C;
  --accent-soft: #F6E8DA;
  --ok: #276B44;
  --ok-soft: #E3F0E8;
  --warn: #8F6110;
  --warn-soft: #F7EDD8;
  --risk: #B04234;
  --risk-soft: #F6E3E0;
  --line: #E5DFD2;
  --shadow: 0 1px 2px rgba(20, 38, 44, .06), 0 8px 24px rgba(20, 38, 44, .08);
  --shadow-lg: 0 2px 6px rgba(20, 38, 44, .08), 0 20px 48px rgba(20, 38, 44, .16);
  --radius: 14px;
  --radius-sm: 9px;
  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

/* synligt tangentbordsfokus (mus-klick påverkas inte) */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.tool-header :focus-visible { outline-color: #fff; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; margin: 0 0 .5em; }
h1 { font-size: clamp(2.1rem, 5vw, 3.6rem); letter-spacing: -.01em; }
h2 { font-size: clamp(1.5rem, 3vw, 2.2rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
a { color: var(--brand); }
img { max-width: 100%; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* ---------- knappar ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px;
  font-weight: 600; font-size: .95rem; text-decoration: none;
  border: 1.5px solid transparent; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  font-family: var(--font-ui);
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: #B4661F; color: #fff; box-shadow: 0 6px 18px rgba(180,102,31,.35); }
.btn-primary:hover { background: #9E5717; }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.btn-ghost:hover { border-color: #fff; background: rgba(255,255,255,.08); }
.btn-outline { background: var(--panel); color: var(--brand); border-color: var(--brand); }
.btn-outline:hover { background: var(--brand-ghost); }
.btn-small { padding: 8px 14px; font-size: .85rem; }

/* ---------- header (landnings-/innehållssidor) ---------- */
.site-header {
  position: sticky; top: 0; z-index: 500;
  background: rgba(247,244,238,.9); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: 28px; height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 1.02rem; letter-spacing: -.01em; }
.logo svg { flex: 0 0 auto; }
.site-nav { margin-left: auto; display: flex; gap: 22px; align-items: center; }
.site-nav a { color: var(--ink-soft); text-decoration: none; font-size: .93rem; font-weight: 500; }
.site-nav a:hover { color: var(--brand); }
.site-nav .btn { color: #fff; }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(155deg, var(--brand-deep) 0%, var(--brand) 55%, #14707A 100%);
  color: #fff; padding: 92px 0 108px;
}
.hero .wrap { position: relative; z-index: 2; max-width: 880px; text-align: center; }
.hero-eyebrow {
  display: inline-block; padding: 6px 16px; border-radius: 999px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25);
  font-size: .82rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  margin-bottom: 26px;
}
.hero h1 { color: #fff; margin-bottom: .4em; }
.hero p.lead { font-size: clamp(1.05rem, 2vw, 1.25rem); color: rgba(255,255,255,.85); max-width: 640px; margin: 0 auto 34px; }
.hero-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.hero-art { position: absolute; inset: 0; z-index: 1; opacity: .5; pointer-events: none; }

/* statistikrad */
.stat-strip { background: var(--brand-deep); color: #fff; padding: 18px 0; }
.stat-strip .wrap { display: flex; justify-content: center; gap: clamp(24px, 6vw, 80px); flex-wrap: wrap; }
.stat { text-align: center; }
.stat b { display: block; font-family: var(--font-display); font-size: 1.7rem; }
.stat span { font-size: .82rem; color: rgba(255,255,255,.7); }

/* ---------- sektioner ---------- */
.section { padding: 84px 0; }
.section.alt { background: #FFFDF9; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { max-width: 640px; margin-bottom: 44px; }
.section-head .kicker { color: var(--accent); font-weight: 700; font-size: .84rem; text-transform: uppercase; letter-spacing: .08em; }
.section-head p { color: var(--muted); }
.center { text-align: center; margin-left: auto; margin-right: auto; }

.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px; box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card .icon {
  width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: var(--brand-ghost); color: var(--brand); margin-bottom: 16px;
}
.card h3 { margin-bottom: .35em; }
.card p { color: var(--muted); font-size: .93rem; margin: 0; }
.card .tag { display: inline-block; margin-top: 14px; font-size: .78rem; font-weight: 600; color: var(--brand); }

/* källkort */
.src-card { display: flex; flex-direction: column; }
.src-card .src-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.src-card .src-top h3 { margin: 0; }
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .72rem; font-weight: 700;
  background: var(--ok-soft); color: var(--ok); white-space: nowrap;
}
.badge.gold { background: var(--accent-soft); color: var(--accent); }
.src-card .src-what { color: var(--ink-soft); font-size: .93rem; margin-bottom: 10px; }
.src-card .src-why { color: var(--muted); font-size: .88rem; margin-bottom: 14px; flex: 1; }
.src-card code {
  display: block; background: #10282E; color: #9FD4CB; font-size: .74rem; padding: 10px 12px;
  border-radius: var(--radius-sm); overflow-x: auto; white-space: pre; margin-bottom: 12px;
}
.src-card .src-links { font-size: .85rem; }

/* steg */
.steps { counter-reset: s; display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.step { position: relative; padding: 26px 26px 26px 74px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.step::before {
  counter-increment: s; content: counter(s);
  position: absolute; left: 22px; top: 24px; width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand); color: #fff; font-family: var(--font-display); font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.step h3 { margin-bottom: .3em; }
.step p { color: var(--muted); font-size: .92rem; margin: 0; }

/* claude-sektionen */
.built-banner {
  background: linear-gradient(135deg, #1A1915, #33302A);
  color: #EDEAE2; border-radius: 20px; padding: clamp(28px, 5vw, 56px);
  display: grid; gap: 32px; grid-template-columns: 1.4fr 1fr; align-items: center;
}
.built-banner h2 { color: #fff; }
.built-banner p { color: rgba(237,234,226,.75); }
.built-banner .mono {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .8rem;
  background: #0F0E0C; border: 1px solid #3F3B33; border-radius: 12px; padding: 18px; line-height: 1.7;
  color: #C9C4B8; overflow-x: auto;
}
.built-banner .mono .c { color: #7FB069; }
.built-banner .mono .d { color: #6B675E; }

/* footer */
.site-footer { background: var(--brand-deep); color: rgba(255,255,255,.75); padding: 48px 0 40px; font-size: .88rem; }
.site-footer .wrap { display: grid; gap: 32px; grid-template-columns: 2fr 1fr 1fr; }
.site-footer h4 { color: #fff; font-size: .95rem; margin: 0 0 12px; }
.site-footer a { color: rgba(255,255,255,.85); text-decoration: none; display: block; margin-bottom: 8px; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.footer-note { border-top: 1px solid rgba(255,255,255,.15); margin-top: 36px; padding-top: 20px; font-size: .8rem; color: rgba(255,255,255,.55); }

/* ============================================================
   VERKTYGET
   ============================================================ */
.tool-body { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }

.tool-header {
  display: flex; align-items: center; gap: 14px; padding: 0 16px; height: 58px;
  background: var(--brand-deep); color: #fff; z-index: 1200; flex: 0 0 auto;
}
.tool-header .logo { color: #fff; font-size: .95rem; }
.tool-header .logo small { display: block; font-size: .68rem; font-weight: 400; color: rgba(255,255,255,.6); line-height: 1; }

.searchbox { position: relative; flex: 1; max-width: 520px; }
.searchbox input {
  width: 100%; padding: 10px 14px 10px 40px; border-radius: 999px; border: none;
  background: rgba(255,255,255,.14); color: #fff; font-size: .93rem; font-family: var(--font-ui);
  outline: none; transition: background .15s;
}
.searchbox input::placeholder { color: rgba(255,255,255,.55); }
.searchbox input:focus { background: rgba(255,255,255,.22); }
.searchbox input:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.searchbox .search-ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); opacity: .7; }
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; background: var(--panel);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); overflow: hidden; display: none;
}
.search-results.open { display: block; }
.search-results button {
  display: block; width: 100%; text-align: left; padding: 11px 16px; border: none; background: none;
  cursor: pointer; font-size: .88rem; color: var(--ink); font-family: var(--font-ui);
  border-bottom: 1px solid var(--line);
}
.search-results button:last-child { border-bottom: none; }
.search-results button:hover { background: var(--brand-ghost); }
.search-results .hint { padding: 10px 16px; font-size: .8rem; color: var(--muted); }

.tool-header .header-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.hbtn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px;
  background: rgba(255,255,255,.12); color: #fff; border: none; cursor: pointer; font-size: .84rem;
  font-family: var(--font-ui); font-weight: 500; text-decoration: none; white-space: nowrap;
}
.hbtn:hover { background: rgba(255,255,255,.22); }

.tool-main { flex: 1; display: flex; position: relative; min-height: 0; }
#map { flex: 1; min-width: 0; background: #DDE7E4; }

/* lagerpanel */
.layer-panel {
  width: 308px; flex: 0 0 auto; background: var(--panel); border-right: 1px solid var(--line);
  overflow-y: auto; z-index: 900; display: flex; flex-direction: column;
}
.layer-panel-head { padding: 16px 18px 10px; position: relative; }
.layer-panel-head h2 { font-size: 1.05rem; margin: 0; }
.layer-panel-head p { font-size: .78rem; color: var(--muted); margin: 4px 0 0; }
.panel-close {
  display: none; position: absolute; top: 10px; right: 10px; width: 40px; height: 40px;
  border-radius: 50%; border: none; background: var(--bg); cursor: pointer;
  font-size: 15px; color: var(--ink-soft);
}
.panel-close:hover { background: var(--line); }
@media (max-width: 900px) { .panel-close { display: block; } }
.layer-group { border-top: 1px solid var(--line); }
.layer-group > summary {
  list-style: none; cursor: pointer; padding: 12px 18px; font-weight: 600; font-size: .88rem;
  display: flex; align-items: center; gap: 8px; user-select: none;
}
.layer-group > summary::-webkit-details-marker { display: none; }
.layer-group > summary .chev { margin-left: auto; transition: transform .18s; opacity: .5; }
.layer-group[open] > summary .chev { transform: rotate(180deg); }
.layer-group .dot { width: 10px; height: 10px; border-radius: 3px; }
.layer-row { padding: 6px 18px 10px 36px; }
.layer-row label { display: flex; align-items: flex-start; gap: 10px; font-size: .85rem; cursor: pointer; padding: 6px 0; }
.layer-row input[type="checkbox"] { margin-top: 3px; accent-color: var(--brand); width: 17px; height: 17px; }
.layer-row .lname { flex: 1; line-height: 1.35; }
.layer-row .lsrc { display: block; font-size: .72rem; color: var(--muted); }
.layer-row input[type="range"] { width: 100%; margin: 6px 0 0; accent-color: var(--brand); height: 14px; }
.layer-legend { margin: 8px 0 0; }
.layer-legend img { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.kust-select { margin: 8px 0 0; width: 100%; padding: 6px 8px; border-radius: 7px; border: 1px solid var(--line); font-family: var(--font-ui); font-size: .82rem; }
.panel-foot { margin-top: auto; padding: 14px 18px; font-size: .72rem; color: var(--muted); border-top: 1px solid var(--line); }

/* rapportpanel */
.report-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(440px, 100%);
  background: var(--bg); box-shadow: -12px 0 40px rgba(20,38,44,.18); z-index: 1000;
  transform: translateX(105%); transition: transform .28s ease; display: flex; flex-direction: column;
}
.report-panel.open { transform: translateX(0); }
.report-head { padding: 18px 20px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.report-head .addr { font-family: var(--font-display); font-size: 1.18rem; font-weight: 600; line-height: 1.25; margin: 0; }
.report-head .coords { font-size: .76rem; color: var(--muted); margin-top: 4px; }
.report-head .report-actions { display: flex; gap: 8px; margin-top: 12px; }
.report-close { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--bg); cursor: pointer; font-size: 15px; color: var(--ink-soft); }
.report-close:hover { background: var(--line); }
.report-scroll { overflow-y: auto; flex: 1; padding: 16px 20px 28px; }

.risk-overview { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.risk-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.risk-chip .rdot { width: 9px; height: 9px; border-radius: 50%; }
.risk-chip.ok { background: var(--ok-soft); color: var(--ok); } .risk-chip.ok .rdot { background: var(--ok); }
.risk-chip.warn { background: var(--warn-soft); color: var(--warn); } .risk-chip.warn .rdot { background: var(--warn); }
.risk-chip.risk { background: var(--risk-soft); color: var(--risk); } .risk-chip.risk .rdot { background: var(--risk); }
.risk-chip.na { background: #ECEAE4; color: var(--muted); } .risk-chip.na .rdot { background: var(--muted); }

.rsec { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 14px; overflow: hidden; }
.rsec-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-weight: 600; font-size: .9rem; }
.rsec-head .sico { width: 30px; height: 30px; border-radius: 8px; background: var(--brand-ghost); color: var(--brand); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.rsec-head .src-note { margin-left: auto; font-size: .68rem; color: var(--muted); font-weight: 400; text-align: right; }
.rsec-body { padding: 0 16px 14px; font-size: .86rem; }
.rsec-body .rrow { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid #F1EDE3; }
.rsec-body .rrow:first-child { border-top: none; }
.rsec-body .rrow .k { color: var(--ink-soft); }
.rsec-body .rrow .v { font-weight: 600; text-align: right; }
.rsec-body .v.ok { color: var(--ok); } .rsec-body .v.warn { color: var(--warn); } .rsec-body .v.risk { color: var(--risk); }
.rsec-body .empty { color: var(--muted); padding: 6px 0; }
.rsec-body .note { font-size: .76rem; color: var(--muted); margin: 8px 0 0; }
.rsec.loading .rsec-body::after {
  content: ""; display: block; height: 12px; margin: 10px 0; border-radius: 6px;
  background: linear-gradient(90deg, #EEE9DD 25%, #F7F3EA 50%, #EEE9DD 75%); background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.poi-list { list-style: none; margin: 4px 0 0; padding: 0; }
.poi-list li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid #F1EDE3; }
.poi-list li:first-child { border-top: none; }
.poi-list .pn { color: var(--ink-soft); }
.poi-list .pd { font-weight: 600; white-space: nowrap; }

.minibar { display: flex; align-items: flex-end; gap: 5px; height: 64px; margin-top: 10px; }
.minibar .bar { flex: 1; background: var(--brand); border-radius: 3px 3px 0 0; min-height: 3px; position: relative; }
.minibar .bar span { position: absolute; bottom: -19px; left: 50%; transform: translateX(-50%); font-size: .62rem; color: var(--muted); white-space: nowrap; }
.minibar-wrap { padding-bottom: 22px; }

.report-disclaimer { font-size: .74rem; color: var(--muted); background: var(--accent-soft); border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 6px; }

/* välkomstöverlägg på kartan */
.map-welcome {
  position: absolute; left: 50%; top: 18px; transform: translateX(-50%); z-index: 800;
  background: var(--panel); border-radius: 999px; box-shadow: var(--shadow-lg);
  padding: 10px 20px; font-size: .88rem; display: flex; gap: 8px; align-items: center; pointer-events: none;
  max-width: calc(100% - 32px); text-align: center;
}
.map-welcome b { color: var(--brand); }

/* Leaflet-justeringar */
.leaflet-container { font-family: var(--font-ui); }
.leaflet-control-attribution { font-size: 10px !important; background: rgba(255,255,255,.85) !important; }
.sel-marker { filter: drop-shadow(0 3px 6px rgba(20,38,44,.4)); }

/* ---------- responsivt ---------- */
@media (max-width: 900px) {
  .layer-panel { position: absolute; left: 0; top: 0; bottom: 0; transform: translateX(-105%); transition: transform .25s ease; box-shadow: 12px 0 40px rgba(20,38,44,.18); }
  .layer-panel.open { transform: translateX(0); }
  .built-banner { grid-template-columns: 1fr; }
  .site-footer .wrap { grid-template-columns: 1fr; gap: 20px; }
  .tool-header .logo small { display: none; }
  .tool-header .logo span.t { display: none; }
  .searchbox { max-width: none; }
  .map-welcome { top: 62px; }  /* under Lager-knappen så de inte överlappar */
}
@media (max-width: 700px) {
  .site-header .wrap { height: auto; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; gap: 12px; }
  .site-nav { gap: 14px; }
  .site-nav a:not(.btn) { display: none; }  /* på små skärmar: bara CTA-knappen */
}

/* markera aktuell sida i navigationen */
.site-nav a[aria-current="page"] { color: var(--brand); font-weight: 600; }

/* mobilknapp för lager */
.layers-toggle { display: none; }
@media (max-width: 900px) {
  .layers-toggle {
    display: flex; position: absolute; left: 12px; top: 12px; z-index: 950; /* över panelen (900) */
    background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
    border-radius: 999px; padding: 11px 18px; font-size: .85rem; font-weight: 600; gap: 7px;
    cursor: pointer; align-items: center; font-family: var(--font-ui); color: var(--ink);
  }
}

/* ---------- nedtonad rörelse ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .rsec.loading .rsec-body::after { animation: none; }
  .layer-panel, .report-panel, .btn, .card { transition: none; }
}

/* ---------- print (platsrapporten) ---------- */
@media print {
  body.tool-body { height: auto; overflow: visible; }
  .tool-header, .layer-panel, #map, .layers-toggle, .map-welcome, .report-actions, .report-close { display: none !important; }
  .tool-main { display: block; }
  .report-panel { position: static; width: 100%; transform: none; box-shadow: none; }
  .report-scroll { overflow: visible; padding: 0; }
  .rsec { break-inside: avoid; }
  .report-panel::before { content: "Samhällsbyggarkartan — platsrapport (vägledande screening, ej beslutsunderlag)"; display: block; font-size: 11px; color: #666; margin-bottom: 12px; }
}
