/* The World Hat Museum — homepage, phase 1 map */

:root {
  --bg: #faf8f5;
  --bg-warm: #f7f4ef;
  --ink: #1c1b19;
  --ink-soft: #3f3c38;
  --ink-muted: #6b675f;
  --nav: #2b2926;
  --land: #e8e6e1;
  --land-edge: #faf8f5;
  --gold: #c9ae72;
  --gold-deep: #b1894c;
  --line: #e4dfd6;
  --pill-border: #cfc9be;
  --card-bg: #fbf8f1;
  --card-border: #e4d8c4;
  --card-shadow: 0 6px 20px rgba(60, 45, 20, 0.12);
  --footer-bg: #1c1b19;
  --footer-ink: #f4f0e8;
  --header-height: 5.25rem;
  --page-pad: clamp(1.25rem, 4vw, 3.5rem);
  --serif: "Playfair Display", "Times New Roman", Times, serif;
  --sans: "Source Sans 3", "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --ease: 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* Header
   ------------------------------------------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: var(--header-height);
  padding: 1.15rem var(--page-pad);
  background: var(--bg);
}

.logo {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(0.92rem, 1.15vw, 1.05rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.15rem 1.85rem;
}

.site-nav a {
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--nav);
  padding: 0.2rem 0;
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--ink);
  border-bottom-color: var(--gold-deep);
}

.site-nav a[aria-current="page"] {
  border-bottom-color: var(--gold);
}

/* Hero + map
   ------------------------------------------- */

.hero {
  position: relative;
  padding: 0.25rem 0 1.5rem;
}

.hero-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.25rem, 4.8vw, 4rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0;
  padding: 0.5rem var(--page-pad) 0;
  max-width: 18ch;
  pointer-events: none;
  position: relative;
  z-index: 2;
}

.map-stage {
  position: relative;
  width: 100%;
  margin-top: -2.5rem;
  min-height: 280px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.map-stage.is-ready {
  opacity: 1;
  transform: none;
}

.map-canvas {
  width: 100%;
  overflow: hidden;
}

#map-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.country {
  fill: var(--land);
  stroke: var(--land-edge);
  stroke-width: 0.7;
  stroke-linejoin: round;
  stroke-linecap: round;
  cursor: pointer;
  outline: none;
}

.country:focus-visible {
  stroke: var(--gold-deep);
  stroke-width: 1.2;
}

.region-gold {
  fill: url(#gold-leaf-soft);
  stroke: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.region-gold.is-visible {
  opacity: 1;
}

#map-svg.is-foil .region-gold {
  fill: url(#gold-leaf-foil);
}

.country-border {
  fill: none;
  stroke: var(--land-edge);
  stroke-width: 0.7;
  stroke-linejoin: round;
  stroke-linecap: round;
  pointer-events: none;
}

.country-border.is-active {
  /* Default: hide borders inside the gold so the leaf is seamless.
     The merged .region-gold and .region-outline draw the outer shape. */
  stroke: transparent;
}

#map-svg.show-inner-borders .country-border.is-active {
  stroke: #f3ead4;
}

.region-outline {
  fill: none;
  stroke: #f3ead4;
  stroke-width: 1.35;
  stroke-linejoin: round;
  stroke-linecap: round;
  opacity: 0;
  pointer-events: none;
}

.region-outline.is-visible {
  opacity: 1;
}

.island-hit {
  fill: transparent;
  cursor: pointer;
}

.markers {
  pointer-events: none;
}

.marker {
  pointer-events: auto;
  cursor: pointer;
  outline: none;
}

.marker-leader {
  stroke: #c4b089;
  stroke-width: 1;
  stroke-linecap: round;
  fill: none;
}

.marker-dot {
  fill: #c9ae72;
  stroke: #f7f0e2;
  stroke-width: 1.15;
}

.marker-pulse {
  fill: #c9ae72;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}

.marker:hover .marker-dot,
.marker.is-open .marker-dot,
.marker:focus-visible .marker-dot {
  fill: #b1894c;
  stroke: #fff8ec;
}

.tag-card {
  fill: var(--card-bg);
  stroke: var(--card-border);
  stroke-width: 0.9;
  filter: url(#tag-shadow);
}

.tag-label {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 15px;
  fill: var(--ink);
  dominant-baseline: alphabetic;
}

.marker.is-open .tag-card,
.marker:hover .tag-card {
  stroke: #d7c7a8;
}

@media (prefers-reduced-motion: no-preference) {
  .marker-pulse {
    animation: marker-pulse 2.6s ease-out infinite;
  }
}

@keyframes marker-pulse {
  0% {
    transform: scale(1);
    opacity: 0.45;
  }
  70% {
    transform: scale(3.1);
    opacity: 0;
  }
  100% {
    transform: scale(3.1);
    opacity: 0;
  }
}

/* Always-visible tags on desktop; tap-to-show on smaller screens. */
@media (max-width: 899px) {
  .marker-tag,
  .marker-leader {
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  .marker.is-open .marker-tag,
  .marker.is-open .marker-leader {
    opacity: 1;
  }
}

.map-tooltip {
  position: absolute;
  z-index: 3;
  min-width: 0;
  max-width: 14rem;
  padding: 0.55rem 0.85rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 9px;
  box-shadow: var(--card-shadow);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.map-tooltip.is-visible {
  opacity: 1;
  transform: none;
}

.tooltip-name {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  color: var(--ink);
  line-height: 1.3;
}

.map-error {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

/* Browse
   ------------------------------------------- */

.browse {
  padding: 0.5rem var(--page-pad) 3.5rem;
}

.browse h2 {
  margin: 0 0 1.15rem;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.65rem, 2.4vw, 2.05rem);
  letter-spacing: -0.01em;
  color: var(--ink);
}

.pills {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 0.65rem;
  margin: 0;
  padding: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.45rem;
  padding: 0.35rem 1.15rem;
  border: 1px solid var(--pill-border);
  border-radius: 999px;
  background: transparent;
  font-family: var(--serif);
  font-size: 1.02rem;
  font-weight: 400;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.pill:hover,
.pill:focus-visible {
  border-color: var(--gold-deep);
  color: var(--ink);
  background: rgba(201, 174, 114, 0.08);
}

.pill.is-active,
.pill.is-active:hover,
.pill.is-active:focus-visible {
  border-color: var(--gold-deep);
  color: var(--ink);
  background: rgba(201, 174, 114, 0.22);
}

/* Footer
   ------------------------------------------- */

.site-footer {
  background: var(--footer-bg);
  color: var(--footer-ink);
  padding: 2.4rem var(--page-pad) 2.2rem;
  display: grid;
  grid-template-columns: 1.3fr 1fr auto;
  gap: 2rem 1.5rem;
  align-items: start;
}

.footer-brand {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.92rem;
  margin: 0 0 0.55rem;
}

.footer-tagline,
.footer-copy {
  margin: 0;
  font-size: 0.88rem;
  color: rgba(244, 240, 232, 0.72);
  max-width: 22rem;
}

.footer-copy {
  margin-top: 0.65rem;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.5rem;
  padding-top: 0.15rem;
}

.footer-nav a:hover,
.footer-social a:hover {
  color: var(--gold);
}

.footer-social {
  text-align: right;
  font-size: 0.92rem;
}

.footer-social a {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.footer-social svg {
  width: 1.35rem;
  height: 1.35rem;
}

/* Layout adjustments
   ------------------------------------------- */

@media (min-width: 900px) {
  .hero-title {
    position: absolute;
    top: 0.35rem;
    left: 0;
    padding: 0.35rem var(--page-pad) 0;
  }

  .map-stage {
    margin-top: 0.4rem;
  }
}

@media (max-width: 720px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.7rem;
    padding-top: 1rem;
    padding-bottom: 0.85rem;
  }

  .site-nav {
    justify-content: flex-start;
    gap: 0.15rem 1.15rem;
  }

  .site-nav a {
    font-size: 0.9rem;
  }

  .hero-title {
    max-width: none;
    padding-top: 0.75rem;
    font-size: clamp(2.15rem, 8.6vw, 2.7rem);
  }

  .map-stage {
    margin-top: 0.25rem;
  }

  .map-tooltip {
    padding: 0.45rem 0.7rem 0.5rem;
  }

  .tooltip-name {
    font-size: 0.98rem;
  }

  .site-footer {
    grid-template-columns: 1fr;
  }

  .footer-social {
    text-align: left;
  }

  .footer-social a {
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .country,
  .map-tooltip,
  .map-stage,
  .site-nav a,
  .pill,
  .marker-tag,
  .marker-leader,
  .region-gold {
    transition: none;
  }

  .marker-pulse {
    animation: none;
    opacity: 0.28;
    transform: scale(1.7);
  }

  .map-stage {
    transform: none;
  }
}

/* Regional zoom (clicking a region)
   ------------------------------------------- */

.map-frame {
  position: relative;
  width: 100%;
  margin: 0 auto;
  transition: width 0.75s cubic-bezier(0.65, 0, 0.35, 1);
}

.map-frame.is-zoomed {
  width: min(100%, 900px);
}

.hero-title {
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.hero.is-zoomed .hero-title {
  opacity: 0;
  visibility: hidden;
}

.markers {
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.map-stage.is-zoomed .markers {
  opacity: 0;
  visibility: hidden;
}

.map-stage.is-zoomed .island-hits {
  display: none;
}

/* Hairline borders at every zoom level. */
.map-stage.is-zoomed .country,
.map-stage.is-zoomed .country-border {
  vector-effect: non-scaling-stroke;
  stroke-width: 0.8px;
}

.map-stage.is-zoomed .region-outline {
  vector-effect: non-scaling-stroke;
  stroke-width: 1.4px;
}

.map-stage.is-zoomed .country {
  cursor: default;
}

.map-stage.is-zoomed .country.is-pickable {
  cursor: pointer;
}

.back-pill[hidden],
.zoom-pills[hidden],
.geo-status[hidden],
.geo-empty[hidden] {
  display: none;
}

.back-pill {
  position: absolute;
  z-index: 6;
  top: 1rem;
  left: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.2rem;
  padding: 0.28rem 0.95rem 0.3rem 0.85rem;
  border: 1px solid var(--pill-border);
  border-radius: 999px;
  background: #fbf8f1;
  box-shadow: 0 4px 16px rgba(60, 45, 20, 0.08);
  font-family: var(--serif);
  font-size: 0.98rem;
  color: var(--ink-soft);
  animation: zoom-fade 0.5s ease both;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.back-pill:hover,
.back-pill:focus-visible {
  border-color: var(--gold-deep);
  color: var(--ink);
  outline: none;
}

.zoom-lines {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  overflow: visible;
}

.zoom-lines.is-ready {
  opacity: 1;
}

.zoom-leader {
  stroke: #c4b089;
  stroke-width: 1;
  stroke-linecap: round;
  fill: none;
}

.zoom-dot {
  fill: #c9ae72;
  stroke: #f7f0e2;
  stroke-width: 1.15;
  transition: fill 0.2s ease;
}

.zoom-dot.is-selected {
  fill: var(--gold-deep);
}

.zoom-pills {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.zoom-pills.is-ready {
  opacity: 1;
}

.country-pill {
  position: absolute;
  pointer-events: auto;
  padding: 0.5rem 1rem 0.55rem;
  border: 1px solid var(--card-border);
  border-radius: 9px;
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.12rem;
  line-height: 1.25;
  letter-spacing: 0.01em;
  color: var(--ink);
  white-space: nowrap;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.country-pill:hover,
.country-pill:focus-visible {
  border-color: var(--gold-deep);
  outline: none;
  transform: translateY(-1px);
}

.country-pill.is-selected {
  border-color: var(--gold-deep);
  background: #f6ecd6;
}

@keyframes zoom-fade {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 639px) {
  .back-pill {
    top: 0.5rem;
    left: 0.5rem;
    min-height: 2rem;
    font-size: 0.88rem;
  }

  .zoom-pills.is-flow {
    position: static;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.55rem;
    padding: 0.85rem var(--page-pad) 0;
  }

  .zoom-pills.is-flow .country-pill {
    position: static;
    font-size: 1rem;
    padding: 0.4rem 0.85rem 0.45rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .map-frame,
  .hero-title,
  .markers,
  .zoom-pills,
  .zoom-lines,
  .back-pill,
  .country-pill {
    transition: none;
    animation: none;
  }
}

@media (max-width: 899px) {
  .hero-title {
    max-height: 9rem;
    overflow: hidden;
    transition: opacity 0.45s ease, visibility 0.45s ease, max-height 0.7s ease, padding 0.7s ease;
  }

  .hero.is-zoomed .hero-title {
    max-height: 0;
    padding-top: 0;
  }
}
