/* ============================================================
   components.css - buttons, cards, mascots, widgets
   ============================================================ */

/* ---------- Icons and artwork ---------- */
.icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: middle;
  fill: currentColor;
}
.art {
  display: block;
  max-width: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

/* ---------- Icon buttons (top bar) ---------- */
.iconbtn {
  flex: 0 0 auto;
  width: var(--touch);
  height: var(--touch);
  min-width: var(--touch);
  display: grid;
  place-items: center;
  font-size: 1.7rem;
  color: var(--w-primary-d);
  background: var(--paper);
  border: 2px solid rgba(255,255,255,.9);
  border-radius: 50%;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .2s ease;
}
.iconbtn:hover { transform: translateY(-2px) scale(1.05); }
.iconbtn:active { transform: translateY(1px) scale(.96); }
.iconbtn[hidden] { display: none; }

/* ---------- Star count ---------- */
.starcount {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-md);
  font-weight: 800;
  color: var(--w-primary-d);
  background: var(--paper);
  padding: 6px 16px 6px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  border: 2px solid rgba(255,255,255,.86);
}
.starcount .icon { color: #e7b94b; font-size: 1.4em; }

/* ---------- Big primary "play" button ---------- */
.bigbtn {
  font-family: var(--font-fun);
  font-size: var(--fs-md);
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, rgba(255,255,255,.14), transparent 42%), var(--w-primary);
  border: 2px solid rgba(255,255,255,.8);
  border-radius: 999px;
  padding: var(--sp-2) var(--sp-4);
  min-height: var(--touch);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  box-shadow: 0 7px 0 var(--w-primary-d), var(--shadow-soft);
  cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease;
}
.bigbtn:hover { transform: translateY(-2px); }
.bigbtn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--w-primary-d); }
.bigbtn .icon { font-size: 1.3em; }

/* ---------- World cards (home) ---------- */
.worldcard {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border: 4px solid rgba(255, 248, 232, .92);
  border-radius: var(--radius);
  color: var(--ink);
  cursor: pointer;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform .15s ease;
  font-family: var(--font-fun);
}
.worldcard::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 2px dashed rgba(255,255,255,.45);
  border-radius: calc(var(--radius) - 8px);
  pointer-events: none;
}
.worldcard::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255,255,255,.18), transparent 46%),
    repeating-linear-gradient(0deg, rgba(73, 47, 25, .08) 0 1px, transparent 1px 6px);
  mix-blend-mode: soft-light;
}
.worldcard:hover { transform: translateY(-6px) rotate(-1deg); }
.worldcard:active { transform: translateY(-1px) scale(.99); }
.worldcard[data-world-theme="life"]     { background: linear-gradient(160deg, #f4df9f, #9fcb82 45%, #5f9b5a); }
.worldcard[data-world-theme="physical"] { background: linear-gradient(160deg, #f6d28e, #e99b57 48%, #8f79b7); }
.worldcard[data-world-theme="earth"]    { background: linear-gradient(160deg, #f7e1a8, #98cddd 42%, #4f90bd); }
.worldcard > * { position: relative; z-index: 1; }
.worldcard .mascot {
  width: clamp(120px, 15vw, 190px);
  height: clamp(120px, 15vw, 190px);
  filter: drop-shadow(0 10px 12px rgba(77, 52, 28, .26));
}
.worldcard .wc-name {
  font-size: var(--fs-lg);
  font-weight: 900;
  text-align: center;
  line-height: 1.05;
  color: #fffdf5;
  text-shadow: 0 2px 0 rgba(75, 43, 32, .25);
}
.worldcard .wc-tagline {
  max-width: 20ch;
  font-size: var(--fs-sm);
  font-weight: 800;
  text-align: center;
  color: rgba(255,253,245,.94);
  line-height: 1.15;
}
.worldcard .wc-count { font-size: var(--fs-sm); font-weight: 800; color: rgba(255,253,245,.92); }
.worldcard .wc-progress {
  width: 70%;
  height: 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.42);
  border: 2px solid rgba(255,255,255,.58);
  overflow: hidden;
}
.worldcard .wc-progress > span { display:block; height:100%; background:var(--paper); border-radius:999px; transition: width .4s ease; }

/* ---------- Unit cards (world) ---------- */
.unitcard {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  padding: var(--sp-3) var(--sp-2);
  background:
    linear-gradient(180deg, rgba(255,255,255,.52), transparent 44%),
    var(--paper);
  border: 4px solid rgba(255,255,255,.92);
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: transform .14s ease;
  font-family: var(--font-fun);
  color: var(--ink);
}
.unitcard::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: calc(var(--radius) - 8px);
  border: 1px solid var(--paper-line);
  pointer-events: none;
}
.unitcard:hover { transform: translateY(-5px) scale(1.02); }
.unitcard:active { transform: translateY(-1px) scale(.99); }
.unitcard .u-icon {
  width: clamp(64px, 8vw, 104px);
  height: clamp(64px, 8vw, 104px);
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 35% 25%, rgba(255,255,255,.8), transparent 42%),
    var(--w-bg-top);
  border-radius: 50%;
  box-shadow: inset 0 -5px 0 rgba(117, 88, 50, .1), 0 5px 10px rgba(117, 88, 50, .1);
  border: 3px solid rgba(255,255,255,.72);
}
.unitcard .u-icon .icon { width: 70%; height: 70%; }
.unitcard .u-name { font-size: var(--fs-md); font-weight: 900; color: var(--w-primary-d); text-align: center; line-height: 1.1; }
.unitcard .u-stars { display: flex; gap: 3px; color: #d7d2c8; font-size: 1.2rem; }
.unitcard .u-stars .on { color: #e7b94b; }

/* "Play next" suggestion glow */
.unitcard.suggested {
  border-color: var(--w-accent);
  animation: pulse-glow 1.8s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%,100% { box-shadow: var(--shadow-card), 0 0 0 0 rgba(231,185,75,.0); }
  50%     { box-shadow: var(--shadow-card), 0 0 0 10px rgba(231,185,75,.35); }
}
.unitcard .u-badge {
  position: absolute; top: -10px; right: -10px;
  background: var(--w-accent); color: var(--w-ink-on);
  font-size: .8rem; font-weight: 800;
  padding: 4px 10px; border-radius: 999px;
  box-shadow: var(--shadow-soft);
  transform: rotate(8deg);
}

/* ---------- Standalone mascot ---------- */
.mascot { width: clamp(70px, 9vw, 130px); height: clamp(70px, 9vw, 130px); }
.mascot--storybook {
  border-radius: 28% 22% 30% 24%;
  background: #fff4d4;
  box-shadow: 0 8px 20px rgba(91, 66, 38, .18);
}
.mascot--float { animation: bob 3s ease-in-out infinite; }
@keyframes bob { 0%,100%{ transform: translateY(0) } 50%{ transform: translateY(-8px) } }

/* ---------- Placeholder panel (used by M0 game stub) ---------- */
.panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  text-align: center;
  background:
    linear-gradient(180deg, rgba(255,255,255,.55), transparent 38%),
    var(--paper);
  border-radius: var(--radius);
  border: 4px solid rgba(255,255,255,.92);
  box-shadow: var(--shadow-card);
  padding: var(--sp-4);
}
.panel .title { font-size: var(--fs-lg); color: var(--w-primary-d); margin: 0; }
.panel p { font-size: var(--fs-md); color: var(--ink-soft); max-width: 40ch; margin: 0; }

/* ---------- Focus visibility (keyboard a11y) ---------- */
:focus-visible {
  outline: none;
  box-shadow: var(--ring) !important;
}

/* ---------- Screen entrance animation ---------- */
.screen > * { animation: pop-in .35s cubic-bezier(.2,.9,.3,1.3) both; }
@keyframes pop-in { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
