/* Girovago — strada e natura: asfalto, bosco, ocra, carta da viaggio. */
:root {
  --paper: #f4efe2;
  --paper-2: #ebe4d1;
  --card: #fffdf7;
  --ink: #22262a;
  --ink-2: #4d5459;
  --line: #d9d0b8;
  --asphalt: #23282c;
  --forest: #2f5d3a;
  --forest-2: #1f3d2a;
  --moss: #6f8f4e;
  --ochre: #c9821a;
  --ochre-2: #e8a33d;
  --sky: #2f6f8f;
  --danger: #a8321f;
  --ok: #2f6b3a;
  --warn: #8a5a00;
  --focus: #1b64d6;
  --shadow: 0 1px 2px rgb(30 25 10 / .12), 0 6px 18px rgb(30 25 10 / .08);
  --on-forest: #fff;
  --radius: 14px;
  --nav-h: 62px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
:root[data-theme="dark"] {
  --paper: #171a18; --paper-2: #1e2320; --card: #232826; --ink: #ece8da; --ink-2: #b5b9ae; --line: #38403a;
  --forest: #7cb38a; --forest-2: #12241a; --moss: #9bbf75; --ochre: #e8a33d; --ochre-2: #f0b95e; --sky: #78b4d1;
  --danger: #ff8e7a; --ok: #8ccf98; --warn: #f0c36a; --focus: #7fb0ff; --asphalt: #0f1211;
  --shadow: 0 1px 2px rgb(0 0 0 / .5), 0 6px 18px rgb(0 0 0 / .35); --on-forest: #10211a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #171a18; --paper-2: #1e2320; --card: #232826; --ink: #ece8da; --ink-2: #b5b9ae; --line: #38403a;
    --forest: #7cb38a; --forest-2: #12241a; --moss: #9bbf75; --ochre: #e8a33d; --ochre-2: #f0b95e; --sky: #78b4d1;
    --danger: #ff8e7a; --ok: #8ccf98; --warn: #f0c36a; --focus: #7fb0ff; --asphalt: #0f1211;
    --shadow: 0 1px 2px rgb(0 0 0 / .5), 0 6px 18px rgb(0 0 0 / .35); --on-forest: #10211a;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font: 16px/1.45 var(--sans); -webkit-text-size-adjust: 100%; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.15; margin: 0 0 .5rem; letter-spacing: .005em; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
a { color: var(--sky); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--asphalt); color: #fff; padding: .6rem 1rem; z-index: 10000; }
.skip:focus { left: 0; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 1rem; }

/* Guscio: tab in basso su mobile, barra laterale da 900px */
.shell { display: flex; flex-direction: column; height: 100%; }
#main { flex: 1; min-height: 0; overflow: auto; outline: none; padding-bottom: var(--nav-h); }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--forest-2); display: flex; z-index: 2000; border-top: 3px solid var(--ochre);
}
.nav .brand { display: none; }
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: #d8e3d4; text-decoration: none; font-size: .72rem; min-width: 0; padding: 4px 2px;
}
.nav a svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a[aria-current="page"] { color: #fff; background: rgb(255 255 255 / .1); box-shadow: inset 0 3px 0 var(--ochre-2); }
.nav a:focus-visible { outline-color: #fff; outline-offset: -4px; }
@media (min-width: 900px) {
  .shell { flex-direction: row; }
  #main { padding-bottom: 0; }
  .nav {
    position: static; width: 220px; height: auto; flex-direction: column; justify-content: flex-start; padding: 1rem .6rem;
    border-top: 0; border-right: 4px solid var(--ochre); gap: 4px;
  }
  .nav .brand { display: flex; align-items: center; gap: .6rem; color: #fff; font: 700 1.35rem var(--serif); padding: .2rem .6rem 1.2rem; }
  .nav .brand img { width: 38px; height: 38px; border-radius: 10px; }
  .nav a { flex: 0; flex-direction: row; justify-content: flex-start; gap: .8rem; padding: .7rem .8rem; font-size: 1rem; border-radius: 10px; }
  .nav a[aria-current="page"] { box-shadow: inset 4px 0 0 var(--ochre-2); }
}

/* Pagine */
.page { max-width: 880px; margin: 0 auto; padding: 1rem 1rem 2rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.hero {
  background: linear-gradient(180deg, var(--forest-2), #2b5236); color: #f4efe2; border-radius: var(--radius);
  padding: 1.2rem 1.1rem; margin-bottom: 1rem; position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 14px; height: 4px; opacity: .8;
  background: repeating-linear-gradient(90deg, var(--ochre-2) 0 22px, transparent 22px 44px);
}
.hero h1, .hero h2 { color: #fff; } .hero p { color: #d8e3d4; margin-bottom: 1.1rem; }

/* Componenti */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: .9rem; }
.card h3 { margin-bottom: .25rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .6rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; }
.btn {
  appearance: none; border: 2px solid var(--forest); background: var(--forest); color: var(--on-forest); font: 600 .95rem var(--sans);
  padding: .55rem 1rem; min-height: 44px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: transparent; color: var(--forest); }
.btn.ochre { background: var(--ochre); border-color: var(--ochre); color: #1c1608; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.small { min-height: 36px; padding: .3rem .75rem; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { min-width: 44px; min-height: 44px; padding: 0; justify-content: center; }
label.field { display: block; font-weight: 600; font-size: .9rem; }
label.field > span { display: block; margin-bottom: .2rem; }
input, select, textarea {
  width: 100%; font: 400 1rem var(--sans); color: var(--ink); background: var(--card); border: 2px solid var(--line);
  border-radius: 10px; padding: .55rem .7rem; min-height: 44px;
}
textarea { min-height: 90px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--forest); }
.check { display: flex; align-items: center; gap: .5rem; min-height: 44px; font-weight: 500; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  border: 2px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: .25rem .7rem; min-height: 36px;
  font: 600 .85rem var(--sans); cursor: pointer; display: inline-flex; align-items: center; gap: .35rem;
}
.chip[aria-pressed="true"] { background: var(--forest); border-color: var(--forest); color: var(--on-forest); }
.badge { display: inline-block; border-radius: 6px; padding: .1rem .5rem; font: 700 .75rem var(--sans); background: var(--paper-2); color: var(--ink); border: 1px solid var(--line); }
.badge.ok { color: var(--ok); border-color: var(--ok); } .badge.warn { color: var(--warn); border-color: var(--warn); } .badge.bad { color: var(--danger); border-color: var(--danger); }
.alert { border-left: 5px solid var(--ochre); background: var(--paper-2); padding: .6rem .8rem; border-radius: 8px; margin-bottom: .75rem; }
.alert.bad { border-color: var(--danger); } .alert.ok { border-color: var(--ok); }
.state { text-align: center; padding: 2rem 1rem; color: var(--ink-2); }
.state .big { font: 2rem var(--serif); color: var(--forest); }
.spinner { width: 28px; height: 28px; border: 4px solid var(--line); border-top-color: var(--forest); border-radius: 50%; margin: 0 auto .6rem; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } * { scroll-behavior: auto !important; } }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px dashed var(--line); padding: .6rem 0; }
.list > li:last-child { border-bottom: 0; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .5rem; margin: .5rem 0; }
.kv > div { background: var(--paper-2); border-radius: 10px; padding: .5rem .7rem; }
.kv b { display: block; font: 700 1.25rem var(--serif); }
.kv span { font-size: .78rem; color: var(--ink-2); }
.seg { display: inline-flex; border: 2px solid var(--forest); border-radius: 999px; overflow: hidden; margin-bottom: .9rem; }
.seg button { border: 0; background: transparent; color: var(--forest); font: 600 .9rem var(--sans); padding: .5rem 1rem; min-height: 40px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--forest); color: var(--on-forest); }
.bar { height: 10px; background: var(--paper-2); border-radius: 6px; overflow: hidden; } .bar > i { display: block; height: 100%; background: var(--ochre); }
.stars { color: var(--ochre); letter-spacing: 1px; }
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: .4rem; z-index: 6000; pointer-events: none; }
.toast { background: var(--asphalt); color: #fff; padding: .6rem 1rem; border-radius: 10px; box-shadow: var(--shadow); max-width: 90vw; pointer-events: auto; }
.toast.bad { background: var(--danger); color: #fff; }
@media (min-width: 900px) { .toasts { bottom: 20px; left: 220px; } }

/* Dialog */
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(560px, 94vw); max-height: 90vh; background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / .4); }
dialog::backdrop { background: rgb(10 15 10 / .55); }
dialog form { display: flex; flex-direction: column; max-height: 90vh; }
dialog header { padding: 1rem 1rem .4rem; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
dialog header h2 { margin: 0; }
dialog .body { padding: 1rem; overflow: auto; }
dialog footer { padding: .8rem 1rem; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
dialog .err { color: var(--danger); font-weight: 600; margin-top: .5rem; }

/* Mappa */
.mapview { position: relative; height: 100%; }
.mapview .map { position: absolute; inset: 0; }
.map-tools { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 900; display: flex; gap: .5rem; flex-wrap: wrap; pointer-events: none; }
.map-tools > * { pointer-events: auto; box-shadow: var(--shadow); }
.map-tools .btn, .map-tools .btn.secondary { background: var(--card); color: var(--ink); border-color: var(--line); }
.map-tools .btn.active, .btn.ochre { background: var(--ochre); border-color: var(--ochre); color: #1c1608; }
.map-note { position: absolute; left: 50%; transform: translateX(-50%); bottom: 14px; z-index: 900; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .4rem .8rem; box-shadow: var(--shadow); max-width: 92%; text-align: center; font-size: .85rem; }
.sheet {
  position: absolute; z-index: 1000; background: var(--card); box-shadow: 0 -6px 30px rgb(0 0 0 / .3); overflow: auto;
  left: 0; right: 0; bottom: 0; max-height: 72%; border-radius: 18px 18px 0 0; padding: 1rem;
}
@media (min-width: 900px) { .sheet { left: auto; right: 12px; top: 64px; bottom: 12px; width: 400px; max-height: none; border-radius: var(--radius); } }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: -.4rem auto .6rem; }
.pin { width: 30px; height: 30px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg); border: 2px solid #fff; display: grid; place-items: center; box-shadow: 0 2px 6px rgb(0 0 0 / .45); }
.pin span { transform: rotate(45deg); font: 700 13px var(--sans); color: #fff; }
.pin.fav { outline: 3px solid var(--ochre-2); }
.stopnum { width: 28px; height: 28px; border-radius: 50%; background: var(--asphalt); color: #fff; border: 2px solid var(--ochre-2); display: grid; place-items: center; font: 700 13px var(--sans); }
.leaflet-container { font-family: var(--sans); }
.tripmap { height: 320px; border-radius: var(--radius); border: 1px solid var(--line); margin-bottom: .9rem; z-index: 0; }
.stoplist { counter-reset: s; }
.stoplist > li { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: start; }
.stoplist .num { width: 30px; height: 30px; border-radius: 50%; background: var(--asphalt); color: #fff; display: grid; place-items: center; font-weight: 700; border: 2px solid var(--ochre-2); }
.leg { margin: 0 0 0 14px; padding: .15rem 0 .15rem 1.2rem; border-left: 4px dotted var(--ochre); color: var(--ink-2); font-size: .85rem; list-style: none; }
.legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .8rem; color: var(--ink-2); }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: .3rem; vertical-align: -1px; }
