/* ================================
   Races – Sleek Glass UI (v2)
   Connected image+text panel with wrap
   ================================ */

/* ---------- Theme tokens ---------- */
:root {
  --bg: #0e1013;
  --panel: rgba(255,255,255,0.06);
  --panel-hover: rgba(255,255,255,0.09);
  --panel-border: rgba(255,255,255,0.12);
  --text: #eef2f6;
  --muted: #a9b1ba;
  --accent: #1b8adf;
  --accent-body: #2f4b88;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 24px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.03);
  --shadow-soft: 0 6px 18px rgba(0,0,0,0.28);
}

/* ---------- Base (fixed gradient coverage) ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100%;
  margin: 0;
  padding: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;

  background:
    radial-gradient(1200px 800px at 10% -10%, color-mix(in srgb, var(--accent-body) 35%, transparent), transparent 60%),
    radial-gradient(1000px 700px at 100% 0%, rgba(86,98,246,0.06), transparent 60%),
    var(--bg);
  background-repeat: no-repeat;
  background-attachment: fixed, fixed, scroll;

  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--accent) transparent; }
*::-webkit-scrollbar { height: 8px; width: 8px; }
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent), rgba(66,167,162,0.6));
  border-radius: 20px;
}
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- Layout ---------- */
.container {
  display: block;
  width: min(1280px, 92vw);
  margin: 28px auto;
  padding: 0;
}

.main-content {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 22px;
  align-items: start;
}

/* Left column */
.left-column { display: block; }

/* Right side (sticky info) */
.right-column {
  display: grid;
  gap: 12px;
  position: sticky;
  top: 18px;
}

/* ---------- Connected panel (image + text) ---------- */
.race-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 16px;
  transition: transform .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.race-panel:hover {
  background: var(--panel-hover);
  border-color: rgba(255,255,255,0.18);
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}

/* The floated image block (wrap target) */
.race-media {
  float: left;
  width: min(360px, 46%);
  margin: 0 18px 14px 0;
  padding: 10px;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
  overflow: hidden;
}

.race-media img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 640px;
  object-fit: contain;
  object-position: center;
  border-radius: calc(var(--radius) - 8px);
  user-select: none;
}

/* Placeholder inside the same floated box */
.race-media .placeholder {
  display: grid;
  place-items: center;
  min-height: 260px;
  color: var(--muted);
  font-size: 14px;
}

/* Text flows around the float */
.race-text {
  line-height: 1.45;
  color: var(--text);
}

/* Clear float at end of panel */
.race-panel::after {
  content: "";
  display: block;
  clear: both;
}

/* Paragraph styling */
.race-text p {
  font-size: clamp(12px, 1.05vw, 16px);
  line-height: 1.55;
  margin: 0 0 10px 0;
}

/* Links inside text */
.race-text a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 2px;
  transition: color .2s ease, text-decoration-color .2s ease;
}
.race-text a:hover {
  color: var(--accent);
  text-decoration-color: #ffffff;
}

/* ---------- Info stack ---------- */
.info-box {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;

  padding: 12px 14px;
  min-height: 58px;
  height: auto;
  overflow-wrap: anywhere;

  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);

  font-size: clamp(14px, 1.25vw, 20px);
  letter-spacing: .3px;

  transition: transform .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.info-box:hover {
  background: var(--panel-hover);
  border-color: rgba(255,255,255,0.18);
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}

.info-box a,
.info-box a:visited,
.info-box a:active {
  color: #ffffff;
  text-decoration: none;
  border: none;
  outline: none;
  transition: color .2s ease, opacity .2s ease, text-shadow .2s ease;
  text-shadow: 0 0 0 transparent;
}
.info-box a:hover {
  color: var(--accent);
  text-shadow: 0 0 18px rgba(66,167,162,0.35);
}

/* Make the first three boxes pop a bit */
.right-column .info-box:nth-child(-n+3) {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03)),
    var(--panel);
  border: 1px solid rgba(255,255,255,0.18);
}

/* ---------- Codex number box: smaller + grey ---------- */
.info-box.info-codex {
  font-size: clamp(12px, 1vw, 15px);
  color: var(--muted);
  letter-spacing: 0.4px;
}

/* Region gradients (from super-styles) – improve legibility */
.info-box[class*="region-"] {
  color: #f6f6f6;
  border: 1px solid rgba(255,255,255,0.22);
  text-shadow: 0 1px 0 rgba(255,255,255,0.35);
}
.info-box[class*="region-"] a { color: #f6f6f6; }

/* Download button blends with card */
.right-column .info-box:last-child { padding: 0; }
.right-column .info-box:last-child a {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; padding: 12px 14px;

  background: none !important;
  border: 0 !important;
  border-radius: inherit;
  box-shadow: none !important;
  outline: none;

  font-weight: inherit;
  color: inherit;
  text-align: inherit;
  line-height: 1.2;

  -webkit-appearance: none;
  appearance: none;
}
.right-column .info-box:last-child a:hover {
  background: none !important;
  color: var(--accent);
  text-shadow: 0 0 12px color-mix(in srgb, var(--accent) 50%, transparent);
}
.right-column .info-box:last-child a:focus-visible { outline: none; }

/* ---------- Focus ring ---------- */
a:focus-visible,
.info-box:focus-within {
  outline: 2px solid transparent;
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--accent) 70%, transparent),
    0 0 0 6px color-mix(in srgb, var(--accent) 18%, transparent),
    var(--shadow-soft);
  border-color: rgba(255,255,255,0.24);
}

/* ---------- Micro-underline anim ---------- */
@media (prefers-reduced-motion: no-preference) {
  .info-box a,
  .race-text a {
    position: relative;
  }
  .info-box a::after,
  .race-text a::after {
    content: "";
    position: absolute;
    left: 0; bottom: -2px;
    width: 100%; height: 1px;
    background: currentColor;
    transform-origin: left;
    transform: scaleX(0);
    transition: transform .22s ease;
  }
  .info-box a:hover::after,
  .race-text a:hover::after {
    transform: scaleX(1);
  }
}

/* ---------- Clickable (pronunciation) ---------- */
.info-box.clickable,
.info-box.clickable:hover,
.info-box.clickable:focus,
.info-box.clickable * {
  text-decoration: none !important;
}

.info-box.clickable {
  cursor: pointer;
  color: inherit;
  position: relative;
}
.info-box.clickable:hover,
.info-box.clickable:focus {
  outline: none;
  background: var(--panel-hover);
  border-color: rgba(255,255,255,0.18);
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
  color: var(--accent);
  text-shadow: 0 0 18px rgba(66,167,162,0.35);
}
.info-box.clickable .info-label {
  position: relative;
  display: inline-block;
}
.info-box.clickable .info-label::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform-origin: left;
  transform: scaleX(0);
  transition: transform .22s ease;
}
.info-box.clickable:hover .info-label::after,
.info-box.clickable:focus .info-label::after {
  transform: scaleX(1);
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .main-content { grid-template-columns: 1.6fr 1fr; }
}

@media (max-width: 980px) {
  .main-content { grid-template-columns: 1fr; }
  .right-column {
    position: static;
    grid-template-columns: repeat(2, 1fr);
  }
  .right-column .info-box { min-height: 56px; }

  /* Make wrap panel feel nicer on tablet */
  .race-media { width: min(340px, 52%); }
}

@media (max-width: 680px) {
  /* On phones: no wrap, stack image above text */
  .race-media {
    float: none;
    width: 100%;
    margin: 0 0 14px 0;
  }
  .right-column { grid-template-columns: 1fr; }
}
