/* [50-modal] Fenêtre modale universelle et onglet Recherche */
/* ==========================================================================
   5. FENÊTRE MODALE UNIVERSELLE FIDÈLE (EXACT REVIEW_1 & REVIEW_4)
   ========================================================================== */
/* Cadre commun des fenêtres :
   fond noir à colonnes de chevrons Art déco, liseré or, bandeau métal sombre,
   cartouche de titre trapézoïdal doré, onglets argentés, croix rouge sur médaillon or.
   Les fenêtres s'ouvrent DANS le cadre de jeu (980 × 640), comme l'original. */
.game-modal-curtain,
.custom-modal-overlay {
  position: absolute;
  /* rideau sous le bandeau de ressources : celui-ci reste visible et non assombri */
  inset: var(--modal-top, 30px) 0 0 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
}
.game-modal-curtain.hidden,
.custom-modal-overlay.hidden {
  display: none !important;
}

.game-modal-box,
.custom-modal-box,
.leaderboard-panel:not(.tournament-folder) {
  --mf-gold: #9d815d;
  --mf-gold-hi: #dec4a2;
  position: relative;
  width: 760px;
  max-width: 960px;
  max-height: 630px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='38' height='26'%3E%3Cg fill='none' stroke='%23b8913c' stroke-opacity='.32' stroke-width='1'%3E%3Cpath d='M0 13 19 4l19 9M0 22l19-9 19 9'/%3E%3Cpath d='M.5 0v26'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 38px 26px,
    #090a0b;
  border: 2px solid var(--mf-gold);
  border-radius: 2px;
  box-shadow: 0 0 0 1px #000, inset 0 0 0 1px #000, 0 10px 34px rgba(0, 0, 0, 0.9);
  color: var(--text-cream);
  font-family: 'Josefin Sans', 'Gill Sans', 'Trebuchet MS', sans-serif;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

/* Bandeau de tête en métal sombre */
.modal-crown-trapezoid,
.leaderboard-panel:not(.tournament-folder) > .leaderboard-header {
  position: relative;
  flex-shrink: 0;
  height: 48px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: linear-gradient(180deg, #3c3c3c 0%, #222 40%, #131313 70%, #0c0c0c 100%);
  border-bottom: 1px solid #000;
}
/* filet clair en arc, comme le reflet du bandeau d'origine */
.modal-crown-trapezoid::before,
.leaderboard-panel:not(.tournament-folder) > .leaderboard-header::before {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  top: 10px;
  height: 30px;
  border-top: 2px solid rgba(220, 220, 220, 0.16);
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  pointer-events: none;
}

/* Cartouche du titre : trapèze doré, plus large en haut */
.modal-crown-title,
.leaderboard-panel:not(.tournament-folder) > .leaderboard-header h2 {
  position: relative;
  z-index: 0;
  min-width: 240px;
  max-width: calc(100% - 120px);
  height: 42px;
  margin: 0;
  padding: 0 52px 2px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #decab0;
  font-family: 'Limelight', serif;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 1px;
  text-shadow: 0 1px 2px #000;
}
.modal-crown-title::before,
.leaderboard-panel:not(.tournament-folder) > .leaderboard-header h2::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -2;
  background: linear-gradient(90deg, var(--mf-gold-hi) 0 30px, var(--mf-gold) 30px calc(100% - 30px), var(--mf-gold-hi) calc(100% - 30px));
  clip-path: polygon(0 0, 100% 0, calc(100% - 26px) 100%, 26px 100%);
}
.modal-crown-title::after,
.leaderboard-panel:not(.tournament-folder) > .leaderboard-header h2::after {
  content: '';
  position: absolute;
  inset: 0 4px 2px;
  z-index: -1;
  background: linear-gradient(180deg, #353535 0%, #141414 55%, var(--ink-black) 100%);
  clip-path: polygon(0 0, 100% 0, calc(100% - 23px) 100%, 23px 100%);
}

/* Croix rouge sur médaillon or */
.modal-corner-close,
.leaderboard-panel:not(.tournament-folder) .leaderboard-close {
  position: absolute;
  top: 7px;
  right: 10px;
  z-index: 2;
  width: 32px;
  height: 32px;
  padding: 0;
  box-sizing: border-box;
  border-radius: 50%;
  border: 1px solid #302210;
  background: radial-gradient(circle at 40% 30%, #f3e2cc 0%, #c7a373 35%, #836339 75%, #4c381e 100%);
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.8);
  color: transparent;
  font-size: 0;
  cursor: pointer;
  transform: none;
  transition: filter 0.15s;
}
.modal-corner-close::before,
.modal-corner-close::after,
.leaderboard-panel:not(.tournament-folder) .leaderboard-close::before,
.leaderboard-panel:not(.tournament-folder) .leaderboard-close::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 6px;
  margin: -3px 0 0 -10px;
  border-radius: 2px;
  background: linear-gradient(180deg, #e76658 0%, #b83628 50%, #7a2017 100%);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
  transform: rotate(45deg);
}
.modal-corner-close::after,
.leaderboard-panel:not(.tournament-folder) .leaderboard-close::after { transform: rotate(-45deg); }
.modal-corner-close:hover,
.leaderboard-panel:not(.tournament-folder) .leaderboard-close:hover {
  transform: none;
  background: radial-gradient(circle at 40% 30%, #f8eddf 0%, #d7b383 35%, #926f42 75%, #4c381e 100%);
  filter: brightness(1.08);
}

/* Barre d'onglets : onglets argentés, l'actif en bronze */
.modal-nav-tabs {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 4px 14px 0;
  background: linear-gradient(180deg, #161616 0%, #070707 100%);
  border-bottom: 2px solid var(--mf-gold);
}
.modal-tab-btn {
  min-width: 96px;
  height: 28px;
  padding: 0 14px;
  margin: 0;
  background: linear-gradient(180deg, #2c2c2c 0%, #0a0a0a 100%);
  border: 1px solid #7a7a7a;
  border-top-color: #cfcfcf;
  border-bottom: none;
  border-radius: 1px 1px 0 0;
  color: #fff;
  font-family: 'Josefin Sans', 'Gill Sans', sans-serif;
  font-size: 12.5px;
  font-weight: 400;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  text-shadow: 0 1px 1px #000;
  white-space: nowrap;
  cursor: pointer;
}
.modal-tab-btn:hover { background: linear-gradient(180deg, #3a3a3a 0%, #121212 100%); }
.modal-tab-btn.active {
  background: linear-gradient(180deg, #897151 0%, #413321 45%, #17120b 100%);
  border-color: #c4a67f;
  color: #fff;
}

.modal-inner-padding {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
}

.modal-flavor-intro {
  font-family: 'Limelight', serif;
  font-style: italic;
  font-size: 12.5px;
  line-height: 1.45;
  color: #c5b5a0;
  margin-bottom: 14px;
  border-left: 3px solid var(--gold-primary);
  padding-left: 10px;
}

.modal-middle-grid {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 16px;
  margin-bottom: 14px;
}

.building-artwork-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.building-artwork-portrait {
  width: 190px;
  height: 140px;
  border: 1.5px solid var(--gold-dark);
  border-radius: 4px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.8);
}

.building-artwork-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.level-transition-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-family: 'Limelight', serif;
  font-weight: 800;
  color: var(--gold-highlight);
}

.lvl-arrow {
  color: #e65c4c;
  font-size: 14px;
}

/* Tableau */
.game-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  background: rgba(8, 8, 9, 0.85);
  border: 1px solid #362b1d;
}

.game-table th {
  background: linear-gradient(180deg, #1a221f 0%, #0c1210 100%);
  color: var(--gold-highlight);
  font-family: 'Limelight', serif;
  font-size: 10px;
  font-weight: 700;
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid #413525;
}

.game-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #1f1911;
  color: #eee;
}

.game-table tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.status-check {
  color: #6aeabb;
  font-weight: bold;
}

.status-cross {
  color: #e8695b;
  font-weight: bold;
}

/* Bulle de dialogue du Conseiller dans la modale */
.advisor-speech-bubble-row {
  background: rgba(251, 246, 239, 0.95);
  color: #1a3c31;
  border: 1px solid #b19877;
  border-radius: 4px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  box-shadow: inset 0 0 6px rgba(0,0,0,0.1);
}

.advisor-bubble-face {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid #35745f;
  overflow: hidden;
  flex-shrink: 0;
}

.advisor-bubble-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.advisor-speech-text {
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.35;
}

/* Boutons d'action : BUILD & BUILD NOW */
.modal-bottom-buttons-row {
  display: flex;
  justify-content: center;
  gap: 16px;
}

/* Gros boutons d'action des fenêtres (BUILD / BUILD NOW de l'original) :
   rouge brillant à reflet coupé, ou gris anthracite, coins arrondis, liseré clair */
.btn-big-red-build,
.btn-big-grey-instant {
  flex: 1;
  padding: 7px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  border-radius: 6px;
  color: #fff;
  font-family: 'Josefin Sans', 'Gill Sans', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  cursor: pointer;
  transition: filter 0.15s;
}
.btn-big-red-build {
  background: linear-gradient(180deg, #db5f51 0%, #ae392c 48%, #88271c 52%, #611911 100%);
  border: 1px solid #f6c3bd;
  box-shadow: inset 0 1px 0 rgba(249, 219, 216, 0.55), 0 0 0 2px #0b211a, 0 0 9px rgba(140, 210, 255, 0.45);
}
.btn-big-grey-instant {
  background: linear-gradient(180deg, #5c5c5c 0%, #2e2e2e 48%, #1a1a1a 52%, #0a0a0a 100%);
  border: 1px solid #c8c8c8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 0 0 2px #000;
}
.btn-big-red-build:hover:not(:disabled),
.btn-big-grey-instant:hover:not(:disabled) { filter: brightness(1.15); }
.btn-big-red-build:disabled,
.btn-big-grey-instant:disabled {
  cursor: not-allowed;
  filter: grayscale(0.85) brightness(0.7);
}
.build-btn-time,
.build-btn-cost {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  font-variant-numeric: tabular-nums;
}
.build-btn-time { color: #eed7b9; }
.build-btn-cost { color: #bdf0ff; }

/* Bouton secondaire générique des panneaux (hôpital, marché noir…) */
.btn-city-action {
  min-height: 24px;
  padding: 4px 12px;
  background: linear-gradient(180deg, #4a4a4a 0%, #222 50%, #141414 51%, #080808 100%);
  border: 1px solid #a8a8a8;
  border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 3px rgba(0, 0, 0, 0.8);
  color: #fff;
  font-family: 'Josefin Sans', 'Gill Sans', sans-serif;
  font-size: 12px;
  text-shadow: 0 1px 1px #000;
  cursor: pointer;
}
.btn-city-action:hover:not(:disabled) { filter: brightness(1.2); }
.btn-city-action:disabled { opacity: 0.5; cursor: not-allowed; }


/* ==========================================================================
   ONGLET RECHERCHE (STYLE REVIEW_4.JPG)
   ========================================================================== */
/* Fenêtre élargie pour l'onglet Recherche */
.game-modal-box.modal-wide {
  width: 880px;
}
/* plusieurs onglets : hauteur fixe aussi, pour ne pas sauter d'un onglet à l'autre */
#building-modal .game-modal-box.modal-wide { height: 96%; }

.research-tree-layout {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

/* Plateau : capture de l'arbre original (bibliothèque, cartes et liaisons) */
.research-tree-board {
  position: relative;
  flex-shrink: 0;
  width: 542px;
  height: 476px;
  background: #11251f; /* plan d'architecte : 99-zresearch-plan.css */
  border: 1px solid #433523;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8);
}

/* Carte interactive posée exactement sur la carte de l'original (117x51) */
.research-card {
  position: absolute;
  width: 117px;
  height: 51px;
  cursor: pointer;
  border-radius: 1px;
  transition: box-shadow 0.15s, background-color 0.15s;
}

.research-card:hover {
  box-shadow: 0 0 0 2px #e9c9a0, 0 0 12px rgba(226, 184, 129, 0.6);
}

.research-card.is-selected {
  box-shadow: 0 0 0 2px var(--gold-amber), 0 0 16px rgba(222, 175, 113, 0.85);
}

.research-card.is-locked {
  background: rgba(0, 0, 0, 0.62);
}

.research-card.is-locked:hover {
  background: rgba(0, 0, 0, 0.45);
}

.research-card.is-researching {
  animation: researchPulse 1.4s ease-in-out infinite;
}

@keyframes researchPulse {
  0%, 100% { box-shadow: 0 0 0 2px #4ebd94, 0 0 6px rgba(78, 189, 148, 0.4); }
  50% { box-shadow: 0 0 0 2px #8defcb, 0 0 16px rgba(78, 189, 148, 0.9); }
}

/* Nom dans le bandeau noir du bas de la carte */
.research-card-name {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 3px;
  font-family: 'Josefin Sans', sans-serif;
  font-size: 10.5px;
  font-weight: 700;
  color: #ddc19d;
  text-align: center;
  text-shadow: 0 1px 2px #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.research-card.is-locked .research-card-name {
  color: #8c8273;
}

.research-card-lock,
.research-card-timer {
  position: absolute;
  left: 50%;
  top: 9px;
  transform: translateX(-50%);
  font-size: 15px;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
}

/* Pastille de niveau : recouvre le cercle blanc de l'original (centre ≈ x+111, y+6) */
.research-level-pip {
  position: absolute;
  left: 96px;
  top: -9px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #ffffff 0%, #e6eef0 70%, #c9d6da 100%);
  border: 2px solid #4f8fa3;
  box-shadow: 0 0 0 1px #0b2a33, 0 2px 4px rgba(0, 0, 0, 0.8);
  color: #1b1b1b;
  font-family: 'Josefin Sans', sans-serif;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.research-card.is-locked .research-level-pip {
  background: radial-gradient(circle at 40% 35%, #8a8a8a, #4a4a4a);
  border-color: #3b3b3b;
  color: #ddd;
}

.research-card.is-maxed .research-level-pip {
  background: radial-gradient(circle at 40% 35%, #edd3b2, var(--gold-primary) 75%);
  border-color: #66461b;
}

/* Fiche de détail à droite de l'arbre */
.research-detail-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.research-detail-header h3 {
  color: #e2b983;
  font-family: 'Limelight', serif;
  font-size: 16px;
}

#research-selected-lvl {
  color: #bbb;
  font-size: 12px;
}

.research-art-frame {
  width: 230px;
  height: 75px;
  border: 2px solid var(--gold-dark);
  border-radius: 2px;
  background: #000;
  image-rendering: auto;
  align-self: center;
}

.research-desc-box {
  font-size: 11.5px;
  color: #c5b5a0;
  line-height: 1.35;
}

.research-prereq-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
}

.prereq-row.ok {
  color: #88d3b8;
}

.prereq-row.ko {
  color: #ed897d;
}

.research-cost-table th,
.research-cost-table td {
  padding: 3px 5px;
  font-size: 11px;
}

.research-buttons-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.research-buttons-col .btn-big-red-build,
.research-buttons-col .btn-big-grey-instant {
  width: 100%;
  padding: 7px 8px;
  font-size: 12px;
}
