/* andAndrea — catalog + guide reader styles. Phone-first (~390px), magazine feel. */

:root {
  --radius: 18px;
  --shadow: 0 10px 26px rgba(0, 0, 0, 0.12);
  --hairline: rgba(127, 127, 127, 0.25);
}

/* styles.css sets html/body height:100% for the install shell; on content
   pages that would clamp position:sticky to one screen — undo it. */
html:has(body.guides-body) { height: auto; }
body.guides-body {
  background: var(--paper);
  height: auto;
  min-height: 100dvh;
  margin: 0;
}

/* ---------- Top app bar (shared) ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 52px;
  padding: env(safe-area-inset-top) 0.9rem 0;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--hairline);
}
.appbar .bar-inner {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  min-height: 52px;
}
.appbar .back {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-left: -8px;
  border-radius: 50%;
  color: var(--magenta);
  text-decoration: none;
  font-size: 1.5rem;
  line-height: 1;
}
.appbar .back:active { background: rgba(218, 24, 132, 0.12); }
.appbar .bar-title {
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.appbar .bar-title.show { opacity: 1; }
.appbar .avatar-sm {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  object-fit: cover;
}

/* ---------- Catalog ---------- */
.catalog {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem 1rem calc(2rem + env(safe-area-inset-bottom));
}
.catalog-hello {
  margin: 0.6rem 0.15rem 1.1rem;
}
.catalog-hello h1 {
  font-size: 1.7rem;
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem;
}
.catalog-hello p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.5;
}
.card-grid { display: grid; gap: 1.1rem; }

.guide-card {
  position: relative;
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: #fff;
  aspect-ratio: 5 / 4;
  background: #222;
  transform: translateZ(0);
}
.guide-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.guide-card .scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 42%, rgba(0,0,0,0.72) 100%);
}
.guide-card .card-text {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 0.9rem;
}
.guide-card .kicker {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--magenta);
  border-radius: 999px;
  padding: 0.22rem 0.6rem;
  margin-bottom: 0.45rem;
}
.guide-card h2 {
  margin: 0 0 0.3rem;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-shadow: 0 2px 10px rgba(0,0,0,0.45);
}
.guide-card .meta {
  font-size: 0.82rem;
  opacity: 0.92;
}
.guide-card:active { filter: brightness(0.92); }

.catalog-empty {
  text-align: center;
  color: var(--muted);
  padding: 4rem 1.5rem;
  line-height: 1.6;
}

/* ---------- Store: locked cards, membership, login ---------- */
.appbar .account-link {
  margin-left: auto;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--magenta);
  text-decoration: none;
  padding: 0.4rem 0.2rem 0.4rem 0.8rem;
}

.guide-card.locked {
  aspect-ratio: auto;
  min-height: 200px;
  background: linear-gradient(135deg, #2b0a1e 0%, #5c1140 55%, var(--magenta) 160%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: 0.9rem;
  cursor: pointer;
}
.guide-card.locked .card-text {
  position: static;
  padding: 1.3rem 1rem 0.4rem;
}
.guide-card.locked .scrim { background: none; }
/* Locked card with public cover art: photo behind, darkened for legibility. */
.guide-card.locked.has-photo { background: #222; }
.guide-card.locked.has-photo .scrim {
  background: linear-gradient(180deg, rgba(0,0,0,0.22) 0%, rgba(0,0,0,0.78) 100%);
}
.guide-card.locked .card-text,
.guide-card.locked .btn-buy,
.guide-card.locked .locked-note { position: relative; z-index: 1; }
.card-teaser {
  font-size: 0.9rem;
  line-height: 1.5;
  opacity: 0.92;
  margin: 0.1rem 0 0.45rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.btn-buy {
  background: #fff;
  color: var(--magenta);
  margin: 0.35rem 1rem 0.2rem;
  min-height: 46px;
  font-size: 0.95rem;
}
.locked-note {
  color: #fff;
  opacity: 0.85;
  font-size: 0.85rem;
  margin: 0.2rem 1rem 0.4rem;
}

.membership-banner {
  border: 2px solid var(--magenta);
  border-radius: var(--radius);
  padding: 1.1rem 1.1rem 1.2rem;
  text-align: center;
}
.membership-banner h2 {
  margin: 0 0 0.3rem;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}
.membership-banner p {
  margin: 0 0 0.8rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}
.membership-banner .promo-line {
  color: var(--magenta);
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0 0 0.35rem;
}
.membership-banner .promo-line s { color: var(--muted); font-weight: 400; }
.membership-banner .btn { width: 100%; }
.member-signin {
  display: inline-block;
  margin-top: 0.7rem;
  font-size: 0.88rem;
  color: var(--magenta);
}

/* Login page */
.login-wrap {
  max-width: 26rem;
  margin: 0 auto;
  padding: 2.5rem 1.4rem calc(3rem + env(safe-area-inset-bottom));
  text-align: center;
}
.login-wrap .avatar { margin: 0 auto 0.9rem; }
.login-wrap h1 { font-size: 1.5rem; margin: 0 0 0.5rem; letter-spacing: -0.02em; }
.login-sub { color: var(--muted); font-size: 0.95rem; line-height: 1.55; margin: 0 0 1.2rem; }
#login-form { display: flex; flex-direction: column; gap: 0.7rem; }
#login-form input {
  min-height: 52px;
  border: 1.5px solid var(--hairline);
  border-radius: 14px;
  padding: 0 1rem;
  font-size: 1.05rem;
  font-family: inherit;
  background: var(--paper);
  color: var(--ink);
}
#login-form input:focus { outline: 2px solid var(--magenta); border-color: transparent; }
#code-form { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 0.9rem; }
.code-input {
  min-height: 56px;
  border: 1.5px solid var(--hairline);
  border-radius: 14px;
  font-size: 1.7rem;
  letter-spacing: 0.45em;
  text-align: center;
  font-family: inherit;
  background: var(--paper);
  color: var(--ink);
}
.code-input:focus { outline: 2px solid var(--magenta); border-color: transparent; }
.login-error { color: #d33; font-size: 0.9rem; margin: 0; }
.login-wrap a { color: var(--magenta); font-weight: 600; }
.login-sent { font-size: 1.15rem; margin: 0.6rem 0; }
.login-expired { color: var(--muted); font-size: 0.9rem; margin-top: 1.5rem; }

/* Locked-guide buy screen */
.buy-screen {
  max-width: 26rem;
  margin: 0 auto;
  padding: 3.5rem 1.4rem;
  text-align: center;
}
.buy-screen .kicker {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--magenta);
  color: #fff;
  border-radius: 999px;
  padding: 0.24rem 0.65rem;
  margin-bottom: 0.6rem;
}
.buy-screen h1 { font-size: 1.7rem; margin: 0 0 0.6rem; letter-spacing: -0.02em; }
.buy-teaser { color: var(--muted); line-height: 1.6; margin: 0 0 1.4rem; }
.buy-screen .btn { width: 100%; }
.buy-membership { color: var(--muted); font-size: 0.92rem; margin-top: 1rem; }
.linklike {
  background: none;
  border: none;
  color: var(--magenta);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.buy-back {
  display: inline-block;
  margin-top: 2rem;
  color: var(--magenta);
  text-decoration: none;
  font-weight: 600;
}

/* ---------- Reader ---------- */
.reader { max-width: 680px; margin: 0 auto; }

.hero-wrap { position: relative; }
.hero-wrap img {
  width: 100%;
  height: min(62vh, 560px);
  object-fit: cover;
  display: block;
}
.hero-wrap .scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.05) 30%, rgba(0,0,0,0.65) 100%);
}
.hero-text {
  position: absolute;
  left: 1.1rem;
  right: 1.1rem;
  bottom: 1.2rem;
  color: #fff;
}
.hero-text .kicker {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--magenta);
  border-radius: 999px;
  padding: 0.24rem 0.65rem;
  margin-bottom: 0.5rem;
}
.hero-text h1 {
  margin: 0 0 0.3rem;
  font-size: clamp(1.8rem, 7.5vw, 2.6rem);
  line-height: 1.08;
  letter-spacing: -0.025em;
  text-shadow: 0 2px 14px rgba(0,0,0,0.5);
}
.hero-text .byline { font-size: 0.9rem; opacity: 0.95; margin: 0; }

/* Chapter chips */
.chapters {
  position: sticky;
  top: calc(52px + env(safe-area-inset-top));
  z-index: 30;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.6rem 1rem;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--hairline);
  scrollbar-width: none;
}
.chapters::-webkit-scrollbar { display: none; }
.chapters a {
  flex: 0 0 auto;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  border: 1.5px solid var(--hairline);
  border-radius: 999px;
  padding: 0.38rem 0.85rem;
  white-space: nowrap;
}
.chapters a.active {
  background: var(--magenta);
  border-color: var(--magenta);
  color: #fff;
}

/* Article body */
.article { padding: 0.4rem 1.15rem 2rem; }
.article section { scroll-margin-top: calc(112px + env(safe-area-inset-top)); }
.article .sec-title {
  margin: 2.2rem 0 0.9rem;
  font-size: 1.55rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.article .sec-title::before {
  content: "";
  display: block;
  width: 44px;
  height: 4px;
  border-radius: 2px;
  background: var(--magenta);
  margin-bottom: 0.55rem;
}
.article h3 {
  font-size: 1.18rem;
  margin: 1.7rem 0 0.5rem;
  letter-spacing: -0.01em;
}
.article h4 {
  font-size: 1.04rem;
  margin: 1.5rem 0 0.35rem;
  padding-left: 0.7rem;
  border-left: 3px solid var(--magenta);
}
.article p { line-height: 1.68; margin: 0.65rem 0; font-size: 1.0rem; }
.article ol, .article ul { padding-left: 1.25rem; margin: 0.65rem 0; }
.article li { line-height: 1.6; margin: 0.5rem 0; }
.article a { color: var(--magenta); text-decoration-thickness: 1.5px; text-underline-offset: 2px; }

/* Figures & galleries */
.article figure { margin: 1.3rem -1.15rem; }
.article figure img {
  width: 100%;
  height: auto;
  display: block;
}
.article figcaption {
  font-size: 0.84rem;
  color: var(--muted);
  padding: 0.5rem 1.15rem 0;
  text-align: center;
  line-height: 1.45;
}
.gallery {
  display: flex;
  gap: 0.55rem;
  overflow-x: auto;
  margin: 1.3rem -1.15rem;
  padding: 0 1.15rem;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.gallery::-webkit-scrollbar { display: none; }
.gallery img {
  flex: 0 0 auto;
  height: 220px;
  width: auto;
  border-radius: 14px;
  scroll-snap-align: start;
  box-shadow: var(--shadow);
}
.gallery img, .article figure img { cursor: pointer; }

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.96);
  display: none;
}
.lightbox.open { display: block; }
.lightbox .lb-track {
  display: flex;
  height: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.lightbox .lb-track::-webkit-scrollbar { display: none; }
.lightbox .lb-slide {
  flex: 0 0 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  scroll-snap-align: center;
  padding: 3rem 0 2.4rem;
}
.lightbox .lb-slide img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.lightbox .lb-cap {
  color: #ddd;
  font-size: 0.85rem;
  padding: 0.6rem 1.2rem 0;
  text-align: center;
}
.lightbox .lb-close {
  position: absolute;
  top: calc(0.6rem + env(safe-area-inset-top));
  right: 0.8rem;
  z-index: 2;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.14);
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox .lb-count {
  position: absolute;
  top: calc(1.05rem + env(safe-area-inset-top));
  left: 1.1rem;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
}

/* ---------- Map ---------- */
.map-block { margin: 1rem 0 0; }
.map-chips {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.2rem 1.15rem 0.75rem;
  scrollbar-width: none;
}
.map-chips::-webkit-scrollbar { display: none; }
.map-chips button {
  flex: 0 0 auto;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--hairline);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.map-chips button.on {
  color: #fff;
  background: var(--chip, var(--magenta));
  border-color: var(--chip, var(--magenta));
}
#map {
  height: 62vh;
  min-height: 340px;
  z-index: 1; /* keep Leaflet panes under the sticky bars */
}
.place-list { padding: 0.4rem 1.15rem 1rem; }
.place-group h4 {
  margin: 1.2rem 0 0.3rem;
  padding: 0;
  border: none;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.place-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--hairline);
}
.place-row .dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--chip, var(--magenta));
}
.place-row .p-name {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
  background: none;
  border: none;
  font-family: inherit;
  color: var(--ink);
  text-align: left;
  padding: 0;
  cursor: pointer;
}
.place-row a {
  flex: 0 0 auto;
  font-size: 0.8rem;
  color: var(--magenta);
  text-decoration: none;
  font-weight: 600;
}

/* End card */
.endcard {
  text-align: center;
  padding: 2.2rem 1.4rem calc(3rem + env(safe-area-inset-bottom));
  color: var(--muted);
}
.endcard .btn { margin-top: 1rem; }

.loading, .load-error {
  text-align: center;
  color: var(--muted);
  padding: 4.5rem 1.5rem;
  line-height: 1.6;
}

@media (min-width: 700px) {
  .card-grid { grid-template-columns: 1fr 1fr; }
  .article figure { margin-left: 0; margin-right: 0; }
  .article figure img { border-radius: var(--radius); }
}
