/* ============================================================================
   The demo hub's chrome: the apex site's layout (`caissachess.org/site.css`)
   in the light palette of the portals themselves.

   The apex is dark, but the parent portal and the LMS are light inside
   (`#fafafa` page, white cards, red accents). The hub sends visitors straight
   into those screens, so it is light too, to avoid a dark-to-light jump on
   every click. Values come from the parent portal's
   `src/shared/styles/global/_colors.scss`; the names in comments are its
   SCSS variables.

   Structure (header, hero, cards, caps, footer, motion, breakpoints) mirrors
   the apex sheet. The hub's own rules live in `hub.css`.
   ========================================================================= */

:root {
  --red: #dc2626; /* $primary-red */
  --red-bright: #ef4444; /* $accent-red */
  --red-deep: #b91c1c; /* $secondary-red */
  --red-soft: #fecaca; /* $lighter-red */
  --red-wash: #fee2e2; /* $lightest-red */

  --page: #fafafa; /* $off-white */
  --ink: #18181b; /* $gray-900 */
  --body: #3f3f46; /* $gray-700 */
  --muted: #52525b; /* $gray-600 */
  --faint: #71717a; /* $gray-500 */
  --line: #e4e4e7; /* $gray-200 */
  --line-strong: #d4d4d8; /* $gray-300 */
  --chip: #f4f4f5; /* $gray-100 */

  --surface: #ffffff;
  --shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.04), 0 1px 3px rgba(24, 24, 27, 0.04);
  --shadow-lg: 0 16px 40px rgba(24, 24, 27, 0.09), 0 2px 6px rgba(24, 24, 27, 0.04);

  --gut: clamp(22px, 5vw, 96px);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: light;
}

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

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;

  /* The apex's red ember top-left and warm glow bottom-right, turned down
     for a light page. On white the red only has to tint, not glow. */
  background:
    radial-gradient(
      ellipse 1000px 800px at 0% 0%,
      rgba(220, 38, 38, 0.075) 0%,
      transparent 62%
    ),
    radial-gradient(
      ellipse 800px 600px at 100% 100%,
      rgba(234, 179, 8, 0.05) 0%,
      transparent 50%
    ),
    var(--page);
  background-attachment: fixed;

  color: var(--body);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* The chessboard texture, dark squares this time, masked so it fades out
   before it reaches the copy. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.028;
  background-image: repeating-conic-gradient(#18181b 0% 25%, transparent 0% 50%);
  background-size: 80px 80px;
  mask-image: radial-gradient(ellipse 80% 80% at 30% 40%, #000 0%, transparent 60%);
  -webkit-mask-image: radial-gradient(ellipse 80% 80% at 30% 40%, #000 0%, transparent 60%);
}

.wrap {
  width: 100%;
  max-width: 1240px;
  margin-inline: auto;
  padding-inline: var(--gut);
  position: relative;
  z-index: 5;
}

/* ------------------------------------------------------------------ header */

.head {
  padding-block: clamp(22px, 4vh, 34px);
}

.head__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  text-decoration: none;
  color: inherit;
}

.brand__logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 12px rgba(220, 38, 38, 0.22));
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand__name {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.brand__sub {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--faint);
}

/* A quiet link in the masthead, not a button: the cards are the page's
   primary action. */
.head__back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  transition:
    color 0.3s var(--ease),
    background 0.3s var(--ease),
    border-color 0.3s var(--ease),
    box-shadow 0.3s var(--ease);
}

.head__back:hover,
.head__back:focus-visible {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}

/* -------------------------------------------------------------------- hero */

main {
  flex: 1;
  padding-block: clamp(30px, 6vh, 70px) clamp(50px, 9vh, 110px);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--faint);
  margin-bottom: clamp(18px, 3vh, 26px);
}

.eyebrow::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 3px var(--red-wash);
  flex-shrink: 0;
}

h1 {
  margin: 0 0 clamp(20px, 3.5vh, 30px);
  font-size: clamp(2.3rem, 4.6vw, 3.3rem);
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -0.035em;
  color: var(--ink);
}

/* Gradient-filled text. If either clip declaration is dropped the text falls
   back to `--ink` and stays legible. */
.accent {
  background: linear-gradient(135deg, var(--red-bright) 0%, var(--red-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  padding-bottom: 0.06em;
}

.lede {
  margin: 0;
  font-size: clamp(1rem, 1.35vw, 1.19rem);
  line-height: 1.72;
  color: var(--body);
  max-width: 60ch;
}

/* ------------------------------------------------------------- hero layout */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.7fr);
  gap: clamp(30px, 5vw, 64px);
  align-items: center;
}

.hero__art {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: clamp(230px, 26vw, 340px);
}

.hero__art::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(220, 38, 38, 0.13) 0%,
    rgba(220, 38, 38, 0.04) 42%,
    transparent 68%
  );
}

.hero__art::after {
  content: "";
  position: absolute;
  inset: 8%;
  z-index: 0;
  border-radius: 50%;
  border: 1px solid rgba(24, 24, 27, 0.07);
  background: rgba(255, 255, 255, 0.55);
  box-shadow:
    0 0 0 clamp(18px, 2.6vw, 34px) rgba(255, 255, 255, 0.45),
    0 24px 60px rgba(220, 38, 38, 0.08);
}

.hero__mark {
  position: relative;
  z-index: 1;
  width: clamp(140px, 15vw, 200px);
  height: auto;
  filter: drop-shadow(0 16px 30px rgba(220, 38, 38, 0.22));
}

@media (prefers-reduced-motion: no-preference) {
  .hero__mark {
    animation: float 7s ease-in-out infinite;
  }

  @keyframes float {
    50% {
      transform: translateY(-11px);
    }
  }
}

@media (max-width: 1000px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero__art {
    display: none;
  }
}

/* ------------------------------------------------------------- section head */

.sect {
  margin-top: clamp(52px, 9vh, 96px);
}

.sect__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 16px;
  margin-bottom: clamp(22px, 3.5vh, 32px);
  border-bottom: 1px solid var(--line);
}

.sect__title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink);
}

.sect__note {
  font-size: 12.5px;
  color: var(--faint);
}

/* ------------------------------------------------------------------- cards */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: clamp(16px, 2vw, 22px);
}

/* The apex card on white: the same 4px lift and red border on hover, with a
   real shadow in place of the dark theme's glass. */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: clamp(22px, 2.4vw, 30px);
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition:
    transform 0.35s var(--ease),
    border-color 0.35s var(--ease),
    box-shadow 0.35s var(--ease);
}

/* A red wash that fades in from the top-left on hover. Inert, so it never
   intercepts the click. */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    ellipse 120% 100% at 0% 0%,
    rgba(220, 38, 38, 0.07) 0%,
    transparent 62%
  );
  transition: opacity 0.35s var(--ease);
}

.card > * {
  position: relative;
  z-index: 1;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--red-soft);
  box-shadow: var(--shadow-lg);
}

.card:hover::before,
.card:focus-visible::before {
  opacity: 1;
}

.card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.card__icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--red-wash);
  color: var(--red);
  transition:
    background 0.35s var(--ease),
    color 0.35s var(--ease),
    box-shadow 0.35s var(--ease);
}

.card:hover .card__icon,
.card:focus-visible .card__icon {
  background: var(--red);
  color: #fff;
  box-shadow: 0 6px 18px rgba(220, 38, 38, 0.3);
}

.card__go {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  color: var(--faint);
  transition:
    color 0.35s var(--ease),
    transform 0.35s var(--ease);
}

.card:hover .card__go,
.card:focus-visible .card__go {
  color: var(--red);
  transform: translateX(4px);
}

.card__title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.card__desc {
  font-size: 14px;
  line-height: 1.62;
  color: var(--muted);
  margin: 0;
}

/* The destination, spelled out: on a page whose job is sending people
   elsewhere, saying where is worth the line. */
.card__host {
  margin-top: auto;
  padding-top: 6px;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------- capability strip */

.caps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: clamp(18px, 2.4vw, 30px);
}

.cap__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 7px;
}

.cap__desc {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--muted);
  margin: 0;
}

.cap__rule {
  width: 26px;
  height: 2px;
  border-radius: 2px;
  background: var(--red);
  margin-bottom: 14px;
}

/* ------------------------------------------------------------------ footer */

footer {
  padding-bottom: clamp(24px, 4vh, 34px);
  font-size: 13px;
  color: var(--faint);
}

/* The rule sits on the inner element so it spans the text column, not the
   gutter padding of `.wrap`. */
.foot__inner {
  border-top: 1px solid var(--line);
  padding-top: clamp(24px, 4vh, 34px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px 30px;
  flex-wrap: wrap;
}

.foot__links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}

.foot__links a {
  color: var(--faint);
  text-decoration: none;
  transition: color 0.25s var(--ease);
}

.foot__links a:hover,
.foot__links a:focus-visible {
  color: var(--ink);
}

/* ------------------------------------------------------------------- focus */

a:focus-visible,
.card:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

/* ------------------------------------------------------------------ motion */

/* Decorative only, and off when the OS asks for less motion. `backwards`
   holds the from-state during the delay. */
@media (prefers-reduced-motion: no-preference) {
  .rise {
    animation: rise 0.6s var(--ease) backwards;
    animation-delay: calc(70ms * var(--d, 0));
  }

  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(14px);
    }
  }
}

/* -------------------------------------------------------------- responsive */

@media (max-width: 720px) {
  body::before {
    /* An 80px grid on a 390px screen reads as stripes; bigger and fainter
       keeps it a texture. */
    background-size: 120px 120px;
    opacity: 0.02;
  }

  .brand__logo {
    width: 36px;
    height: 36px;
  }

  .brand__name {
    font-size: 17px;
  }

  .head__back {
    padding: 7px 11px;
    font-size: 12.5px;
  }

  .foot__inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 359px) {
  .brand__sub {
    display: none;
  }
}
