/* ============================================================
   Portugal — A Journey Through Sun & Tile
   Design system: warm paper + azulejo blue + terracotta + gold
   ============================================================ */

:root {
  --ink: #17140f;
  --paper: #faf6ee;
  --cream: #f4efe3;
  --azul: #1c4e80;
  --azul-deep: #123a63;
  --terracota: #c4643b;
  --gold: #d9a441;
  --dark: #0e1216;
  --dark-2: #151b21;
  --text-dark: #f2ede2;
  --muted: #6d675c;
  --muted-dark: #a8a294;
  --line: #e3dcc9;
  --line-dark: #2a323b;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(23, 20, 15, .10);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

a { color: var(--azul); }

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

.section { padding: 84px 0; }
.section-dark { background: var(--dark); color: var(--text-dark); }
.section-cream { background: var(--cream); }

/* ---------- header / nav ---------- */

.site-head {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: rgba(13, 17, 20, .78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; }
.brand-word {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: .02em;
  color: var(--paper);
}

.main-nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }

.main-nav a {
  color: var(--text-dark);
  text-decoration: none;
  font-size: .92rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background .2s, color .2s;
}
.main-nav a:hover { background: rgba(250, 246, 238, .12); color: #fff; }
.main-nav a.nav-quiz { color: var(--gold); }

/* ---------- hero ---------- */

.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  isolation: isolate;
}

.hero-bg {
  position: absolute;
  inset: -4%;
  background-image: url("https://thumb.wikimedia.org/wikipedia/commons/thumb/b/b5/Le_tram_28.jpg/1280px-Le_tram_28.jpg");
  background-size: cover;
  background-position: center;
  animation: kenburns 28s ease-in-out infinite alternate;
  z-index: -2;
}
@keyframes kenburns {
  from { transform: scale(1); }
  to   { transform: scale(1.09) translateY(-1.5%); }
}

.hero-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 14, 18, .62) 0%, rgba(10, 14, 18, .28) 38%, rgba(10, 14, 18, .78) 100%);
  z-index: -1;
}

.hero-inner {
  text-align: center;
  padding: 120px 24px 90px;
  max-width: 860px;
}

.kicker {
  margin: 0 0 10px;
  font-size: .85rem;
  font-weight: 600;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold);
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(3.4rem, 10vw, 7rem);
  line-height: .95;
  margin: 0 0 18px;
  color: var(--paper);
  letter-spacing: .01em;
}

.hero-sub {
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  color: rgba(242, 237, 226, .92);
  margin: 0 0 30px;
}

.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: .98rem;
  font-weight: 600;
  padding: 13px 24px;
  border-radius: 999px;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .2s ease, background .2s;
}
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--gold); color: #20180a; }
.btn-primary:hover { background: #e6b455; box-shadow: 0 8px 20px rgba(217, 164, 65, .35); }

.btn-ghost {
  background: transparent;
  color: var(--paper);
  border: 1.5px solid rgba(242, 237, 226, .55);
}
.btn-ghost:hover { border-color: var(--paper); background: rgba(242, 237, 226, .08); }

.hero-stats {
  list-style: none;
  display: flex;
  gap: 28px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 44px 0 0;
  padding: 0;
}
.hero-stats li { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hero-stats strong {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--paper);
}
.hero-stats span { font-size: .8rem; color: rgba(242, 237, 226, .72); }

.scroll-hint {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(242, 237, 226, .8);
  animation: bob 2.2s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, 8px); }
}

/* ---------- azulejo tile band ---------- */

.tile-band {
  height: 26px;
  background-color: var(--cream);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26'%3E%3Crect width='26' height='26' fill='%23f4efe3'/%3E%3Cpath d='M13 3 L23 13 L13 23 L3 13 Z' fill='none' stroke='%231c4e80' stroke-width='2'/%3E%3Ccircle cx='13' cy='13' r='2.4' fill='%23c4643b'/%3E%3C/svg%3E");
  background-size: 26px 26px;
}

/* ---------- section headers ---------- */

.sec-head { max-width: 760px; margin-bottom: 40px; }
.sec-head .kicker { color: var(--terracota); }
.section-dark .sec-head .kicker { color: var(--gold); }

h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2rem, 4.4vw, 3rem);
  line-height: 1.08;
  margin: 0 0 14px;
}

.lede {
  font-size: 1.06rem;
  color: var(--muted);
  margin: 0;
}
.section-dark .lede { color: var(--muted-dark); }

/* ---------- cards (welcome triad, festivals) ---------- */

.triad, .festivals {
  display: grid;
  gap: 22px;
  grid-template-columns: repeat(3, 1fr);
}

.card {
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.section-cream .card { background: #fff; }

.card figure, .gcard figure { margin: 0; }

.card img, .gcard img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.card h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 8px;
  padding: 18px 20px 0;
}
.card p { margin: 0; padding: 0 20px 20px; color: var(--muted); font-size: .95rem; }

/* ---------- map section ---------- */

.map-shell {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 18px;
  align-items: stretch;
}

#leaflet-map {
  height: 620px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--cream);
  z-index: 0;
}

.map-controls {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  gap: 8px;
  z-index: 500;
}
/* position inside map-shell via relative wrapper */
.map-shell { position: relative; }
.map-controls { position: absolute; top: 16px; left: 16px; }

.chip {
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: .88rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .18s ease;
}
.chip:hover { border-color: var(--azul); color: var(--azul); }
.chip-on { background: var(--azul); border-color: var(--azul); color: #fff; }
.chip-on:hover { background: var(--azul-deep); color: #fff; }

.chip-btn {
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(4px);
}

.cat-legend { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 8px; }
.cat-legend li { display: flex; align-items: center; gap: 9px; font-size: .92rem; color: var(--muted); }

.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.cat-history  { background: var(--terracota); }
.cat-art      { background: #7b4fa0; }
.cat-food     { background: #b8860b; }
.cat-nature   { background: #3e7d4f; }
.cat-culture  { background: var(--azul); }
.cat-sea      { background: #2c8ca6; }

.map-panel {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  overflow-y: auto;
  max-height: 620px;
}
.map-panel h3 { font-family: var(--font-display); font-size: 1.3rem; margin: 0 0 8px; }
.map-panel p { color: var(--muted); font-size: .95rem; margin: 0 0 10px; }

.panel-pin img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 12px;
}

.panel-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.meta-chip {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
}
.meta-chip.cat-history { background: #f3e2d8; }
.meta-chip.cat-art { background: #e9def0; }
.meta-chip.cat-food { background: #f4e9cd; }
.meta-chip.cat-nature { background: #dfeee2; }
.meta-chip.cat-culture { background: #dde8f3; }
.meta-chip.cat-sea { background: #d8ecf2; }

.panel-fact { font-size: .85rem; color: var(--muted); margin: 8px 0 0; }
.panel-fact strong { color: var(--ink); }

.map-credit { font-size: .78rem; color: var(--muted); margin-top: 14px; }

/* leaflet marker dots */
.pin-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2.5px solid #fff;
  box-shadow: 0 1px 6px rgba(0,0,0,.35);
  cursor: pointer;
  transition: transform .15s ease;
}
.pin-dot:hover { transform: scale(1.25); }

/* ---------- timeline (dark) ---------- */

.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 34px;
  position: relative;
  max-width: 760px;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: linear-gradient(180deg, var(--gold), var(--line-dark));
}

.tl-item { position: relative; margin-bottom: 22px; }

.tl-dot {
  position: absolute;
  left: -34px;
  top: 26px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--dark);
  box-shadow: 0 0 0 2px rgba(217, 164, 65, .5);
}

.tl-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--dark-2);
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  color: var(--text-dark);
  font-family: var(--font-body);
  transition: border-color .2s, transform .2s;
}
.tl-card:hover { border-color: rgba(217, 164, 65, .6); transform: translateX(3px); }

.tl-year {
  display: block;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 4px;
}
.tl-card h3 { margin: 0 0 6px; font-size: 1.12rem; font-weight: 600; }

.tl-more {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height .45s ease, opacity .35s ease;
  color: var(--muted-dark);
  font-size: .95rem;
  margin: 0;
}
.tl-card.open .tl-more { max-height: 260px; opacity: 1; }

.tl-img { margin: 14px 0 0; border-radius: 10px; overflow: hidden; }
.tl-img img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }

.old-map { max-width: 760px; margin-top: 48px; }
.old-map img { border-radius: var(--radius); box-shadow: var(--shadow); }
.old-map figcaption { font-size: .82rem; color: var(--muted-dark); margin-top: 10px; }

/* ---------- galleries (art & food) ---------- */

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 26px; }

.gallery {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(3, 1fr);
}
.gallery-food { grid-template-columns: repeat(2, 1fr); }

.gcard {
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.gcard figure { margin: 0; }
.gcard img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; cursor: zoom-in; }

.gmeta { padding: 16px 18px 18px; }
.era {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--terracota);
  margin-bottom: 6px;
}
.gmeta h3 { font-family: var(--font-display); font-size: 1.12rem; font-weight: 600; margin: 0 0 6px; }
.gmeta p { margin: 0; color: var(--muted); font-size: .9rem; }

.gcard.hidden { display: none; }

/* ---------- fado / culture ---------- */

.fado {
  display: grid;
  grid-template-columns: 5fr 6fr;
  gap: 28px;
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 34px;
}
.fado-img { margin: 0; min-height: 340px; }
.fado-img img { width: 100%; height: 100%; object-fit: cover; }

.fado-body { padding: 28px 28px 24px; display: flex; flex-direction: column; gap: 14px; }
.fado-body h3 { font-family: var(--font-display); font-size: 1.6rem; margin: 0; }
.fado-body p { margin: 0; color: var(--muted); }

.player { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }

.track-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: var(--cream);
  border: 1.5px solid transparent;
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  font-family: var(--font-body);
  text-align: left;
  transition: border-color .18s, background .18s;
}
.track-btn:hover { border-color: var(--azul); }
.track-btn[aria-pressed="true"] { border-color: var(--azul); background: #e8eef6; }
.track-name { font-weight: 600; font-size: .95rem; color: var(--ink); }
.track-sub { font-size: .8rem; color: var(--muted); }

.player-bar { display: flex; align-items: center; gap: 12px; }
.play-btn {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--azul);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, transform .15s;
}
.play-btn:hover { background: var(--azul-deep); transform: scale(1.06); }
.now-playing { font-size: .9rem; color: var(--muted); }

.player-credit { margin: 0; font-size: .78rem; color: var(--muted); }

.saudade {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2.6vw, 1.8rem);
  font-weight: 400;
  font-style: italic;
  color: var(--ink);
  border-left: 4px solid var(--terracota);
  margin: 0 0 34px;
  padding: 6px 0 6px 24px;
  max-width: 720px;
}

/* ---------- planner ---------- */

.planner { display: flex; flex-direction: column; gap: 18px; max-width: 760px; }

.plan-group { border: none; margin: 0; padding: 0; }
.plan-group legend { font-weight: 600; font-size: .95rem; margin-bottom: 8px; color: var(--text-dark); }
.section-dark .chip { background: var(--dark-2); border-color: var(--line-dark); color: var(--text-dark); }
.section-dark .chip:hover { border-color: var(--gold); color: var(--gold); }
.section-dark .chip-on { background: var(--gold); border-color: var(--gold); color: #20180a; }

.plan-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.section-dark .btn-ghost { color: var(--text-dark); border-color: rgba(242, 237, 226, .4); }

.itinerary { list-style: none; margin: 34px 0 0; padding: 0; display: grid; gap: 14px; max-width: 760px; }
.itin-stop {
  display: grid;
  grid-template-columns: 84px 96px 1fr;
  gap: 14px;
  align-items: center;
  background: var(--dark-2);
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  padding: 14px 18px;
}
.itin-time {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--gold);
  font-size: 1.05rem;
}
.itin-stop img {
  width: 96px; height: 72px;
  object-fit: cover;
  border-radius: 8px;
}
.itin-stop .no-img {
  width: 96px; height: 72px;
  border-radius: 8px;
  background: var(--dark);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted-dark);
  font-size: .7rem;
  text-align: center;
  padding: 6px;
}
.itin-body h3 { margin: 0 0 4px; font-size: 1.02rem; color: var(--text-dark); }
.itin-body p { margin: 0; font-size: .88rem; color: var(--muted-dark); }

/* ---------- quiz ---------- */

.quiz {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
  max-width: 720px;
}
.quiz-head { display: flex; justify-content: space-between; margin-bottom: 14px; font-size: .85rem; color: var(--muted); }
.quiz-q { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; margin: 0 0 18px; }

.quiz-opts { display: grid; gap: 10px; }
.quiz-opt {
  text-align: left;
  background: var(--cream);
  border: 1.5px solid transparent;
  border-radius: 10px;
  padding: 13px 16px;
  font-size: .98rem;
  cursor: pointer;
  font-family: var(--font-body);
  transition: border-color .15s, background .15s;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--azul); }
.quiz-opt.correct { border-color: #3e7d4f; background: #e2efe6; font-weight: 600; }
.quiz-opt.wrong { border-color: var(--terracota); background: #f6e4da; }
.quiz-opt:disabled { cursor: default; opacity: .85; }

.quiz-explain { margin: 16px 0 0; font-size: .92rem; color: var(--muted); }
.quiz-actions { display: flex; gap: 10px; margin-top: 18px; }

/* ---------- footer ---------- */

.site-foot { background: var(--dark); color: var(--text-dark); padding-bottom: 40px; }
.foot-inner { padding-top: 34px; font-size: .9rem; color: var(--muted-dark); max-width: 860px; }
.foot-inner a { color: var(--gold); }
.foot-credits { margin-bottom: 0; font-size: .8rem; }

/* ---------- lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(10, 12, 14, .93);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.lightbox[hidden] { display: none; }

.lb-img { max-width: min(1100px, 92vw); max-height: 78vh; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.lb-cap {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 80vw;
  text-align: center;
  color: var(--text-dark);
  font-size: .85rem;
  margin: 0;
}
.lb-close {
  position: absolute;
  top: 18px; right: 22px;
  background: none; border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}

/* ---------- reveal animations ---------- */

.rv { opacity: 0; transform: translateY(18px); }
.rv.on { opacity: 1; transform: none; transition: opacity .7s ease, transform .7s ease; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-bg { animation: none; }
  .scroll-hint { animation: none; }
  .rv { opacity: 1; transform: none; transition: none; }
}

/* ---------- responsive ---------- */

@media (max-width: 980px) {
  .triad, .festivals, .gallery { grid-template-columns: repeat(2, 1fr); }
  .fado { grid-template-columns: 1fr; }
  .fado-img { min-height: 260px; }
  .map-shell { grid-template-columns: 1fr; }
  #leaflet-map { height: 480px; }
  .map-panel { max-height: none; }
}

@media (max-width: 640px) {
  .section { padding: 60px 0; }
  .triad, .festivals, .gallery, .gallery-food { grid-template-columns: 1fr; }
  #leaflet-map { height: 420px; }
  .itin-stop { grid-template-columns: 70px 1fr; }
  .itin-stop img, .itin-stop .no-img { grid-column: 2; width: 100%; height: 90px; }
  .hero-inner { padding-top: 140px; }
}
