/* The control lives outside #app so screen changes never remove the exit route. */
@layer components {
  .fullscreen-button {
    position:fixed;
    right:calc(16px + env(safe-area-inset-right,0px));
    bottom:calc(16px + env(safe-area-inset-bottom,0px));
    z-index:60;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:9px;
    min-width:48px;
    min-height:48px;
    padding:11px 15px;
    border:1px solid #d9d0e9;
    border-radius:15px;
    background:#fff;
    color:var(--purple-dark);
    box-shadow:0 3px 15px #49356114;
    font-size:.8rem;
    font-weight:600;
    line-height:1.25;
    white-space:nowrap;
    touch-action:manipulation;
    transition:background .16s,border-color .16s;
  }
  .fullscreen-button:hover { background:var(--purple-soft); border-color:#bbaad7; }
  .fullscreen-button:focus-visible { outline:3px solid #8a73d8; outline-offset:4px; }
  .fullscreen-button svg { width:20px; height:20px; flex-shrink:0; }
  .fullscreen-button .fullscreen-exit,
  .fullscreen-button[aria-pressed=true] .fullscreen-enter { display:none; }
  .fullscreen-button[aria-pressed=true] .fullscreen-exit { display:block; }

}

@layer responsive {
  .has-fullscreen-control .main { padding-bottom:80px; }
  .has-fullscreen-control .player-footer {
    min-height:calc(80px + env(safe-area-inset-bottom,0px));
    align-items:center;
    padding-right:calc(190px + env(safe-area-inset-right,0px));
  }
  .has-fullscreen-control .completion-caption { padding-bottom:calc(88px + env(safe-area-inset-bottom,0px)); }
  .has-fullscreen-control .reward-stage { padding-bottom:calc(88px + env(safe-area-inset-bottom,0px)); }
  .has-fullscreen-control .pause-backdrop { padding:16px 0 calc(80px + env(safe-area-inset-bottom,0px)); }
  .has-fullscreen-control .toast { bottom:calc(80px + env(safe-area-inset-bottom,0px)); }
  @media(max-width:650px) {
    .fullscreen-button { padding:12px; }
    .fullscreen-button [data-fullscreen-label] { display:none; }
    .has-fullscreen-control .player-footer { padding-right:calc(84px + env(safe-area-inset-right,0px)); }
  }

  /* Give teaching media the space left by the controls, instead of retaining
     the windowed layout's pixel caps. Contain keeps every picture visible. */
  :root:fullscreen .player {
    height:100vh;
    height:100dvh;
    min-height:0;
    display:grid;
    grid-template-rows:auto auto minmax(0,1fr) auto;
  }
  :root:fullscreen .player-header { padding:10px 24px; }
  :root:fullscreen .player-header .brand-subtitle { display:none; }
  :root:fullscreen .session-progress { margin:0 auto; width:min(650px,70vw); }
  :root:fullscreen .session-progress>div:first-child { margin-bottom:5px; }
  :root:fullscreen .progress-track { height:6px; }
  :root:fullscreen .question { min-height:0; padding:10px 24px 0; }
  :root:fullscreen .question-heading { flex-shrink:0; }
  :root:fullscreen .question h1 { font-size:clamp(1.3rem,3.8vh,2.6rem); }
  :root:fullscreen .question-help { margin:4px 0 10px; flex-shrink:0; }
  :root:fullscreen .answer-grid {
    flex:1;
    min-height:0;
    width:100%;
    max-width:none;
    grid-auto-rows:minmax(0,1fr);
    gap:clamp(10px,1.6vw,24px);
  }
  :root:fullscreen .answer-choice { min-height:0; display:flex; flex-direction:column; }
  :root:fullscreen .answer-choice>.answer-card {
    display:flex;
    flex-direction:column;
    flex:1;
    min-height:0;
    padding:clamp(8px,1vw,16px);
  }
  :root:fullscreen .answer-card :is(img,video,.blank-card-space,.distractor-symbol) {
    flex:1;
    min-height:0;
    height:0;
    width:100%;
    object-fit:contain;
  }
  :root:fullscreen .answer-card>span { flex-shrink:0; margin:6px 0 0; font-size:clamp(.9rem,2.4vh,1.35rem); }
  :root:fullscreen .clip-play { flex-shrink:0; margin:4px auto 0; }
  :root:fullscreen .video-controls { flex-shrink:0; margin-top:6px; }
  :root:fullscreen .feedback { flex-shrink:0; min-height:22px; padding-top:6px; }
  :root:fullscreen .player-footer {
    min-height:64px;
    padding:8px calc(195px + env(safe-area-inset-right,0px)) 8px 24px;
  }
  :root:fullscreen .fullscreen-button { bottom:calc(8px + env(safe-area-inset-bottom,0px)); }
  @media(min-aspect-ratio:3/2) and (min-width:651px) {
    :root:fullscreen .answers-4 { grid-template-columns:repeat(4,minmax(0,1fr)); }
  }
  @media(max-width:650px) {
    :root:fullscreen .player-header { padding:8px 12px; }
    :root:fullscreen .question { padding:8px 12px 0; }
    :root:fullscreen .question-help { font-size:.8rem; margin-bottom:8px; }
    :root:fullscreen .player-footer { padding-left:12px; padding-right:calc(84px + env(safe-area-inset-right,0px)); }
    :root:fullscreen .answers-3 { grid-template-columns:repeat(2,minmax(0,1fr)); }
  }
  @media(max-width:650px) and (orientation:portrait) {
    :root:fullscreen .answers-2 { grid-template-columns:1fr; grid-template-rows:repeat(2,minmax(0,1fr)); }
  }
  @media(max-height:500px) and (min-width:651px) {
    :root:fullscreen .player-header { padding:4px 16px; }
    :root:fullscreen .player-header .brand-flower { font-size:26px; }
    :root:fullscreen .question { padding-top:4px; }
    :root:fullscreen .question-help { font-size:.75rem; margin:0 0 5px; }
    :root:fullscreen .repeat-button { width:32px; height:32px; }
    :root:fullscreen .answers-4 { grid-template-columns:repeat(4,minmax(0,1fr)); }
    :root:fullscreen .player-footer { min-height:54px; }
  }
}
