/*
  Country Mash: what its two pages need on top of site.css. The picker is
  country-mash.blade.php, and the country it makes is created-country.blade.php.

  The map reads its colours from the --map-* values below, and redraws when the visitor
  switches between light and dark.
*/

:root {
  --map-ocean: #e2eaf2;
  --map-land: #c0ccd9;
  --map-land-hover: #9aacbf;
  --map-coast: #ffffff;
}
html[data-theme="dark"] {
  --map-ocean: #0c1524;
  --map-land: #24364f;
  --map-land-hover: #38547e;
  --map-coast: #09101b;
}

/* A small flag picture. */
.flag { display: block; object-fit: cover; border-radius: 3px; box-shadow: 0 0 0 1px rgba(14, 27, 43, .12); }

/* ═══ The picker ═══════════════════════════════════════════ */
.picker {
  display: grid;
  grid-template-columns: minmax(330px, 400px) minmax(0, 1fr);
  gap: clamp(20px, 2.6vw, 32px);
  align-items: start;
  width: 100%;
  max-width: 1440px;
  margin-inline: auto;
  padding: clamp(18px, 2.6vw, 30px) clamp(14px, 3vw, 28px) 0;
}
.picker-panel { position: sticky; top: calc(var(--header-h) + 20px); }

.picker h1 {
  margin-top: 12px;
  font: 600 clamp(2.2rem, 4.2vw, 3.1rem)/1.02 var(--serif);
  letter-spacing: -.03em;
}
.picker h1 em { color: var(--accent); font-style: italic; }
.picker-sub { margin-top: 14px; color: var(--ink-2); font-size: 1rem; line-height: 1.6; }

/* Steps */
.steps { display: flex; align-items: center; gap: 8px; margin-top: 22px; }
.step { display: flex; align-items: center; gap: 8px; color: var(--ink-3); font: 500 .7rem/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; transition: color .2s; }
.step-num {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  font-size: .68rem;
  transition: background .2s, color .2s, border-color .2s;
}
.step.active { color: var(--ink); }
.step.active .step-num { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.step.done { color: var(--ok); }
.step.done .step-num { border-color: var(--ok); background: var(--ok); color: #fff; }
.step-line { flex: 1; min-width: 12px; max-width: 40px; height: 1.5px; background: var(--line-strong); }

/* Chosen countries */
.slots { display: flex; flex-direction: column; gap: 8px; margin-top: 22px; }
.slot {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 12px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 14px;
  background: transparent;
}
.slot.filled { border: 1.5px solid var(--slot-color, var(--line-strong)); background: var(--surface); box-shadow: var(--shadow); }
.slot.pulse { animation: slot-pulse .35s var(--ease); }
@keyframes slot-pulse { 40% { transform: scale(1.025); } }
.slot-num {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-3);
  font: 500 .75rem/1 var(--mono);
}
.slot.filled .slot-num { background: var(--slot-color); color: #fff; }
.slot-flag { width: 44px; height: 30px; flex-shrink: 0; }
.slot-emoji { flex-shrink: 0; font-size: 1.6rem; line-height: 1; }
.slot-text { min-width: 0; flex: 1; }
.slot-name { overflow: hidden; font: 600 1.05rem/1.2 var(--serif); letter-spacing: -.01em; text-overflow: ellipsis; white-space: nowrap; }
.slot-sub { margin-top: 2px; color: var(--ink-3); font: 400 .7rem/1.3 var(--mono); letter-spacing: .04em; }
.slot-empty-hint { color: var(--ink-3); font-size: .9rem; }
.slot-clear {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-3);
  font-size: .9rem;
  cursor: pointer;
}
.slot-clear:hover { background: var(--surface-2); color: var(--ink); }
.btn-add-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 14px;
  background: transparent;
  color: var(--ink-3);
  font: 500 .875rem/1 var(--sans);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.btn-add-slot:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* The Mash button */
.mash-wrap { margin-top: 16px; }
.btn-mash { width: 100%; min-height: 54px; background: var(--ink); color: var(--bg); font-size: 1rem; opacity: .4; pointer-events: none; }
.btn-mash.ready { background: var(--accent); color: var(--accent-ink); opacity: 1; pointer-events: auto; }
.btn-mash.ready:hover { background: var(--accent-hover); }
.btn-mash span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Search */
.search-wrap { position: relative; z-index: 200; }
.search-input {
  width: 100%;
  min-height: 48px;
  padding: 0 16px 0 44px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: 400 1rem/1.4 var(--sans);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-input::placeholder { color: var(--ink-3); }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-icon { position: absolute; top: 50%; left: 15px; color: var(--ink-3); transform: translateY(-50%); pointer-events: none; }
.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  z-index: 300;
  display: none;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.search-dropdown.open { display: block; }
.search-item { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 14px; color: var(--ink); font-size: .95rem; cursor: pointer; }
.search-item:hover { background: var(--surface-2); }
.search-item.is-selected { background: var(--accent-soft); }
.search-item .flag { width: 26px; height: 18px; flex-shrink: 0; }
.search-item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; margin-left: auto; }
.search-item-region { color: var(--ink-3); font: 500 .65rem/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.search-item-picked { color: var(--accent); font: 500 .65rem/1 var(--mono); }

/* Map */
.map-section { min-width: 0; }
.map-container { margin-top: 12px; overflow: hidden; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--map-ocean); box-shadow: var(--shadow); isolation: isolate; }
#map { width: 100%; height: clamp(380px, calc(100vh - 200px), 780px); background: var(--map-ocean); }
.map-hint { margin-top: 10px; text-align: center; }
.mobile-search-panel { display: none; }

.leaflet-container { font-family: var(--sans); }
.leaflet-control-attribution { opacity: .55; font-size: 9px !important; }
.leaflet-bar { border: 1px solid var(--line-strong) !important; border-radius: 10px !important; box-shadow: var(--shadow) !important; overflow: hidden; }
.leaflet-control-zoom a { border-color: var(--line) !important; background: var(--surface) !important; color: var(--ink) !important; }
.leaflet-control-zoom a:hover { background: var(--surface-2) !important; }
.leaflet-interactive:focus { outline: none; }

.leaflet-tooltip { padding: 0 !important; border: 0 !important; background: none !important; box-shadow: none !important; }
.leaflet-tooltip::before { display: none !important; }
.nf-tooltip { min-width: 200px; max-width: 250px; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-lg); color: var(--ink); font-family: var(--sans); pointer-events: none; }
.nf-tt-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.nf-tt-flag { width: 34px; height: 23px; flex-shrink: 0; }
.nf-tt-name { font: 600 1rem/1.2 var(--serif); }
.nf-tt-body { padding: 10px 14px 12px; }
.nf-tt-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.nf-tt-key { color: var(--ink-3); font: 500 .6rem/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.nf-tt-val { font-size: .8rem; font-weight: 500; text-align: right; white-space: normal; }
.nf-tt-hint { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--accent); font: 500 .62rem/1 var(--mono); letter-spacing: .08em; text-align: center; text-transform: uppercase; }

/* Confirm window */
.modal-backdrop { position: fixed; inset: 0; z-index: 2000; display: none; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; background: rgba(9, 16, 27, .6); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.modal-backdrop.open { display: flex; }
.modal { width: 100%; max-width: 500px; margin: auto; padding: clamp(22px, 4vw, 34px) clamp(16px, 4vw, 30px); border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-lg); text-align: center; animation: pop .25s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.modal-flags { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: center; gap: 10px; margin: 18px 0 20px; }
.modal-flag-wrap { width: 76px; }
.modal-flag-img { width: 68px; height: 46px; margin: 0 auto 6px; }
.modal-flag-emoji { display: grid; place-items: center; width: 68px; height: 46px; margin: 0 auto 6px; font-size: 2rem; }
.modal-flag-name { font: 600 .8rem/1.2 var(--serif); overflow-wrap: anywhere; }
.modal-plus { align-self: flex-start; margin-top: 10px; color: var(--accent); font: 600 1.25rem/1 var(--serif); }
.modal-title { font: 600 clamp(1.3rem, 4vw, 1.6rem)/1.15 var(--serif); letter-spacing: -.02em; overflow-wrap: anywhere; }
.modal-desc { margin: 10px 0 20px; color: var(--ink-2); font-size: .92rem; line-height: 1.6; }
.model-selector { margin-bottom: 16px; text-align: left; }
.model-selector .label { display: block; margin-bottom: 8px; }
.model-select {
  width: 100%;
  min-height: 46px;
  padding: 0 38px 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%2366768a' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 14px center;
  color: var(--ink);
  font: 400 .95rem/1.2 var(--sans);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.model-select:focus { border-color: var(--accent); outline: none; }
.model-select option { background: var(--surface); color: var(--ink); }
.modal-captcha { display: flex; justify-content: center; min-height: 78px; margin-bottom: 16px; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.modal-actions .btn { flex: 1 1 140px; }

/* While the country is being made */
.gen-overlay { position: fixed; inset: 0; z-index: 2100; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px; background: var(--bg); text-align: center; }
.gen-overlay.open { display: flex; }
.gen-nations { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; }
.gen-nations .flag { width: 54px; height: 36px; }
.gen-times { color: var(--accent); font: 600 1.2rem/1 var(--serif); }
.gen-title { max-width: 22ch; font: 600 clamp(1.5rem, 5vw, 2.2rem)/1.15 var(--serif); letter-spacing: -.02em; overflow-wrap: anywhere; }
.gen-line { min-height: 1.2em; transition: opacity .3s; }

/* Tablets and phones: one column, and the Mash button stays at the bottom of the screen. */
@media (max-width: 959.98px) {
  .picker { grid-template-columns: minmax(0, 1fr); padding-bottom: 96px; }
  .picker-panel { position: static; }
  #map { height: clamp(320px, 62vw, 560px); }
  .mash-wrap {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 150;
    margin: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--surface);
  }
  .mash-wrap .btn-mash { max-width: 560px; margin-inline: auto; display: flex; }
  .toast { bottom: 96px; }
  .picker ~ .site-footer, .site-main:has(.picker) ~ .site-footer { padding-bottom: 104px; }
}

/* Phones: a world map is too small to tap, so a search takes its place. */
@media (max-width: 600px) {
  .map-section { display: none; }

  /* The search is the main control here, so it moves up, right under the introduction.
     The panel and the side column dissolve into the page, so their parts can be put
     in a new order. */
  .picker { display: flex; flex-direction: column; align-items: stretch; gap: 0; }
  .picker-panel, .picker-side { display: contents; }
  .picker-intro { order: 1; }
  .mobile-search-panel { display: block; order: 2; margin-top: 20px; }
  .steps { order: 3; }
  .slots { order: 4; margin-top: 16px; }

  .mobile-search-panel .label { display: block; margin-bottom: 10px; }
  .mobile-search-panel .search-dropdown { max-height: min(340px, 46vh); }

  /* Only the step you're on is named. */
  .step span { display: none; }
  .step.active span { display: inline; }
  .step-line { max-width: none; }

  .picker h1 { font-size: clamp(2rem, 9.6vw, 2.6rem); }
  .slot { min-height: 58px; padding: 8px 10px; }
}

/* Fingers need a bigger target than a mouse pointer does. */
@media (pointer: coarse) {
  .slot-clear { width: 42px; height: 42px; }
}

/* ═══ The country page ═════════════════════════════════════ */
.entry-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(40px, 7vw, 84px) clamp(16px, 4vw, 32px) 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  text-align: center;
}
/* Faint lines of latitude and longitude behind the name. */
.entry-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, var(--line) 0 1px, transparent 1px 56px),
    repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 56px);
  opacity: .55;
  -webkit-mask-image: radial-gradient(ellipse 75% 85% at 50% 0%, #000 0%, transparent 72%);
  mask-image: radial-gradient(ellipse 75% 85% at 50% 0%, #000 0%, transparent 72%);
  pointer-events: none;
}
.entry-hero-inner { position: relative; max-width: 900px; margin-inline: auto; }

.fusion-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-bottom: clamp(20px, 3vw, 30px); }
.fusion-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 14px 0 8px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--ink-2); font-size: .85rem; font-weight: 500; }
.fusion-chip .flag { width: 24px; height: 16px; }
.fusion-x { color: var(--ink-3); }
.fusion-arrow { color: var(--accent); }

/* The name is sized to fit on one line where it can: --len is how many letters it has,
   set on the element, so a long name gets smaller letters and isn't cut mid-word. */
.country-name {
  font: 600 clamp(1.9rem, min(10vw, calc(165vw / var(--len, 8)), calc(1500px / var(--len, 8))), 6rem)/1 var(--serif);
  letter-spacing: -.04em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.country-official { margin-top: 14px; color: var(--ink-2); font: italic 400 clamp(1rem, 2.2vw, 1.3rem)/1.4 var(--serif); text-wrap: balance; }
@media (max-width: 520px) {
  /* With several source countries the chips wrap, and the crosses would dangle. */
  .fusion-x { display: none; }
}

.key-facts {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  max-width: 900px;
  margin: clamp(28px, 4vw, 44px) auto 0;
  border-top: 1px solid var(--line);
}
.key-fact { padding: 18px 14px; border-right: 1px solid var(--line); }
.key-fact:last-child { border-right: 0; }
.key-fact dt { margin-bottom: 6px; }
.key-fact dd { margin: 0; font: 600 1.05rem/1.25 var(--serif); overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .key-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .key-fact:nth-child(even) { border-right: 0; }
  .key-fact:nth-child(n+3) { border-top: 1px solid var(--line); }
}

.entry { width: 100%; max-width: 1120px; margin-inline: auto; padding: clamp(24px, 4vw, 44px) clamp(16px, 3vw, 28px) 0; }

.visuals-row { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; align-items: start; }
.content-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.right-stack { display: flex; flex-direction: column; gap: 20px; }
@media (max-width: 820px) { .visuals-row { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .content-row { grid-template-columns: 1fr; } }

.card-label { display: block; margin-bottom: 14px; }

.flag-frame, .coa-frame { position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; }
.flag-frame { width: 100%; aspect-ratio: 3 / 2; background: var(--surface-2); }
.flag-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.coa-card { text-align: center; }
.coa-frame { width: 100%; max-width: 210px; aspect-ratio: 3 / 4; margin: 0 auto; background: #fff; }
.coa-frame img { display: block; width: 100%; height: 100%; object-fit: contain; }
.img-ph { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px; color: var(--ink-3); font-size: .85rem; text-align: center; }
.coa-frame .img-ph { color: #66768a; }
.img-missing { opacity: .4; }

.model-tag { display: inline-flex; align-items: center; gap: 7px; min-height: 28px; margin-top: 14px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--ink-3); font-size: .75rem; }
.model-tag-dot { width: 6px; height: 6px; flex-shrink: 0; border-radius: 50%; background: var(--accent); }
.flag-caption { margin-top: 14px; color: var(--ink-2); font: italic 400 1rem/1.6 var(--serif); }

.info-table { margin: 0; }
.irow { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.irow:first-child { padding-top: 0; }
.irow:last-child { padding-bottom: 0; border-bottom: 0; }
.irow dt { flex-shrink: 0; }
.irow dd { margin: 0; font-size: .92rem; font-weight: 500; text-align: right; overflow-wrap: anywhere; }
.irow dd.is-code { color: var(--accent); font: 500 .95rem/1.2 var(--mono); letter-spacing: .14em; }

.desc-text { color: var(--ink-2); font-size: 1.02rem; line-height: 1.8; }
.desc-text::first-letter { float: left; margin: 6px 10px 0 0; color: var(--accent); font: 600 3.4em/.8 var(--serif); }

.facts-list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.fact-item { display: flex; align-items: flex-start; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); color: var(--ink-2); font-size: .95rem; line-height: 1.65; }
.fact-item:first-child { padding-top: 0; }
.fact-item:last-child { padding-bottom: 0; border-bottom: 0; }
.fact-num { display: grid; place-items: center; width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font: 500 .75rem/1 var(--mono); }

.born-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.born-card { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.born-flag { display: block; width: 100%; height: 96px; object-fit: cover; border-bottom: 1px solid var(--line); }
.born-info { padding: 12px 16px 14px; }
.born-name { font: 600 1.05rem/1.25 var(--serif); }
.born-meta { margin-top: 4px; color: var(--ink-3); font-size: .8rem; line-height: 1.5; }

