/*
 * Greetings Elements — shared style bundle.
 *
 * Visuals match the rest of the ART site: bone background, maroon accent,
 * gold highlights, Fraunces serif headings, Source Sans 3 body. Tokens are
 * declared via var(--*) with hard-coded fallbacks so the widget still looks
 * right on pages that don't load art-elements/art-styles.css.
 *
 * Per-widget Elementor Style controls override the local --ge-* tokens.
 */

.ge-hero,
.ge-player {
  /* Site tokens (with safe fallbacks if art-styles.css isn't on the page) */
  --ge-bg:         var(--bone,        #FAF7F1);
  --ge-bg-soft:    var(--sand,        #F0EBDF);
  --ge-card:       #FFFFFF;
  --ge-card-hover: var(--sand,        #F0EBDF);
  --ge-accent:     var(--maroon,      #5A1A2B);
  --ge-accent-2:   var(--gold,        #D4A52A);
  --ge-text:       var(--ink,         #1A1814);
  --ge-muted:      var(--slate,       #5C5A55);
  --ge-draft:      var(--peach,       #E89B6C);
  --ge-border:     var(--border,      #D9D2C2);
  --ge-serif:      var(--serif, "Fraunces", "Source Serif 4", Georgia, serif);
  --ge-sans:       var(--sans,  "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  box-sizing: border-box;
}

.ge-hero *,
.ge-player * {
  box-sizing: border-box;
}

/* ---- Hero widget (kept for back-compat; no longer registered) ---- */
.ge-hero {
  text-align: center;
  padding: 3rem 1rem 1.5rem;
  font-family: var(--ge-sans);
}

.ge-hero__title {
  margin: 0;
  font-family: var(--ge-serif);
  font-weight: 500;
  font-size: clamp(2rem, 5vw, 3rem);
  color: var(--ge-accent);
}

.ge-hero__subtitle {
  color: var(--ge-muted);
  margin: 0.5rem 0 0;
}

/* ============================================================
   Player wrapper — sits inside its Elementor column, never wider
   than --container, and clips its own drawer so the slide-in
   panel can't push horizontal scroll onto the page.
   ============================================================ */
.ge-player {
  position: relative;
  max-width: var(--container, 1240px);
  margin: 0 auto;
  padding: clamp(16px, 2.5vw, 28px);
  background: transparent;
  color: var(--ge-text);
  font-family: var(--ge-sans);
  border-radius: 0;
  overflow: hidden; /* contain off-screen drawer + any wide map shrink */
}

.ge-player__inner {
  max-width: 100%;
  margin: 0 auto;
}

.ge-loading {
  text-align: center;
  color: var(--ge-muted);
  padding: 2rem 1rem;
}

/* Speed control */
.ge-speed {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 1.2rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--ge-border);
  border-radius: 999px;
  background: var(--ge-card);
  font-size: 0.85rem;
  color: var(--ge-muted);
}

.ge-speed input[type="range"] {
  flex: 1;
  accent-color: var(--ge-accent);
}

.ge-speed .ge-speed__val {
  color: var(--ge-text);
  font-variant-numeric: tabular-nums;
  min-width: 2.5em;
  text-align: right;
}

/* ---- Shared bits ---- */
.ge-flag {
  font-size: 1.4em;
  line-height: 1;
}

/* Country section (used by the fallback list when D3 isn't available) */
.ge-country {
  margin-bottom: 3rem;
}

.ge-country__name {
  font-family: var(--ge-serif);
  font-weight: 500;
  font-size: 1.7rem;
  color: var(--ge-accent);
  border-bottom: 2px solid var(--ge-accent-2);
  padding-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1rem;
}

/* Language block — rendered as a clear card panel with an alternating
   tint so a user scrolling through (e.g.) Kenya's three languages can
   always tell where one ends and the next begins. Uses :nth-of-type so
   the alternation skips any non-language siblings (the country heading
   in the fallback list). */
.ge-language {
  margin: 0 0 1rem;
  padding: 1rem 1.1rem 1.1rem;
  border: 1px solid var(--ge-border);
  border-radius: 12px;
  background: var(--ge-bg-soft);
}

.ge-language:nth-of-type(even) {
  background: var(--ge-bg);
}

.ge-language:last-child {
  margin-bottom: 0;
}

.ge-language__name {
  font-family: var(--ge-serif);
  font-weight: 500;
  color: var(--ge-accent);
  font-size: 1.2rem;
  margin: 0 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--ge-border);
}

.ge-endonym {
  color: var(--ge-muted);
  font-weight: 400;
  font-size: 0.9em;
}

.ge-voice-pickers {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: -0.3rem 0 0.9rem;
  font-size: 0.85rem;
  color: var(--ge-muted);
}

.ge-voice-pickers select {
  font: inherit;
  color: var(--ge-text);
  background: var(--ge-card);
  border: 1px solid var(--ge-border);
  border-radius: 8px;
  padding: 0.2rem 0.5rem;
  margin-left: 0.4rem;
}

/* ---- Card grid (greeting cards inside a language block) ---- */
.ge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--ge-card-min, 230px), 1fr));
  gap: 0.9rem;
}

.ge-card {
  position: relative;
  border: 1px solid var(--ge-border);
  background: var(--ge-card);
  border-radius: var(--ge-card-radius, 14px);
  padding: 0.35rem;
  /* Greeting on the left, reply on the right of each card. Widths and
     paddings are tuned so the two columns hold their side-by-side layout
     even inside the drawer's narrowest breakpoint (mobile bottom sheet),
     and only collapse to a stack on truly tiny screens. */
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.25rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ge-card:hover {
  border-color: var(--ge-accent-2);
  box-shadow: 0 6px 18px rgba(58, 22, 33, 0.08);
}

.ge-card > .ge-row {
  flex: 1 1 130px;
  min-width: 120px;
}

.ge-row {
  position: relative;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ge-text);
  border-radius: 9px;
  padding: 0.55rem 0.6rem;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, color 0.12s;
  font: inherit;
  width: 100%;
  /* Native <button> defaults to white-space: pre / nowrap in some browsers,
     so long meanings refuse to wrap and spill out of the card. Force normal
     wrapping and break very long words. */
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  /* Defeat WP / theme / browser button defaults — pink hover/tap tints,
     iOS rounded-grey style, default focus rings — so the row only ever
     shows the colours defined below. */
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}

.ge-row > * {
  /* The flex parent has min-width:160px; the row's own contents must also
     be allowed to shrink so wrapped text is bounded by the row, not by the
     longest unwrapped phrase. */
  min-width: 0;
  max-width: 100%;
}

.ge-phrase,
.ge-meaning {
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

.ge-row:hover,
.ge-row:focus,
.ge-row:active {
  background: var(--ge-card-hover);
  color: var(--ge-text);
  outline: none;
}

.ge-row:focus-visible {
  outline: 2px solid var(--ge-accent);
  outline-offset: 1px;
}

.ge-row.is-playing {
  background: var(--ge-card-hover);
  border-color: var(--ge-accent);
  box-shadow: inset 0 0 0 1px var(--ge-accent);
}

.ge-row.is-playing .ge-phrase,
.ge-row.is-playing .ge-icon {
  color: var(--ge-accent);
}

.ge-role {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ge-accent-2);
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.ge-phrase {
  font-family: var(--ge-serif);
  font-size: 1rem;
  line-height: 1.25;
  font-weight: 500;
  color: var(--ge-text);
  margin-bottom: 0.2rem;
}

.ge-meaning {
  color: var(--ge-muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.ge-icon {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--ge-accent);
  font-weight: 600;
}

.ge-icon::before {
  content: "\25B6 play";
}

.ge-row.is-playing .ge-icon::before {
  content: "\25B6 playing\2026";
}

.ge-row.is-playing .ge-icon {
  animation: ge-pulse 1s ease-in-out infinite;
}

@keyframes ge-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* "Pending Review" status — sits on its own row above the greeting/reply
   columns so longer labels don't bleed into the right-hand phrase. The
   outer span is the full-width flex row; the inner pill carries the visual
   styling and shrinks to its text. */
.ge-draft {
  position: static;
  order: -1;
  flex: 0 0 100%;
  display: flex;
  justify-content: flex-end;
  margin: 0 0 0.25rem;
}

.ge-draft__pill {
  display: inline-block;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--ge-draft);
  border: 1px solid var(--ge-draft);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  background: var(--ge-card);
  white-space: nowrap;
}

.ge-foot {
  text-align: center;
  color: var(--ge-muted);
  padding: 1.5rem 1rem 0.5rem;
  font-size: 0.85rem;
  border-top: 1px solid var(--ge-border);
  margin-top: 1.5rem;
}

/* ---- Stats strip — sits above the map/country area, summarising the
   dataset the user is browsing (filtered country count, language count,
   total greetings). Styled to match the site's stat blocks. ---- */
.ge-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 0 0 1.25rem;
  padding: 0.9rem 1.1rem;
  background: var(--ge-card);
  border: 1px solid var(--ge-border);
  border-radius: 14px;
}

@media (max-width: 480px) {
  .ge-stats {
    grid-template-columns: 1fr;
    gap: 0.4rem;
    padding: 0.75rem 1rem;
  }
}

.ge-stat {
  text-align: center;
  padding: 0.1rem 0.25rem;
  border-left: 1px solid var(--ge-border);
}

.ge-stat:first-child {
  border-left: 0;
}

@media (max-width: 480px) {
  .ge-stat {
    border-left: 0;
    border-top: 1px solid var(--ge-border);
    padding: 0.45rem 0;
    text-align: left;
    display: flex;
    align-items: baseline;
    gap: 0.65rem;
  }
  .ge-stat:first-child {
    border-top: 0;
    padding-top: 0;
  }
}

.ge-stat__num {
  display: block;
  font-family: var(--ge-serif);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 500;
  line-height: 1;
  color: var(--ge-accent);
}

.ge-stat__label {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ge-muted);
}

@media (max-width: 480px) {
  .ge-stat__label {
    margin-top: 0;
  }
}

/* ============================================================
   Map view — D3 Africa map + country index + slide-in drawer.
   The stage MUST clip overflow so the panel sitting at right:0
   with translateX(100%) can't push the page horizontally.
   ============================================================ */
.ge-stage {
  position: relative;
  overflow: hidden; /* contains the off-screen drawer panel */
  border-radius: 14px;
}

.ge-map-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 820px) {
  .ge-map-wrap {
    grid-template-columns: 1fr;
  }
}

.ge-map {
  width: 100%;
  background: var(--ge-card);
  border: 1px solid var(--ge-border);
  border-radius: 14px;
  padding: 0.4rem;
}

.ge-map-svg {
  width: 100%;
  height: auto;
  display: block;
  max-width: 100%;
  /* Pin the rendered aspect to the viewBox so themes that ham-fistedly set
     svg { height: 100% } can't stretch or squash Africa. */
  aspect-ratio: 1 / 0.95;
}

.ge-map-country {
  fill: var(--ge-bg-soft);
  stroke: var(--ge-card);
  stroke-width: 0.6;
  transition: fill 0.15s ease, stroke-width 0.15s ease, opacity 0.15s ease;
}

.ge-map-country.has-greetings {
  fill: var(--ge-accent);
  stroke: var(--ge-card);
  stroke-width: 0.6;
}

.ge-map-country.has-greetings:hover {
  fill: var(--ge-accent-2);
  stroke: var(--ge-text);
  stroke-width: 1.4;
}

.ge-map-country.no-greetings {
  opacity: 0.7;
}

.ge-map-country.no-greetings:hover {
  opacity: 0.85;
}

/* Selected country wears its flag (via inline fill="url(#ge-flag-XXX)").
   The dark outline + soft drop-shadow stop it from melting into the map. */
.ge-map-country.is-selected {
  stroke: var(--ge-text);
  stroke-width: 1.6;
  filter: drop-shadow(0 1px 4px rgba(26, 24, 20, 0.25));
}

.ge-map-label {
  font-family: var(--ge-sans);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  fill: var(--ge-card);
  pointer-events: none;
  paint-order: stroke;
  stroke: rgba(58, 22, 33, 0.55);
  stroke-width: 2.2px;
  stroke-linejoin: round;
}

/* ---- Country index (right rail at desktop, stacks below on narrow screens).
   Card is a flex column: the "Countries" header stays fixed at the top, the
   list below it is what actually scrolls. ---- */
.ge-index {
  background: var(--ge-card);
  border: 1px solid var(--ge-border);
  border-radius: 14px;
  padding: 0;
  max-height: 520px;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* keep rounded corners on the scrolling list */
}

/* Fixed header row holding the label and the live search input. */
.ge-index__head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--ge-border);
  background: var(--ge-card);
  flex-shrink: 0;
}

.ge-index__title {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ge-accent-2);
  font-weight: 700;
  flex-shrink: 0;
}

.ge-index__search {
  flex: 1 1 auto;
  min-width: 0;
}

.ge-player .ge-index__input {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: var(--ge-bg-soft);
  border: 1px solid var(--ge-border);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font: inherit;
  font-size: 0.78rem;
  color: var(--ge-text);
  outline: none;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}

.ge-player .ge-index__input::placeholder {
  color: var(--ge-muted);
  opacity: 1;
}

.ge-player .ge-index__input:focus,
.ge-player .ge-index__input:focus-visible {
  border-color: var(--ge-accent);
  background: var(--ge-card);
  box-shadow: 0 0 0 2px rgba(90, 26, 43, 0.12);
}

.ge-index__empty {
  list-style: none;
  padding: 0.6rem 0.75rem;
  color: var(--ge-muted);
  font-size: 0.85rem;
  text-align: center;
}

.ge-index__list {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  /* The scrolling region. min-height:0 is the flex gotcha that lets the
     list shrink below its content size so overflow-y actually kicks in. */
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.ge-index__btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--ge-text);
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.ge-index__btn:hover,
.ge-index__btn:focus-visible {
  background: var(--ge-card-hover);
  border-color: var(--ge-border);
  color: var(--ge-accent);
  outline: none;
}

.ge-index__meta {
  margin-left: auto;
  color: var(--ge-muted);
  font-size: 0.75rem;
  font-weight: 400;
}

/* ---- Slide-in drawer ---- */
.ge-drawer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.ge-drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 24, 20, 0.35);
  opacity: 0;
  transition: opacity 0.24s ease;
}

.ge-drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(460px, 92%);
  height: 100%;
  background: var(--ge-card);
  border-left: 1px solid var(--ge-border);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.2, 0.7, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -16px 0 36px rgba(26, 24, 20, 0.12);
}

.ge-drawer.is-open {
  pointer-events: auto;
}

.ge-drawer.is-open .ge-drawer__backdrop {
  opacity: 1;
}

.ge-drawer.is-open .ge-drawer__panel {
  transform: translateX(0);
}

.ge-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--ge-border);
  background: var(--ge-bg-soft);
}

.ge-drawer__heading {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  flex: 1 1 auto;
}

.ge-drawer__title {
  margin: 0;
  font-family: var(--ge-serif);
  font-weight: 500;
  font-size: 1.4rem;
  color: var(--ge-accent);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.ge-drawer__subtitle {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--ge-muted);
}

/* Specificity bump (.ge-player ancestor) + explicit reset on every
   interactive state stops the WP theme from painting this button pink /
   another colour. The close button is a <button>, which most themes
   restyle aggressively. */
.ge-player .ge-drawer__close {
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  background-color: transparent;
  border: 1px solid transparent;
  color: var(--ge-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
  flex-shrink: 0;
  outline: none;
  text-shadow: none;
  box-shadow: none;
}

.ge-player .ge-drawer__close:hover,
.ge-player .ge-drawer__close:focus,
.ge-player .ge-drawer__close:focus-visible,
.ge-player .ge-drawer__close:active {
  color: var(--ge-accent);
  background: var(--ge-card);
  background-color: var(--ge-card);
  border-color: var(--ge-border);
  outline: none;
}

.ge-drawer__body {
  padding: 1.1rem 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
}

/* Language tabs — when a country has more than one language, the drawer
   shows them as tabs (underline style) so users switch between languages
   instead of scrolling through them stacked. */
.ge-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem;
  border-bottom: 1px solid var(--ge-border);
  margin: 0 0 1rem;
}

.ge-tab {
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  background: transparent;
  border: 0;
  font: inherit;
  cursor: pointer;
  padding: 0.55rem 0.85rem 0.65rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.05rem;
  color: var(--ge-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px; /* sit on top of .ge-tabs border so the active line is continuous */
  border-radius: 6px 6px 0 0;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
  outline: none;
}

.ge-tab:hover {
  color: var(--ge-accent);
  background: var(--ge-bg-soft);
}

.ge-tab:focus-visible {
  outline: 2px solid var(--ge-accent);
  outline-offset: -2px;
}

.ge-tab.is-active {
  color: var(--ge-accent);
  border-bottom-color: var(--ge-accent);
  background: transparent;
}

.ge-tab__header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.ge-tab__name {
  font-family: var(--ge-serif);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.15;
}

.ge-tab__count {
  display: inline-block;
  font-family: var(--ge-sans);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ge-accent-2);
  background: var(--ge-bg-soft);
  padding: 0.18rem 0.42rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.ge-tab.is-active .ge-tab__count {
  color: var(--ge-card);
  background: var(--ge-accent);
}

.ge-tab__endonym {
  font-size: 0.7rem;
  line-height: 1.15;
  color: var(--ge-muted);
}

.ge-tab.is-active .ge-tab__endonym {
  color: var(--ge-accent);
  opacity: 0.72;
}

/* Tab panel — the active language's content. The tab strip is the header,
   so we strip the panel chrome that .ge-language carries elsewhere. */
.ge-tabpanel .ge-language {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

/* Drawer-specific language name override (only used by the legacy
   single-block layout — kept as a no-op safeguard). */
.ge-drawer__body .ge-language__name {
  font-size: 1.05rem;
}
/* In the drawer, drop the auto-fill grid to single-column so each greeting
   gets the full panel width and the cards never wrap to dot-sized boxes. */
.ge-drawer__body .ge-grid {
  grid-template-columns: 1fr;
}

/* Phone: drawer becomes a bottom sheet so it doesn't fight a narrow viewport. */
@media (max-width: 720px) {
  .ge-drawer__panel {
    width: 100%;
    top: auto;
    bottom: 0;
    height: min(82%, 640px);
    transform: translateY(100%);
    border-left: 0;
    border-top: 1px solid var(--ge-border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -16px 36px rgba(26, 24, 20, 0.18);
  }
  .ge-drawer.is-open .ge-drawer__panel {
    transform: translateY(0);
  }
  /* Grip handle, matches common bottom-sheet UX. */
  .ge-drawer__panel::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: var(--ge-border);
  }
  .ge-drawer__head {
    padding-top: 1.4rem;
  }
}
