/* shared/components.css
   ────────────────────────────────────────
   Reusable building blocks. All visual look-and-feel for the site
   lives here. Pages just compose these classes — they don't restyle
   them.

   Conventions:
     .x        → base block
     .x--mod   → modifier (BEM-ish, but loose)
     .x__part  → inner part

   Depends on tokens.css (var(--*)) and fonts.css.
*/

/* ─── reset & base ──────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  background-image:
    radial-gradient(rgba(42,38,34,.045) 1px, transparent 1.2px),
    linear-gradient(180deg, rgba(255,255,255,.6), transparent 240px);
  background-size: 26px 26px, 100% 100%;
  color: var(--ink);
  font-family: var(--f-body);
  font-size: var(--t-base);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--f-display); margin: 0; line-height: 1.1; }
p { margin: 0; }
button { font: inherit; }

/* ─── layout ────────────────────────────────────── */

.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 56px 56px 120px;
}

.stack  { display: flex; flex-direction: column; gap: var(--sp-4); }
.row    { display: flex; flex-direction: row;    gap: var(--sp-3); align-items: center; }
.row--wrap { flex-wrap: wrap; }

/* ─── topbar (back-to-home) ─────────────────────── */
/* Used on every project page so kids can always get home. */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-6);
}

.brand { display: flex; align-items: center; gap: var(--sp-4); text-decoration: none; color: inherit; }

.brand-mark {
  width: 54px; height: 54px;
  border-radius: var(--r-lg);
  background: var(--c2);
  display: grid; place-items: center;
  border: var(--stroke);
  box-shadow: var(--shadow-stamp);
  transform: rotate(-4deg);
  font-family: var(--f-display);
  font-size: 28px; font-weight: 700;
  color: var(--ink);
}

.brand-name {
  font-family: var(--f-display);
  font-size: var(--t-xl);
  letter-spacing: .02em;
  font-weight: 600;
}
.brand-name .dot { color: var(--c1); }

.brand-sub {
  font-family: var(--f-mono);
  font-size: var(--t-xs);
  color: var(--ink-soft);
  margin-top: 2px;
  letter-spacing: .04em;
}

/* ─── buttons / pills ───────────────────────────── */

.btn {
  appearance: none;
  font-family: var(--f-display);
  font-size: var(--t-md);
  font-weight: 600;
  padding: 12px 22px;
  border-radius: var(--r-pill);
  border: var(--stroke);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-stamp);
  transition: transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
  display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover  { transform: translate(-1px,-1px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

.btn--primary { background: var(--c2); }
.btn--accent  { background: var(--c1); color: white; }
.btn--ghost   { background: transparent; box-shadow: none; border-style: dashed; }

.pill {
  font-family: var(--f-body);
  font-weight: 600;
  font-size: var(--t-sm);
  padding: 10px 16px;
  border-radius: var(--r-pill);
  border: 2px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform var(--dur-fast), box-shadow var(--dur-fast);
}
.pill:hover  { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--ink); }
.pill:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.pill.is-active { background: var(--c3); color: white; }

/* ─── card (the foundational element) ──────────── */

.card {
  position: relative;
  background: var(--surface);
  border: var(--stroke);
  border-radius: var(--r-xl);
  padding: 22px 20px 20px;
  box-shadow: 5px 5px 0 var(--ink);
  transition: transform var(--dur) var(--ease-bounce), box-shadow var(--dur);
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: flex; flex-direction: column;
}
.card:hover {
  transform: translate(-2px,-4px) rotate(var(--tilt, 0deg));
  box-shadow: 8px 9px 0 var(--ink);
}
.card:active { transform: translate(2px, 3px); box-shadow: 2px 2px 0 var(--ink); }
.card--static { cursor: default; }
.card--static:hover { transform: none; box-shadow: 5px 5px 0 var(--ink); }

.card__emoji {
  width: 64px; height: 64px;
  border-radius: var(--r-lg);
  background: var(--card-bg, var(--c2));
  border: 2.5px solid var(--ink);
  display: grid; place-items: center;
  font-size: 36px; line-height: 1;
  margin-bottom: 14px;
  box-shadow: 3px 3px 0 var(--ink);
}
.card__title { font-family: var(--f-display); font-size: var(--t-lg); margin: 0 0 6px; }
.card__desc  { font-size: var(--t-sm); color: var(--ink-soft); line-height: 1.5; }
.card__meta  {
  margin-top: auto; padding-top: 14px;
  font-family: var(--f-mono); font-size: var(--t-xs); color: var(--ink-soft);
  display: flex; align-items: center; justify-content: space-between;
}
.card__go {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--card-bg, var(--c2));
  border: 2px solid var(--ink);
  display: grid; place-items: center;
  font-size: 14px; line-height: 1;
  transition: transform var(--dur) var(--ease-out);
}
.card:hover .card__go { transform: translateX(3px); }

/* ─── badges & sticker decorations ─────────────── */

.badge {
  display: inline-block;
  background: var(--c1);
  color: white;
  font-family: var(--f-display);
  font-size: var(--t-sm);
  padding: 5px 10px;
  border: 2.5px solid var(--ink);
  border-radius: var(--r-pill);
  box-shadow: 2px 2px 0 var(--ink);
}
.badge--corner {
  position: absolute; top: -12px; right: -10px;
  transform: rotate(8deg);
}

.sticker {
  font-size: 28px;
  background: var(--surface);
  border: 2.5px solid var(--ink);
  border-radius: var(--r-pill);
  width: 56px; height: 56px;
  display: grid; place-items: center;
  box-shadow: var(--shadow-stamp);
}

.tape {
  position: absolute;
  width: 110px; height: 26px;
  background: var(--tape-1);
  border-top: 1px dashed rgba(0,0,0,.15);
  border-bottom: 1px dashed rgba(0,0,0,.15);
}

/* ─── fact chip (dashed pill for facts/stats) ──── */

.fact-chip {
  background: var(--bg);
  border: 2px dashed var(--ink);
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: var(--t-sm);
  font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.fact-chip .emo { font-size: 18px; }

/* ─── section headings ─────────────────────────── */

.section-head {
  display: flex; align-items: baseline; gap: 18px;
  margin: 0 6px 22px;
}
.section-head__emoji {
  font-size: 44px; line-height: 1;
  transform: rotate(-6deg);
  display: inline-block;
}
.section-head__title { font-family: var(--f-display); font-size: var(--t-h2); margin: 0; }
.section-head__count {
  font-family: var(--f-mono); font-size: var(--t-sm);
  color: var(--ink-soft);
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--r-pill);
  padding: 4px 10px;
  align-self: center;
}
.section-head__rule {
  flex: 1; height: 4px; border-radius: 2px;
  background: repeating-linear-gradient(90deg, var(--ink) 0 8px, transparent 8px 14px);
  align-self: center;
  opacity: .35;
}

/* ─── grids ────────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 22px;
}
@media (max-width: 1100px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 780px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}

/* ─── footer ───────────────────────────────────── */

.footer {
  margin-top: 40px;
  padding-top: 26px;
  border-top: 3px dashed var(--paper-line);
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--f-mono);
  font-size: var(--t-xs);
  color: var(--ink-soft);
}
.footer .heart { color: var(--c1); }

/* ─── project page scaffold ─────────────────────── */
/* Use this on /games/{slug}/ and /tools/{slug}/ index.html so every
   project has the same chrome: back-to-home + page title + content. */

.proj {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 32px 96px;
}

.proj__head {
  display: flex; align-items: center; gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}
.proj__back {
  font-family: var(--f-body);
  font-size: var(--t-sm);
  font-weight: 600;
  text-decoration: none;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--r-pill);
  padding: 8px 14px;
  box-shadow: 3px 3px 0 var(--ink);
  display: inline-flex; align-items: center; gap: 6px;
  transition: transform var(--dur-fast), box-shadow var(--dur-fast);
}
.proj__back:hover  { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--ink); }
.proj__back:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

.proj__title {
  font-family: var(--f-display);
  font-size: var(--t-h1);
  display: flex; align-items: center; gap: var(--sp-4);
}
.proj__emoji {
  font-size: 56px;
  background: var(--card-bg, var(--c2));
  width: 88px; height: 88px;
  border-radius: var(--r-xl);
  border: var(--stroke);
  box-shadow: var(--shadow-stamp);
  display: grid; place-items: center;
}

.proj__board {
  background: var(--surface);
  border: var(--stroke);
  border-radius: var(--r-2xl);
  padding: 32px;
  box-shadow: var(--shadow-stamp-lg);
  position: relative;
}

/* ─── focus styles (accessibility) ─────────────── */

:focus-visible {
  outline: 3px solid var(--c3);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ─── helpers ──────────────────────────────────── */

.hand-note {
  font-family: var(--f-hand);
  font-size: 28px;
  color: var(--c1);
  line-height: 1;
}

/* ─── responsive chrome ─────────────────────────────────
   Mobile-friendly adjustments for the page frame, topbar,
   section headings, cards, and project scaffold. Grid
   breakpoints live with .grid above. */

@media (max-width: 720px) {
  .page {
    padding: 24px 18px 64px;
  }

  .topbar {
    margin-bottom: var(--sp-5);
    gap: var(--sp-3);
  }
  .brand { gap: var(--sp-3); }
  .brand-mark {
    width: 44px; height: 44px;
    font-size: 22px;
    border-radius: var(--r-md);
  }

  .section-head {
    gap: 12px;
    margin: 0 2px 16px;
    flex-wrap: wrap;
  }
  .section-head__emoji { font-size: 32px; }
  .section-head__rule { display: none; }

  .grid { gap: 14px; }
  .card { padding: 18px 16px 16px; }
  .card__emoji {
    width: 52px; height: 52px;
    font-size: 30px;
    margin-bottom: 10px;
  }

  /* project pages */
  .proj { padding: 28px 16px 64px; }
  .proj__head {
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
    flex-wrap: wrap;
  }
  .proj__title { font-size: var(--t-h1); gap: var(--sp-3); }
  .proj__emoji {
    width: 60px; height: 60px;
    font-size: 36px;
    border-radius: var(--r-lg);
  }
  .proj__board { padding: 18px; }
  .proj__back { padding: 6px 12px; font-size: var(--t-xs); }

  .footer {
    flex-direction: column;
    gap: 6px;
    text-align: center;
  }
}

@media (max-width: 400px) {
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .card { padding: 16px 14px 14px; }
  .brand-sub { display: none; }
  .section-head__count { display: none; }
}
