/* =============================================================
   World Cultures — stylesheet
   An editorial "atlas" aesthetic: warm paper, refined serif
   display type, amber + teal accents, full light/dark support.
   ============================================================= */

:root {
  /* Palette — light */
  --paper:      #faf6ef;
  --paper-2:    #f2ebe0;
  --surface:    #ffffff;
  --surface-2:  #fbf8f2;
  --ink:        #211b16;
  --ink-soft:   #4b4139;
  --muted:      #8a7d70;
  --line:       #e7ddce;
  --accent:     #c8781f;   /* amber / saffron */
  --accent-ink: #a35f12;
  --accent-soft:#f6e6cf;
  --teal:       #176a63;
  --teal-soft:  #d9ece9;
  --gold:       #d9a441;
  --shadow:     0 1px 2px rgba(33,27,22,.05), 0 12px 32px -12px rgba(33,27,22,.18);
  --shadow-sm:  0 1px 2px rgba(33,27,22,.06), 0 4px 14px -8px rgba(33,27,22,.16);
  --radius:     18px;
  --radius-sm:  12px;
  --maxw:       1180px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  --paper:      #14100c;
  --paper-2:    #1a1510;
  --surface:    #1f1913;
  --surface-2:  #241d16;
  --ink:        #f4ece1;
  --ink-soft:   #d8cbba;
  --muted:      #a2917f;
  --line:       #362c22;
  --accent:     #e8963a;
  --accent-ink: #f2b264;
  --accent-soft:#3a2a14;
  --teal:       #4bb3a8;
  --teal-soft:  #14312e;
  --gold:       #e6b955;
  --shadow:     0 1px 2px rgba(0,0,0,.4), 0 18px 40px -16px rgba(0,0,0,.6);
  --shadow-sm:  0 1px 2px rgba(0,0,0,.4), 0 6px 18px -10px rgba(0,0,0,.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:#14100c; --paper-2:#1a1510; --surface:#1f1913; --surface-2:#241d16;
    --ink:#f4ece1; --ink-soft:#d8cbba; --muted:#a2917f; --line:#362c22;
    --accent:#e8963a; --accent-ink:#f2b264; --accent-soft:#3a2a14;
    --teal:#4bb3a8; --teal-soft:#14312e; --gold:#e6b955;
    --shadow:0 1px 2px rgba(0,0,0,.4),0 18px 40px -16px rgba(0,0,0,.6);
    --shadow-sm:0 1px 2px rgba(0,0,0,.4),0 6px 18px -10px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, var(--teal-soft), transparent 55%),
    var(--paper);
  background-attachment: fixed;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: clamp(16px, 4vw, 32px); }

h1,h2,h3,h4 { font-family: var(--serif); font-weight: 600; line-height: 1.15; letter-spacing: -.01em; margin: 0; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent); color: #fff; }

/* ===== Header ===== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(140%) blur(12px);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  border-bottom: 1px solid var(--line);
  transition: box-shadow .25s ease;
}
.site-header.scrolled { box-shadow: var(--shadow-sm); }
.header-inner { display: flex; align-items: center; gap: 20px; justify-content: space-between; height: 70px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { font-size: 28px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.15)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text strong { font-family: var(--serif); font-size: 20px; letter-spacing: -.02em; }
.brand-accent { color: var(--accent); }
.brand-text small { color: var(--muted); font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; }

.header-tools { display: flex; align-items: center; gap: 12px; }
.search { position: relative; display: flex; align-items: center; }
.search-icon { width: 18px; height: 18px; color: var(--muted); position: absolute; left: 12px; pointer-events: none; }
.search input {
  font: inherit; font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 16px 9px 38px; width: 220px; transition: .2s ease; outline: none;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); width: 250px; }
.theme-toggle {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 17px;
  transition: .2s ease;
}
.theme-toggle:hover { border-color: var(--accent); transform: translateY(-1px); }
.theme-icon-moon { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-moon { display: inline; }

/* ===== Loading / spinner ===== */
.loading { display: grid; place-items: center; gap: 16px; padding: 120px 0; color: var(--muted); }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Hero (explore view) ===== */
.hero { padding: clamp(36px, 6vw, 68px) 0 20px; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--accent-ink); font-weight: 700; margin-bottom: 18px;
  background: var(--accent-soft); padding: 6px 14px; border-radius: 999px;
}
.hero h1 { font-size: clamp(34px, 6vw, 60px); max-width: 15ch; }
.hero h1 em { font-style: italic; color: var(--accent); }
.hero-lead { font-size: clamp(16px, 2vw, 19px); color: var(--ink-soft); max-width: 60ch; margin-top: 18px; }
.hero-stats { display: flex; gap: 34px; margin-top: 30px; flex-wrap: wrap; }
.hero-stat b { font-family: var(--serif); font-size: 30px; color: var(--accent); display: block; line-height: 1; }
.hero-stat span { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* ===== Section heading ===== */
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 44px 0 20px; flex-wrap: wrap; }
.section-head h2 { font-size: clamp(22px, 3vw, 30px); }
.section-head p { color: var(--muted); margin: 4px 0 0; font-size: 14.5px; }

/* ===== Region filter chips ===== */
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-soft); transition: .18s ease; white-space: nowrap;
}
.chip:hover { border-color: var(--accent); color: var(--ink); transform: translateY(-1px); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ===== Country grid ===== */
.country-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px; margin-top: 8px; }
.country-card {
  position: relative; display: flex; align-items: center; gap: 16px; padding: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  overflow: hidden;
}
.country-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: linear-gradient(var(--accent), var(--gold)); opacity: 0; transition: opacity .2s ease;
}
.country-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: transparent; }
.country-card:hover::before { opacity: 1; }
.country-card:hover .cc-arrow { transform: translateX(4px); opacity: 1; }
.cc-flag { font-size: 40px; line-height: 1; filter: drop-shadow(0 3px 6px rgba(0,0,0,.12)); flex-shrink: 0; }
.cc-body { flex: 1; min-width: 0; }
.cc-top { display: flex; align-items: baseline; gap: 8px; justify-content: space-between; }
.cc-name { font-size: 19px; }
.cc-region { font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--paper-2); padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.cc-tagline { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-arrow { font-size: 18px; color: var(--accent); opacity: .35; transition: .2s ease; flex-shrink: 0; }
.country-card.is-main { border-color: var(--accent); background: linear-gradient(180deg, var(--accent-soft), var(--surface) 60%); }
.country-card.is-main::before { opacity: 1; }
.cc-badge { position: absolute; top: 12px; right: 12px; font-size: 9.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #fff; background: var(--accent); padding: 3px 9px; border-radius: 999px; }

.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* ===== "Explore other countries" strip (country page) ===== */
.more-countries { margin: 4px 0 54px; }
.more-row {
  display: flex; gap: 16px; overflow-x: auto; padding: 4px 2px 14px;
  scroll-snap-type: x proximity; scrollbar-width: thin;
}
.more-row .country-card { flex: 0 0 auto; width: 262px; scroll-snap-align: start; }
.more-row::-webkit-scrollbar { height: 8px; }
.more-row::-webkit-scrollbar-track { background: transparent; }
.more-row::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
.more-row::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ===== Country detail view ===== */
.back-link { display: inline-flex; align-items: center; gap: 8px; margin: 26px 0 8px; color: var(--muted); font-size: 14px; font-weight: 600; }
.back-link:hover { color: var(--accent); }

.country-hero {
  position: relative; border-radius: var(--radius); padding: clamp(26px, 4vw, 44px);
  background:
    radial-gradient(600px 300px at 88% 0%, var(--accent-soft), transparent 65%),
    linear-gradient(135deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; margin-top: 6px;
}
.ch-copy { position: relative; z-index: 2; max-width: min(62%, 640px); }

/* ===== Country map — digital vector art ===== */
.ch-map {
  position: absolute; z-index: 1; top: 50%; right: clamp(14px, 3vw, 46px);
  transform: translateY(-50%);
  width: clamp(190px, 32%, 340px); aspect-ratio: 1 / 1;
  display: grid; place-items: center; pointer-events: none;
  animation: mapIn .6s cubic-bezier(.2,.7,.2,1) both;
}
.ch-map::before {                       /* soft radial halo behind the shape */
  content: ""; position: absolute; inset: -12%;
  background: radial-gradient(closest-side, var(--accent-soft), transparent 78%);
  opacity: .9; filter: blur(6px);
}
.ch-map-svg {
  position: relative; width: 100%; height: 100%; overflow: visible;
  filter: drop-shadow(0 10px 22px color-mix(in srgb, var(--accent) 40%, transparent));
}
.cm-s0 { stop-color: var(--accent); }
.cm-s1 { stop-color: var(--teal); }
.cm-fill { opacity: .96; }
.cm-dot { fill: #fff; opacity: .18; }
.cm-stroke { stroke: color-mix(in srgb, var(--paper) 70%, #fff); stroke-width: .5; stroke-linejoin: round; opacity: .55; }
:root[data-theme="dark"] .cm-dot { opacity: .12; }
:root[data-theme="dark"] .cm-stroke { stroke: color-mix(in srgb, var(--ink) 30%, transparent); }

/* capital-city star */
.cm-cap-star { fill: #ffd23f; stroke: #6b4e00; stroke-width: .35; stroke-linejoin: round; filter: drop-shadow(0 0 1.2px rgba(0,0,0,.35)); }
.cm-cap-halo { fill: #ffd23f; opacity: .28; }
.cm-cap-label { font-family: var(--sans); font-weight: 700; font-size: 3.4px; fill: var(--ink);
  paint-order: stroke; stroke: var(--surface); stroke-width: 1.1px; stroke-linejoin: round; }
/* island clusters (territorial) */
.cm-isl-dot { fill: var(--gold); stroke: var(--accent-ink); stroke-width: .22; }
.cm-isl-label { font-family: var(--sans); font-weight: 600; font-size: 2.9px; fill: var(--ink-soft);
  paint-order: stroke; stroke: var(--surface); stroke-width: 1px; stroke-linejoin: round; }
:root[data-theme="dark"] .cm-cap-label,
:root[data-theme="dark"] .cm-isl-label { stroke: color-mix(in srgb, var(--paper) 85%, #000); }

@keyframes mapIn { from { opacity: 0; transform: translateY(-50%) scale(.9) rotate(-3deg); } to { opacity: 1; transform: translateY(-50%) scale(1) rotate(0); } }
@media (max-width: 860px) {
  .ch-copy { max-width: 100%; }
  .ch-map { width: 58%; right: -5%; opacity: .15; }   /* becomes a background watermark */
  .ch-map::before { display: none; }
  .ch-map-svg { filter: none; }
}
@media (prefers-reduced-motion: reduce) { .ch-map { animation: none; } }
.country-hero .ch-flag { font-size: clamp(60px, 12vw, 104px); line-height: 1; filter: drop-shadow(0 8px 18px rgba(0,0,0,.2)); }
.country-hero .ch-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 6px; }
.ch-region { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--teal); font-weight: 700; background: var(--teal-soft); padding: 5px 12px; border-radius: 999px; }
.ch-main-badge { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #fff; font-weight: 700; background: var(--accent); padding: 5px 12px; border-radius: 999px; }
.country-hero h1 { font-size: clamp(32px, 6vw, 54px); margin-top: 10px; }
.country-hero .ch-tagline { font-family: var(--serif); font-style: italic; font-size: clamp(16px, 2.4vw, 22px); color: var(--accent-ink); margin-top: 6px; }
.country-hero .ch-summary { font-size: 16px; color: var(--ink-soft); max-width: 68ch; margin-top: 16px; }

/* Category layout: sidebar nav + content */
.country-body { display: grid; grid-template-columns: 258px 1fr; gap: 26px; margin: 28px 0 60px; align-items: start; }
.cat-nav { position: sticky; top: 90px; display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow-sm); }
.cat-nav-title { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 8px 12px 4px; }
.cat-btn {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; font: inherit;
  font-size: 14.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer; border: none;
  background: transparent; border-radius: var(--radius-sm); padding: 10px 12px; transition: .16s ease; position: relative;
}
.cat-btn .ci { font-size: 18px; width: 24px; text-align: center; }
.cat-btn:hover { background: var(--paper-2); color: var(--ink); }
.cat-btn[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.cat-btn[aria-selected="true"] .cat-star { color: var(--gold); }
.cat-star { margin-left: auto; font-size: 11px; color: var(--accent); }

.cat-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: clamp(22px, 3vw, 36px); min-height: 340px; }
.cat-panel-head { display: flex; align-items: center; gap: 14px; padding-bottom: 18px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.cat-panel-head .cp-icon { font-size: 30px; width: 58px; height: 58px; display: grid; place-items: center; background: var(--accent-soft); border-radius: 16px; flex-shrink: 0; }
.cat-panel-head h2 { font-size: clamp(24px, 3.4vw, 32px); }
.cat-panel-head .cp-sub { color: var(--muted); font-size: 13px; }
.cat-main-pill { margin-left: auto; align-self: flex-start; font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); background: var(--accent-soft); padding: 5px 11px; border-radius: 999px; }
.cat-content { font-size: 16.5px; line-height: 1.75; color: var(--ink-soft); max-width: 72ch; }
.cat-highlights { margin-top: 26px; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.hl {
  display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px; border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--surface-2), var(--surface)); border: 1px solid var(--line); font-size: 14px; color: var(--ink);
}
.hl::before { content: "◆"; color: var(--accent); font-size: 11px; margin-top: 4px; }

/* ===== Music sound-signature card ===== */
.sound-sig {
  display: flex; align-items: center; gap: 16px; margin: 0 0 24px; padding: 14px 18px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: linear-gradient(120deg, var(--accent-soft), var(--surface-2));
}
.sound-play {
  flex-shrink: 0; width: 54px; height: 54px; border-radius: 50%; border: none; cursor: pointer;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(160deg, var(--accent), var(--accent-ink));
  box-shadow: 0 8px 20px -8px var(--accent); transition: transform .16s ease, box-shadow .16s ease;
}
.sound-play:hover { transform: scale(1.07); }
.sound-play:active { transform: scale(0.97); }
.sound-play:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }
.sound-play .sp-icon { font-size: 18px; margin-left: 3px; }
.sound-play .eq { display: none; gap: 3px; height: 22px; align-items: flex-end; }
.sound-play .eq i { width: 3px; height: 6px; background: #fff; border-radius: 2px; animation: eqb .9s ease-in-out infinite; }
.sound-play .eq i:nth-child(1) { animation-delay: 0s;    animation-duration: .8s; }
.sound-play .eq i:nth-child(2) { animation-delay: .18s;  animation-duration: 1.1s; }
.sound-play .eq i:nth-child(3) { animation-delay: .05s;  animation-duration: .7s; }
.sound-play .eq i:nth-child(4) { animation-delay: .27s;  animation-duration: 1.0s; }
.sound-play .eq i:nth-child(5) { animation-delay: .12s;  animation-duration: .85s; }
@keyframes eqb { 0%, 100% { height: 5px; } 50% { height: 20px; } }
.sound-sig.playing .sp-icon { display: none; }
.sound-sig.playing .eq { display: flex; }
.sound-sig.playing .sound-play { box-shadow: 0 0 0 6px var(--accent-soft), 0 8px 20px -8px var(--accent); }
.sound-meta { min-width: 0; }
.sound-meta strong { font-family: var(--serif); font-size: 16.5px; display: block; line-height: 1.2; }
.sound-meta span { font-size: 12.5px; color: var(--ink-soft); }
.sound-hint { margin-left: auto; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; white-space: nowrap; }
@media (max-width: 560px) { .sound-hint { display: none; } }
@media (prefers-reduced-motion: reduce) { .sound-play .eq i { animation: none; height: 12px; } }

/* fade-in animation */
.fade-in { animation: fade .4s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== Footer ===== */
.site-footer { border-top: 1px solid var(--line); margin-top: 40px; background: color-mix(in srgb, var(--paper) 60%, transparent); }
.footer-inner { padding: 30px 0; color: var(--ink-soft); font-size: 14px; }
.footer-sub { color: var(--muted); font-size: 12.5px; margin-top: 6px; }

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .country-body { grid-template-columns: 1fr; }
  .cat-nav { position: static; flex-direction: row; overflow-x: auto; gap: 6px; }
  .cat-nav-title { display: none; }
  .cat-btn { white-space: nowrap; }
  .cat-star { display: none; }
}
@media (max-width: 560px) {
  .brand-text small { display: none; }
  .search input { width: 130px; }
  .search input:focus { width: 150px; }
  .hero-stats { gap: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; scroll-behavior: auto; } }
