/* SamSam World! components: buttons, pills, cards, chips, avatar, toggle, segmented control, progress bar, sheet, toast, hold ring */

/* ---------- focus: always visible for keyboards, never for fingers ---------- */
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus) !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--muted); font-size: var(--fs-small); font-weight: var(--fw-bold); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

/* ---------- the shell's type: clean system font, lighter weights (games keep the rounded font) ---------- */
#screens, #splash, #bar, .sheet, #book, #toast { font-family: var(--font-ui); --fw-head: 700; --fw-bold: 500; font-weight: 500; }

/* ---------- buttons ---------- */
.btn-primary, .btn-soft, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px;
  border-radius: var(--r-pill); padding: 12px 26px; font-weight: 650; font-size: 17px; line-height: 1.1; letter-spacing: -.01em;
  transition: transform .12s, box-shadow .12s; position: relative; white-space: nowrap;
}
.btn-primary { background: var(--ink); color: #fff; box-shadow: var(--sh-card); }
.btn-soft { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 1px var(--hair), var(--sh-xs); }
.btn-danger { background: #fff; color: var(--danger); box-shadow: inset 0 0 0 1.5px #F3C4C4; }
.btn-primary:active, .btn-soft:active, .btn-danger:active { transform: scale(.97); }
.btn-primary.small, .btn-soft.small, .btn-danger.small { min-height: 44px; font-size: 15px; padding: 8px 16px; }
.icon-btn {
  width: 56px; height: 56px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 1px var(--hair), var(--sh-xs); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; flex: none; position: relative; transition: transform .12s;
}
.icon-btn:active { transform: scale(.94); }
.ic-sticker { color: var(--sticker); display: inline-flex; }

/* ---------- pills, chips, cards ---------- */
.pill { display: inline-flex; align-items: center; gap: 8px; background: #fff; border-radius: var(--r-pill); box-shadow: inset 0 0 0 1px var(--hair), var(--sh-xs); padding: 10px 18px; font-weight: 650; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--tint); color: var(--land-text); border-radius: var(--r-pill); padding: 6px 14px; font-weight: var(--fw-head); font-size: var(--fs-small); }
.chip.plain { background: #fff; color: var(--muted); box-shadow: 0 0 0 1.5px var(--line); }
.panel { background: #fff; border-radius: var(--r-md); border: 1px solid var(--line); padding: 8px 22px; }

/* ---------- avatar: an animal in a coloured circle ---------- */
.avatar { width: var(--size); height: var(--size); border-radius: 50%; background: var(--av-bg); flex: none;
  display: inline-flex; align-items: center; justify-content: center; }

/* ---------- segmented control and toggle (grown-up settings) ---------- */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--ground); border-radius: var(--r-pill); padding: 4px; box-shadow: inset 0 0 0 1.5px var(--line); }
.seg button { min-height: 44px; min-width: 52px; padding: 8px 16px; border-radius: var(--r-pill); font-weight: var(--fw-head); font-size: 17px; color: var(--muted); transition: background .15s, color .15s; }
.seg button.on { background: var(--ink); color: #fff; }
.toggle { width: 70px; height: 44px; border-radius: var(--r-pill); background: #CDD2E4; position: relative; transition: background .2s; flex: none; margin: 2px; }
.toggle::after { content: ''; position: absolute; top: 4px; left: 4px; width: 36px; height: 36px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(30,35,72,.25); transition: transform .2s; }
.toggle.on { background: var(--music); }
.toggle.on::after { transform: translateX(26px); }

/* ---------- progress bar (its colours follow the land vars) ---------- */
.progress { height: 12px; border-radius: var(--r-pill); background: var(--tint); overflow: hidden; }
.progress > div { height: 100%; border-radius: var(--r-pill); background: var(--accent); transition: width .5s; }

/* ---------- a sheet: a card over a dimmed screen (forms, recorder) ---------- */
/* --vvt / --vvh: the part of the window that is really in view while a keyboard is up (js/ui/screens.js sets them): on iPhone and iPad
   the keyboard covers the bottom of the page without making the page smaller. The shadow dims what lies outside that part. */
.sheet { position: fixed; left: 0; right: 0; top: var(--vvt, 0px); height: var(--vvh, 100%); z-index: 400; background: rgba(30, 35, 72, .42); box-shadow: 0 0 0 100vmax rgba(30, 35, 72, .42);
  display: flex; align-items: center; justify-content: center;
  padding: max(12px, var(--safe-t)) max(12px, var(--safe-r)) max(12px, var(--safe-b)) max(12px, var(--safe-l)); animation: fadeIn .2s; }
.sheet.out { animation: fadeOut .2s forwards; }
.sheet-card { background: #fff; border-radius: var(--r-lg); padding: 20px 24px 22px; width: min(600px, 100%); max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y;
  box-shadow: var(--sh-pop); animation: sheetIn .3s cubic-bezier(.2,.9,.3,1.15); }
@keyframes sheetIn { from { transform: translateY(30px) scale(.97); opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 28px; font-weight: var(--fw-head); }
.sheet-x { width: 48px; height: 48px; box-shadow: 0 0 0 1.5px var(--line); }
.form-label { display: block; margin: 16px 0 8px; font-weight: var(--fw-head); font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.field { width: 100%; min-height: 54px; border: 2px solid var(--line); border-radius: var(--r-sm); padding: 10px 16px; font: inherit; font-size: 22px; font-weight: var(--fw-head); color: var(--ink); background: var(--ground); user-select: text; -webkit-user-select: text; }
.field:focus-visible, .field:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-err { min-height: 1.3em; margin: 12px 0 0; color: var(--danger); font-weight: var(--fw-bold); font-size: var(--fs-small); }
.form-btns { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.avatar-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; }
.avatar-pick button { display: flex; align-items: center; justify-content: center; padding: 6px; border-radius: var(--r-md); min-height: 80px; box-shadow: 0 0 0 2px transparent; transition: box-shadow .15s, transform .15s; }
.avatar-pick button.on { box-shadow: 0 0 0 4px var(--primary); transform: scale(1.04); }
.child-form .avatar-pick { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
.child-form .avatar-pick button { min-height: 64px; padding: 4px; }
.child-form .avatar-pick .avatar { --size: 50px !important; }
@media (max-width: 560px) { .child-form .avatar-pick { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ---------- toast: a note for grown-ups (shown, never spoken) ---------- */
#toast { position: fixed; top: max(84px, calc(var(--safe-t) + 76px)); left: 50%; transform: translate(-50%, -20px); opacity: 0; transition: .25s; z-index: 600; pointer-events: none;
  background: var(--ink); color: #fff; font-size: 17px; font-weight: var(--fw-head); padding: 12px 20px; border-radius: var(--r-pill); max-width: calc(100vw - 32px); text-align: center; box-shadow: var(--sh-pop); }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- the hold ring (grown-up buttons fill a ring while held); sized by its host ---------- */
.ring { position: absolute; inset: -6px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(var(--primary) calc(var(--p, 0) * 360deg), transparent 0);
  -webkit-mask: radial-gradient(closest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
  mask: radial-gradient(closest-side, transparent calc(100% - 6px), #000 calc(100% - 5px)); }
.btn-soft .ring, .btn-danger .ring { border-radius: var(--r-pill); -webkit-mask: none; mask: none; inset: auto 12px -10px 12px; height: 5px; background: linear-gradient(90deg, var(--primary) calc(var(--p, 0) * 100%), transparent 0); }
.btn-danger .ring { background: linear-gradient(90deg, var(--danger) calc(var(--p, 0) * 100%), transparent 0); }
/* a phone: the window uses the width it has */
@media (max-width: 480px) { .sheet-card { padding: 16px 16px 18px; border-radius: 24px; } .sheet-head h2 { font-size: 24px; } }
.new-dot { position: absolute; top: -3px; right: -3px; width: 18px; height: 18px; border-radius: 50%; background: #E5383B; border: 3px solid #fff; animation: pulse 1s infinite; }
