/* =========================================================
   bystrom.se – stilmall
   2017-03  Örjan   Första versionen
   2026-11          Ny responsiv design (mobil, mörkt läge).
   2026-11          Bildvisare, karta över resorna, bildtexter.
   ========================================================= */

:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --text: #2a2420;
  --muted: #6b6058;
  --line: #e6ddd2;
  --accent: #a8461f;
  --accent-soft: #f3e3d8;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 6px 20px rgb(0 0 0 / .07);
  --radius: 10px;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16130f;
    --surface: #211c18;
    --text: #efe8df;
    --muted: #b3a698;
    --line: #3a322b;
    --accent: #e58e62;
    --accent-soft: #3a261b;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 6px 20px rgb(0 0 0 / .35);
  }
}

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

html { scroll-behavior: smooth; scroll-padding-top: 72px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 var(--sans);
  -webkit-text-size-adjust: 100%;
}

img { max-width: 100%; height: auto; }

/* "hidden" ska alltid dölja, även element som har display: flex/grid */
[hidden] { display: none !important; }

a { color: var(--accent); }
a:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: clamp(2rem, 5vw + 1rem, 3.4rem); letter-spacing: -.01em; }
h2 { font-size: clamp(1.4rem, 2vw + 1rem, 1.9rem); }
h3 { font-size: 1.2rem; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

.skip {
  position: absolute; left: -9999px; top: 8px;
  background: var(--surface); padding: 8px 14px; border-radius: 6px; z-index: 100;
}
.skip:focus { left: 8px; }

/* ---------- Sidhuvud ---------- */
.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.site-header .wrap {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 24px; padding-top: 14px; padding-bottom: 14px;
}
.brand {
  font-family: var(--serif); font-size: 1.45rem; font-weight: 600;
  color: var(--text); text-decoration: none;
}
.brand span { color: var(--accent); }

.site-nav ul { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; }
.site-nav a {
  display: block; padding: 6px 12px; border-radius: 999px;
  color: var(--text); text-decoration: none; font-weight: 500;
}
.site-nav a:hover { background: var(--accent-soft); }
.site-nav a[aria-current="page"], .site-nav a.active { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) {
  .site-nav a[aria-current="page"], .site-nav a.active { color: #16130f; }
}

/* ---------- Innehåll ---------- */
/* (#main i stället för main – annars vinner .wrap och luften under menyn försvinner) */
#main { padding-top: 36px; padding-bottom: 56px; }

.breadcrumb { font-size: .9rem; color: var(--muted); margin-bottom: 12px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb span[aria-hidden] { margin: 0 6px; }

.hero { margin-bottom: 28px; }
.kicker {
  text-transform: uppercase; letter-spacing: .12em; font-size: .78rem;
  font-weight: 600; color: var(--accent); margin: 0 0 6px;
}
.lead { font-size: 1.15rem; color: var(--muted); max-width: 60ch; margin: 0; }

section { margin-top: 48px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Kollage (2 x 2 på mobil, 4 i rad på dator) */
.collage {
  display: grid; gap: 10px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 800px) { .collage { grid-template-columns: repeat(4, 1fr); } }
.collage img {
  display: block; width: 100%; aspect-ratio: 35 / 26; object-fit: cover;
  border-radius: var(--radius); background: var(--line);
}

/* Kort (resor och album) */
.cards { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
  color: inherit; text-decoration: none; transition: transform .2s;
}
.card:hover { transform: translateY(-3px); }
.card img { display: block; width: 100%; aspect-ratio: 35 / 26; object-fit: cover; }
.card-body { padding: 14px 16px 18px; }
.card-body h3 { margin-bottom: 4px; }
.card-body p { margin: 0; color: var(--muted); font-size: .95rem; }
.card-cta { display: inline-block; margin-top: 10px; color: var(--accent); font-weight: 600; }

/* Stort kort (senaste resan på startsidan) */
.feature { display: grid; }
@media (min-width: 760px) {
  .feature { grid-template-columns: 1.1fr 1fr; }
  .feature img { height: 100%; aspect-ratio: auto; }
  .feature .card-body { padding: 28px; align-self: center; }
}

/* Text */
.prose { max-width: 65ch; }
.prose p { margin: 0 0 .7em; }

.about { display: grid; gap: 28px; align-items: start; }
@media (min-width: 760px) { .about { grid-template-columns: 1fr 1fr; } }
.about figure { margin: 0; }
.about img { display: block; width: 100%; border-radius: var(--radius); }
figcaption { font-size: .9rem; color: var(--muted); margin-top: 6px; }

/* ---------- Resedagbok ---------- */
.trip-facts { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.trip-facts li {
  background: var(--accent-soft); color: var(--text);
  padding: 4px 12px; border-radius: 999px; font-size: .9rem;
}

.day-nav {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  margin: 28px -16px 0; padding: 10px 16px;
}
.day-nav ul {
  display: flex; gap: 6px; margin: 0; padding: 0; list-style: none;
  overflow-x: auto; scrollbar-width: none;
}
.day-nav ul::-webkit-scrollbar { display: none; }
.day-nav a {
  display: block; white-space: nowrap; padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: .9rem;
}
.day-nav a:hover { border-color: var(--accent); color: var(--accent); }

.day { margin-top: 44px; }
.day-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.day-head .date { color: var(--accent); font-weight: 600; font-size: .95rem; }
.day .prose { margin: 6px 0 16px; color: var(--muted); }
.day .prose p { margin: 0 0 .25em; }

/* Bildgalleri: rader med jämn höjd, oavsett liggande/stående bilder */
.gallery { display: flex; flex-wrap: wrap; gap: 8px; }
.gallery::after { content: ""; flex-grow: 999; }
.gallery img {
  --r: 1.346;                       /* liggande bild 350 x 260 */
  flex: var(--r) 1 calc(var(--r) * 120px);
  display: block; min-width: 0; height: auto;
  border-radius: 6px; background: var(--line);
}
.gallery img.p { --r: .743; }       /* stående bild 260 x 350 */
@media (min-width: 700px) { .gallery img { flex-basis: calc(var(--r) * 190px); } }

.note { font-size: .9rem; color: var(--muted); font-style: italic; }

/* ---------- Bildvisare (js/gallery.js) ---------- */
.zoomable { cursor: zoom-in; transition: filter .2s, transform .2s; }
.zoomable:hover { filter: brightness(1.08); }
.zoomable:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.lightbox {
  position: fixed; inset: 0; width: auto; height: auto; max-width: none; max-height: none;
  border: 0; padding: 0; margin: 0; background: transparent; overflow: hidden;
}
.lightbox::backdrop { background: rgb(10 8 6 / .93); }
.lightbox[open] { display: grid; place-items: center; }
.lightbox figure { margin: 0; padding: 0 12px; }
.lightbox img {
  display: block; margin: 0 auto; border-radius: 6px; background: #222;
  width: min(92vw, 640px, calc(74vh * var(--ar, 1.346)));
  aspect-ratio: var(--ar, 1.346); height: auto; object-fit: contain;
}
/* Stora bilder (från verktyg\bygg.ps1) får ta upp nästan hela skärmen */
.lightbox img.hires { width: min(94vw, 1800px, calc(80vh * var(--ar, 1.5))); }
.lightbox figcaption {
  display: flex; justify-content: space-between; gap: 16px;
  max-width: min(92vw, 640px); margin: 12px auto 0;
  color: #efe8df; font-size: .95rem;
}
.lightbox figure:has(img.hires) figcaption { max-width: min(94vw, 1800px, calc(80vh * var(--ar, 1.5))); }
.lb-count { color: #b3a698; white-space: nowrap; }
.lb-btn {
  position: absolute; z-index: 2; border: 0; cursor: pointer;
  width: 48px; height: 48px; border-radius: 50%;
  background: rgb(255 255 255 / .14); color: #fff; font-size: 30px; line-height: 1;
}
.lb-btn:hover { background: rgb(255 255 255 / .28); }
.lb-close { top: 14px; right: 14px; }
.lb-prev { left: 14px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 14px; top: 50%; transform: translateY(-50%); }
@media (max-width: 700px) {
  .lb-prev, .lb-next { top: auto; bottom: 20px; transform: none; }
  .lb-prev { left: calc(50% - 60px); }
  .lb-next { right: calc(50% - 60px); }
}

/* ---------- Karta (js/map.js) ---------- */
.map {
  height: 440px; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); background: var(--line); z-index: 0;
}
@media (max-width: 600px) { .map { height: 320px; } }
.leaflet-container { font: inherit; }
.leaflet-popup-content a { font-weight: 600; }

.places { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; }
.places li {
  padding: 4px 12px; border-radius: 999px; font-size: .9rem;
  border: 1px dashed var(--line); color: var(--muted);
}
.places li:has(a) { border: 1px solid var(--accent); background: var(--accent-soft); }
.places a { color: var(--text); font-weight: 600; text-decoration: none; }
.places a::after { content: " →"; color: var(--accent); }
.legend { font-size: .85rem; color: var(--muted); margin: 10px 0 0; }
.legend .dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--accent); vertical-align: -1px; margin: 0 4px 0 10px;
}
.legend .dot.full { background: var(--accent); }

/* ---------- Sidfot ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 24px 0 40px; color: var(--muted); font-size: .9rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }
.site-footer p { margin: 0; }
.site-footer a { color: var(--muted); }

.back-top { display: inline-block; margin-top: 10px; font-size: .9rem; color: var(--muted); }

/* ---------- Kontaktformulär ---------- */
.contact-form { display: grid; gap: 6px; max-width: 560px; }
.contact-form label { font-weight: 600; margin-top: 12px; }
.contact-form .hint { font-weight: 400; color: var(--muted); font-size: .9rem; }
.contact-form input, .contact-form textarea {
  font: inherit; font-size: 17px;          /* minst 16 px – annars zoomar iPhone in */
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; width: 100%;
}
.contact-form textarea { resize: vertical; min-height: 160px; }
.contact-form input:focus, .contact-form textarea:focus { outline: 3px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.contact-form button {
  justify-self: start; margin-top: 18px; cursor: pointer;
  font: inherit; font-weight: 600; color: #fff; background: var(--accent);
  border: 0; border-radius: 999px; padding: 13px 26px; touch-action: manipulation;
}
@media (prefers-color-scheme: dark) { .contact-form button { color: #16130f; } }
.contact-form button:hover { filter: brightness(1.08); }
.contact-form .note { margin-top: 8px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.notice { display: none; max-width: 560px; padding: 14px 16px; border-radius: var(--radius); margin: 0 0 20px; border: 1px solid; }
.notice:target { display: block; }
.notice.ok  { border-color: #3d8b5a; background: color-mix(in srgb, #3d8b5a 14%, var(--surface)); }
.notice.err { border-color: #b3412e; background: color-mix(in srgb, #b3412e 14%, var(--surface)); }

/* ---------- Startsidan ---------- */
section.first { margin-top: 8px; }
.map-small { height: 340px; }
@media (max-width: 600px) { .map-small { height: 260px; } }

/* ---------- Föregående / nästa resa (skapas av verktyg\bygg.ps1) ---------- */
.trip-pager { display: grid; gap: 12px; margin-top: 48px; }
@media (min-width: 600px) { .trip-pager { grid-template-columns: 1fr 1fr; } }
.trip-pager a {
  display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); text-decoration: none; font-family: var(--serif); font-size: 1.1rem;
}
.trip-pager a span { display: block; font-family: var(--sans); font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.trip-pager a.next { text-align: right; grid-column: 2; }
@media (max-width: 599px) { .trip-pager a.next { grid-column: auto; } }
.trip-pager a:hover { border-color: var(--accent); }

/* =========================================================
   iPhone och iPad
   ========================================================= */

/* Innehållet hamnar inte under "notchen" när telefonen hålls liggande */
.wrap {
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
.day-nav {
  margin-left: calc(-1 * max(16px, env(safe-area-inset-left)));
  margin-right: calc(-1 * max(16px, env(safe-area-inset-right)));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
.site-footer { padding-bottom: max(40px, calc(16px + env(safe-area-inset-bottom))); }

/* Bildvisaren: rätt höjd även när Safaris adressfält syns/döljs */
.lightbox img { width: min(92vw, 640px, calc(74dvh * var(--ar, 1.346))); }
.lightbox img.hires { width: min(94vw, 1800px, calc(80dvh * var(--ar, 1.5))); }
.lb-close { top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); }
@media (max-width: 700px) {
  .lb-prev, .lb-next { bottom: calc(20px + env(safe-area-inset-bottom)); }
}
/* Sidan bakom bildvisaren ska inte scrolla */
html:has(dialog[open]) { overflow: hidden; }

/* Inga fördröjda dubbeltryck på knappar och bilder */
.zoomable, .lb-btn, .site-nav a, .day-nav a, .card { touch-action: manipulation; }
* { -webkit-tap-highlight-color: transparent; }

/* Pekskärm: större tryckytor (Apple rekommenderar minst 44 px) */
@media (pointer: coarse) {
  .site-nav a { padding: 11px 14px; }
  .day-nav a { padding: 9px 14px; }
  .breadcrumb a, .site-footer a, .section-head > a { display: inline-block; padding: 10px 0; }
  .legend { line-height: 2; }
}

/* Pekskärm: inga "fastnade" hover-effekter efter tryck */
@media (hover: none) {
  .card:hover { transform: none; }
  .zoomable:hover { filter: none; }
  .site-nav a:hover { background: transparent; }
  .site-nav a[aria-current="page"]:hover, .site-nav a.active:hover { background: var(--accent); }
}

/* Smal telefon: menyn på egen rad under namnet, utan att bryta */
@media (max-width: 420px) {
  .site-header .wrap { padding-top: 10px; padding-bottom: 8px; }
  .site-nav { width: 100%; }
  .site-nav ul { justify-content: space-between; }
  .site-nav a { padding-left: 12px; padding-right: 12px; }
  .hero { margin-bottom: 20px; }
  #main { padding-top: 24px; }
}
