/* ============================================================
   Home — full-viewport split: Puzzle | Education
   Reuses the Sortify hero language (beige + glow, float bits,
   chips, stacked shadows). No page scroll; halves stack on mobile.
   ============================================================ */
body.home {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.split {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 0;
}

/* ---------- Halves ---------- */
.half {
  position: relative;
  display: flex;
  align-items: stretch;
  min-height: 0;
  overflow: hidden;
  padding: clamp(20px, 7vh, 88px) clamp(20px, 3.5vw, 56px) clamp(20px, 4vh, 48px);
}

.half-casual {
  background:
    radial-gradient(640px 420px at 82% 92%, color-mix(in oklab, var(--lilac) 45%, var(--beige)) 0%, transparent 66%),
    var(--beige);
}

.half-edu {
  background:
    radial-gradient(640px 420px at 18% 92%, var(--brand-soft) 0%, transparent 64%),
    var(--beige);
  border-left: 1px solid var(--line);
}

.half-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  max-width: 640px;
  margin: 0 auto;
}

.half-casual .half-inner {
  max-width: 680px;
}

.half-edu .half-inner {
  max-width: calc(540px + clamp(140px, 12vw, 190px) + var(--s-4));
  display: grid;
  grid-template-columns: minmax(0, 540px) clamp(140px, 12vw, 190px);
  align-items: stretch;
  gap: var(--s-4);
}

.half-copy {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: clamp(8px, 1.6vh, 16px);
  min-width: 0;
  width: 100%;
}

/* Bottom blocks of both halves share one top line and one bottom line */
.split {
  --bottom-h: clamp(300px, 42vh, 450px);
}

.casual-games {
  margin-top: auto;
  height: var(--bottom-h);
  width: 100%;
  max-width: 680px;
}

.edu-bottom {
  margin-top: auto;
  height: var(--bottom-h);
  width: 100%;
  max-width: 540px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--s-3);
  padding: clamp(14px, 2vh, 20px);
}

.edu-bottom .subject-row {
  flex: 1;
  grid-auto-rows: 1fr;
  gap: var(--s-2);
}

.edu-bottom .subject {
  background: var(--beige);
  border: 1px solid var(--line);
  box-shadow: none;
}

.edu-bottom .half-actions {
  margin-top: 0;
}

.half-copy .eyebrow {
  margin: 0;
}

.half h1,
.half h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--w-bold);
  font-size: clamp(34px, min(4vw, 6.4vh), 60px);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
  color: var(--ink);
  text-wrap: balance;
}

.half h1 em,
.half h2 em {
  font-style: normal;
  color: var(--brand-pressed);
}

.half h2 em {
  color: #6a57b8; /* lilac family, dark enough for text contrast */
}

.half-lede {
  margin: 0;
  max-width: 42ch;
  font-size: clamp(15px, 2vh, 18px);
  color: var(--ink-2);
  text-wrap: pretty;
}

.half-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
  margin-top: var(--s-1);
}

.half-actions .btn-ghost {
  padding: 8px 16px;
  font-size: 14px;
}

.half-badge {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 44px;
}

.app-icon {
  display: block;
  aspect-ratio: 1;
  border-radius: 22.5%; /* iOS icon corner */
  box-shadow: var(--shadow-card);
}

.app-icon-sm {
  width: 44px;
  height: 44px;
}

.icon-stack {
  display: flex;
}

.icon-stack .app-icon + .app-icon {
  margin-left: -12px;
  outline: 3px solid var(--beige);
}

.chip-lilac {
  background: var(--lilac);
  box-shadow:
    inset 0 -3px 0 #8f80c8,
    0 3px 0 rgba(43, 36, 24, 0.1);
}

/* ---------- Education: subject pills ---------- */
.subject-row {
  list-style: none;
  margin-bottom: 0;
  padding: 0;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
}

.subject {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: var(--s-3);
  align-items: center;
  align-content: center;
  padding: clamp(8px, 1.6vh, 16px);
  font-family: var(--font-display);
  font-weight: var(--w-semibold);
  font-size: 16px;
  color: var(--ink);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}

.subject span {
  width: clamp(34px, 5vh, 44px);
  height: clamp(34px, 5vh, 44px);
  flex: none;
  display: grid;
  place-items: center;
  font-size: 20px;
  border-radius: var(--r-md);
}

.subject span {
  grid-row: 1 / 3;
}

.subject strong {
  font-weight: var(--w-semibold);
  align-self: end;
}

.subject small {
  align-self: start;
  font-family: var(--font-body);
  font-weight: var(--w-regular);
  font-size: 13px;
  color: var(--ink-2);
}

.subject.words span { background: var(--orange); box-shadow: inset 0 -2px 0 var(--orange-dark); }
.subject.numbers span { background: var(--blue); box-shadow: inset 0 -2px 0 var(--blue-dark); }
.subject.memory span { background: var(--green); box-shadow: inset 0 -2px 0 var(--green-dark); }
.subject.trace span { background: var(--yellow); box-shadow: inset 0 -2px 0 var(--yellow-dark); }

/* ---------- Education: mascot ---------- */
.half-mascot {
  position: relative;
  align-self: end;
  margin-bottom: calc(-1 * clamp(20px, 4vh, 48px)); /* sit on the half's bottom edge */
  padding-top: 56px; /* room for the speech bubble */
}

.half-mascot img {
  display: block;
  width: 100%;
  max-height: 46vh;
  object-fit: contain;
  object-position: bottom;
  filter: drop-shadow(0 16px 24px rgba(43, 36, 24, 0.18));
}

.half-mascot .mascot-speech {
  top: 0;
  left: 18%;
  font-size: 14px;
  max-width: 160px;
}

/* ---------- Puzzle: two game cards ---------- */
.casual-games {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4);
}

.casual-game {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
}

.casual-game-art {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  height: clamp(68px, 9.5vh, 108px);
}

.casual-game-art .app-icon {
  height: 72%;
  width: auto;
}

.art-rulesort {
  background: var(--lilac);
}

.art-blocknest {
  background: var(--blue);
}

.casual-game-copy {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: clamp(4px, 0.8vh, 8px);
  padding: clamp(10px, 1.6vh, 18px) clamp(12px, 1.4vw, 16px);
  min-height: 0;
}

.casual-game-copy h3 {
  margin: 0;
  font-size: clamp(20px, 1.5vw, 24px);
  line-height: 1.2;
}

.casual-game-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 0.65vh, 7px);
  width: 100%;
}

.casual-game-features li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: clamp(13px, 0.92vw, 14.5px);
  line-height: 1.38;
  color: var(--ink-2);
}

.casual-game-features .feat-emoji {
  flex: none;
  font-size: clamp(14px, 1vw, 16px);
  line-height: 1.38;
}

.casual-game-features .feat-note {
  display: block;
  font-size: clamp(11.5px, 0.8vw, 12.5px);
  color: var(--ink-muted);
  line-height: 1.3;
}

.casual-game-copy a:not(.btn) {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  font-size: var(--t-small);
  font-weight: var(--w-semibold);
  color: var(--brand-pressed);
}

.casual-game-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-1) var(--s-4);
  margin-top: auto; /* same button line in both cards */
  padding-top: var(--s-2);
}

.btn-store-sm {
  padding: 8px 16px;
  font-size: 14px;
  gap: 8px;
  box-shadow:
    inset 0 -3px 0 #000000,
    0 3px 0 rgba(43, 36, 24, 0.18);
}

.btn-store-sm .apple-glyph {
  width: 16px;
  height: 16px;
}

.btn-store-sm .btn-store-text small {
  font-size: 8px;
}

/* Sort shapes (home-only; no longer in colors_and_type.css) */
.sort-shape { display: block; width: clamp(32px, 4vw, 64px); aspect-ratio: 1; flex: none; background: var(--ink); }
.sort-circle { border-radius: 50%; }
.sort-square { border-radius: 8px; transform: rotate(-10deg); }
.sort-triangle { clip-path: polygon(50% 0, 100% 100%, 0 100%); }

/* Floating shapes on the puzzle side */
.shape-bits .sort-shape {
  position: absolute;
  width: 26px;
  opacity: 0.5;
}

/* ---------- Footer ---------- */
.home-footer {
  width: 100%;
  background: var(--beige);
  border-top: 1px solid var(--line);
  padding: 8px clamp(12px, 2.5vw, 40px);
  font-size: clamp(11px, 0.85vw, 12.5px);
  color: var(--ink-2);
}

.home-footer-inner {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-4);
  flex-wrap: nowrap;
}

.footer-left,
.footer-right {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: var(--s-2);
}

.footer-label {
  font-family: var(--font-display);
  font-weight: var(--w-semibold);
  color: var(--ink);
}

.home-footer a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: rgba(43, 36, 24, 0.25);
  text-underline-offset: 3px;
  transition: color var(--ease-snappy) var(--dur-fast), text-decoration-color var(--ease-snappy) var(--dur-fast);
}

.home-footer a:hover {
  color: var(--brand-pressed);
  text-decoration-color: var(--brand-pressed);
}

.home-footer .sep {
  color: var(--ink-2);
  opacity: 0.5;
}

.home-footer .sep-pipe {
  margin: 0 var(--s-1);
  opacity: 0.35;
}

/* ---------- Medium widths: mascot drops out, copy gets the room ---------- */
@media (max-width: 1100px) {
  .br-wide {
    display: none;
  }

  .half-edu .half-inner {
    grid-template-columns: 1fr;
    max-width: 520px;
  }

  .half-mascot {
    display: none;
  }
}

/* ---------- Shorter side-by-side screens: drop secondary lines ---------- */
@media (min-width: 901px) and (max-height: 820px) {
  .split {
    --bottom-h: clamp(280px, 39vh, 335px);
  }

  .subject small {
    display: none;
  }

  .subject strong {
    align-self: center;
  }

  .casual-game-art {
    height: clamp(52px, 7vh, 70px);
  }

  .casual-game-copy {
    padding: 8px 12px;
    gap: 3px;
  }

  .casual-game-features {
    gap: 2px;
  }

  .casual-game-features li {
    font-size: 12px;
    line-height: 1.3;
  }

  .casual-game-features .feat-emoji {
    font-size: 13px;
  }

  .casual-game-features .feat-note {
    font-size: 11px;
  }
}

/* ---------- Narrow screens: stack halves, keep the essentials ---------- */
@media (max-width: 900px) {
  .topnav {
    display: none;
  }

  .topbar-inner {
    height: 56px;
    min-height: 0;
    padding-top: 0;
    padding-bottom: 0;
  }

  .split {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .half {
    padding: var(--s-4);
  }

  .half-edu {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .half-copy {
    gap: var(--s-2);
  }

  .half h1,
  .half h2 {
    font-size: clamp(28px, 4.6vh, 40px);
  }

  .half-lede,
  .half-badge,
  .half-edu .float-bits {
    display: none;
  }

  .subject {
    font-size: 12px;
    padding-right: 10px;
  }

  .subject span {
    width: 24px;
    height: 24px;
    font-size: 13px;
  }

  .half-actions .btn-ghost,
  .btn-store-sm {
    padding: 6px 12px;
    font-size: 13px;
  }

  .btn-store-sm .btn-store-text small {
    display: none;
  }

  .casual-game-links {
    gap: 0 var(--s-3);
    margin-top: 0;
  }

  .casual-game-copy a:not(.btn) {
    min-height: 30px;
  }

  .casual-games {
    gap: var(--s-3);
  }

  .casual-game-art {
    height: clamp(48px, 8vh, 80px);
  }

  .half {
    align-items: center;
  }

  .half-inner,
  .half-copy,
  .edu-bottom,
  .casual-games {
    height: auto;
    max-width: 100%;
  }

  .edu-bottom {
    gap: var(--s-2);
  }

  .subject-row {
    gap: var(--s-2);
  }

  .subject {
    min-height: 0;
  }

  .subject small {
    display: none;
  }

  .casual-game-copy {
    padding: var(--s-2) var(--s-3);
  }

  .casual-game-copy h3 {
    font-size: 17px;
  }

  .casual-game-copy p,
  .casual-game-features {
    display: none;
  }

  .home-footer {
    padding: var(--s-3) var(--s-3);
  }

  .home-footer-inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--s-2);
    flex-wrap: wrap;
  }

  .footer-left,
  .footer-right {
    justify-content: center;
    text-align: center;
    flex-wrap: wrap;
  }
}

/* ---------- Short viewports: scroll instead of clipping ---------- */
@media (max-height: 680px) {
  body.home {
    height: auto;
    min-height: 100dvh;
    overflow: auto;
  }

  .split {
    grid-template-rows: auto;
  }
}
