/* Nonchalant raid roster — hand-editable, no build step.
   Palette comes from the guild emblem; --logo-bg is generated in /img/logo-theme.css. */

:root {
  --bronze: #B08D57;
  --gold: #D9B56A;
  --gold-soft: #e8cf95;
  --crimson: #8B1E1E;
  --ink: #121010;
  --bg: var(--logo-bg, #121010);

  --text: #ECE3D0;
  --text-muted: #A99F8D;
  --text-faint: #7d7466;

  --card: #1a1715;
  --card-2: #211d1a;
  --line: rgba(176, 141, 87, 0.22);
  --line-strong: rgba(176, 141, 87, 0.45);

  --ok: #6FBF73;
  --short: #E0A43A;
  --bad: #D9534F;

  /* Role colours: muted takes on the sheet's role cells. */
  --tank: #5E7FA3;    --tank-bg: rgba(94, 127, 163, 0.16);   --tank-text: #B4CBE3;
  --healer: #5E9466;  --healer-bg: rgba(94, 148, 102, 0.16); --healer-text: #B2DBB2;
  --melee: #A34A45;   --melee-bg: rgba(163, 74, 69, 0.17);   --melee-text: #EAB0AB;
  --ranged: #B08F3C;  --ranged-bg: rgba(176, 143, 60, 0.17); --ranged-text: #EAD08E;

  --font-display: 'Cinzel', 'Trajan Pro', 'Palatino Linotype', Georgia, serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --radius: 10px;
  --gap: 16px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* Subtle film-grain texture over everything. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 0.9  0 0 0 0 0.75  0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
body > * { position: relative; z-index: 1; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -40px; z-index: 50;
  padding: 8px 14px; border-radius: 6px;
  background: var(--gold); color: var(--ink); font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 12px; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- Hero ---------- */

.hero {
  background:
    radial-gradient(ellipse 60% 120% at 50% 40%, transparent 35%, rgba(0, 0, 0, 0.5) 100%),
    radial-gradient(circle 340px at calc(50% - 230px) 50%, rgba(217, 181, 106, 0.08), transparent 70%),
    var(--bg);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.hero::after {
  /* thin crimson + gold rule along the bottom */
  content: '';
  position: absolute; left: 50%; bottom: -1px; transform: translateX(-50%);
  width: min(420px, 60%); height: 2px;
  background: linear-gradient(90deg, transparent, var(--crimson) 25%, var(--gold) 50%, var(--crimson) 75%, transparent);
}
.hero-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 22px 24px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
}
.emblem {
  flex: none;
  width: 180px; height: 180px;
  /* The glow lives on the wrapper so the image mask doesn't clip it. */
  filter: drop-shadow(0 0 22px rgba(217, 181, 106, 0.28)) drop-shadow(0 0 4px rgba(217, 181, 106, 0.2));
}
.emblem img {
  display: block; width: 100%; height: 100%;
  -webkit-mask-image: var(--logo-mask, none);
  mask-image: var(--logo-mask, none);
}
.hero-text { min-width: 0; }
.eyebrow {
  margin: 0 0 6px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--bronze);
}
h1 {
  margin: 0;
  font: 700 clamp(1.4rem, 1rem + 2vw, 2.6rem)/1.12 var(--font-display);
  letter-spacing: 0.02em;
  color: var(--gold);
  text-shadow: 0 2px 18px rgba(217, 181, 106, 0.18);
}
.h1-sub { display: block; color: var(--text); font-weight: 600; font-size: 0.62em; letter-spacing: 0.06em; margin-top: 4px; }

.cta {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 14px; padding: 9px 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #e6c47c, var(--gold) 45%, var(--bronze));
  color: var(--ink);
  font: 700 14px/1 var(--font-display); letter-spacing: 0.08em; text-transform: uppercase;
  text-decoration: none;
  box-shadow: 0 0 0 1px rgba(255, 230, 170, 0.35) inset, 0 4px 18px rgba(217, 181, 106, 0.28);
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}
.cta:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 0 0 1px rgba(255, 230, 170, 0.45) inset, 0 6px 24px rgba(217, 181, 106, 0.4); }
.cta:active { transform: translateY(0); }
.cta:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 3px; }
.cta svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Toolbar ---------- */

.toolbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(18, 16, 16, 0.86);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.toolbar-inner {
  max-width: 1680px; margin: 0 auto;
  padding: 10px 24px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px;
}
.search {
  position: relative;
  flex: 1 1 260px; max-width: 420px;
  margin: 0;
}
.search input {
  width: 100%; height: 40px;
  padding: 0 38px 0 38px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: rgba(0, 0, 0, 0.35); color: var(--text);
  font: inherit; font-size: 15px;
}
.search input::placeholder { color: var(--text-faint); }
.search input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(217, 181, 106, 0.2); }
.search input::-webkit-search-cancel-button { filter: grayscale(1) brightness(1.6); cursor: pointer; }
.search-icon {
  position: absolute; left: 13px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%);
  fill: none; stroke: var(--bronze); stroke-width: 2; stroke-linecap: round; pointer-events: none;
}
.search-kbd {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  min-width: 20px; padding: 1px 6px; border: 1px solid var(--line-strong); border-radius: 5px;
  font: 600 11px/16px var(--font-body); color: var(--text-faint); text-align: center; pointer-events: none;
}
.search input:focus ~ .search-kbd, .search input:not(:placeholder-shown) ~ .search-kbd { display: none; }

.chip {
  height: 36px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: transparent; color: var(--text);
  font: 600 13px var(--font-body); letter-spacing: 0.03em; cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip:hover { border-color: var(--gold); }
.chip[aria-pressed='true'] { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.chip .chip-count { opacity: 0.75; font-weight: 500; }

.status {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 13px; color: var(--text-muted); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex: none; }
.status[data-state='live'] .status-dot { background: var(--ok); box-shadow: 0 0 0 0 rgba(111, 191, 115, 0.6); animation: ping 2.4s infinite; }
.status[data-state='live'] .status-text strong { color: var(--ok); }
.status[data-state='stale'] { border-color: rgba(224, 164, 58, 0.5); color: var(--short); background: rgba(224, 164, 58, 0.08); }
.status[data-state='stale'] .status-dot { background: var(--short); }
.status[data-state='sample'] .status-dot { background: var(--gold); }
.status[data-state='sample'] .status-text strong { color: var(--gold); }
.status[data-state='error'] { border-color: rgba(217, 83, 79, 0.5); color: #f0a09d; }
.status[data-state='error'] .status-dot { background: var(--bad); }
.status strong { font-weight: 600; }

.search-result {
  max-width: 1680px; margin: 0 auto; padding: 0 24px;
  font-size: 13px; color: var(--text-muted);
}
.search-result:empty { display: none; }
.search-result:not(:empty) { padding-bottom: 10px; }
.search-result b { color: var(--gold); font-weight: 600; }

/* ---------- Grid & cards ---------- */

.grid {
  max-width: 1680px;
  margin: 0 auto;
  padding: 22px 24px 8px;
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
  align-items: start;
}
@media (min-width: 720px)  { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.card {
  position: relative;
  background: linear-gradient(180deg, var(--card-2), var(--card) 160px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  overflow: hidden;
}
.card::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--bronze), var(--gold), var(--bronze), transparent);
  opacity: 0.7;
}
.card.is-live { border-color: rgba(217, 83, 79, 0.55); box-shadow: 0 0 0 1px rgba(217, 83, 79, 0.25), 0 10px 30px rgba(0, 0, 0, 0.35); }
.card.is-live::before { background: linear-gradient(90deg, transparent, var(--crimson), #d9534f, var(--crimson), transparent); opacity: 1; }
.card[hidden] { display: none; }

.card-head { padding: 16px 18px 12px; }
.card-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-title {
  margin: 0;
  font: 700 1.2rem/1.2 var(--font-display);
  letter-spacing: 0.03em;
  color: var(--gold);
}
.when { margin: 6px 0 0; font-size: 14px; color: var(--text); }
.when-local { font-weight: 600; }
.when-et { display: inline-block; margin-left: 4px; font-size: 11.5px; color: var(--text-faint); white-space: nowrap; }
.when-et abbr { text-decoration: none; font-weight: 600; letter-spacing: 0.04em; }
.countdown { margin: 4px 0 0; font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.countdown strong { color: var(--gold-soft); font-weight: 600; }
.card.is-live .countdown strong { color: #f0a09d; }

.live-badge {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; margin-top: 1px; border-radius: 999px;
  background: rgba(139, 30, 30, 0.85); color: #fff;
  font: 700 10.5px/1.4 var(--font-body); letter-spacing: 0.12em; text-transform: uppercase;
  box-shadow: 0 0 0 0 rgba(217, 83, 79, 0.7);
  animation: live-pulse 1.8s ease-out infinite;
}
.live-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #ffb4b0; }
.live-badge[hidden] { display: none; }

/* Role balance */
.balance { padding: 0 18px 14px; }
.balance-bar { display: flex; gap: 2px; height: 8px; margin-bottom: 10px; }
.tick { flex: 1; border-radius: 2px; background: rgba(255, 255, 255, 0.06); }
.tick.tank { background: var(--tank); }
.tick.healer { background: var(--healer); }
.tick.melee { background: var(--melee); }
.tick.ranged { background: var(--ranged); }
.tick.missing { background: transparent; box-shadow: inset 0 0 0 1px rgba(224, 164, 58, 0.45); }

.balance-counts {
  margin: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 6px;
  text-align: center;
}
.bc { padding: 5px 2px 4px; border-radius: 6px; background: rgba(255, 255, 255, 0.03); border: 1px solid transparent; }
.bc dt { font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-faint); }
.bc dd { margin: 0; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.bc dd small { font-size: 11px; font-weight: 500; color: var(--text-faint); }
.bc.ok dd { color: var(--ok); }
.bc.short { border-color: rgba(224, 164, 58, 0.35); background: rgba(224, 164, 58, 0.07); }
.bc.short dd { color: var(--short); }
.bc-sum {
  display: flex; justify-content: center; align-items: baseline; gap: 6px;
  padding-top: 4px; border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 10px; font-weight: 600; color: var(--text-faint); letter-spacing: 0.1em; text-transform: uppercase;
}
.bc-sum dd { margin: 0; }
.bc-sum b { font-size: 12px; letter-spacing: 0; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.bc-total { grid-column: 1 / span 2; }
.bc-dps { grid-column: 3 / span 2; }
.bc-dps.ok b { color: var(--ok); }
.bc-dps.short b { color: var(--short); }

/* Roster table */
.roster { width: 100%; border-collapse: collapse; table-layout: fixed; }
.roster .col-class { width: 74px; }
.roster th, .roster td { padding: 0; text-align: left; font-weight: 400; }

.role-head th {
  padding: 6px 18px 5px;
  font: 600 11px/1.3 var(--font-body); letter-spacing: 0.14em; text-transform: uppercase;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  border-left: 3px solid var(--role);
  background: var(--role-bg);
  color: var(--role-text);
}
.role-head .rh { display: flex; justify-content: space-between; }
.role-head .rh-count { opacity: 0.85; font-variant-numeric: tabular-nums; }
.role-tank   { --role: var(--tank);   --role-bg: var(--tank-bg);   --role-text: var(--tank-text); }
.role-healer { --role: var(--healer); --role-bg: var(--healer-bg); --role-text: var(--healer-text); }
.role-melee  { --role: var(--melee);  --role-bg: var(--melee-bg);  --role-text: var(--melee-text); }
.role-ranged { --role: var(--ranged); --role-bg: var(--ranged-bg); --role-text: var(--ranged-text); }
.role-none   { --role: #6b645a; --role-bg: rgba(255, 255, 255, 0.04); --role-text: var(--text-muted); }

.p-row td { padding: 5px 0; border-top: 1px solid rgba(255, 255, 255, 0.035); vertical-align: top; }
.p-row td:first-child { padding-left: 18px; }
.p-row td:last-child { padding-right: 18px; }
.p-name {
  display: flex; align-items: baseline; gap: 8px;
  color: var(--cls, var(--text)); font-weight: 500; overflow-wrap: anywhere;
}
.pip { flex: none; width: 8px; height: 8px; border-radius: 2px; background: var(--pip, #888); transform: translateY(-1px); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4); }
.p-class { font-size: 12px; color: var(--text-faint); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-top: 1px; }
.cls-shaman .p-name { text-shadow: 0 0 10px rgba(0, 112, 221, 0.55); }
.p-row mark { background: rgba(217, 181, 106, 0.28); color: inherit; border-radius: 3px; padding: 0 1px; }

.open-slot td { padding: 4px 18px; border-top: 1px solid rgba(255, 255, 255, 0.035); }
.open-slot span {
  display: block; padding: 3px 10px;
  border: 1px dashed rgba(224, 164, 58, 0.5); border-radius: 6px;
  color: var(--short); font-size: 13px; font-style: italic;
}
.none-row td { padding: 5px 18px; color: var(--text-faint); font-size: 13px; font-style: italic; border-top: 1px solid rgba(255, 255, 255, 0.035); }

/* Search states */
.grid.searching .p-row:not(.hit) { opacity: 0.38; }
.grid.searching .open-slot, .grid.searching .none-row { opacity: 0.3; }
.p-row.hit td { background: rgba(217, 181, 106, 0.1); }
.p-row.hit td:first-child { box-shadow: inset 3px 0 0 var(--gold); }

/* Changed rows on refresh */
.changed td, .role-head.changed th { animation: changed 4.5s ease-out; }

/* Class composition strip */
.comp {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  padding: 10px 18px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.comp-group { display: inline-flex; gap: 3px; }
.cdot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); }

/* Skeletons */
.skeleton {
  min-height: 760px;
  background:
    linear-gradient(90deg, transparent, rgba(217, 181, 106, 0.05), transparent) 0 0 / 200% 100% no-repeat,
    repeating-linear-gradient(180deg, transparent 0 190px, rgba(255, 255, 255, 0.025) 190px 191px, transparent 191px 220px, rgba(255, 255, 255, 0.03) 220px 236px),
    var(--card);
  animation: shimmer 1.6s linear infinite;
}

.empty { max-width: 640px; margin: 24px auto; padding: 0 24px; text-align: center; color: var(--text-muted); }

.footer {
  max-width: 1680px; margin: 0 auto; padding: 18px 24px 36px;
  font-size: 12.5px; color: var(--text-faint); text-align: center;
}
.footer strong { color: var(--text-muted); font-weight: 600; }

/* ---------- Motion ---------- */

@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(111, 191, 115, 0.55); } 70%, 100% { box-shadow: 0 0 0 7px rgba(111, 191, 115, 0); } }
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 rgba(217, 83, 79, 0.7); } 70%, 100% { box-shadow: 0 0 0 9px rgba(217, 83, 79, 0); } }
@keyframes shimmer { from { background-position: 150% 0, 0 0, 0 0; } to { background-position: -50% 0, 0 0, 0 0; } }
@keyframes changed { 0%, 35% { background-color: rgba(217, 181, 106, 0.32); } 100% { background-color: transparent; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .live-badge { box-shadow: 0 0 0 2px rgba(217, 83, 79, 0.6); }
  .changed td, .role-head.changed th { background-color: rgba(217, 181, 106, 0.22); }
}

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .hero-inner { padding: 14px 16px 14px; gap: 14px; justify-content: flex-start; }
  .emblem { width: 120px; height: 120px; }
  .eyebrow { font-size: 10px; letter-spacing: 0.22em; margin-bottom: 4px; }
  .toolbar-inner { padding: 8px 12px; gap: 8px; }
  .search { flex-basis: 100%; max-width: none; }
  .search-kbd { display: none; }
  .status { font-size: 12px; padding: 5px 10px; }
  .search-result { padding: 0 12px; }
  .grid { padding: 14px 12px 8px; gap: 12px; }
  .card-head { padding: 14px 14px 10px; }
  .balance { padding: 0 14px 12px; }
  .role-head th, .open-slot td, .none-row td { padding-left: 14px; padding-right: 14px; }
  .p-row td:first-child { padding-left: 14px; }
  .p-row td:last-child { padding-right: 14px; }
  .comp { padding: 10px 14px 12px; }
}
