/**
 * global.css — base typography, layout primitives and shared components.
 * Loaded after tokens.css + reset.css on every page.
 */

/* ---- Base ------------------------------------------------------------ */

body {
  background-color: var(--color-bg-primary);
  color: var(--color-text-body);
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
}

main {
  display: block;
}

/* ---- Anchor scroll offset ------------------------------------------------
 * The header is sticky, so any element that can be an anchor target (TOC
 * links, header dropdown links, smooth-scroll.js) needs enough top offset
 * that scrolling to it doesn't tuck it behind the header. --header-height
 * is kept accurate by header.js's setHeaderHeightVar(). */
h2[id],
h3[id],
section[id],
[tabindex="-1"] {
  scroll-margin-top: calc(var(--header-height) + 1.25rem);
}

h1, h2, h3 {
  color: var(--color-heading-gold);
  font-weight: var(--font-weight-extrabold);
  line-height: 1.25;
}

h1 {
  font-size: var(--font-size-h1);
}

h2 {
  font-size: var(--font-size-h2);
}

h3 {
  font-size: var(--font-size-h3);
  font-weight: var(--font-weight-bold);
}

p {
  margin-bottom: var(--space-paragraph);
}

p:last-child {
  margin-bottom: 0;
}

a {
  transition: color var(--transition-fast), opacity var(--transition-fast);
}

a:hover {
  opacity: 0.85;
}

/* ---- Inline contextual links (internal linking within body copy) --------------------- */
/* Distinct accent color + underline so a contextual link stands out from the surrounding
   paragraph text without competing visually with the gold heading color. */
.inline-link {
  color: var(--color-accent-light);
  text-decoration: underline;
  text-decoration-color: rgba(255, 194, 31, 0.45);
  text-underline-offset: 3px;
  font-weight: var(--font-weight-medium);
}

.inline-link:hover {
  color: var(--color-heading-gold);
  text-decoration-color: currentColor;
  opacity: 1;
}

strong {
  color: var(--color-white);
  font-weight: var(--font-weight-semibold);
}

/* ---- Skip link --------------------------------------------------------- */

.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  z-index: var(--z-modal);
  padding: 0.75rem 1.5rem;
  background: var(--color-accent-light);
  color: var(--color-text-on-light);
  font-weight: var(--font-weight-semibold);
  border-radius: 0 0 var(--radius-card) 0;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 0;
}

/* ---- Layout ------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin-inline: auto;
  padding-inline: var(--container-padding-inline);
}

.page-section {
  padding-block: var(--space-section);
}

.page-section__inner {
  display: grid;
  gap: var(--space-h2-to-text);
}

.page-section--muted {
  background-color: var(--color-bg-dark);
}

.section-intro {
  max-width: 90ch;
}

.h3-block {
  display: grid;
  gap: var(--space-h3-to-text);
  margin-top: var(--space-paragraph);
}

/* ---- Buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.75rem;
  border-radius: var(--radius-pill);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-small);
  text-align: center;
  white-space: nowrap;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}

.btn:hover {
  opacity: 1;
  transform: translateY(-2px);
}

.btn--primary {
  background: var(--gradient-cta);
  color: var(--color-white);
  box-shadow: 0 6px 18px rgba(239, 52, 56, 0.35);
}

.btn--primary:hover {
  background: var(--gradient-cta-hover);
}

.btn--secondary {
  background: var(--color-btn-secondary-bg);
  color: var(--color-white);
  border: 1px solid var(--color-btn-secondary-border);
}

.btn--secondary:hover {
  background: rgba(255, 194, 31, 0.1);
}

.btn--block {
  width: 100%;
}

/* ---- Breadcrumb ------------------------------------------------------------- */

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: var(--font-size-small);
  color: var(--color-text-body);
}

.breadcrumb__item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.breadcrumb__item:not(:last-child)::after {
  content: '/';
  color: var(--color-accent-light);
}

.breadcrumb__link:hover {
  color: var(--color-accent-light);
}

.breadcrumb__current {
  color: var(--color-heading-gold);
}

/* ---- Rating -------------------------------------------------------------------- */

.rating {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  background: rgba(255, 194, 31, 0.12);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-semibold);
  color: var(--color-white);
}

.rating__stars {
  display: inline-flex;
  gap: 0.15rem;
  color: var(--color-accent-light);
}

.rating__value {
  color: var(--color-heading-gold);
}

/* ---- Tables ---------------------------------------------------------------------- */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-card);
}

.data-table {
  min-width: 100%;
  background: var(--color-bg-dark);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.data-table caption {
  caption-side: top;
  text-align: left;
  padding: var(--space-card-padding) var(--space-card-padding) 0.75rem;
  font-weight: var(--font-weight-semibold);
  color: var(--color-heading-gold);
}

.data-table th,
.data-table td {
  padding: 0.85rem 1.25rem;
  text-align: left;
  font-size: var(--font-size-small);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.data-table thead th {
  background: rgba(255, 194, 31, 0.1);
  color: var(--color-heading-gold);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.75rem;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* ---- Lists ------------------------------------------------------------------------ */

.content-list {
  display: grid;
  gap: 0.6rem;
  margin-bottom: var(--space-paragraph);
}

.content-list:last-child {
  margin-bottom: 0;
}

.content-list__item {
  position: relative;
  padding-left: 1.5rem;
}

.content-list__item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent-light);
}

.content-list--numbered {
  counter-reset: step;
}

.content-list--numbered .content-list__item {
  padding-left: 2.25rem;
}

.content-list--numbered .content-list__item::before {
  counter-increment: step;
  content: counter(step);
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--gradient-cta);
  color: var(--color-white);
  font-size: 0.7rem;
  font-weight: var(--font-weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  top: 0;
}

/* ---- Cards grid utility -------------------------------------------------------------- */

.cards-grid {
  display: grid;
  gap: var(--space-card-gap);
  grid-template-columns: 1fr;
}

@media (min-width: 480px) {
  .cards-grid--2up {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) {
  .cards-grid--2col {
    grid-template-columns: repeat(2, 1fr);
  }

  .cards-grid--3col {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .cards-grid--3col {
    grid-template-columns: repeat(3, 1fr);
  }

  .cards-grid--4col {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1440px) {
  .cards-grid--4col {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ---- Card base --------------------------------------------------------------------------- */

.card {
  background: var(--color-bg-dark);
  border-radius: var(--radius-card);
  padding: var(--space-card-padding);
  box-shadow: var(--shadow-card);
}

/* ---- Badge --------------------------------------------------------------------------------- */

.badge-18plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--color-danger);
  color: var(--color-white);
  font-weight: var(--font-weight-bold);
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* ---- Form fields (login/registration mock) ----------------------------------------------------- */

.form-field {
  display: grid;
  gap: 0.5rem;
}

.form-field label {
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-medium);
  color: var(--color-white);
}

.form-field input {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-card);
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border-subtle);
  color: var(--color-white);
}

.form-field input:focus-visible {
  border-color: var(--color-accent-light);
}

/* ---- Animation hook (opt-in, default state = no animation) ----------------------------------------------------- */

.fade-in {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.fade-in.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .fade-in {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ---- Utility ---------------------------------------------------------------------------------- */

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

.text-note {
  font-size: var(--font-size-small);
  color: var(--color-text-body);
  opacity: 0.85;
}

.cards-grid--spaced {
  margin-top: var(--space-h2-to-text);
}

/* ---- 2-up cards (e.g. iOS/Android download cards) ------------------------------------ */
/* Grid items already stretch to equal height by default; turning the card itself into a
   flex column lets a gap open up between its heading/list/CTA and lets the CTA sit flush
   at the bottom (margin-top: auto) regardless of how much text precedes it, so both cards'
   buttons line up on the same row even when their list lengths differ. */
.cards-grid--2up .card {
  display: flex;
  flex-direction: column;
  gap: var(--space-h3-to-text);
}

.cards-grid--2up .card > .btn {
  margin-top: auto;
}

/* ---- Bonus cards (used on /bonus/) --------------------------------------------------------------- */

.bonus-card {
  display: grid;
  gap: 0.75rem;
  align-content: start;
}

.bonus-card__image {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-card);
  background: var(--color-bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.bonus-card__image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---- Platform cards (used on /app/) -------------------------------------------------------------- */

.platform-card {
  display: grid;
  gap: 0.85rem;
  align-content: start;
}

.platform-card img {
  border-radius: var(--radius-card);
}

/* ---- 404 page ------------------------------------------------------------------------------------ */

.error-404__inner {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 1rem;
  padding-block: clamp(2rem, 8vw, 5rem);
}

.error-404__code {
  margin: 0;
  font-size: clamp(4rem, 14vw, 8rem);
  font-weight: var(--font-weight-extrabold);
  line-height: 1;
  background: var(--gradient-cta);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.error-404__subtitle {
  max-width: 56ch;
}
