/* Home, the "Command post": the page grid and the campaigns card. The quiz, the event banner and
   the chat have their own files. Tokens and shared components only (see docs/DESIGN.md). */
@layer pages {
  /* The main column, and the chat on the right that stays in view while the page scrolls. */
  .home-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 380px); gap: var(--gap); align-items: start; }
  .home-main { min-width: 0; gap: var(--gap); }
  /* Search and the day timer: one group on the right of the header, level with each other. */
  .home-tools { display: flex; align-items: center; gap: var(--sp-3); margin-left: auto; min-width: 0; }
  .home-tools .find-friends { flex: 0 1 300px; width: 300px; min-width: 180px; }
  .home-day { flex: none; }
  .home-day .icon { color: var(--text-3); }
  @media (max-width: 900px) { .home-grid { grid-template-columns: minmax(0, 1fr); } }
  @media (max-width: 640px) { .home-tools { width: 100%; margin-left: 0; flex-wrap: wrap; } .home-tools .find-friends { flex: 1 1 200px; width: auto; min-width: 0; } }

  /* ── Campaigns ── */
  .campaign-list { display: flex; flex-direction: column; gap: var(--sp-5); }
  .campaign-skeleton { height: 300px; border-radius: var(--r-lg); }

  /* Your country's battle: a well with the two countries, the damage split and the call to join. */
  .campaign { display: flex; flex-direction: column; gap: var(--sp-5); padding: var(--sp-5); }
  .campaign-top { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2) var(--sp-3); flex-wrap: wrap; }

  .versus { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: var(--sp-4); }
  .side { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); min-width: 0; min-height: 100%; padding: var(--sp-4) var(--sp-3);
    text-align: center; border-radius: var(--r-md); background: var(--surface-raised); border: 1px solid var(--border-subtle); box-shadow: var(--shadow-1), var(--highlight); }
  .side.friend { border-color: color-mix(in srgb, var(--blue) 45%, transparent);
    background: linear-gradient(180deg, var(--blue-soft), transparent 75%), var(--surface-raised); }
  .side .flag.big { margin-bottom: var(--sp-1); }
  .side-name { font: var(--fw-semibold) var(--fs-h2) / 1.1 var(--font-display); letter-spacing: var(--ls-display); overflow-wrap: anywhere; }
  .side-role { display: inline-flex; align-items: center; gap: 6px; }
  .vs { font: var(--fw-bold) var(--fs-h2) / 1 var(--font-display); letter-spacing: var(--ls-cta); color: var(--text-3); }

  .score { display: flex; flex-direction: column; gap: var(--sp-2); }
  .score-nums { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); }
  .score-nums .friend { color: var(--blue-text); }
  .score-nums .enemy { color: var(--red-text); }

  /* The damage split: your side blue, the enemy red, a battle you are not in neutral. */
  .share { display: flex; gap: 2px; height: 12px; border-radius: var(--r-pill); overflow: hidden; background: var(--surface-sunken); box-shadow: var(--input-shadow); }
  .share i { display: block; height: 100%; transition: width .8s var(--ease); }
  .share .friend { background: linear-gradient(180deg, color-mix(in srgb, var(--blue) 62%, var(--on-accent)), var(--blue)); }
  .share .enemy { background: linear-gradient(180deg, color-mix(in srgb, var(--red) 62%, var(--on-accent)), var(--red)); }
  .share .neutral { background: var(--text-3); }
  .share .neutral + .neutral { background: var(--border-strong); }
  .share.thin { height: 6px; gap: 1px; }

  /* Every other battle: one compact row each. */
  .campaign-others { display: flex; flex-direction: column; gap: var(--sp-1); }
  .campaign-rows { display: flex; flex-direction: column; max-height: 360px; overflow-y: auto; }
  .battle-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "names btn" "meta btn"; gap: var(--sp-2) var(--sp-4); align-items: center;
    padding: var(--sp-3) var(--sp-2); border-top: 1px solid var(--border-subtle); border-radius: var(--r-sm); transition: background-color var(--t-fast); }
  .battle-row:first-child { border-top-color: transparent; }
  .battle-row:hover { background: var(--surface-2); }
  .br-names { grid-area: names; display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
  .br-side { flex: 1; display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
  .br-side.right { justify-content: flex-end; }
  .br-side b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-ui); }
  .br-side .flag { flex: none; }
  .br-vs { flex: none; }
  .br-meta { grid-area: meta; display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
  .br-meta small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .battle-row .btn { grid-area: btn; }

  @media (max-width: 560px) {
    .campaign { padding: var(--sp-4); }
    .versus { gap: var(--sp-2); }
    .side { padding: var(--sp-3) var(--sp-2); }
    .vs { font-size: var(--fs-h3); }
    .battle-row .btn { --btn-h: var(--h-md); }
  }
}
