/**
 * Oliver's Cool Math Games hub — dark portal layout (inspired by common game-hub patterns).
 * Not affiliated with coolmathgames.com
 */

:root {
  --cmg-bg: #050a14;
  --cmg-bg-elevated: #0a1628;
  --cmg-bg-card: #0f1f3a;
  --cmg-border: rgba(255, 255, 255, 0.08);
  --cmg-text: #ffffff;
  --cmg-text-muted: #94a3b8;
  --cmg-yellow: #f7ce46;
  --cmg-yellow-dim: #c9a532;
  --cmg-nav-hover: rgba(247, 206, 70, 0.15);
  --cmg-radius: 10px;
  --cmg-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  --cmg-max: 1120px;
}

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

html {
  scroll-behavior: smooth;
}

body.cmg-page {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--cmg-bg);
  color: var(--cmg-text);
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
}

.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 999;
  padding: 8px 16px;
  background: var(--cmg-yellow);
  color: #000;
  font-weight: 700;
}
.skip-link:focus {
  left: 16px;
  top: 8px;
}

/* ——— Top nav ——— */
.cmg-topbar {
  background: linear-gradient(180deg, #060d1a 0%, var(--cmg-bg) 100%);
  border-bottom: 1px solid var(--cmg-border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.cmg-cats {
  max-width: var(--cmg-max);
  margin: 0 auto;
  padding: 10px 20px 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 20px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cmg-cats a {
  color: var(--cmg-text-muted);
  text-decoration: none;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.cmg-cats a:hover,
.cmg-cats a:focus-visible {
  color: var(--cmg-yellow);
  border-bottom-color: var(--cmg-yellow);
}

.cmg-brandbar {
  max-width: var(--cmg-max);
  margin: 0 auto;
  padding: 12px 20px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 8px 16px;
  text-align: center;
}

.cmg-hub-link {
  color: var(--cmg-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}
.cmg-hub-link:hover {
  color: var(--cmg-yellow);
}

.cmg-site-title {
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--cmg-text);
}

.cmg-site-tag {
  font-size: 0.8rem;
  color: var(--cmg-text-muted);
  width: 100%;
  text-align: center;
}

@media (min-width: 600px) {
  .cmg-brandbar {
    justify-content: space-between;
    text-align: left;
  }
  .cmg-site-tag {
    width: auto;
    margin-left: auto;
  }
}

/* ——— Main ——— */
.cmg-main {
  max-width: var(--cmg-max);
  margin: 0 auto;
  padding: 20px 16px 0;
}

.cmg-hero-strip {
  border-radius: var(--cmg-radius);
  overflow: hidden;
  margin-bottom: 24px;
  min-height: 120px;
  background: var(--cmg-bg-elevated)
    url("../img/coolmath-style-hero.png") center top / cover no-repeat;
  position: relative;
  box-shadow: var(--cmg-shadow);
}

.cmg-hero-strip::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(5, 10, 20, 0.55) 0%,
    rgba(5, 10, 20, 0.85) 100%
  );
  pointer-events: none;
}

.cmg-intro {
  position: relative;
  z-index: 1;
  padding: 28px 20px 32px;
  text-align: center;
}

.cmg-intro h1 {
  margin: 0;
  font-size: clamp(1.5rem, 5vw, 2.25rem);
  font-weight: 800;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.6);
}

.cmg-intro p {
  margin: 10px auto 0;
  max-width: 520px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 1rem;
  line-height: 1.5;
}

/* ——— Staff picks / New — two columns ——— */
.cmg-split-picks {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  margin-bottom: 32px;
}

@media (min-width: 800px) {
  .cmg-split-picks {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }
}

.cmg-section-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.cmg-section-bar h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cmg-text);
}

.cmg-see-all {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--cmg-yellow);
  text-decoration: none;
  white-space: nowrap;
}
.cmg-see-all:hover {
  text-decoration: underline;
}

.cmg-pick-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cmg-pick-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--cmg-bg-card);
  border: 1px solid var(--cmg-border);
  border-radius: var(--cmg-radius);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}

.cmg-pick-item:hover {
  background: #132744;
  border-color: rgba(247, 206, 70, 0.35);
  transform: translateX(2px);
}

.cmg-pick-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  flex-shrink: 0;
  background: linear-gradient(145deg, #1e3a5f, #0f2744);
}

.cmg-pick-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cmg-pick-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--cmg-text);
}

.cmg-pick-sub {
  font-size: 0.8rem;
  color: var(--cmg-text-muted);
  line-height: 1.25;
}

/* ——— Featured row ——— */
.cmg-featured {
  margin-bottom: 36px;
}

.cmg-featured-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

@media (min-width: 700px) {
  .cmg-featured-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.cmg-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--cmg-bg-card);
  border-radius: var(--cmg-radius);
  overflow: hidden;
  border: 1px solid var(--cmg-border);
  box-shadow: var(--cmg-shadow);
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}

.cmg-card:hover {
  transform: translateY(-3px);
  border-color: rgba(247, 206, 70, 0.45);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.cmg-card--feat .cmg-card-top {
  height: 120px;
}

@media (min-width: 700px) {
  .cmg-card--feat .cmg-card-top {
    height: 140px;
  }
}

.cmg-card-top {
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.75rem;
  line-height: 1;
  background: linear-gradient(145deg, #1a3354, #0d1f35);
}

.cmg-card-top--img {
  background-size: cover;
  background-position: center;
  font-size: 0;
}

.cmg-card-body {
  padding: 12px 12px 14px;
  background: rgba(0, 0, 0, 0.2);
}

.cmg-card-body h3 {
  margin: 0 0 4px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--cmg-text);
  line-height: 1.25;
}

.cmg-card-body p {
  margin: 0;
  font-size: 0.72rem;
  color: var(--cmg-text-muted);
  line-height: 1.35;
}

.grad-a {
  background: linear-gradient(135deg, #059669, #10b981);
}
.grad-b {
  background: linear-gradient(135deg, #ea580c, #fbbf24);
}
.grad-c {
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
}
.grad-d {
  background: linear-gradient(135deg, #0891b2, #22d3ee);
}
.grad-e {
  background: linear-gradient(135deg, #db2777, #f472b6);
}
.grad-f {
  background: linear-gradient(135deg, #1d4ed8, #60a5fa);
}
.grad-g {
  background: linear-gradient(135deg, #65a30d, #84cc16);
}
.grad-h {
  background: linear-gradient(135deg, #0e7490, #14b8a6);
}

/* ——— Section grids ——— */
.cmg-game-section {
  margin-bottom: 32px;
  scroll-margin-top: 88px;
}

.cmg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

/* ——— Quick Math ——— */
.cmg-quick-section {
  margin-bottom: 36px;
  scroll-margin-top: 88px;
}

.quickmath {
  background: var(--cmg-bg-elevated);
  border-radius: var(--cmg-radius);
  padding: 20px 20px 22px;
  border: 2px solid rgba(247, 206, 70, 0.45);
  box-shadow: var(--cmg-shadow);
}

.quickmath h2 {
  margin: 0 0 12px;
  font-size: 1.2rem;
  color: var(--cmg-yellow);
}

.quickmath-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.quickmath-q {
  font-size: clamp(22px, 5vw, 32px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--cmg-text);
}

.quickmath input[type="number"] {
  width: 100px;
  padding: 10px 12px;
  font-size: 20px;
  border: 1px solid var(--cmg-border);
  border-radius: 8px;
  text-align: center;
  background: var(--cmg-bg);
  color: var(--cmg-text);
}

.quickmath input:focus {
  outline: none;
  border-color: var(--cmg-yellow);
  box-shadow: 0 0 0 2px rgba(247, 206, 70, 0.25);
}

.quickmath button {
  background: var(--cmg-yellow);
  color: #1a1505;
  border: none;
  padding: 12px 22px;
  font-size: 16px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}

.quickmath button:hover {
  filter: brightness(1.06);
}

.quickmath button:active {
  transform: translateY(1px);
}

.quickmath .qm-stats {
  font-size: 15px;
  color: var(--cmg-text-muted);
  margin-top: 4px;
}

.quickmath .qm-msg {
  min-height: 24px;
  font-weight: 700;
  margin-top: 8px;
}

.quickmath .qm-msg.ok {
  color: #4ade80;
}
.quickmath .qm-msg.bad {
  color: #f87171;
}

/* ——— Benefits ——— */
.cmg-benefits {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 24px 18px;
  margin: 24px 0 32px;
  background: var(--cmg-bg-elevated);
  border: 1px solid var(--cmg-border);
  border-radius: var(--cmg-radius);
}

@media (min-width: 700px) {
  .cmg-benefits {
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
  }
}

.cmg-benefit {
  text-align: center;
}

.cmg-benefit-icon {
  font-size: 1.75rem;
  margin-bottom: 8px;
  line-height: 1;
}

.cmg-benefit h3 {
  margin: 0 0 6px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--cmg-text);
}

.cmg-benefit p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--cmg-text-muted);
  line-height: 1.4;
}

/* ——— Footer ——— */
.cmg-footer-cta {
  background: linear-gradient(180deg, #0a1628 0%, #060d18 100%);
  border: 1px solid var(--cmg-border);
  border-radius: var(--cmg-radius);
  padding: 28px 20px;
  text-align: center;
  margin-bottom: 28px;
}

.cmg-footer-cta p {
  margin: 0 0 16px;
  font-size: 1.05rem;
  font-weight: 600;
}

.cmg-btn-yellow {
  display: inline-block;
  background: var(--cmg-yellow);
  color: #1a1505;
  font-weight: 800;
  font-size: 1rem;
  padding: 12px 28px;
  border-radius: 8px;
  text-decoration: none;
  transition: filter 0.15s;
}
.cmg-btn-yellow:hover {
  filter: brightness(1.08);
}

.cmg-footer-links {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  padding: 8px 8px 28px;
  border-top: 1px solid var(--cmg-border);
  margin-top: 8px;
}

@media (min-width: 600px) {
  .cmg-footer-links {
    grid-template-columns: repeat(4, 1fr);
  }
}

.cmg-footer-col h4 {
  margin: 0 0 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cmg-text-muted);
}

.cmg-footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cmg-footer-col a {
  display: block;
  color: var(--cmg-text);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 4px 0;
}
.cmg-footer-col a:hover {
  color: var(--cmg-yellow);
}

.cmg-foot {
  text-align: center;
  font-size: 0.8rem;
  color: var(--cmg-text-muted);
  padding: 16px 12px 8px;
  max-width: var(--cmg-max);
  margin: 0 auto;
}

.cmg-disclaimer {
  font-size: 0.75rem;
  opacity: 0.85;
  margin-top: 8px;
}

/* Focus rings match yellow accent on dark UI */
.cmg-page a:focus-visible,
.cmg-page button:focus-visible {
  outline: 2px solid var(--cmg-yellow);
  outline-offset: 2px;
}
