/* =====================================================================
   AnimalSake Memory Match — baby-animal card game
   Resource page + accessible DOM card grid. Matches AnimalSake theme.
   ===================================================================== */

:root {
  --as-bg:     #fdf6e9;
  --as-card:   #fff8ec;
  --as-brown:  #4b2f20;
  --as-orange: #ff5a00;
  --as-green:  #5aa545;
  --as-yellow: #f8e7c2;
  --as-blue:   #2e9fe6;
  --as-purple: #8b5cf6;
  --as-shadow: 0 12px 30px rgba(75, 47, 32, 0.14);

  --as-brown-soft:  #6f5b4a;
  --as-orange-deep: #e54f00;
  --as-green-deep:  #468539;
  --as-line:        #efe0c8;
  --as-card-soft:   #fffdf8;
  --radius:    22px;
  --radius-sm: 14px;
  --maxw: 980px;
  --font: "Baloo 2", "Quicksand", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--as-brown);
  background:
    radial-gradient(1200px 520px at 50% -160px, #ffe9c9 0%, rgba(255,233,201,0) 70%),
    var(--as-bg);
  line-height: 1.55;
  font-size: 17px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.12; margin: 0; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
strong { color: var(--as-orange-deep); }
a { color: var(--as-orange-deep); text-decoration: none; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 13px 24px;
  font-family: var(--font); font-weight: 700; font-size: 16px; color: #fff;
  cursor: pointer; text-decoration: none;
  transition: transform .12s ease, background-color .15s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn--lg { padding: 16px 32px; font-size: 18px; }
.btn--sm { padding: 9px 14px; font-size: 14px; }
.btn--primary { background: var(--as-green); box-shadow: 0 8px 18px rgba(90,165,69,.32); }
.btn--primary:hover { background: var(--as-green-deep); }
.btn--orange { background: var(--as-orange); box-shadow: 0 8px 18px rgba(255,90,0,.28); }
.btn--orange:hover { background: var(--as-orange-deep); }
.btn--ghost { background: var(--as-card-soft); color: var(--as-brown); border: 2px solid var(--as-line); }
.btn--ghost:hover { background: #fff; border-color: #e3cfa8; }

:focus-visible { outline: 3px solid var(--as-blue); outline-offset: 3px; border-radius: 8px; }

/* ---------- Page chrome ---------- */
.wordmark { display: inline-flex; align-items: baseline; gap: 6px; font-weight: 800; font-size: 26px; }
.wordmark__paw { font-size: 22px; }
.wordmark__a { color: var(--as-brown); }
.wordmark__b { color: var(--as-orange); }
.site-nav a { font-weight: 700; color: var(--as-brown); }
.site-nav a:hover { color: var(--as-orange-deep); }

.page { max-width: var(--maxw); margin: 0 auto; padding: 8px 20px 48px; }
.resource { display: flex; flex-direction: column; gap: 26px; }

/* ---------- Intro ---------- */
.eyebrow {
  display: inline-block; font-weight: 700; font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--as-orange); background: #fff; border: 2px solid var(--as-line); border-radius: 999px;
  padding: 5px 14px; margin-bottom: 12px;
}
.intro h1 { font-size: 40px; color: var(--as-brown); margin-bottom: 12px; }
.lede { font-size: 20px; color: var(--as-brown); max-width: 62ch; margin-bottom: 18px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.meta-pill { display: inline-flex; align-items: center; gap: 7px; background: var(--as-card); border: 2px solid var(--as-line); border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 14px; color: var(--as-brown); }
.learn { background: var(--as-yellow); border-radius: var(--radius); padding: 20px 22px; }
.learn__title { font-size: 18px; color: var(--as-brown); margin-bottom: 14px; }
.learn__list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.learn__list li { display: flex; align-items: center; gap: 9px; background: #fffdf8; border-radius: var(--radius-sm); padding: 12px 12px; font-weight: 700; font-size: 14px; box-shadow: 0 3px 8px rgba(75,47,32,.07); }
.learn__list li span { font-size: 22px; }

/* =====================================================================
   Game widget
   ===================================================================== */
.game-shell { position: relative; border-radius: var(--radius); overflow: hidden; min-height: 560px; display: flex; flex-direction: column; }

.hud {
  display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap;
  background: var(--as-card); border: 2px solid var(--as-line);
  border-radius: var(--radius); box-shadow: var(--as-shadow); padding: 12px 16px; margin-bottom: 14px;
}
.hud__title { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; color: var(--as-brown); }
.hud__logo { font-size: 22px; }
.hud__stats { display: flex; gap: 8px; flex-wrap: wrap; }
.hud__actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; color: var(--as-brown); background: var(--as-yellow); border-radius: 999px; padding: 7px 13px; white-space: nowrap; }

/* board */
.board-wrap { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px 0; }
.board { display: grid; grid-template-columns: repeat(var(--cols, 4), 1fr); gap: 12px; width: min(560px, 100%); }

.toast {
  position: absolute; left: 50%; top: -2px; transform: translateX(-50%) translateY(-6px);
  background: var(--as-card); color: var(--as-brown); border: 2px solid var(--as-green);
  border-radius: 999px; padding: 9px 18px; font-weight: 700; font-size: 15px;
  box-shadow: var(--as-shadow); max-width: 92%; text-align: center; z-index: 5;
  opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* cards */
.card { position: relative; aspect-ratio: 3 / 4; border: 0; background: transparent; padding: 0; cursor: pointer; perspective: 800px; -webkit-tap-highlight-color: transparent; }
.card__inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .42s ease; }
.card.is-flipped .card__inner, .card.is-matched .card__inner { transform: rotateY(180deg); }
.card__back, .card__front {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  border-radius: 16px; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: var(--as-shadow); overflow: hidden;
}
.card__back { background: linear-gradient(160deg, #ff7d31 0%, #ff5a00 100%); border: 3px solid #fff3e2; }
.card__back svg { opacity: .95; width: 46%; height: auto; }
.card__front { background: var(--as-card); border: 3px solid var(--as-line); transform: rotateY(180deg); padding: 6px; }
.card__front--baby { background: var(--as-yellow); }
.card__name { font-weight: 800; font-size: clamp(12px, 3.4vw, 15px); color: var(--as-brown); }
.card__tag { font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--as-green-deep); }
.card__baby { font-weight: 800; font-size: clamp(16px, 5vw, 22px); color: var(--as-brown); }
.face { width: 66%; height: auto; display: block; }

.card.is-matched { cursor: default; }
.card.is-matched .card__front { border-color: var(--as-green); box-shadow: 0 0 0 3px rgba(90,165,69,.35), var(--as-shadow); }
.card.is-matched .card__front::after {
  content: "✓"; position: absolute; top: -10px; right: -10px; width: 26px; height: 26px;
  background: var(--as-green); color: #fff; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 15px; border: 2px solid #fff;
}

/* =====================================================================
   Overlays (scoped to the game shell)
   ===================================================================== */
.overlay {
  position: absolute; inset: 0; z-index: 10;
  display: grid; place-items: center; padding: 20px;
  background: radial-gradient(900px 420px at 50% -10%, #ffe9c9 0%, rgba(255,233,201,0) 60%), rgba(253,246,233,0.97);
  border-radius: var(--radius); overflow-y: auto;
}
.overlay[hidden] { display: none; }
.overlay__card { width: min(540px, 100%); background: var(--as-card); border: 2px solid var(--as-line); border-radius: 26px; box-shadow: var(--as-shadow); padding: 32px 28px; text-align: center; }
.overlay__card--wide { width: min(620px, 100%); }
.overlay__emoji { font-size: 54px; line-height: 1; margin-bottom: 6px; }
.overlay__title { font-size: 36px; color: var(--as-brown); margin-bottom: 10px; }
.overlay__sub { font-size: 18px; color: var(--as-brown); margin-bottom: 16px; }
.overlay__sub--left { text-align: left; }
.overlay__pick { font-weight: 700; color: var(--as-brown-soft); margin-bottom: 12px; }
.overlay__actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }

.level-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; }
.level-btn { flex-direction: column; gap: 2px; padding: 14px 22px; }
.level-btn__sub { font-size: 12px; font-weight: 600; opacity: .9; }

.howto-list { text-align: left; display: flex; flex-direction: column; gap: 10px; margin: 4px 0 22px; }
.howto-list li { background: var(--as-card-soft); border: 2px solid var(--as-line); border-left: 6px solid var(--as-green); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 15px; }

/* win */
.stars { font-size: 34px; letter-spacing: 6px; margin: 2px 0 6px; }
.stars .star-on { color: #ff9e1b; }
.stars .star-off { color: #e2d2b0; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px auto 16px; max-width: 460px; }
.result-grid li { background: var(--as-card-soft); border: 1px solid var(--as-line); border-radius: 12px; padding: 10px 8px; text-align: center; }
.result-grid .rk { display: block; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--as-brown-soft); margin-bottom: 4px; }
.result-grid .rv { font-size: 22px; font-weight: 800; color: var(--as-brown); }

.recap { background: var(--as-yellow); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 18px; }
.recap__title { font-size: 15px; color: var(--as-brown); margin-bottom: 10px; }
.recap-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 14px; text-align: left; }
.recap-list li { font-weight: 600; font-size: 14px; color: var(--as-brown); }
.recap-list li strong { color: var(--as-brown); }
.recap-list li .bb { color: var(--as-orange-deep); font-weight: 800; }

.medallion { width: 76px; height: 76px; margin: 0 auto 8px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffd25e, #ff9e1b 70%); display: grid; place-items: center; box-shadow: 0 10px 22px rgba(255,158,27,.4), inset 0 -6px 12px rgba(180,90,0,.25); border: 4px solid #fff3d6; }
.medallion__star { color: #fff; font-size: 36px; text-shadow: 0 2px 4px rgba(160,80,0,.35); }

/* =====================================================================
   Related links
   ===================================================================== */
.related__title { font-size: 24px; color: var(--as-brown); margin-bottom: 16px; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.related-card { display: flex; align-items: center; gap: 12px; background: var(--as-card); border: 2px solid var(--as-line); border-radius: var(--radius-sm); padding: 16px 18px; font-weight: 700; font-size: 16px; color: var(--as-brown); box-shadow: 0 4px 10px rgba(75,47,32,.07); transition: transform .12s ease, border-color .15s ease; }
.related-card:hover { transform: translateY(-2px); border-color: var(--as-orange); color: var(--as-orange-deep); }
.related-card__emoji { font-size: 26px; }

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .page { padding: 4px 14px 36px; }
  .resource { gap: 20px; }
  .intro h1 { font-size: 30px; }
  .lede { font-size: 17px; }
  .learn__list { grid-template-columns: repeat(2, 1fr); }

  .hud { padding: 10px 12px; gap: 8px 10px; }
  .hud__title { font-size: 18px; }
  .hud__actions { margin-left: 0; }

  .board { gap: 9px; }
  .overlay__title { font-size: 30px; }
  .overlay__card { padding: 26px 20px; }
  .recap-list { grid-template-columns: 1fr; }
}

@media (max-width: 380px) {
  .intro h1 { font-size: 26px; }
  .board { gap: 7px; }
  .card__name { font-size: 12px; }
}

/* =====================================================================
   Reduced motion
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card__inner { transition: none; }
  .toast { transition: none; }
  .btn, .related-card { transition: none; }
  .btn:hover, .related-card:hover { transform: none; }
}
