/* Freefall simulator page. Colors come from the tokens in styles.css. */

.ff-stage{background:var(--panel);border-radius:1.25rem;overflow:hidden;border:1px solid var(--line)}
.ff-scene{background:linear-gradient(180deg,var(--scene-top),var(--scene-low))}
.ff-scene svg{display:block;width:100%;height:auto;aspect-ratio:400/260}
.ff-scene-box{position:relative}
.ff-motion-note{
  position:absolute;left:50%;bottom:.85rem;transform:translateX(-50%);width:min(30rem,calc(100% - 1.5rem));
  display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:.5rem .9rem;text-align:center;
  background:var(--panel);border:1px solid var(--line);border-radius:1rem;padding:.7rem .9rem;box-shadow:0 12px 30px -16px rgba(10,37,64,.5)
}
.ff-motion-note[hidden]{display:none}
/* First-visit tip: just below the scene, so it doesn't hide the jumper it asks you to watch */
.ff-tip{
  position:relative;margin:.5rem;
  display:flex;flex-wrap:wrap;align-items:center;gap:.5rem .75rem;padding:.6rem 2.6rem .6rem .9rem;
  background:var(--panel);border:1px solid var(--line);border-radius:1rem;box-shadow:0 12px 30px -16px rgba(10,37,64,.5)
}
.ff-tip[hidden]{display:none}
.ff-tip p{margin:0;flex:1 1 12rem;font-size:.92rem;color:var(--ink)}
.ff-tip .ff-action{background:var(--accent);border-color:var(--accent);color:var(--on-accent)}
.ff-tip-close{
  position:absolute;top:.35rem;right:.35rem;width:2.25rem;height:2.25rem;padding:0;border:0;border-radius:50%;
  font:inherit;font-size:1rem;color:var(--ink-soft);background:transparent;cursor:pointer
}
.ff-tip-close:hover{color:var(--ink);background:var(--sky-low)}
.ff-tip-close:focus-visible{outline:3px solid var(--focus);outline-offset:1px}
/* Phones: a short explanation over the scene after each change. Wide screens show the
   full caption beside the scene, so it isn't needed there. */
.ff-flash{
  position:absolute;left:.5rem;right:.5rem;bottom:.5rem;margin:0;padding:.45rem .7rem;font-size:.85rem;line-height:1.35;
  color:var(--ink);background:var(--panel);opacity:.95;border-radius:.6rem;pointer-events:none
}
.ff-flash[hidden]{display:none}
@media (min-width:900px){.ff-flash{display:none}}
@media (prefers-reduced-motion:no-preference){.ff-flash:not([hidden]){animation:ff-flash-in .25s ease-out}}
@keyframes ff-flash-in{from{opacity:0;transform:translateY(6px)}to{opacity:.95;transform:none}}
.ff-motion-note p{margin:0;font-size:.92rem;color:var(--ink-soft)}
.ff-motion-note .ff-action{background:var(--accent);border-color:var(--accent);color:var(--on-accent)}
.ff-air circle{fill:var(--ink)}
/* Air the body has just turned aside: the flow that pushes the jumper around.
   Blue, to stand apart from the orange suit and yellow boots on both skies. */
.ff-scene{--flow:#1D5FD6;--scene-top:#9CCBF0;--scene-low:#EAF4FB}
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]) .ff-scene{--flow:#6FD8FF;--scene-top:#08162A;--scene-low:#12294A}}
:root[data-theme="dark"] .ff-scene{--flow:#6FD8FF;--scene-top:#08162A;--scene-low:#12294A}
.ff-air circle.is-deflected{fill:var(--flow);opacity:1}

/* Jumper: fixed colors, so the suit, boots and gloves read the same on light and dark skies */
.ff-jumper{--suit:#FF6A1A;--suit-far:#C24A0B;--boot:#FFD23F;--boot-far:#C9A200;--glove:#F4CFA6;--glove-far:#C9A27C;--gear:#33415A;--visor:#7FC8F2}
/* Line widths are set by figure.js, which also uses them for the air dots. */
.ff-suit,.ff-boot{fill:none;stroke-linecap:round;stroke-linejoin:round}
.ff-suit{stroke:var(--suit)}
.ff-suit.is-far{stroke:var(--suit-far)}
.ff-boot{stroke:var(--boot)}
.ff-boot.is-far{stroke:var(--boot-far)}
.ff-glove{fill:var(--glove)}
.ff-glove.is-far{fill:var(--glove-far)}
.ff-container{fill:var(--gear);stroke:var(--gear);stroke-linejoin:round}
.ff-helmet{fill:var(--gear)}
.ff-visor{fill:var(--visor)}

/* Top-down compass */
.ff-compass-ring{fill:var(--panel);stroke:var(--line);stroke-width:1.5;opacity:.9}
.ff-compass-label{font-family:var(--body);font-size:10px;fill:var(--ink-soft)}

/* Readouts and explanation */
.ff-readout{display:flex;flex-wrap:wrap;gap:.5rem 1.5rem;align-items:center;justify-content:space-between;padding:.85rem 1.1rem;border-top:1px solid var(--line)}
.ff-readout p{margin:0}
.ff-readout-label{display:block;font-size:.8rem;color:var(--ink-soft)}
.ff-caption{padding:.85rem 1.1rem 1rem;background:var(--panel);border:1px solid var(--line);border-radius:1rem;min-height:4.5rem}
.ff-caption p{margin:0}
.ff-caption p + p{margin-top:.45rem}
.ff-combo{font-weight:700;padding:.55rem .75rem;border-radius:.75rem;background:var(--mark);color:var(--ink)}

/* Controls */
.ff-controls{display:grid;grid-template-columns:repeat(auto-fit,minmax(15rem,1fr));gap:.75rem}
/* min-width:0 lets the groups shrink with big system fonts (fieldsets otherwise keep their content width). */
.ff-group{min-width:0;margin:0;padding:.7rem .8rem .8rem;border:1px solid var(--line);border-radius:1rem;background:var(--panel);display:grid;grid-template-columns:1fr 1fr;align-content:start;gap:.5rem}
.ff-group legend{padding:0 .35rem;font-weight:700;font-size:.9rem;color:var(--ink-soft)}
.ff-toggle,.ff-action{
  font:inherit;font-size:.95rem;color:var(--ink);background:transparent;cursor:pointer;
  border:1.5px solid var(--line);border-radius:999px;padding:.4rem .9rem
}
.ff-toggle{line-height:1.25;overflow-wrap:anywhere;hyphens:auto}
.ff-toggle:hover,.ff-action:hover{border-color:var(--ink)}
.ff-toggle:focus-visible,.ff-action:focus-visible{outline:3px solid var(--focus);outline-offset:2px}
.ff-toggle[aria-pressed="true"]{background:var(--ink);border-color:var(--accent);color:var(--panel);font-weight:700;box-shadow:inset 0 0 0 1.5px var(--accent)}
.ff-action{font-weight:700;border-color:var(--ink)}
/* "Simulação" group: below the position groups, full width, its two buttons side by side. */
.ff-sim-group{margin-top:.75rem}
.ff-main + footer{padding-top:0}

/* Layout: scene, buttons and explanation. Stacked by default, in this order. */
.ff-layout{display:grid;grid-template-columns:minmax(0,1fr);gap:.75rem;margin-top:1.25rem}
/* Never wider than the screen, even with a very large system font. */
.ff-layout > *{min-width:0}

/* Wide screens: scene on the left, buttons beside it, so both are always in view. */
@media (min-width:900px){
  .ff-main,.ff-main + footer{max-width:62rem}
  /* A one-line heading leaves room for the scene and buttons on a laptop screen. */
  .ff-main .page-top{--title-size:clamp(2rem,3vw,2.75rem)}
  .ff-main h1{margin-bottom:.5rem}
  .ff-main h1 br{display:none}
  .ff-main h1 br + span::before{content:" "}
  .ff-main > .intro{margin-bottom:0}
  .ff-layout{grid-template-columns:minmax(0,1fr) 19rem;grid-template-areas:"stage panel" "caption panel";align-items:start}
  .ff-stage{grid-area:stage}
  .ff-panel{grid-area:panel}
  .ff-caption{grid-area:caption}
  .ff-controls{grid-template-columns:1fr}
}

/* Narrower screens: playing comes first, reading after. The intro moves below the
   explanation, and the scene stays at the top of the screen while the buttons scroll. */
@media (max-width:899px){
  .ff-main{display:flex;flex-direction:column}
  .ff-layout{order:1}
  .ff-main > .intro{order:2;margin:1.25rem 0 0}
}
@media (max-width:899px) and (orientation:portrait) and (min-height:560px){
  .ff-stage{position:sticky;top:env(safe-area-inset-top,0px);z-index:4;box-shadow:0 10px 24px -18px rgba(10,37,64,.6)}
}

/* Phones: smaller heading, the movement readout over the scene's top-left corner (the compass
   has the top right), and the four groups in a 2 × 2 grid with each group's buttons stacked. */
@media (max-width:640px){
  .ff-main .page-top{--title-size:clamp(1.5rem,7vw,2.4rem)}
  .ff-main h1{margin-bottom:.5rem}
  .ff-layout{margin-top:.5rem;gap:.6rem}
  .ff-stage{position:relative}
  /* Sized against the scene (the compass takes the right quarter), not the text size,
     so a bigger system font doesn't squeeze it. */
  .ff-readout{
    position:absolute;top:.5rem;left:.5rem;max-width:72%;padding:.3rem .6rem;overflow-wrap:anywhere;hyphens:auto;
    border:0;border-radius:.6rem;background:var(--panel);opacity:.92;font-size:.85rem;line-height:1.3
  }
  .ff-readout-label{display:block;font-size:.7rem}
  /* Set by view.js when the readout would cover the jumper (very large system font). */
  .ff-stage.readout-below .ff-readout{position:static;max-width:none;opacity:1;border-radius:0;border-top:1px solid var(--line)}
  .ff-controls{grid-template-columns:repeat(2,minmax(0,1fr));gap:.5rem}
  .ff-group{grid-template-columns:1fr;padding:.35rem .5rem .5rem;gap:.35rem}
  .ff-group legend{font-size:.78rem;padding:0 .25rem}
  .ff-toggle{font-size:.86rem;padding:.4rem .5rem;min-height:2.6rem}
  .ff-action{font-size:.88rem;padding:.4rem .9rem}
  .ff-sim-group{margin-top:.5rem;grid-template-columns:1fr 1fr}
}
