/* ============================================================
   SANTA OLIVER — Snowman Workshop
   A bright sticker-book panel sitting inside the dark North
   Pole page. Sized for thumbs first: every tappable thing
   clears 44px, and nothing needs a precise drag.
   ============================================================ */

.sm-app {
  --sm-ink: #1b2b3d;
  --sm-ink-soft: #5c7089;
  --sm-line: #d3e0ee;
  --sm-panel: #ffffff;
  --sm-frost: #eef6ff;
  margin-top: 18px;
  display: grid;
  gap: 14px;
}
/* Grid items default to min-width:auto, so they refuse to shrink below their
   content's minimum. The category chips are a nowrap flex row ~750px wide, so
   without this the whole tray inflated to that width on a phone and half the
   stickers sat off-screen instead of the chips simply scrolling. */
.sm-app > * { min-width: 0; }

/* Inside the fullscreen activity window the title bar already reads "Snowman
   Workshop", so the card's own icon, heading and blurb say it a second time.
   On a phone that duplication pushed the sticker tray entirely below the fold,
   leaving a child looking at a snowman with no visible way to dress it. */
#snowman.in-window > .toy-ico,
#snowman.in-window > h3,
#snowman.in-window > .toy-sub { display: none; }
#snowman.in-window .sm-app { margin-top: 0; }
@media (max-width: 899px) {
  #snowman.in-window { padding: 12px; }
}

/* ---------------- stage ---------------- */
.sm-stage {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  background: var(--sm-frost);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
}
/* The stage hugs the artwork rather than letterboxing it. Any surround would
   have to track the scene's sky AND its ground AND whatever tint the weather
   lays over both -- three things that drift apart the moment one changes. With
   no gap there is nothing to keep in sync. On phones the artwork drives the
   width; on wider screens it is sized by height so the tray keeps its room. */
.sm-stage {
  aspect-ratio: 400 / 560;          /* the scene's own proportions */
  width: min(100%, 43vh);           /* 43vh x 1.4 keeps it under ~60vh tall */
  margin-inline: auto;
}
.sm-canvas { display: block; height: 100%; }
.sm-canvas svg { display: block; width: 100%; height: 100%; }

/* Tools float over the stage so the snowman keeps the space. They must sit
   above .sm-canvas, which is itself layered so the ground band can sit under
   it; without this the Finish button hides behind the artwork. */
.sm-tools, .sm-sound, .sm-finish { z-index: 2; }
.sm-tools {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sm-tool {
  width: 58px;
  min-height: 50px;
  padding: 5px 2px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  border-radius: 12px;
  border: 1px solid var(--sm-line);
  background: rgba(255, 255, 255, 0.94);
  color: var(--sm-ink);
  cursor: pointer;
  font: inherit;
  transition: transform .12s ease, background .15s ease;
}
.sm-tool b { font-size: 19px; line-height: 1; font-weight: 400; }
.sm-tool em {
  font-style: normal;
  font-size: 10.5px;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--sm-ink-soft);
}
@media (hover: hover) and (pointer: fine) {
  .sm-tool:hover:not(:disabled) { background: #fff; transform: translateY(-1px); }
}
.sm-tool:active:not(:disabled) { transform: translateY(1px); }
.sm-tool:disabled { opacity: .38; cursor: default; }
.sm-tool:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(200, 162, 74, .55); }

.sm-sound {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 46px;
  height: 46px;
  font-size: 20px;
  border-radius: 50%;
  border: 1px solid var(--sm-line);
  background: rgba(255, 255, 255, 0.94);
  cursor: pointer;
  line-height: 1;
}
.sm-sound:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(200, 162, 74, .55); }

.sm-finish {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 13px 24px;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  /* Darkened: white on the old #35a86a measured 3.02:1, under the 4.5:1
     needed for 15px bold. The bottom of the gradient was always fine. */
  background: linear-gradient(180deg, #1f7d4c, #14663c);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  min-height: 44px;
  box-shadow: 0 6px 16px rgba(12, 70, 42, .45);
}
@media (hover: hover) and (pointer: fine) {
  .sm-finish:hover { filter: brightness(1.06); }
}
.sm-finish:active { transform: translateY(1px); }
.sm-finish:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(200, 162, 74, .6); }

/* ---------------- tray ---------------- */
.sm-tray {
  background: var(--sm-panel);
  border-radius: 18px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

/* All nine categories are always on screen, at every width. They used to be a
   nowrap scrolling row, which hid five of them behind an invisible overlay
   scrollbar -- not just on phones: the tray is a narrow column on desktop too,
   so the row overflowed there as well. A wrapping grid removes the problem
   everywhere rather than papering over it with a scroll cue. */
.sm-cats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--sm-line);
}
.sm-cat {
  min-width: 0;
  min-height: 62px;
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 14px;
  border: 2px solid var(--sm-line);
  background: var(--sm-frost);
  color: var(--sm-ink);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, border-color .15s ease, background .15s ease;
}
.sm-cat-ico { font-size: 21px; line-height: 1; }
@media (hover: hover) and (pointer: fine) {
  .sm-cat:hover { transform: translateY(-2px); }
}
.sm-cat:active { transform: translateY(1px); }
.sm-cat.is-on {
  /* The old cream fill measured 1.01:1 against the unselected frost -- the
     same luminance, so "which one is chosen" was carried by hue alone. */
  background: #ffe2a6;
  border-color: #8a6a1f;
  box-shadow: inset 0 0 0 1px #8a6a1f, 0 3px 0 rgba(138, 106, 31, .35);
}
.sm-cat:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(200, 162, 74, .55); }

.sm-hint {
  margin: 0 2px 9px;
  font-size: 12.5px;
  color: var(--sm-ink-soft);
}

.sm-items { max-height: 40vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(94px, 1fr));
  gap: 9px;
}

/* A sticker shows the real item on the child's own snowman. */
.sm-sticker {
  padding: 6px 4px 7px;
  border-radius: 15px;
  border: 2px solid var(--sm-line);
  background: var(--sm-frost);
  cursor: pointer;
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: transform .12s ease, border-color .15s ease, background .15s ease;
}
.sm-sticker-art {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 11px;
  overflow: hidden;
  background: #fff;
  pointer-events: none;
}
.sm-sticker-art svg { display: block; width: 100%; height: 100%; }
.sm-sticker-name {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--sm-ink);
  line-height: 1.2;
  text-align: center;
  pointer-events: none;
}
@media (hover: hover) and (pointer: fine) {
  .sm-sticker:hover { transform: translateY(-2px); border-color: #9fc4e6; }
}
.sm-sticker:active { transform: scale(0.97); border-color: #9fc4e6; }
.sm-sticker.is-on {
  border-color: #8a6a1f;
  background: #ffe2a6;
  box-shadow: inset 0 0 0 1px #8a6a1f, 0 3px 0 rgba(138, 106, 31, .35);
}
.sm-sticker:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(200, 162, 74, .55); }
/* The little bounce that makes a tap feel like placing a sticker. */
.sm-sticker.is-pop { animation: smPop .26s ease; }
@keyframes smPop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.12) rotate(-2deg); }
  100% { transform: scale(1); }
}

/* ---------------- collection shelf ---------------- */
.sm-shelf {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  padding: 12px 14px 14px;
}
.sm-shelf h4 {
  margin: 0 0 9px;
  font-size: 14px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--gold-200, #e3c878);
}
.sm-shelf-row {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding-bottom: 5px;
  -webkit-overflow-scrolling: touch;
}
.sm-shelf-item {
  flex: 0 0 auto;
  width: 92px;
  padding: 5px;
  border-radius: 13px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.94);
  cursor: pointer;
  font: inherit;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sm-shelf-art {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 9px;
  overflow: hidden;
  pointer-events: none;
}
.sm-shelf-art svg { display: block; width: 100%; height: 100%; }
.sm-shelf-name {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--sm-ink);
  text-align: center;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}
@media (hover: hover) and (pointer: fine) {
  .sm-shelf-item:hover { transform: translateY(-2px); }
}
.sm-shelf-item:active { transform: scale(0.97); }
.sm-shelf-item:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(200, 162, 74, .55); }

/* ---------------- modal ---------------- */
.sm-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(8, 18, 30, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow-y: auto;
}
.sm-modal[hidden] { display: none; }
.sm-modal-card {
  position: relative;
  width: min(560px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #f6fbff, #e9f3fd);
  border-radius: 20px;
  padding: 26px 22px 22px;
  text-align: center;
  color: var(--sm-ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.42);
}
.sm-modal-card h3 {
  margin: 0 0 14px;
  font-family: var(--display, Georgia, serif);
  font-size: 25px;
  color: #17457a;
}
.sm-x {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--sm-line);
  background: #fff;
  cursor: pointer;
  font-size: 15px;
  color: var(--sm-ink-soft);
  line-height: 1;
}
.sm-x:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(200, 162, 74, .55); }

.sm-name-art, .sm-cert-art { width: 190px; margin: 0 auto 14px; }
.sm-name-art svg, .sm-cert-art svg {
  display: block; width: 100%; height: auto;
  border-radius: 13px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .16);
}
.sm-modal-card input[type="text"] {
  width: 100%;
  max-width: 330px;
  padding: 13px 15px;
  font: inherit;
  font-size: 17px;
  text-align: center;
  border-radius: 12px;
  border: 2px solid var(--sm-line);
  background: #fff;
  color: var(--sm-ink);
}
.sm-modal-card input[type="text"]:focus {
  outline: none;
  border-color: var(--gold, #c8a24a);
  box-shadow: 0 0 0 3px rgba(200, 162, 74, .3);
}
.sm-or {
  margin: 12px 0;
  font-size: 13px;
  color: var(--sm-ink-soft);
  text-transform: uppercase;
  letter-spacing: .12em;
}
.sm-btn {
  padding: 12px 20px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #1f7d4c, #14663c);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  min-height: 44px;
}
.sm-btn--ghost {
  background: #fff;
  color: var(--sm-ink);
  border: 2px solid var(--sm-line);
}
@media (hover: hover) and (pointer: fine) {
  .sm-btn:hover { filter: brightness(1.05); }
}
.sm-btn:active { transform: translateY(1px); }
.sm-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(200, 162, 74, .6); }
.sm-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}
.sm-done-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}
.sm-cert-preview {
  background: #fffdf6;
  border: 6px double var(--gold, #c8a24a);
  border-radius: 12px;
  padding: 16px 14px 14px;
}
/* Scoped to .sm-modal-card so it outranks `.sm-modal-card h3` (0,2,0 beats
   0,1,1). The banner is now a real <h3> -- the dialog needs a heading to be
   named -- and without this it would inherit that rule's 25px dark blue,
   which on the red banner is both oversized and close to unreadable. */
.sm-modal-card .sm-cert-banner {
  background: #c0392b;
  color: #fff;
  font-family: var(--display, Georgia, serif);
  font-size: 20px;
  padding: 8px 14px;
  border-radius: 7px;
  display: inline-block;
  margin: 0 0 13px;
}
.sm-cert-line { margin: 0; font-size: 14px; line-height: 1.55; color: #4b5a4f; }

.sm-vh {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------- wider screens ----------------
   Stage and tray sit side by side, and the stage sticks so the snowman
   stays in view while scrolling a long sticker list. */
@media (min-width: 900px) {
  .sm-app {
    grid-template-columns: minmax(320px, 1fr) minmax(340px, 1.05fr);
    grid-template-areas: "stage tray" "shelf shelf";
    align-items: start;
  }
  .sm-stage { grid-area: stage; position: sticky; top: 12px; }
  .sm-tray  { grid-area: tray; }
  .sm-shelf { grid-area: shelf; }
  .sm-stage { width: min(100%, 46vh); }
  .sm-items { max-height: 52vh; }
  .sm-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
}

/* ---------------- phones ---------------- */
/* ---------------- phone: swipeable rows ----------------
   Wrapping all nine categories cost three rows, and the sticker grid added
   several more, so the tray pushed everything into a long vertical scroll.
   On a phone both become single swipeable rows instead.

   The reason the original scrolling row failed its audit was not the scroll,
   it was that nothing showed there was more: a phone's overlay scrollbar is
   invisible at rest. So the edges fade only while there is something to
   scroll to, driven by .can-left / .can-right from snowman-ui.js. That is a
   real cue in the direction of travel, and it disappears at each end.

   Scoped to the whole single-column layout, not just portrait phones. A phone
   in landscape is ~844px wide, which sat above a 700px breakpoint and so fell
   back to the wrapped grid -- in the one orientation where vertical space is
   scarcest. Above 900px the layout is two columns and the tray has its own
   height to work with. */
@media (max-width: 899px) {
  .sm-cats {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 8px;
  }
  .sm-cats::-webkit-scrollbar { display: none; }
  .sm-cat { flex: 0 0 auto; min-width: 78px; scroll-snap-align: center; }

  .sm-items { max-height: none; overflow: visible; }
  .sm-grid {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 8px;
    padding-bottom: 4px;
  }
  .sm-grid::-webkit-scrollbar { display: none; }
  .sm-sticker { flex: 0 0 90px; scroll-snap-align: center; }

  /* Fade whichever edge still has content beyond it. */
  .sm-cats.can-right, .sm-grid.can-right {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 34px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 34px), transparent);
  }
  .sm-cats.can-left, .sm-grid.can-left {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 34px);
    mask-image: linear-gradient(to right, transparent, #000 34px);
  }
  .sm-cats.can-left.can-right, .sm-grid.can-left.can-right {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 34px, #000 calc(100% - 34px), transparent);
    mask-image: linear-gradient(to right, transparent, #000 34px, #000 calc(100% - 34px), transparent);
  }
}

@media (max-width: 560px) {
  /* The tray is two short swipeable rows now rather than several wrapped
     ones, so the stage can have some of its height back. */
  .sm-stage { width: min(100%, 38vh); }

  .sm-cat { min-height: 52px; padding: 6px 8px; font-size: 11px; }
  .sm-cat-ico { font-size: 18px; }
  .sm-cat-name { line-height: 1.15; }

  .sm-tool { width: 50px; min-height: 44px; }
  .sm-tool b { font-size: 17px; }
  .sm-tool em { font-size: 10px; }
  .sm-finish { padding: 11px 18px; font-size: 15px; }
  .sm-sticker { flex-basis: 84px; }
  .sm-done-grid { grid-template-columns: 1fr; }
  .sm-modal-card { padding: 22px 16px 18px; }
  .sm-modal-card h3 { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  .sm-sticker, .sm-cat, .sm-tool, .sm-shelf-item { transition: none; }
  .sm-sticker.is-pop { animation: none; }
}
