/* Doberdò. Ascolta il Carso – WIP
   Direction: the app as an extension of the trail signage.
   Full-bleed photography, big condensed numerals, a reading serif, hairline rules,
   square corners, one accent (the red of the scotano / smoke bush in autumn).
   Swap the tokens below when the designer's brand arrives. */

:root {
  --paper: #f3f1ec;
  --ink: #161513;
  --ink-2: #4a4843;
  --ink-3: #77736b;
  --rule: rgba(22, 21, 19, .16);
  --accent: #b8321e;          /* scotano red */
  --on-dark: #f3f1ec;
  --on-dark-2: rgba(243, 241, 236, .62);
  --rule-dark: rgba(243, 241, 236, .18);
  --f-head: 'Fira Sans Condensed', 'Arial Narrow', sans-serif;
  --f-text: 'Vollkorn', Georgia, serif;
  --gutter: 20px;
  --top-h: 52px;
  --nav-h: 54px;
  --mini-h: 0px;
  --safe-t: env(safe-area-inset-top);
  --safe-b: env(safe-area-inset-bottom);
  --reading-scale: 1;
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--paper); }
body {
  font-family: var(--f-text);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + var(--mini-h) + var(--safe-b));
}
body.has-mini { --mini-h: 56px; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; border-radius: 0; }
a, button { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
img { display: block; max-width: 100%; }
.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 8px; top: 8px; z-index: 100; background: var(--paper); padding: 8px 12px; }
#view { outline: none; display: block; }

/* Small uppercase labels: the signage voice */
.label {
  font-family: var(--f-head);
  font-weight: 600;
  font-size: .78rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}

/* ---------- Top bar ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  height: calc(var(--top-h) + var(--safe-t));
  padding: var(--safe-t) var(--gutter) 0;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
}
body.ready .top { transition: background-color .25s, border-color .25s, color .25s; }
/* Over a photo (home, stop pages) until you scroll past it */
body.over .top { position: fixed; left: 0; right: 0; background: transparent; border-color: transparent; color: var(--on-dark); }
body.over.scrolled .top { background: var(--paper); border-color: var(--ink); color: var(--ink); }
.brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; font-family: var(--f-head); text-transform: uppercase; letter-spacing: .08em; flex: 1; min-width: 0; }
.brand b { font-weight: 800; font-size: 1rem; }
.brand span { font-weight: 500; font-size: 1rem; opacity: .6; }
.offline { font-family: var(--f-head); font-size: .72rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
body.over:not(.scrolled) .offline { color: var(--on-dark); }
.lang { display: flex; gap: 2px; }
.lang button { font-family: var(--f-head); font-weight: 600; font-size: .9rem; letter-spacing: .08em; padding: 8px 8px 6px; border-bottom: 2px solid transparent; opacity: .55; }
.lang button[aria-pressed="true"] { opacity: 1; border-bottom-color: currentColor; }

/* ---------- Photo heroes ---------- */
.photo-hero { position: relative; color: var(--on-dark); background: var(--ink); overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; }
.photo-hero > .bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, rgba(10, 10, 9, .55) 0, rgba(10, 10, 9, 0) 22%),
    linear-gradient(to top, rgba(10, 10, 9, .86) 0, rgba(10, 10, 9, .5) 38%, rgba(10, 10, 9, 0) 70%);
}
.photo-hero > .in { position: relative; z-index: 1; padding: 0 var(--gutter) 28px; }

/* Home */
.home-hero { min-height: 100vh; min-height: 100svh; }
.home-hero .in { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 28px); }
body.has-mini .home-hero .in { padding-bottom: calc(var(--nav-h) + var(--mini-h) + var(--safe-b) + 28px); }
.home-hero h1 {
  font-family: var(--f-head);
  font-weight: 800;
  text-transform: uppercase;
  font-size: clamp(3.6rem, 19.5vw, 8.5rem);
  line-height: .82;
  letter-spacing: -.01em;
  margin: 14px 0 6px;
}
.home-hero .sub { font-family: var(--f-text); font-style: italic; font-size: clamp(1.6rem, 7.5vw, 2.4rem); line-height: 1.1; }
.home-hero p.welcome { font-size: 1.02rem; line-height: 1.5; max-width: 30em; margin-top: 18px; color: rgba(243, 241, 236, .88); }
.cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 26px;
  padding: 18px 20px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-family: var(--f-head);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  max-width: 460px;
}
.cta small { display: block; font-weight: 500; font-size: .78rem; letter-spacing: .1em; opacity: .85; margin-top: 2px; }
.cta .arrow { font-size: 1.6rem; line-height: 1; }
.cta:active { background: #9c2a18; }

/* One orchestrated entrance, on the home page only */
.home-hero .in > * { animation: rise .7s cubic-bezier(.2, .7, .2, 1) both; }
.home-hero .in > :nth-child(2) { animation-delay: .08s; }
.home-hero .in > :nth-child(3) { animation-delay: .16s; }
.home-hero .in > :nth-child(4) { animation-delay: .24s; }
.home-hero .in > :nth-child(5) { animation-delay: .32s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* Stop */
.stop-hero { min-height: 64vh; min-height: 64svh; }
.stop-hero .in { padding-top: calc(var(--top-h) + var(--safe-t) + 12px); }
.back { position: absolute; z-index: 2; left: var(--gutter); top: calc(var(--top-h) + var(--safe-t) + 4px); }
.back a { font-family: var(--f-head); font-weight: 600; font-size: .85rem; letter-spacing: .12em; text-transform: uppercase; text-decoration: none; display: inline-block; padding: 8px 0; }
.stop-hero .num { font-family: var(--f-head); font-weight: 800; font-size: clamp(6rem, 34vw, 10rem); line-height: .78; letter-spacing: -.02em; }
.stop-hero .meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 16px 0 8px; color: var(--on-dark-2); }
.stop-hero .meta .cat { color: var(--on-dark); }
.stop-hero h1 { font-family: var(--f-text); font-weight: 600; font-size: clamp(1.75rem, 7.6vw, 2.6rem); line-height: 1.1; max-width: 18em; }

/* ---------- Page blocks ---------- */
.page-head { padding: 28px var(--gutter) 0; }
.page-head h1 { font-family: var(--f-head); font-weight: 800; text-transform: uppercase; font-size: clamp(2.6rem, 13vw, 4rem); line-height: .88; margin-top: 10px; }
.block { margin: 44px var(--gutter) 0; border-top: 1px solid var(--ink); padding-top: 12px; }
.block > .label { display: block; margin-bottom: 18px; }
.lead { font-size: 1.32rem; line-height: 1.45; }
.wrap { max-width: 720px; margin: 0 auto; }

/* Three dimensions: a typographic list, not cards */
.dims { list-style: none; }
.dims li { padding: 18px 0 20px; border-top: 1px solid var(--rule); }
.dims li:first-child { border-top: 0; padding-top: 0; }
.dims h3 { font-family: var(--f-head); font-weight: 800; text-transform: uppercase; font-size: 2rem; line-height: 1; letter-spacing: .01em; }
.dims p { margin-top: 8px; color: var(--ink-2); }
.dims .go { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 10px; }
.dims .go a { font-family: var(--f-head); font-weight: 600; font-size: 1rem; text-decoration: none; border-bottom: 2px solid var(--accent); padding-bottom: 1px; }

.steps { list-style: none; counter-reset: s; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 48px 1fr; gap: 8px; padding: 14px 0; border-top: 1px solid var(--rule); }
.steps li:first-child { border-top: 0; padding-top: 0; }
.steps li::before { content: counter(s); font-family: var(--f-head); font-weight: 800; font-size: 2.2rem; line-height: .9; color: var(--accent); }

.foot { margin: 40px var(--gutter) 0; padding: 14px 0 24px; border-top: 1px solid var(--rule); font-size: .82rem; color: var(--ink-3); line-height: 1.5; }
.foot a { color: var(--ink-2); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 50px; padding: 0 20px; font-family: var(--f-head); font-weight: 600; font-size: 1rem; letter-spacing: .08em; text-transform: uppercase; text-decoration: none; }
.btn-ink { background: var(--ink); color: var(--on-dark); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-line { border: 1px solid var(--ink); }
.btn-block { width: 100%; }
.link-btn { font-family: var(--f-head); font-weight: 600; font-size: .9rem; letter-spacing: .1em; text-transform: uppercase; border-bottom: 2px solid var(--accent); padding: 4px 0 2px; }

/* Install strip (home) */
.strip { display: flex; align-items: center; gap: 14px; margin: 0 var(--gutter); padding: 14px 0; border-bottom: 1px solid var(--rule); }
.strip p { flex: 1; font-size: .98rem; }
.strip .x { font-size: 1.5rem; line-height: 1; width: 36px; height: 36px; color: var(--ink-3); }

/* Offline */
.meter { height: 3px; background: var(--rule); margin: 14px 0 10px; }
.meter span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.offline-text { color: var(--ink-2); margin-bottom: 16px; }
.done-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.done-line strong { font-family: var(--f-head); font-weight: 600; font-size: 1.05rem; }
.done-line strong::before { content: '✓ '; color: var(--accent); }

/* ---------- Stop list (index) ---------- */
.progress { display: flex; align-items: baseline; gap: 14px; margin-top: 18px; color: var(--ink-2); }
.progress b { font-family: var(--f-head); font-weight: 800; font-size: 2.2rem; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.progress .meter { flex: 1; margin: 0; align-self: center; }
.index { list-style: none; margin: 26px var(--gutter) 0; border-top: 1px solid var(--ink); }
.index li { border-bottom: 1px solid var(--rule); }
.row { display: grid; grid-template-columns: 62px 1fr 76px; gap: 12px; align-items: center; padding: 16px 0; text-decoration: none; }
.row:active { background: rgba(22, 21, 19, .04); }
.row .n { font-family: var(--f-head); font-weight: 800; font-size: 3.3rem; line-height: .8; letter-spacing: -.02em; }
.row .t { font-weight: 600; font-size: 1.12rem; line-height: 1.25; margin-top: 4px; }
.row .m { color: var(--ink-3); display: flex; gap: 6px 12px; flex-wrap: wrap; }
.row .s { font-family: var(--f-head); font-size: .85rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-top: 4px; }
.row img { width: 76px; height: 76px; object-fit: cover; background: var(--rule); }
.row.is-done .n { color: var(--ink-3); }

/* ---------- Player ("deck") ---------- */
.deck { background: var(--ink); color: var(--on-dark); padding: 20px var(--gutter) 18px; }
.deck-head { display: flex; align-items: center; gap: 16px; }
.play { flex-shrink: 0; width: 64px; height: 64px; display: grid; place-items: center; background: var(--accent); color: #fff; position: relative; }
.play svg { width: 26px; height: 26px; fill: currentColor; }
.play:active { background: #9c2a18; }
.deck.is-loading .play::after { content: ''; position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: #fff; animation: load 1s ease-in-out infinite; transform-origin: left; }
@keyframes load { 0% { transform: scaleX(0); } 60% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }
.deck-info { min-width: 0; flex: 1; }
.deck-info .label { color: var(--on-dark-2); display: block; }
.deck-info .ti { font-family: var(--f-head); font-weight: 500; font-size: 1.15rem; line-height: 1.2; margin-top: 3px; }
.time { font-family: var(--f-head); font-weight: 600; font-size: 1.05rem; font-variant-numeric: tabular-nums; letter-spacing: .02em; margin-top: 3px; }
.time .of { color: var(--on-dark-2); }
.resume { font-family: var(--f-head); font-size: .85rem; color: #ffb4a6; margin-top: 2px; }
.seek { --p: 0%; display: block; width: 100%; height: 30px; margin-top: 12px; -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer; }
.seek::-webkit-slider-runnable-track { height: 3px; background: linear-gradient(to right, var(--on-dark) var(--p), var(--rule-dark) var(--p)); }
.seek::-moz-range-track { height: 3px; background: var(--rule-dark); }
.seek::-moz-range-progress { height: 3px; background: var(--on-dark); }
.seek::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--on-dark); margin-top: -5.5px; }
.seek::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--on-dark); }
.ctrl { display: flex; border-top: 1px solid var(--rule-dark); margin-top: 8px; }
.ctrl button { flex: 1; height: 46px; font-family: var(--f-head); font-weight: 600; font-size: .95rem; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.ctrl button + button { border-left: 1px solid var(--rule-dark); }
.ctrl button:active { background: rgba(255, 255, 255, .08); }
.parts { list-style: none; margin-top: 10px; border-top: 1px solid var(--rule-dark); }
.parts button { width: 100%; display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: baseline; text-align: left; padding: 12px 0; border-bottom: 1px solid var(--rule-dark); font-family: var(--f-head); }
.parts .pn { font-weight: 800; font-size: 1.3rem; line-height: 1; color: var(--on-dark-2); }
.parts .pt { font-size: 1.05rem; font-weight: 500; }
.parts .pd { font-size: .9rem; color: var(--on-dark-2); font-variant-numeric: tabular-nums; }
.parts button.is-current .pn, .parts button.is-current .pt { color: #ff8f7a; }
.deck--compact { padding: 14px 16px 6px; margin-bottom: 20px; }
.deck--compact .play { width: 48px; height: 48px; }
.deck--compact .play svg { width: 20px; height: 20px; }

/* ---------- Reading ---------- */
.read-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.textsize { font-family: var(--f-text); font-weight: 700; font-size: 1.05rem; padding: 4px 2px; border-bottom: 2px solid var(--ink); }
.prose { font-size: calc(1.14rem * var(--reading-scale)); line-height: 1.66; max-width: 36em; }
.prose p + p { margin-top: .85em; }
.prose .part { transition: opacity .3s; scroll-margin-top: 90px; }
.prose .part + .part { margin-top: 1.8em; }
.prose .part h3 { font-family: var(--f-head); font-weight: 600; font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); margin-bottom: .7em; }
.prose .part h3 b { color: var(--accent); font-weight: 800; margin-right: 6px; }
.prose.has-current .part:not(.is-current) { opacity: .5; }
.prose.has-current .part.is-current h3 { color: var(--ink); }

.extra { margin: 52px var(--gutter) 0; border-top: 6px solid var(--ink); padding-top: 14px; }
.extra h2 { font-family: var(--f-text); font-weight: 600; font-size: 1.7rem; line-height: 1.15; margin: 12px 0 10px; }
.extra .intro { font-style: italic; font-size: 1.15rem; color: var(--ink-2); margin-bottom: 20px; }
.extra .prose { font-size: calc(1.06rem * var(--reading-scale)); }
.switch { display: flex; gap: 22px; margin-bottom: 18px; border-bottom: 1px solid var(--rule); }
.switch button { font-family: var(--f-head); font-weight: 600; font-size: .9rem; letter-spacing: .1em; text-transform: uppercase; padding: 8px 0; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--ink-3); }
.switch button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

.finish { margin: 0 var(--gutter); padding: 16px 0; border-bottom: 1px solid var(--rule); font-family: var(--f-head); font-size: 1.05rem; }
.finish b { color: var(--accent); }
.finish a { font-weight: 600; }

.pager { display: grid; grid-template-columns: 1fr 1fr; margin: 52px var(--gutter) 0; border-top: 1px solid var(--ink); }
.pager a { padding: 14px 0 18px; text-decoration: none; display: flex; flex-direction: column; gap: 4px; }
.pager a.next { grid-column: 2; text-align: right; border-left: 1px solid var(--rule); padding-left: 14px; }
.pager a.prev { padding-right: 14px; }
.pager .label { color: var(--ink-3); }
.pager b { font-family: var(--f-head); font-weight: 800; font-size: 2.4rem; line-height: .9; }
.pager span.t { font-weight: 600; line-height: 1.25; }

/* ---------- QR ---------- */
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 24px 16px; }
.qr-item svg { width: 100%; height: auto; background: #fff; }
.qr-item b { display: block; font-family: var(--f-head); font-weight: 600; margin-top: 8px; }
.qr-item code { display: block; font-size: .72rem; color: var(--ink-3); word-break: break-all; }

/* ---------- Mini player ---------- */
.mini {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--nav-h) + var(--safe-b));
  z-index: 30;
  height: 56px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 4px 0 var(--gutter);
  background: var(--ink); color: var(--on-dark);
}
.mini-bar { position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--rule-dark); }
.mini-bar span { display: block; height: 100%; width: 0; background: var(--accent); }
.mini-play { width: 40px; height: 40px; display: grid; place-items: center; background: var(--accent); color: #fff; flex-shrink: 0; }
.mini-play svg { width: 18px; height: 18px; fill: currentColor; }
.mini-info { flex: 1; min-width: 0; display: flex; flex-direction: column; text-decoration: none; line-height: 1.2; font-family: var(--f-head); }
.mini-kicker { font-size: .72rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--on-dark-2); }
.mini-title { font-size: 1rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-close { width: 48px; height: 48px; font-size: 1.6rem; line-height: 1; color: var(--on-dark-2); }

/* ---------- Bottom navigation: words, not icons ---------- */
.tabs-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 25;
  display: flex;
  background: var(--paper);
  border-top: 1px solid var(--ink);
  padding-bottom: var(--safe-b);
}
.tabs-nav a { flex: 1; height: var(--nav-h); display: grid; place-items: center; text-decoration: none; font-family: var(--f-head); font-weight: 600; font-size: .88rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); position: relative; }
.tabs-nav a + a { border-left: 1px solid var(--rule); }
.tabs-nav a[aria-current="page"] { color: var(--ink); }
.tabs-nav a[aria-current="page"]::before { content: ''; position: absolute; left: 0; right: 0; top: -1px; height: 4px; background: var(--accent); }

/* ---------- Sheet & toast ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: none; align-items: flex-end; justify-content: center; background: rgba(16, 15, 14, .55); }
.sheet.show { display: flex; }
.sheet-panel { width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; background: var(--paper); border-top: 6px solid var(--ink); padding: 22px var(--gutter) calc(20px + var(--safe-b)); animation: sheet .25s cubic-bezier(.2, .7, .2, 1); }
.sheet-panel h2 { font-family: var(--f-head); font-weight: 800; text-transform: uppercase; font-size: 2rem; line-height: .95; }
.sheet-panel > p { color: var(--ink-2); margin-top: 10px; }
.install-steps { margin: 20px 0; border-top: 1px solid var(--rule); padding-top: 14px; }
.install-steps h3 { font-family: var(--f-head); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; font-size: .8rem; color: var(--ink-3); margin-bottom: 6px; }
.install-steps .steps li { grid-template-columns: 34px 1fr; padding: 10px 0; }
.install-steps .steps li::before { font-size: 1.6rem; }
.sheet-actions { display: grid; gap: 10px; }
@keyframes sheet { from { transform: translateY(30px); opacity: 0; } }

.toast { position: fixed; left: var(--gutter); right: var(--gutter); top: calc(var(--top-h) + var(--safe-t) + 8px); z-index: 60; background: var(--ink); color: var(--on-dark); padding: 12px 16px; font-family: var(--f-head); font-size: .95rem; opacity: 0; transform: translateY(-6px); pointer-events: none; transition: opacity .2s, transform .2s; max-width: 520px; margin: 0 auto; }
.toast.show { opacity: 1; transform: none; }

.empty { padding: 120px var(--gutter); font-family: var(--f-head); font-size: 1.2rem; }

@media (min-width: 760px) {
  :root { --gutter: 40px; }
  .stop-hero .in, .home-hero .in { max-width: 1000px; }
  .block, .index, .pager, .extra, .finish, .page-head, .strip, .foot { max-width: 760px; margin-left: auto; margin-right: auto; }
  .page-head { padding-left: 0; padding-right: 0; }
  .deck { padding-left: max(var(--gutter), calc((100% - 760px) / 2)); padding-right: max(var(--gutter), calc((100% - 760px) / 2)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
