/*
 * Art direction "Interface en jeu": colours and fonts taken from the Civ VI
 * base-game UI files (Base/Assets/UI):
 * - Civ6_Styles.xml, most used colours: #070F17, #051D33, #102B43 (16,43,67),
 *   #294A6C (41,74,108), text #D0D4D9 (208,212,217);
 * - Civ6_ColorAtlas.xml: GoldMetal #CBAD73, GoldMetalDark #826F4B,
 *   Science #44B3EA, Civ6DarkRed #981E1E, COLOR_MEDIUM_GREEN #076E27,
 *   Emergency_Bronze #CE7C33.
 * Not from the game: --muted, --panel-hi, and --partial (Emergency_Bronze
 * darkened so that white text stays readable), chosen here.
 * Colour-blind mode (html.colorblind, js/core/settings.js): --ok becomes
 * Okabe-Ito blue #0072B2 and --ko a neutral grey #4A5058 (chosen here);
 * --partial is unchanged.
 * Fonts: the game uses Minion Pro (titles) and Myriad Pro (text), Adobe
 * commercial fonts; the site uses the free Crimson Pro and Source Sans 3
 * (Google Fonts, index.html) as look-alikes, not equivalents.
 */
:root {
  --bg: #070F17;
  --bar: #051D33;
  --panel: #0D2438;
  --panel-hi: #102B43;
  --panel-2: #294A6C;
  --text: #D0D4D9;
  --muted: #A9B4BF;
  --gold: #CBAD73;
  --gold-dk: #826F4B;
  --gold-lt: #E8D4A6;
  --accent: #44B3EA;
  --ok: #076E27;
  --partial: #A8601F;
  --ko: #981E1E;
  /* History rows (non-classic modes): dark fill + brighter border. */
  --ok-line: #1E9A45;
  --ok-row: #062A14;
  --ko-row: #2A0F12;
  --radius: 4px;
  --serif: "Crimson Pro", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
}

html.colorblind {
  --ok: #0072B2;
  --ko: #4A5058;
  --ok-line: #3A9AD9;
  --ok-row: #062236;
  --ko-row: #1C1F23;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  /* Main-menu art of the game (statue carrying the globe, img/bg/), darkened
     and tinted night blue so that text stays readable; 960 px version below
     960 px wide. Some browsers (iOS Safari) ignore "fixed" and let the image
     scroll with the page. */
  --bg-shade:
    linear-gradient(180deg, rgba(7, 15, 23, .55) 0%, rgba(7, 15, 23, .7) 45%, rgba(7, 15, 23, .95) 85%, var(--bg) 100%),
    radial-gradient(ellipse 90% 80% at 50% 35%, transparent 30%, rgba(5, 29, 51, .7) 100%);
  background: var(--bg-shade), url("../img/bg/atlas.webp") center 15% / cover no-repeat, var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.45 var(--sans);
}
@media (max-width: 960px) {
  body { background-image: var(--bg-shade), url("../img/bg/atlas-960.webp"); }
}

/* Top bar */
header { background: var(--bar); border-bottom: 2px solid var(--gold-dk); }
/* One row: title | mode tabs | settings gear. The tabs wrap inside their
   column when the row is too narrow, and drop below the title and gear on
   phones (max-width: 700px). */
header .bar {
  max-width: 1280px; margin: 0 auto; padding: 10px 24px;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px 24px;
}
@media (max-width: 700px) {
  header .bar { padding: 10px 16px; }
  header nav { grid-column: 1 / -1; grid-row: 2; }
}
h1 {
  margin: 0;
  font-family: var(--serif); font-weight: 600;
  letter-spacing: .04em;
  color: var(--gold);
  font-size: 2rem;
}

h1 a { color: inherit; text-decoration: none; }
h1 a:hover { color: var(--gold-lt); }

nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 2px; }
nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 10px;
  border-radius: var(--radius);
  font-size: .9rem; font-weight: 600; white-space: nowrap;
}
nav a:hover { color: #fff; background: rgba(41, 74, 108, .45); }
nav a.active { color: #fff; background: var(--panel-hi); box-shadow: inset 0 -2px 0 var(--accent); }
nav a.solved::after { content: " ✓"; color: var(--gold); }

/* Settings button (gear) and dialog, js/core/settings.js */
.icon-btn {
  grid-column: 3; grid-row: 1;
  width: 44px; height: 44px; display: grid; place-items: center; padding: 0;
  color: var(--gold); background: none; border: 1px solid transparent; border-radius: 50%; cursor: pointer;
}
.icon-btn:hover { color: var(--gold-lt); background: rgba(41, 74, 108, .45); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#settings {
  width: min(420px, calc(100vw - 32px)); padding: 20px 24px 24px;
  color: var(--text); background: linear-gradient(180deg, var(--panel-hi) 0%, #0A1C2C 100%);
  border: 1px solid var(--gold-dk); border-radius: 6px; box-shadow: 0 20px 40px rgba(0, 0, 0, .6);
}
#settings::backdrop { background: rgba(7, 15, 23, .7); }
#settings h2 { margin: 0 0 16px; font-family: var(--serif); font-weight: 600; font-size: 1.5rem; color: var(--gold-lt); }
.setting { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.setting input { flex: none; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); cursor: pointer; }
.setting-label { display: block; font-weight: 600; color: #fff; }
.setting-hint { display: block; font-size: .85rem; color: var(--muted); }
.dialog-close {
  display: block; margin: 20px 0 0 auto; padding: 10px 16px; min-height: 44px;
  color: var(--text); background: var(--bar); border: 1px solid var(--gold-dk); border-radius: var(--radius);
  font: inherit; font-weight: 600; cursor: pointer;
}
.dialog-close:hover { border-color: var(--gold); color: #fff; }

main { max-width: 760px; margin: 0 auto; padding: 32px 16px 40px; }

/* Panel holding the rule, the clue and the input (js/core/game.js) */
.board {
  max-width: 560px; margin: 0 auto; padding: 24px 28px 28px;
  background: linear-gradient(180deg, var(--panel-hi) 0%, #0A1C2C 100%);
  border: 1px solid var(--panel-2); border-radius: 6px;
  box-shadow: 0 0 0 1px var(--bg), 0 20px 40px rgba(0, 0, 0, .5);
}
@media (max-width: 480px) { .board { padding: 18px 14px 20px; } }

.hint { text-align: center; color: var(--muted); margin: 0 0 18px; }
.notice { text-align: center; color: var(--muted); }
.counter { text-align: center; color: var(--muted); font-size: .9rem; min-height: 1.2em; margin: 14px 0 6px; }
.yesterday { text-align: center; color: var(--muted); font-size: .9rem; margin-top: 24px; }
.legend { text-align: center; font-size: .85rem; color: var(--muted); margin: 0 0 12px; }
.sw { display: inline-block; width: .9em; height: .9em; border-radius: 3px; vertical-align: -1px; margin: 0 4px 0 8px; }
.sw.ok { background: var(--ok); } .sw.partial { background: var(--partial); } .sw.ko { background: var(--ko); }

/* Summary page (#accueil, js/home.js) */
.home { max-width: 640px; margin: 0 auto; }
.home-title { margin: 0 0 4px; text-align: center; font-family: var(--serif); font-weight: 600; font-size: 1.8rem; color: var(--gold-lt); }
.home-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.home-card {
  display: flex; align-items: center; gap: 16px; min-height: 64px; padding: 12px 16px;
  color: var(--text); text-decoration: none;
  background: linear-gradient(180deg, var(--panel-hi) 0%, #0A1C2C 100%);
  border: 1px solid var(--panel-2); border-radius: 6px;
}
.home-card:hover, .home-card:focus-visible { border-color: var(--gold); outline: none; }
.home-icon {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 50%; color: var(--gold-lt); background: var(--bar);
  border: 2px solid var(--gold-dk);
}
.home-card:hover .home-icon { border-color: var(--gold); }
.home-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.home-label { font-family: var(--serif); font-weight: 600; font-size: 1.2rem; color: #fff; }
.home-hint { font-size: .88rem; color: var(--muted); }
.home-status { flex: none; font-size: .82rem; font-weight: 600; color: var(--muted); }
.home-card.solved .home-status { color: var(--gold); }
@media (max-width: 480px) {
  .home-card { align-items: flex-start; }
  .home-status { display: none; }
  .home-card.solved .home-label::after { content: " ✓"; color: var(--gold); }
}

/* Guess input */
.guess { position: relative; max-width: 420px; margin: 0 auto; }
.guess input {
  width: 100%;
  padding: 12px 16px;
  font: inherit; font-size: 1rem;
  color: #fff;
  background: var(--bar);
  border: 1px solid var(--gold-dk);
  border-radius: var(--radius);
  outline: none;
}
.guess input::placeholder { color: var(--muted); }
.guess input:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(68, 179, 234, .35); }
.guess input:disabled { opacity: .6; }
.suggestions {
  position: absolute; z-index: 10; left: 0; right: 0; top: 100%;
  list-style: none; margin: 4px 0 0; padding: 4px;
  background: var(--bar); border: 1px solid var(--gold-dk); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.suggestions li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.suggestions li.active, .suggestions li:hover { background: var(--panel-hi); color: #fff; }
.suggestions img { width: 32px; height: 32px; object-fit: cover; border-radius: 50%; background: var(--panel-2); }

/* Clue frames: brass ring (border-box gradient) around a fill (--frame-fill). */
.frame {
  --frame-fill: var(--bar);
  width: min(260px, 72vw); aspect-ratio: 1; margin: 0 auto 18px;
  overflow: hidden; border-radius: 6px;
  border: 5px solid transparent;
  background:
    linear-gradient(var(--frame-fill), var(--frame-fill)) padding-box,
    conic-gradient(from 200deg, var(--gold-dk), var(--gold-lt), var(--gold), var(--gold-dk), var(--gold-lt), var(--gold-dk)) border-box;
  box-shadow: 0 0 0 1px var(--bg), 0 10px 24px rgba(0, 0, 0, .45);
}
/* Medallion frames (round portraits). */
.portrait-frame, .regard-frame { border-radius: 50%; }
.frame img { width: 100%; height: 100%; object-fit: contain; display: block; user-select: none; -webkit-user-drag: none; }
/* Unsolved clues are drawn on a canvas (js/core/clue.js) with their effects baked in. */
.frame canvas { width: 100%; height: 100%; display: block; }
.portrait-frame img { transform: scale(1.08); transition: filter .5s ease, transform .6s ease; }
.silhouette-frame { --frame-fill: #d9d2bf; }
.silhouette-frame img { filter: brightness(0); transition: transform .5s ease; }
.silhouette-frame img.revealed { filter: none; }
.regard-frame { position: relative; --frame-fill: #808080; }
.regard-frame img {
  position: absolute; left: 50%; top: 50%; height: auto; max-width: none;
  transform: translate(-50%, -50%); transition: width .5s ease;
}
.regard-frame.revealed { --frame-fill: var(--bar); }
.regard-frame.revealed img { position: static; width: 100%; height: 100%; transform: none; }
/* City-state icons have a uniform #181818 background (BBG site). */
.citystate-frame { --frame-fill: #181818; }
/* Tech / civic icons: 160 px, transparent; padding keeps the blur inside the frame. */
.techcivic-frame img { padding: 14%; box-sizing: border-box; transition: filter .5s ease; }
/* Improvement icons: transparent, 186-276 px, various aspect ratios (object-fit: contain). */
.improvement-frame img { padding: 12%; box-sizing: border-box; transition: filter .5s ease; }
/* Unité mode: one play button per sound (the sounds are the only clues). */
.sound-play {
  display: flex; align-items: center; justify-content: center; gap: 8px; margin: 4px auto 18px;
  padding: 12px 22px; min-height: 48px; border: 1px solid var(--gold-lt); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--gold) 0%, #A88A52 100%); color: #1A1408;
  font: inherit; font-weight: 600; font-size: 1.05rem; cursor: pointer;
}
.sound-play:hover:not(:disabled) { filter: brightness(1.08); }
.sound-play.playing { filter: brightness(1.15); box-shadow: 0 0 0 3px rgba(203, 173, 115, .35); }
.sound-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 4px 0 18px; }
.sound-list .sound-play { margin: 0; flex-direction: column; gap: 2px; min-width: 120px; padding: 10px 16px; }
.sound-play:disabled { cursor: not-allowed; filter: grayscale(1) brightness(.7); }
.sound-lock { font-size: .75rem; font-weight: 400; }
.sound-lock:empty { display: none; }
.sound-note { text-align: center; color: var(--muted); margin: -8px 0 14px; }

.toggle { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0 0 12px; cursor: pointer; user-select: none; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.toggle-hint { color: var(--muted); font-size: .85rem; }
@media (max-width: 480px) {
  .toggle { flex-wrap: wrap; row-gap: 0; }
  .toggle-hint { flex-basis: 100%; text-align: center; }
}

/* Cités-État: bonus */
.cs-bonus blockquote {
  max-width: 560px; margin: 12px auto; padding: 12px 16px;
  background: var(--bar); border: 1px solid var(--panel-2); border-radius: var(--radius);
  white-space: pre-line; text-align: left;
}
.cs-bonus { text-align: center; }
.cs-bonus button {
  margin: 12px auto; padding: 8px 14px; min-height: 40px; border: 1px solid var(--gold-lt); border-radius: var(--radius);
  background: transparent; color: var(--gold-lt); font: inherit; font-size: .9rem; cursor: pointer;
}
.cs-bonus button:hover:not(:disabled) { background: rgba(255,255,255,.06); }
.cs-bonus button:disabled { border-color: var(--panel-2); color: var(--muted); cursor: default; }

/* History (non-classic) */
.history { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.guess-row {
  display: flex; align-items: center; gap: 10px; max-width: 420px; width: 100%; margin: 0 auto;
  padding: 6px 14px 6px 6px; border-radius: var(--radius);
  background: var(--ko-row); border: 1px solid var(--ko); color: #fff; font-weight: 600;
}
.guess-row.ok { background: var(--ok-row); border-color: var(--ok-line); }
.guess-row img { width: 40px; height: 40px; object-fit: cover; border-radius: 50%; background: rgba(0,0,0,.3); border: 2px solid var(--ko); }
.guess-row.ok img { border-color: var(--ok-line); }

/* Classic table */
.classic-scroll { overflow-x: auto; margin-top: 12px; }
.classic-row {
  display: grid;
  grid-template-columns: 150px repeat(var(--cols), minmax(92px, 1fr));
  gap: 4px; min-width: calc(150px + var(--cols) * 96px);
}
.classic-table { margin-top: 4px; gap: 4px; }
.classic-header .cell { background: none; border: 0; font-size: .8rem; font-weight: 600; color: var(--gold); min-height: 0; padding: 2px 4px; border-bottom: 1px solid var(--gold-dk); border-radius: 0; }
.cell {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 56px; padding: 4px 6px; border-radius: var(--radius);
  font-size: .82rem; background: var(--panel); border: 1px solid var(--panel-2); color: #fff; word-break: break-word;
}
.cell.ok { background: var(--ok); } .cell.partial { background: var(--partial); } .cell.ko { background: var(--ko); }
.cell.name { justify-content: flex-start; gap: 8px; text-align: left; }
.cell.name img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none; background: rgba(0,0,0,.2); }
.cell .arrow { font-weight: 700; margin-left: 2px; }
.cell .icons { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 3px; }
.cell .icons img { width: 36px; height: 36px; object-fit: contain; }

/* Reveal animation for new guesses */
.reveal { animation: pop .35s ease both; }
.classic-row.reveal { animation: none; }
.classic-row.reveal .cell { animation: flip .55s ease both; animation-delay: calc(var(--i, 0) * var(--reveal-step, 350ms)); }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } }
@keyframes flip { from { opacity: 0; transform: rotateX(90deg); } }
@media (prefers-reduced-motion: reduce) { .reveal, .classic-row.reveal .cell { animation: none; } }

/* Win panel */
.win {
  display: flex; align-items: center; gap: 18px; justify-content: center;
  margin: 16px auto; padding: 18px 20px; max-width: 520px;
  background: var(--panel-hi); border: 1px solid var(--gold-dk); border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(232, 212, 166, .15);
}
.win-portrait {
  width: 88px; height: 88px; object-fit: cover; border-radius: 50%; flex: none;
  border: 3px solid var(--gold); background: var(--bar);
}
.win-title { font-family: var(--serif); font-size: 1.25rem; }
.win p { margin: 4px 0; }
.win-title strong { color: var(--gold-lt); }
.win button {
  margin-top: 6px; padding: 10px 16px; min-height: 44px; border: 1px solid var(--gold-lt); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--gold) 0%, #A88A52 100%); color: #1A1408;
  font: inherit; font-weight: 600; cursor: pointer;
}
.win button:hover { filter: brightness(1.08); }
.next { color: var(--muted); font-size: .9rem; }

footer { text-align: center; color: var(--muted); font-size: .75rem; padding: 0 16px 24px; }
