/* =============================================================================
 * Lookout Workshop — THEME  (flat-vector "toybox": Sago Mini lane)
 * Flat solid fills, no gradients, one consistent outline, a single flat
 * sticker-shadow. A content agent may EXTEND this but must keep the layout
 * ids/classes below working.
 * ========================================================================== */

/* ---- Vendored Baloo 2 (offline-safe, SIL OFL). Latin + Latin-Ext subsets only. ---- */
@font-face {
  font-family: 'Baloo 2';
  font-style: normal;
  font-weight: 500 800;
  font-display: swap;
  src: url('../vendor/fonts/baloo2-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Baloo 2';
  font-style: normal;
  font-weight: 500 800;
  font-display: swap;
  src: url('../vendor/fonts/baloo2-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Warm flat "toybox" palette — 6 base + 2 accents. Solid, no gradients. */
  --sky:        #a9def9;
  --grass:      #8cd867;
  --sand:       #f6c87b;
  --wood:       #c08552;
  --panel:      #fff6e6;   /* cream */
  --panel-edge: #e6d3ac;   /* warm tan — the ONE consistent outline color */
  --ink:        #3b2e4a;   /* deep plum, not black — text + outlines */
  /* control colors (flat fills) */
  --go:         #5ec26a;
  --go-dark:    #3f9a4c;
  --reset:      #ffc24b;
  --rotate:     #5ab1e8;
  --trash:      #ff6b5e;
  --gold:       #ffcb3b;
  --accent:     #ff8a5b;   /* warm coral highlight (selection, focus) */
  --radius: 18px;
  /* ONE flat sticker-shadow: a single solid offset, no blur, no inset. */
  --edge:   0 4px 0 rgba(59,46,74,0.16);
  --font: 'Baloo 2', 'Comic Sans MS', 'Trebuchet MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--sky);           /* flat sky, no gradient */
  color: var(--ink);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ============================================================
 * BASE LAYOUT (desktop ≥ 1200px — unchanged behaviour)
 * ============================================================ */
.app { display: grid; grid-template-rows: auto 1fr auto; height: 100vh; }

/* ---- top bar: title + level picker ---- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 18px; background: var(--panel);
  border-bottom: 3px solid var(--panel-edge);
}
.logo { font-size: 24px; font-weight: 800; letter-spacing: .5px; color: var(--ink); white-space: nowrap; }
.logo span { color: var(--trash); }
#levels { display: flex; gap: 8px; overflow-x: auto; padding: 2px; }
.level-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 3px solid var(--panel-edge); background: var(--panel);
  border-radius: 14px; padding: 6px 12px; cursor: pointer; min-width: 84px;
  box-shadow: var(--edge);
  font-family: var(--font);
  transition: transform .30s cubic-bezier(0.34, 1.56, 0.64, 1), border-color .15s ease, box-shadow .10s ease;
}
.level-btn:hover { transform: translateY(-3px) scale(1.04); }
.level-btn:active { transform: translateY(2px) scaleX(1.07) scaleY(0.90); box-shadow: 0 1px 0 rgba(59,46,74,0.16); transition-duration: .08s; }
.level-btn.active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,138,91,.30), var(--edge); }
.level-icon { font-size: 26px; }
.level-name { font-size: 12px; font-weight: 700; }

/* ---- middle: stage + palette ---- */
.middle { position: relative; display: grid; grid-template-columns: 132px 1fr; gap: 12px; padding: 12px; min-height: 0; }
body.palette-hidden .middle { grid-template-columns: 1fr; }

#palette {
  display: flex; flex-direction: column; gap: 8px; overflow-y: auto;
  padding: 6px; background: var(--panel); border-radius: var(--radius);
  border: 3px solid var(--panel-edge);
}
#palette.locked { opacity: .45; pointer-events: none; }

/* ---- part buttons: flat sticker + press state ---- */
.part-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 3px solid var(--panel-edge); background: #fffdf7;
  border-radius: 14px; padding: 8px 4px; cursor: pointer; font-family: var(--font);
  box-shadow: var(--edge);
  transition: transform .30s cubic-bezier(0.34, 1.56, 0.64, 1), border-color .15s ease, box-shadow .10s ease;
  min-height: 48px;   /* 48px touch target */
}
.part-btn:hover { transform: translateY(-3px) scale(1.04); border-color: var(--accent); }
.part-btn:active { transform: translateY(2px) scaleX(1.06) scaleY(0.92); box-shadow: 0 1px 0 rgba(59,46,74,0.16); transition-duration: .08s; }
.part-icon { font-size: 30px; line-height: 1; }
img.part-icon { width: 40px; height: 40px; object-fit: contain; display: block; }
.part-name { font-size: 12px; font-weight: 700; }
.pup-btn { border-color: var(--pup, var(--trash)); background: color-mix(in srgb, var(--pup, var(--trash)) 14%, white); }

/* stage-wrap: flex so canvas can shrink vertically */
.stage-wrap { position: relative; min-height: 0; display: flex; align-items: center; justify-content: center; }
#stage {
  /* Preserve the playfield ratio while reserving room for the real controls. */
  width: min(100%, calc((100vh - 164px) * 1.5625));
  height: auto;
  max-height: 100%;
  aspect-ratio: 1000 / 640;
  border-radius: var(--radius);
  border: 4px solid var(--panel);
  box-shadow: var(--edge);
  background: var(--sky);           /* flat; per-level bands set by engine */
  touch-action: none;
}

/* spoken-line banner */
#banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 3px solid var(--ink); color: var(--ink);
  padding: 8px 18px; border-radius: 999px; font-size: 18px; font-weight: 800;
  box-shadow: var(--edge); max-width: 80%; text-align: center; z-index: 4;
  white-space: normal; line-height: 1.15;
}
#banner.pulse { animation: pop .50s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes pop {
  0%   { transform: translateX(-50%) scale(.72); }
  55%  { transform: translateX(-50%) scale(1.10); }
  75%  { transform: translateX(-50%) scale(0.97); }
  100% { transform: translateX(-50%) scale(1); }
}

/* ---- bottom: controls ---- */
.bottombar {
  display: flex; justify-content: center; align-items: center;
  gap: 14px; padding: 12px;
  background: var(--panel); border-top: 3px solid var(--panel-edge);
}
.ctrl {
  font-family: var(--font); font-weight: 800; font-size: 20px; color: #fff;
  border: none; border-radius: 16px; padding: 12px 26px; cursor: pointer;
  box-shadow: var(--edge);          /* flat sticker edge */
  transition: transform .30s cubic-bezier(0.34, 1.56, 0.64, 1), filter .15s ease, box-shadow .10s ease;
  min-height: 48px;                 /* 48px touch target */
}
.ctrl:hover { transform: translateY(-3px) scale(1.04); filter: brightness(1.06); }
.ctrl:active { transform: translateY(3px) scaleX(1.08) scaleY(0.90); box-shadow: 0 1px 0 rgba(59,46,74,0.16); transition-duration: .08s; }
.ctrl:disabled { filter: grayscale(.5) brightness(1.03); opacity: .5; cursor: default; box-shadow: none; }
.ctrl.go     { background: var(--go); }
.ctrl.reset  { background: var(--reset); color: #6b4a00; }
.ctrl.rotate { background: var(--rotate); }
.ctrl.trash  { background: var(--trash); }

/* running-state hint */
body[data-state="run"] .ctrl.go { opacity: .5; animation: none; }

/* GO button gentle idle breathe — invites a tap */
.ctrl.go { animation: go-breathe 2.5s ease-in-out infinite; }

/* Logo hover wiggle */
.logo { transition: transform .20s ease; }
.logo:hover { animation: logo-wiggle .55s cubic-bezier(0.34, 1.56, 0.64, 1); }

/* ---- win overlay + confetti ---- */
#win {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(59,46,74,.38); z-index: 20; pointer-events: none;
}
#win.show { display: flex; animation: fade .35s ease; }

#win .card {
  background: var(--panel);
  border-radius: 32px; padding: 36px 52px; text-align: center;
  box-shadow: 0 8px 0 var(--go-dark);
  border: 5px solid var(--go);
  pointer-events: auto;
  animation: spring-in .45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Bigger, floating medal (juice kept — it's motion, not a gradient) */
#win .card .medal,
#win .card > div[style] {
  font-size: 72px;
  display: block;
  margin-bottom: 4px;
  animation: medal-bounce .6s cubic-bezier(0.34, 1.56, 0.64, 1) .2s both;
}

#win .card h2 { margin: 10px 0 6px; font-size: 46px; color: var(--go-dark); }
#win .card p  { margin: 0 0 18px; font-size: 20px; color: var(--ink); }
.win-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.win-next,
.win-retry {
  border: 0; border-radius: 18px; font-family: var(--font); font-weight: 800;
  cursor: pointer; box-shadow: var(--edge);
}
.win-next {
  min-width: 280px; min-height: 78px; padding: 12px 34px;
  background: var(--go); color: #fff; font-size: 36px;
  animation: go-breathe 1.8s ease-in-out infinite;
}
.win-retry { padding: 9px 22px; background: var(--reset); color: #6b4a00; font-size: 17px; }
.win-next:focus-visible,
.win-retry:focus-visible { outline: 5px solid var(--accent); outline-offset: 4px; }

@keyframes fade { from{ opacity:0; } to{ opacity:1; } }
@keyframes spring-in {
  from { transform: translateY(32px) scale(0.80); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
@keyframes medal-bounce {
  from { transform: scale(0.5) rotate(-15deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg); opacity: 1; }
}

#confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 15; }
.confetti-bit { position: absolute; top: -20px; width: 12px; height: 16px; border-radius: 3px; animation: fall 3s linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .9; } }

/* ---- Keyboard focus: visible, chunky, friendly ---- */
.ctrl:focus-visible,
.level-btn:focus-visible,
.part-btn:focus-visible {
  outline: 4px solid var(--accent);
  outline-offset: 3px;
}

/* ============================================================
 * NEW UI PIECES — undo ctrl, hint-bubble, coach-pulse, onboard-tip
 * All flat-vector, one outline, single sticker-shadow. No gradients.
 * ============================================================ */

/* 1) .ctrl.undo — 5th control button variant (soft purple) */
.ctrl.undo { background: #a78bfa; }

/* 2) .hint-bubble — gentle hint popover near the play area */
.hint-bubble {
  position: absolute;
  z-index: 10;
  background: var(--panel);
  color: var(--ink);
  border: 3px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  max-width: 220px;
  left: 16px;
  bottom: 16px;
  box-shadow: var(--edge);
  animation: hint-pop .25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* One short, reading-light goal card. It labels both the stage and the skill. */
.stage-coach {
  position: absolute; z-index: 8; left: 14px; top: 68px;
  display: flex; align-items: center; gap: 10px;
  max-width: min(360px, 45%); padding: 8px 12px 8px 8px;
  background: rgba(255,253,247,.96); color: var(--ink);
  border: 3px solid var(--gold); border-radius: 16px; box-shadow: var(--edge);
  pointer-events: none;
}
.stage-coach-step {
  display: grid; place-items: center; flex: 0 0 38px; height: 38px;
  border-radius: 50%; background: var(--gold); color: #6b4a00;
  font-size: 23px; font-weight: 800;
}
.stage-coach strong,
.stage-coach small { display: block; }
.stage-coach strong { font-size: 16px; line-height: 1.05; }
.stage-coach small { margin-top: 2px; font-size: 12px; line-height: 1.15; font-weight: 700; }
@keyframes hint-pop {
  from { opacity: 0; transform: scale(0.88); }
  to   { opacity: 1; transform: scale(1); }
}

/* 3) .coach-pulse — animated glowing ring on a target element */
.coach-pulse {
  animation: coach-ring 1.1s ease-in-out infinite;
}
@keyframes coach-ring {
  0%   { box-shadow: var(--edge), 0 0 0 0   rgba(255,138,91, 0.70); }
  55%  { box-shadow: var(--edge), 0 0 0 8px rgba(255,138,91, 0.20); }
  100% { box-shadow: var(--edge), 0 0 0 0   rgba(255,138,91, 0.00); }
}

/* 4) .onboard-tip — first-run coach tip (like hint-bubble, a touch more prominent) */
.onboard-tip {
  position: absolute;
  z-index: 12;
  background: var(--panel);
  color: var(--ink);
  border: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 18px 12px 14px;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  max-width: 240px;
  box-shadow: 0 5px 0 rgba(255,138,91,0.28), var(--edge);
  animation: hint-pop .30s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
/* Pointer arrow — small flat triangle pointing upward by default */
.onboard-tip::before {
  content: '';
  position: absolute;
  top: -13px;
  left: 22px;
  border: 7px solid transparent;
  border-bottom-color: var(--accent);
}
.onboard-tip::after {
  content: '';
  position: absolute;
  top: -9px;
  left: 24px;
  border: 5px solid transparent;
  border-bottom-color: var(--panel);
}

/* ============================================================
 * FUN ANIMATION KEYFRAMES
 * ============================================================ */

/* Spring-open for .level-menu and .layout-menu */
@keyframes menu-spring-in {
  from { opacity: 0; transform: scale(0.85) translateY(-6px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);    }
}

/* GO button: soft breathing glow pulse */
@keyframes go-breathe {
  0%   { transform: scale(1);    box-shadow: var(--edge), 0 0 0   0px  rgba(94,194,106, 0.00); }
  45%  { transform: scale(1.03); box-shadow: var(--edge), 0 0 10px 4px rgba(94,194,106, 0.40); }
  100% { transform: scale(1);    box-shadow: var(--edge), 0 0 0   0px  rgba(94,194,106, 0.00); }
}

/* Logo hover wiggle */
@keyframes logo-wiggle {
  0%   { transform: rotate(0deg)   scale(1); }
  20%  { transform: rotate(-5deg)  scale(1.05); }
  45%  { transform: rotate(4deg)   scale(1.05); }
  65%  { transform: rotate(-2deg)  scale(1.02); }
  80%  { transform: rotate(1deg)   scale(1.01); }
  100% { transform: rotate(0deg)   scale(1); }
}

/* ============================================================
 * REDUCED MOTION — extend to cover new animations
 * ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  #win .card,
  #win .card > div[style],
  #win .card .medal {
    animation-duration: .001ms !important;
    animation-delay: 0ms !important;
    transition-duration: .001ms !important;
  }
  /* coach-pulse must be a full no-op — remove the ring entirely */
  .coach-pulse {
    animation: none !important;
    box-shadow: var(--edge) !important;
  }
  /* Disable all new fun animations */
  .ctrl.go                    { animation: none !important; }
  .logo:hover                 { animation: none !important; }
  .level-menu,
  .layout-menu                { animation: none !important; }
  /* Revert springy transitions back to instant for buttons */
  .part-btn,
  .ctrl,
  .level-btn,
  .level-chip,
  .level-chip-caret           { transition-duration: .001ms !important; }
  /* Squash-on-active transforms must be identity too */
  .part-btn:active,
  .ctrl:active,
  .level-btn:active,
  .level-chip:active          { transform: none !important; }
  /* GO breathing glow — remove box-shadow extension */
  .ctrl.go                    { box-shadow: var(--edge) !important; }
}

/* ============================================================
 * RESPONSIVE — TABLET LANDSCAPE  (~820px – 1199px wide)
 * ============================================================ */
@media (max-width: 1199px) and (min-width: 601px) {
  .topbar { padding: 8px 12px; gap: 10px; }
  .logo { font-size: 20px; }
  .level-btn { min-width: 70px; padding: 5px 8px; }  /* kept for back-compat, unused in header */
  .level-icon { font-size: 22px; }
  .level-name { font-size: 11px; }
  .level-chip { font-size: 15px; min-height: 40px; padding: 5px 12px 5px 9px; }
  .level-chip-icon { font-size: 20px; }
  .middle { grid-template-columns: 110px 1fr; gap: 8px; padding: 8px; }
  .part-btn { padding: 6px 3px; min-height: 52px; }
  .part-icon { font-size: 26px; }
  .part-name { font-size: 11px; }
  .stage-wrap { align-items: center; }
  .ctrl { font-size: 18px; padding: 12px 20px; min-height: 52px; }
  .bottombar { gap: 10px; padding: 10px 12px; }
}

/* ============================================================
 * RESPONSIVE — SMALL TABLET / LANDSCAPE PHONE  (≤ 820px wide)
 * ============================================================ */
@media (max-width: 820px) {
  body { overflow: auto; }
  .topbar { padding: 6px 10px; gap: 8px; flex-wrap: nowrap; }
  .logo { font-size: 18px; }
  #levels { gap: 6px; }
  .level-btn { min-width: 60px; padding: 4px 7px; border-radius: 10px; }  /* back-compat, unused in header */
  .level-icon { font-size: 20px; }
  .level-name { font-size: 10px; }
  .level-chip { font-size: 14px; min-height: 40px; padding: 5px 10px 5px 8px; gap: 5px; }
  .level-chip-icon { font-size: 18px; }
  .level-menu { min-width: 180px; max-height: 280px; }
  .middle { grid-template-columns: 88px 1fr; gap: 6px; padding: 6px; }
  #palette { gap: 5px; padding: 4px; }
  .part-btn { padding: 5px 2px; border-radius: 10px; min-height: 50px; }
  .part-icon { font-size: 24px; }
  .part-name { font-size: 10px; }
  .ctrl { font-size: 16px; padding: 10px 16px; min-height: 48px; border-radius: 14px; }
  .bottombar { gap: 8px; padding: 8px 10px; }
  .stage-coach { top: 58px; max-width: 52%; }
}

/* ============================================================
 * RESPONSIVE — PORTRAIT ORIENTATION on tablets / phones
 * ============================================================ */
@media (orientation: portrait) {
  body { overflow: auto; }
  .app { grid-template-rows: auto 1fr auto; height: auto; min-height: 100vh; }
  .middle {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    gap: 8px;
    padding: 8px;
  }
  #palette {
    flex-direction: row;
    overflow-y: visible;
    overflow-x: auto;
    padding: 6px 8px;
    gap: 8px;
    border-radius: 14px;
  }
  .part-btn { flex-shrink: 0; min-width: 60px; min-height: 64px; }
  .stage-wrap { width: 100%; }
  #stage { width: 100%; max-height: none; }
  .bottombar { flex-wrap: wrap; gap: 10px; }
  .ctrl { flex: 1 1 calc(50% - 20px); min-height: 52px; font-size: 17px; }
}

/* ============================================================
 * LEVEL CHIP + LEVEL MENU POPOVER
 * Replaces the old row of .level-btn cards with ONE pill button
 * (.level-chip) that opens a .level-menu dropdown popover.
 * Flat-vector, no gradients, one outline, single sticker-shadow.
 * ============================================================ */

/* -- pill trigger button -- */
.level-chip {
  /* layout */
  display: inline-flex;
  align-items: center;
  gap: 6px;
  /* sizing */
  min-height: 42px;
  padding: 6px 14px 6px 10px;
  /* visuals */
  background: var(--panel);
  border: 3px solid var(--panel-edge);
  border-radius: 999px;           /* full pill */
  box-shadow: var(--edge);
  /* typography */
  font-family: var(--font);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  cursor: pointer;
  /* motion */
  transition: transform .30s cubic-bezier(0.34, 1.56, 0.64, 1), border-color .15s ease, box-shadow .10s ease;
}
.level-chip:hover  { transform: translateY(-3px) scale(1.04); border-color: var(--accent); }
.level-chip:active { transform: translateY(2px) scaleX(1.07) scaleY(0.90); box-shadow: 0 1px 0 rgba(59,46,74,0.16); transition-duration: .08s; }
.level-chip:focus-visible { outline: 4px solid var(--accent); outline-offset: 3px; }

/* icon inside the chip (emoji / img) */
.level-chip-icon { font-size: 22px; line-height: 1; }
img.level-chip-icon { width: 28px; height: 28px; object-fit: contain; display: block; }

/* text label */
.level-chip-title { flex: 1 1 auto; }

/* ▾ caret — simple Unicode arrow, slightly smaller */
.level-chip-caret {
  font-size: 13px;
  opacity: .65;
  line-height: 1;
  margin-left: 2px;
  display: inline-block;                /* needed for transform */
  transition: transform .30s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.level-chip:hover .level-chip-caret { transform: rotate(20deg) scale(1.2); }

/* -- popover panel -- */
.level-menu {
  position: absolute;
  z-index: 200;
  min-width: 200px;
  max-height: 320px;              /* ~7 items before scroll */
  overflow-y: auto;
  background: var(--panel);
  border: 3px solid var(--panel-edge);
  border-radius: 14px;
  box-shadow: var(--edge), 0 10px 28px rgba(59,46,74,0.22);
  padding: 6px;
  font-family: var(--font);
  user-select: none;
  -webkit-user-select: none;
  animation: menu-spring-in .28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  transform-origin: top left;
}

/* -- items inside the popover -- */
.level-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
  border: none;
  border-radius: 9px;
  padding: 9px 12px;
  cursor: pointer;
}
.level-menu-item:hover  { background: color-mix(in srgb, var(--accent) 16%, white); }
.level-menu-item.active { color: var(--go-dark); }
.level-menu-item.locked { opacity: .55; cursor: not-allowed; }
.level-menu-number {
  display: grid; place-items: center; flex: 0 0 28px; height: 28px;
  border-radius: 50%; background: var(--gold); color: #6b4a00; font-size: 15px;
}
.level-menu-copy { display: flex; flex-direction: column; min-width: 0; }
.level-menu-name { line-height: 1.1; }
.level-menu-skill { font-size: 11px; line-height: 1.15; font-weight: 600; opacity: .72; }
.level-menu-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }

/* icon inside each menu item */
.level-menu-item-icon { font-size: 20px; line-height: 1; flex-shrink: 0; }
img.level-menu-item-icon { width: 24px; height: 24px; object-fit: contain; display: block; flex-shrink: 0; }

/* ============================================================
 * DEBUG LAYOUT TOGGLE BUTTON
 * A dev affordance — tasteful toybox look, fixed bottom-right.
 * ============================================================ */
.layout-menu {
  position: fixed;
  z-index: 900;
  min-width: 150px;
  background: var(--panel);
  border: 3px solid var(--panel-edge);
  border-radius: 14px;
  box-shadow: var(--edge), 0 10px 28px rgba(59,46,74,0.22);
  padding: 6px;
  font-family: var(--font);
  user-select: none;
  -webkit-user-select: none;
  animation: menu-spring-in .28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  transform-origin: top right;
}
.layout-menu-title {
  font-size: 11px; font-weight: 800; color: var(--panel-edge);
  text-transform: uppercase; letter-spacing: .6px;
  padding: 4px 10px 6px;
}
.layout-menu-item {
  display: block; width: 100%; text-align: left;
  font-family: var(--font); font-size: 15px; font-weight: 700; color: var(--ink);
  background: transparent; border: none; border-radius: 9px;
  padding: 8px 10px; cursor: pointer;
}
.layout-menu-item:hover  { background: color-mix(in srgb, var(--accent) 16%, white); }
.layout-menu-item.active { color: var(--go-dark); }
.layout-menu-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }

/* ============================================================
 * BASE RULES FOR LAYOUTS 2 & 3  (≥ 1200px only)
 * Collapses .middle so its children participate directly in
 * .app's grid. The actual grid-template-areas are defined in
 * css/layout-2.css and css/layout-3.css respectively.
 * Layout 1 (default) is NOT touched here.
 * ============================================================ */
@media (min-width: 1200px) {
  body[data-layout="2"] .middle,
  body[data-layout="3"] .middle  { display: contents; }

  body[data-layout="2"] .topbar,
  body[data-layout="3"] .topbar  { grid-area: top; }

  body[data-layout="2"] #palette,
  body[data-layout="3"] #palette { grid-area: pal; }

  body[data-layout="2"] .stage-wrap,
  body[data-layout="3"] .stage-wrap { grid-area: stage; }

  body[data-layout="2"] #controls,
  body[data-layout="3"] #controls { grid-area: ctrl; }
}

/* Very narrow portrait (phones < 500px wide): gentle rotation hint. */
@media (orientation: portrait) and (max-width: 499px) {
  body::before {
    content: 'Turn your device sideways 🐾';
    display: block;
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: #fff;
    font-family: var(--font);
    font-size: 15px;
    font-weight: 700;
    padding: 8px 18px;
    border-radius: 999px;
    z-index: 50;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: var(--edge);
  }
}
