/* ============================================================
   sk-game-features-v5.css — the feature layer that sits on top
   of game-realism-v4.css.

   Everything here is created by sk-game-features-v5.js, so this
   file owns its selectors outright and never restyles a control,
   HUD or panel a game already ships. Nothing is positioned in
   flow: every element is fixed or absolute and pointer-transparent
   unless it is a button, so no pad, gauge or intertitle can be
   pushed off the fold by it.

   One centred column at the top holds all three transient surfaces, in the
   order they can appear:
     .gr-obj      (v4 objective, top, fades at 6s)
     #skTipStrip  (enters at 7s, into the space the objective just left)
     #skToasts    (2.4rem down, so it clears whichever of those is up)
   The centre is chosen because it is the one part of the frame no playable
   puts anything in — Fever's HUD is a left/right flex, Climb draws its room
   label into the canvas corner, the Nursery keeps its gauges below the
   screen. The bottom belongs to the pads.
     #skKeyLegend · bottom left, fine pointer only, where no pad ever is.
   ============================================================ */

:root {
  --skf-stock: #F2E8D5;
  --skf-sepia: #D4B483;
  --skf-ink: rgba(10, 8, 6, 0.9);
  --skf-edge: rgba(212, 180, 131, 0.5);
  --skf-ok: #8FA366;
  --skf-warn: #D4B483;
  --skf-danger: #D48474;
  --skf-mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---- Toasts -------------------------------------------------
   Fixed rather than absolute: several playables scroll their
   stage on phones, and a toast that scrolls away is a toast the
   player never reads.
   ------------------------------------------------------------ */
#skToasts {
  position: fixed;
  z-index: 90;
  top: calc(2.4rem + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  width: min(24rem, calc(100vw - 1.4rem));
  pointer-events: none;
}

.skf-toast {
  pointer-events: none;
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  max-width: 100%;
  padding: 0.42rem 0.62rem;
  border: 1px solid var(--skf-edge);
  border-left-width: 3px;
  border-radius: 2px;
  background: var(--skf-ink);
  color: var(--skf-stock);
  font-family: var(--skf-mono);
  font-size: 11px;
  line-height: 1.35;
  letter-spacing: 0.06em;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5);
  text-align: left;
  animation: skf-toast-in 0.34s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
.skf-toast.skf-out { animation: skf-toast-out 0.42s ease forwards; }
.skf-toast .skf-tag {
  flex: none;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--skf-sepia);
  opacity: 0.85;
}
.skf-toast.is-ok { border-left-color: var(--skf-ok); }
.skf-toast.is-ok .skf-tag { color: var(--skf-ok); }
.skf-toast.is-warn { border-left-color: var(--skf-warn); }
.skf-toast.is-danger { border-left-color: var(--skf-danger); }
.skf-toast.is-danger .skf-tag { color: var(--skf-danger); }

@keyframes skf-toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes skf-toast-out {
  to { opacity: 0; transform: translateY(-8px); }
}

/* ---- Session strip: elapsed time + rotating tip ------------- */
#skTipStrip {
  position: fixed;
  z-index: 88;
  left: 50%;
  transform: translateX(-50%);
  top: calc(0.55rem + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: min(30rem, calc(100vw - 1.4rem));
  padding: 0.28rem 0.55rem;
  border: 1px solid rgba(212, 180, 131, 0.34);
  border-radius: 2px;
  background: rgba(10, 8, 6, 0.82);
  color: var(--skf-sepia);
  font-family: var(--skf-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}
#skTipStrip.is-on { opacity: 1; }
#skTipStrip .skf-clock {
  flex: none;
  color: var(--skf-stock);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}
#skTipStrip .skf-sep { flex: none; opacity: 0.45; }
#skTipStrip .skf-tip {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: uppercase;
  transition: opacity 0.3s ease;
}
#skTipStrip .skf-tip.skf-fade { opacity: 0; }

/* On a phone the objective strip and the tip strip both want the
   top centre. The objective is gone by 6s and the tip only enters
   at 7s, but a stacked HUD still gets crowded — so shrink. */
@media (max-width: 560px) {
  #skTipStrip { font-size: 9px; padding: 0.22rem 0.45rem; gap: 0.35rem; }
  #skToasts { width: calc(100vw - 1rem); }
  .skf-toast { font-size: 10px; }
}

/* ---- Desktop key legend ------------------------------------
   Only ever mounted on a fine pointer, so it can safely live in
   the bottom-left corner the touch pads use.
   ------------------------------------------------------------ */
#skKeyLegend {
  position: fixed;
  z-index: 86;
  left: calc(0.6rem + env(safe-area-inset-left, 0px));
  bottom: calc(0.6rem + env(safe-area-inset-bottom, 0px));
  padding: 0.45rem 0.55rem 0.4rem;
  border: 1px solid rgba(212, 180, 131, 0.32);
  border-radius: 2px;
  background: rgba(10, 8, 6, 0.8);
  color: var(--skf-sepia);
  font-family: var(--skf-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.42);
  opacity: 0.42;
  transition: opacity 0.25s ease;
}
#skKeyLegend:hover { opacity: 1; }
#skKeyLegend h3 {
  margin: 0 0 0.3rem;
  font-family: var(--skf-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(212, 180, 131, 0.75);
}
#skKeyLegend dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.16rem 0.5rem;
  margin: 0;
}
#skKeyLegend dt { margin: 0; }
#skKeyLegend dd { margin: 0; color: var(--skf-stock); opacity: 0.86; }
#skKeyLegend kbd {
  display: inline-block;
  min-width: 1.1em;
  padding: 0.05em 0.28em;
  border: 1px solid rgba(212, 180, 131, 0.4);
  border-bottom-width: 2px;
  border-radius: 2px;
  background: rgba(30, 24, 18, 0.9);
  color: var(--skf-stock);
  font-family: inherit;
  font-size: 9px;
  line-height: 1.5;
}
#skKeyLegend .skf-dismiss {
  position: absolute;
  top: -0.45rem;
  right: -0.45rem;
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  border: 1px solid rgba(212, 180, 131, 0.4);
  border-radius: 999px;
  background: rgba(18, 14, 10, 0.95);
  color: var(--skf-sepia);
  font-family: inherit;
  font-size: 9px;
  line-height: 1;
  cursor: pointer;
}
#skKeyLegend .skf-dismiss:hover { color: var(--skf-stock); border-color: var(--skf-sepia); }

@media (hover: none), (pointer: coarse), (max-width: 760px) {
  #skKeyLegend { display: none !important; }
}

/* ---- Control sparks ----------------------------------------
   One fixed, pointer-transparent plate for every particle on the
   page. Individual sparks are absolutely placed inside it and
   remove themselves when their animation ends.
   ------------------------------------------------------------ */
#skSparks {
  position: fixed;
  inset: 0;
  z-index: 84;
  pointer-events: none;
  overflow: hidden;
  contain: strict;
}
.skf-spark {
  position: absolute;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 999px;
  background: var(--skf-sepia);
  will-change: transform, opacity;
  animation: skf-spark var(--skf-life, 520ms) cubic-bezier(0.15, 0.7, 0.35, 1) forwards;
}
.skf-spark.is-ok { background: var(--skf-ok); }
.skf-spark.is-stock { background: var(--skf-stock); }
@keyframes skf-spark {
  from { transform: translate3d(0, 0, 0) scale(1); opacity: 0.95; }
  to   { transform: translate3d(var(--skf-dx, 0px), var(--skf-dy, 0px), 0) scale(0.25); opacity: 0; }
}

/* A ring on the tap point so the press reads even with motion
   reduced down to nothing. */
.skf-ring {
  position: absolute;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 1.5px solid rgba(212, 180, 131, 0.75);
  border-radius: 999px;
  animation: skf-ring 420ms ease-out forwards;
}
@keyframes skf-ring {
  from { transform: scale(0.5); opacity: 0.85; }
  to   { transform: scale(2.1); opacity: 0; }
}

/* ---- Reduced motion / paused film --------------------------
   The sparks plate is emptied by the script under reduced motion;
   these rules cover the film-pause toggle, which can flip after a
   spark is already in flight.
   ------------------------------------------------------------ */
html.sk-film-paused #skSparks,
html.sk-reduce-motion #skSparks { display: none; }

@media (prefers-reduced-motion: reduce) {
  #skSparks { display: none; }
  .skf-toast, .skf-toast.skf-out { animation: none; opacity: 1; }
  #skTipStrip, #skTipStrip .skf-tip { transition: none; }
}
