/* Stugan – ljus & varm. Genomarbetat, lugnt designsystem. */

/* Självhostade variabla typsnitt (Inter brödtext, Bricolage Grotesque rubriker) */
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('/fonts/inter-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('/fonts/inter-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: 'Bricolage Grotesque'; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url('/fonts/bricolage-grotesque-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Bricolage Grotesque'; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url('/fonts/bricolage-grotesque-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

:root {
  --bg:        #F4F3F0;
  --surface:   #FFFFFF;
  --surface-2: #FAFAF8;
  --ink:       #25292E;
  --muted:     #7C8389;
  --line:      #E0DFD9;
  --line-soft: #ECEBE6;

  --primary:      #43698C;  /* dimblå */
  --primary-600:  #375777;
  --primary-tint: #E4ECF2;
  --on-primary:   #FFFFFF;

  /* Punkttyper */
  --t-camera: #C0694A;  /* terrakotta */
  --t-place:  #43698C;  /* dimblå */
  --t-land:   #B0822F;  /* ockra */
  --t-note:   #6E7681;  /* skiffergrå */

  --danger:   #B0413F;

  --radius:   16px;
  --radius-sm: 10px;
  --shadow:   0 6px 24px rgba(33, 41, 51, 0.10);
  --shadow-sm: 0 2px 8px rgba(33, 41, 51, 0.08);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Bricolage Grotesque', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }

/* ---------- Varumärke ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background:
    radial-gradient(circle at 50% 120%, var(--primary) 0 60%, transparent 61%),
    linear-gradient(160deg, #6E8FB0, var(--primary));
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.04);
}
.brand-mark::after {
  /* litet stuglikt tak-motiv */
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(135deg, transparent 46%, rgba(255,255,255,.85) 46% 54%, transparent 54%),
    linear-gradient(225deg, transparent 46%, rgba(255,255,255,.85) 46% 54%, transparent 54%);
  background-position: center 9px; background-size: 24px 12px; background-repeat: no-repeat;
}
.brand-mark.sm { width: 26px; height: 26px; border-radius: 8px; }
.brand-mark.sm::after { background-size: 18px 9px; background-position: center 7px; }
.wordmark {
  font-family: var(--font-display);
  font-weight: 600; letter-spacing: .3px; margin: 0;
  font-size: 26px; color: var(--ink);
}
.wordmark.sm { font-size: 19px; }

/* ---------- Login ---------- */
.login-view {
  min-height: 100%; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(120% 80% at 50% -10%, #ECEEF1 0%, var(--bg) 60%);
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 32px 28px;
  box-shadow: var(--shadow);
}
.login-card .brand { justify-content: center; margin-bottom: 6px; }
.login-sub { text-align: center; color: var(--muted); margin: 0 0 22px; font-size: 14px; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
  font: inherit; color: var(--ink);
  padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 70px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}

/* ---------- Knappar ---------- */
.btn {
  font: inherit; font-weight: 550; cursor: pointer;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 16px; transition: background .15s, border-color .15s, transform .05s;
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-600); }
.btn-ghost { background: transparent; color: var(--ink); border-color: transparent; }
.btn-ghost:hover { background: var(--line-soft); }
.btn-outline { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-outline:hover { border-color: var(--muted); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--line); }
.btn-danger:hover { background: #FBEDED; border-color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn svg, .panel-close svg { display: block; }
.sec-icon svg { display: block; }

.error { color: var(--danger); font-size: 13px; margin: 2px 0 0; }

/* ---------- Topbar ---------- */
.app-view { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--line);
  z-index: 600;
}
.topbar-brand {
  display: flex; align-items: center; gap: 9px;
  background: none; border: none; padding: 0; cursor: pointer; color: inherit;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
#user-name { font-weight: 550; color: var(--ink); }

/* ---------- Dashboard ---------- */
.dashboard {
  flex: 1; overflow-y: auto;
  width: 100%; max-width: 760px; margin: 0 auto;
  padding: 26px 18px calc(40px + env(safe-area-inset-bottom));
}
.dash-head { margin: 4px 2px 22px; }
.dash-greeting { color: var(--muted); font-size: 14px; margin: 0; }
.dash-cottage { font-family: var(--font-display); font-size: 30px; font-weight: 600; margin: 2px 0 0; letter-spacing: -.01em; }
.dash-info { color: var(--ink); font-size: 14px; line-height: 1.55; margin: 10px 0 0; white-space: pre-wrap; }
.dash-date { color: var(--muted); margin: 10px 0 0; font-size: 13px; text-transform: capitalize; }

.stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 10px; margin-bottom: 24px;
}
.stat-tile {
  background: var(--surface); border: 0.5px solid var(--line); border-radius: 12px;
  padding: 12px 12px; display: flex; flex-direction: column; gap: 7px;
}
.stat-tile.stat-total { background: var(--primary-tint); border-color: transparent; }
.stat-num { font-size: 22px; font-weight: 600; color: var(--ink); line-height: 1; }
.stat-total .stat-num { color: var(--primary-600); }
.stat-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat-label .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.section-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.section-card {
  text-align: left; background: var(--surface); border: 0.5px solid var(--line);
  border-radius: 16px; padding: 18px; display: flex; flex-direction: column;
  gap: 2px; cursor: pointer; font: inherit; box-shadow: var(--shadow-sm);
  transition: border-color .15s, transform .05s;
}
.section-card:hover { border-color: var(--muted); }
.section-card:active { transform: translateY(1px); }
.section-card.soon { cursor: default; box-shadow: none; opacity: .65; }
.section-card.soon:hover { border-color: var(--line); }
.sec-icon {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  font-size: 20px; margin-bottom: 10px; background: var(--line-soft);
}
.sec-title { font-size: 16px; font-weight: 600; color: var(--ink); }
.sec-sub { font-size: 13px; color: var(--muted); }
.sec-cta { font-size: 13px; font-weight: 550; color: var(--primary); margin-top: 8px; }
.sec-soon {
  align-self: flex-start; font-size: 11px; color: var(--muted);
  border: 0.5px solid var(--line); border-radius: 999px; padding: 2px 9px; margin-top: 8px;
}

/* ---------- Inställningar ---------- */
.settings-view { flex: 1; overflow-y: auto; }
.settings-wrap {
  width: 100%; max-width: 680px; margin: 0 auto;
  padding: 22px 18px calc(40px + env(safe-area-inset-bottom));
}
.settings-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.back-link {
  background: none; border: none; cursor: pointer; color: var(--primary);
  font: inherit; font-size: 14px; font-weight: 550; padding: 4px 0;
}
.back-link:hover { color: var(--primary-600); }
.view-title { font-family: var(--font-display); font-size: 23px; font-weight: 600; margin: 0; }
.settings-card {
  background: var(--surface); border: 0.5px solid var(--line); border-radius: 16px;
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.settings-section-title { font-size: 16px; font-weight: 600; margin: 0 0 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr 0.7fr; gap: 12px; }
.field-hint { font-size: 12px; color: var(--muted); margin: -2px 0 2px; line-height: 1.4; }

.sweref-box { background: var(--surface-2); border: 0.5px solid var(--line); border-radius: 10px; padding: 12px; }
.sweref-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.sweref-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }
.sweref-row input {
  font: inherit; color: var(--ink); padding: 9px 11px; border: 0.5px solid var(--line);
  border-radius: 8px; background: var(--surface); min-width: 0;
}
.sweref-row input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }

/* ---------- Layout / karta ---------- */
.map-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.layout { position: relative; flex: 1; min-height: 0; }
.map { position: absolute; inset: 0; background: #E6E7E5; }

/* ---------- Panel ---------- */
.panel {
  position: absolute; z-index: 650; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  top: 14px; right: 14px; width: 340px; max-width: calc(100% - 28px);
  border-radius: var(--radius); padding: 20px;
  max-height: calc(100% - 28px); overflow: auto;
}
.panel-close {
  position: absolute; top: 10px; right: 12px; border: none; background: none;
  font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px;
}
.panel-close:hover { color: var(--ink); }

/* ---------- FAB-rad ---------- */
.fab-row {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 640;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; padding-bottom: max(14px, env(safe-area-inset-bottom));
  pointer-events: none;
}
.fab-row > * { pointer-events: auto; }
.filter-chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 550;
  cursor: pointer; box-shadow: var(--shadow-sm); display: inline-flex; align-items: center; gap: 7px;
  transition: border-color .15s, color .15s, background .15s;
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip.active { color: var(--ink); border-color: currentColor; }
.chip[data-type="camera"].active { color: var(--t-camera); }
.chip[data-type="place"].active  { color: var(--t-place); }
.chip[data-type="land"].active   { color: var(--t-land); }
.chip[data-type="note"].active   { color: var(--t-note); }

.fab {
  border-radius: 999px; box-shadow: var(--shadow);
  padding: 12px 18px; font-size: 15px;
}
.fab .plus { font-size: 18px; margin-right: -2px; }

/* ---------- Markörer ---------- */
.marker-pin {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); border: 2px solid #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,.3); display: grid; place-items: center;
}
.marker-pin span { transform: rotate(45deg); font-size: 12px; line-height: 1; }
.marker-pin { cursor: pointer; }

/* Mapbox: lagerväljare (Terräng/Satellit) */
.style-switch {
  display: flex; background: var(--surface); border: 0.5px solid var(--line);
  border-radius: 999px; overflow: hidden; box-shadow: var(--shadow-sm);
}
.style-btn {
  font: inherit; font-size: 13px; font-weight: 550; border: none;
  background: transparent; color: var(--muted); padding: 7px 14px; cursor: pointer;
}
.style-btn.active { background: var(--primary); color: #fff; }

.map-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  text-align: center; color: var(--muted); font-size: 14px; padding: 24px; line-height: 1.6;
}

/* ---------- Punktdetaljer ---------- */
.point-type-badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted);
}
.point-type-badge .dot { width: 10px; height: 10px; border-radius: 50%; }
.panel h3 { margin: 10px 0 4px; font-size: 20px; }
.panel .desc { color: var(--ink); white-space: pre-wrap; line-height: 1.5; margin: 8px 0 0; }
.panel .meta { color: var(--muted); font-size: 12px; margin-top: 14px; }
.panel-actions { display: flex; gap: 8px; margin-top: 18px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 800; display: grid; place-items: center;
  background: rgba(28, 33, 40, .35); padding: 20px;
}
.modal-card {
  background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 520px;
  max-height: 86vh; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 20px; overflow: auto; }

/* Användarlista */
.user-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.user-row:last-child { border-bottom: none; }
.user-row .info { flex: 1; min-width: 0; }
.user-row .info strong { display: block; }
.user-row .info small { color: var(--muted); }
.role-tag {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  padding: 3px 8px; border-radius: 999px;
}
.role-tag.admin { background: var(--primary-tint); color: var(--primary-600); }
.role-tag.member { background: var(--line-soft); color: var(--muted); }
.divider { height: 1px; background: var(--line); margin: 18px 0; border: none; }
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 10px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 14px; z-index: 900; box-shadow: var(--shadow); animation: rise .2s ease;
}
.toast.error { background: var(--danger); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

.hint {
  background: var(--primary-tint); color: var(--primary-600);
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; font-weight: 550;
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 650; box-shadow: var(--shadow-sm);
}

/* ---------- Responsivt ---------- */
@media (max-width: 560px) {
  .panel {
    top: auto; bottom: 0; left: 0; right: 0; width: 100%; max-width: 100%;
    border-radius: var(--radius) var(--radius) 0 0; max-height: 70%;
  }
  .fab-row { flex-direction: column-reverse; align-items: stretch; }
  .fab { width: 100%; }
  .filter-chips { justify-content: center; }
  .user-chip #user-name { display: none; }
}
