/* v5f · apply form as a 2x2 answer-card quiz (apply.js renders it).
   Loads after style.css / v5a / v5b / v5m and only overrides .af-* rules.
   Safari rules: only transform/opacity animate, image panels have fixed px min-heights (no aspect-ratio),
   no vh units, no mask or backdrop-filter on anything that moves. */

/* ---------- card: never changes height between steps ----------
   apply.js stacks an invisible copy of the contact step (.af-ghost) under every step in one grid cell,
   so the card is always as tall as its tallest step at the current width; question steps stretch into it. */
.af-card{--af-mo-min:84px;--af-mo-max:150px;--af-tile-x:66px;--af-gap:10px;width:100%;max-width:470px;justify-self:center;min-height:0;display:flex;flex-direction:column}
.af-stack{flex:1 1 auto;display:grid;margin-top:26px}
.af-stack>*{grid-area:1/1;min-width:0}
.af-stack>.af-step{margin-top:0;display:flex;flex-direction:column}
.af-ghost{visibility:hidden;pointer-events:none}
.af-ghost .af-gap{height:26px}
.af-stack-fin>.af-done{align-self:center;padding:24px 10px}

/* question block: the title always reserves two lines, the help line is always there */
.af-quiz .af-step .af-q{min-height:2.2em;display:flex;align-items:flex-end}
.af-quiz .af-step .af-help{min-height:1.55em}

/* ---------- answer grid: 2x2, grows into the free height up to a cap, rest stays as air above ---------- */
.af-opts.af-grid{flex:1 1 auto;display:grid;grid-template-columns:1fr 1fr;grid-template-rows:1fr 1fr;gap:var(--af-gap);margin-top:auto;padding-top:20px;
  min-height:calc(2 * (var(--af-mo-min) + var(--af-tile-x)) + var(--af-gap) + 20px);max-height:calc(2 * (var(--af-mo-max) + var(--af-tile-x)) + var(--af-gap) + 20px)}
/* full-bleed tile: the picture IS the tile. Layers, bottom to top: image (scales on pick) > white fade (static) > label > hairline/ring > tick */
.af-opt.af-tile{position:relative;display:block;min-height:0;padding:0;border-radius:20px;overflow:hidden;isolation:isolate;background:#EEF5FD;text-align:left;
  box-shadow:0 1px 2px rgba(11,26,46,.05);-webkit-tap-highlight-color:transparent;transform:none;opacity:1;
  transition:box-shadow .25s var(--ease),transform .3s var(--ease),opacity .26s ease}
.af-mo{position:absolute;inset:0;display:block;min-height:0;border-radius:inherit;overflow:hidden;background:none}
/* answer image: square export, subject in the upper part; object-position per image steers the crop */
.af-img{position:absolute;left:0;top:0;width:100%;height:100%;object-fit:cover;object-position:50% 50%;display:block;transform:scale(1);transform-origin:50% 40%;transition:transform .5s var(--ease);-webkit-user-drag:none;user-select:none}
/* soft white fade that grows out of the image's own pale bottom, label sits on it */
.af-opt.af-tile::before{content:"";position:absolute;z-index:1;left:0;right:0;bottom:0;height:52%;pointer-events:none;
  background:linear-gradient(0deg,rgba(255,255,255,.94) 0,rgba(255,255,255,.86) 26%,rgba(255,255,255,.5) 60%,rgba(255,255,255,0) 100%)}
/* hairline, becomes the 2px blue ring when picked */
.af-opt.af-tile::after{content:"";position:absolute;z-index:3;inset:0;border-radius:inherit;pointer-events:none;box-shadow:inset 0 0 0 1px rgba(11,26,46,.09);transition:box-shadow .2s}
.af-lbl{position:absolute;z-index:2;left:14px;right:12px;bottom:12px;display:block;height:auto;margin:0;font-size:15px;font-weight:500;line-height:1.25;letter-spacing:-.012em;color:var(--ink);text-wrap:balance}

/* pick moment: ring + tick, the picked image eases to 1.05, the other three fade back during the 340 ms beat */
.af-tick{position:absolute;z-index:4;top:9px;right:9px;width:22px;height:22px;border-radius:50%;background:var(--blue);box-shadow:0 0 0 3px rgba(255,255,255,.85);opacity:0;transform:scale(.6);transition:opacity .2s,transform .3s var(--ease)}
.af-opt.af-tile.is-on{box-shadow:0 12px 26px -16px rgba(11,141,255,.75);box-shadow:0 12px 26px -16px color-mix(in srgb,var(--blue) 75%,transparent)}
:where(html[data-v="b"]) .af-opt.af-tile.is-on{box-shadow:0 12px 26px -16px rgba(47,107,255,.75);box-shadow:0 12px 26px -16px color-mix(in srgb,var(--blue) 75%,transparent)}
.af-opt.af-tile.is-on::after{box-shadow:inset 0 0 0 2px var(--blue)}
.af-opt.af-tile.is-on .af-tick{opacity:1;transform:none}
.af-opt.af-tile.is-on .af-img{transform:scale(1.05)}
.af-opt.af-tile.is-on .af-tick::after{content:"";position:absolute;left:8px;top:4.6px;width:5px;height:9.4px;border:solid #fff;border-width:0 2px 2px 0;transform:rotate(45deg)}
.af-grid.is-picked .af-opt.af-tile:not(.is-on){opacity:.5}
.af-opt.af-tile:focus-visible{outline:2.5px solid var(--blue);outline-offset:3px;border-radius:20px}

@media (hover:hover){
  .af-opt.af-tile:hover{transform:translateY(-2px);box-shadow:0 14px 28px -18px rgba(16,64,128,.55)}
  .af-opt.af-tile:hover::after{box-shadow:inset 0 0 0 1px rgba(11,141,255,.4);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--blue) 40%,transparent)}
:where(html[data-v="b"]) .af-opt.af-tile:hover::after{box-shadow:inset 0 0 0 1px rgba(47,107,255,.4);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--blue) 40%,transparent)}
  .af-opt.af-tile.is-on:hover{box-shadow:0 14px 28px -16px rgba(11,141,255,.75);box-shadow:0 14px 28px -16px color-mix(in srgb,var(--blue) 75%,transparent)}
:where(html[data-v="b"]) .af-opt.af-tile.is-on:hover{box-shadow:0 14px 28px -16px rgba(47,107,255,.75);box-shadow:0 14px 28px -16px color-mix(in srgb,var(--blue) 75%,transparent)}
  .af-opt.af-tile.is-on:hover::after{box-shadow:inset 0 0 0 2px var(--blue)}
}
@media (hover:none){
  .af-opt.af-tile:hover{transform:none}
  .af-opt.af-tile:active{transform:scale(.98)}
}

/* ---------- motion: cards rise in with a short stagger ---------- */
.af-quiz .af-step.af-in{animation:none}
.af-quiz .af-step .af-q,.af-quiz .af-step .af-help{animation:afin .45s var(--ease) both}
.af-tile{animation:afRise .4s var(--ease) backwards;animation-delay:calc(var(--n,0) * 30ms)}
@keyframes afRise{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:none}}

/* ---------- sizes ---------- */
@media (max-width:640px){
  .af-card{--af-mo-min:76px;--af-mo-max:140px;--af-tile-x:58px;--af-gap:8px;padding:20px 16px 16px;border-radius:24px}
  .af-stack{margin-top:20px}
  .af-ghost .af-gap{height:20px}
  .af-opts.af-grid{padding-top:16px}
  .af-opt.af-tile{border-radius:18px}
  .af-lbl{left:12px;right:10px;bottom:11px;font-size:15px}
  .af-tick{top:8px;right:8px}
}

@media (prefers-reduced-motion:reduce){
  .af-tile,.af-quiz .af-step .af-q,.af-quiz .af-step .af-help{animation:none}
  .af-img{transition:none}
  .af-opt.af-tile.is-on .af-img{transform:none}
  .af-opt.af-tile{transition:none}
  .af-grid.is-picked .af-opt.af-tile:not(.is-on){opacity:1}
  .af-opt.af-tile:hover,.af-opt.af-tile:active{transform:none}
}
.af-stack.af-stack-fin{margin-top:0}

/* text-only answers (default link; ?form=bilder shows the picture cards): rows share the free height */
.af-opts.af-list{flex:0 0 auto;grid-auto-rows:minmax(56px,70px);gap:10px;margin-top:20px}
.af-opts.af-list .af-opt{height:100%;font-size:16.5px}
/* v6.3 · text answers sit right under the question, an empty help line takes no room */
.af-quiz .af-step .af-help[aria-hidden="true"]{display:none}
/* v6.4 · question and answers sit together in the middle of the card */
.af-quiz .af-step:has(.af-list){justify-content:center;padding-bottom:10px}
