/* A phone in landscape or a shallow in-app browser gets a compact threshold
   and a one-row score. Portrait phones keep the full editorial composition. */
@media (max-width:420px){
  #reader .reader-toolbar .wordmark{
    box-sizing:border-box;
    flex:0 0 44px;
    width:44px;
    min-width:44px;
    min-height:44px;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:0;
  }
}
@media (max-width:760px){
  #reader .reader-toolbar .wordmark{min-height:44px}
}

@media (max-width:760px) and (max-height:430px){
  body,
  body:has(.music-player.compact){
    --mobile-player-clearance:calc(78px + env(safe-area-inset-bottom,0px));
  }
  .music-player,
  #reader>.music-player,
  .music-player.compact,
  #reader>.music-player.compact,
  .music-player:not(.compact),
  #reader>.music-player:not(.compact){
    display:flex;
    flex-direction:row;
    align-items:center;
    box-sizing:border-box;
    width:calc(100% - 16px);
    max-width:min(500px,calc(100% - 16px));
    height:56px;
    min-height:56px;
    left:50%;
    bottom:calc(8px + env(safe-area-inset-bottom,0px));
    transform:translateX(-50%);
    padding:5px 7px;
    gap:4px;
    overflow:hidden;
  }
  .music-player .track-meta,
  .music-player.compact .track-meta,
  .music-player:not(.compact) .track-meta{
    display:flex;
    flex:1 1 auto;
    grid-column:auto;
    grid-row:auto;
    min-width:0;
    width:auto;
    max-width:none;
    height:44px;
    justify-content:center;
    text-align:left;
  }
  .music-player .track-meta .small-caps{display:none}
  .music-player .track-meta strong,
  .music-player.compact .track-meta strong,
  .music-player:not(.compact) .track-meta strong{
    font-size:clamp(15px,4.4vw,17px);
    line-height:1.2;
  }
  .music-player .queue-button,
  .music-player:not(.compact) .queue-button,
  .music-player.compact .queue-button,
  .music-player .play-button,
  .music-player #compact-player{
    position:relative;
    inset:auto;
    display:grid!important;
    grid-column:auto;
    grid-row:auto;
    place-items:center;
    flex:0 0 44px;
    width:44px;
    min-width:44px;
    height:44px;
    min-height:44px;
    padding:0;
    margin:0;
  }
  .music-player .previous-track,
  .music-player .next-track,
  .music-player #repeat-toggle,
  .music-player #mute-toggle,
  .music-player .seek,
  .music-player .time-label,
  .music-player .volume,
  .music-player .music-emblem,
  .music-player .music-spectrum{display:none!important}
  .music-player .track-meta.title-scroll::after{width:12px}
  #reader-content{padding-bottom:var(--mobile-player-clearance)}

  /* The disclosure stays above the dock and can scroll within its own frame.
     A short viewport never makes it taller than the remaining reading space. */
  .score-title-peek,
  #reader .score-title-peek{
    top:auto;
    bottom:calc(68px + env(safe-area-inset-bottom,0px));
    max-height:min(34svh,100px);
    padding:8px 11px;
    overflow-y:auto;
  }
  .score-title-peek-label,
  .score-title-peek-credit,
  .score-title-peek-actions{display:none}
  .score-title-peek-name,
  #reader .score-title-peek-name{
    max-height:none;
    margin:0;
    overflow:visible;
    font-size:15px;
    line-height:1.3;
  }

  /* Put the chapter identity in the first reading fold. The rest of the scene
     and its controls remain below in the same scroll flow. */
  #reader[data-page=faction] .faction-scene{min-height:270px}
  #reader[data-page=faction] .faction-scene-copy{
    padding:17px 18px 76px;
    width:100%;
  }
  #reader[data-page=faction] .faction-seal{display:none}
  #reader[data-page=faction] .faction-scene h1{
    font-size:clamp(31px,8.3vw,42px);
    line-height:1.06;
    margin:5px 0;
  }
  #reader[data-page=faction] .faction-scene-copy>p{
    font-size:16px;
    line-height:1.35;
    margin:6px 0;
  }
  #reader[data-page=faction] .faction-scene-shade{
    background:linear-gradient(90deg,#080b19e8,#080b19a0),linear-gradient(0deg,var(--bg),transparent 90%);
  }
  #reader[data-page=faction] .faction-scene-caption{bottom:56px}
  #reader[data-page=profile] #reader-content{padding-top:10px}
  #reader[data-page=profile] .grand-profile{display:flex;flex-direction:column}
  #reader[data-page=profile] .profile-identity{
    order:-1;
    margin-bottom:10px;
    padding-bottom:10px;
  }
  #reader[data-page=profile] .profile-controls{margin-bottom:12px}
}

/* At 234px there is room for the identity, choice and music opt-in, but not
   for four separate text bands. Keep the full welcome at normal phone height. */
@media (max-width:760px) and (max-height:300px){
  /* Keep the sanctuary identity above the compact music dock in shallow views. */
  .sanctuary{padding-top:76px;padding-bottom:var(--mobile-player-clearance,78px)}
  .sanctuary-heading,body.daylight .sanctuary-heading{padding:8px 9px}
  .sanctuary-heading .eyebrow.ornament{font-size:10px;line-height:1.1}
  .sanctuary-heading h1,body.daylight .sanctuary-heading h1{
    font-size:clamp(24px,7.2vw,30px);line-height:1.04;margin:4px 0 0;
  }
  .sanctuary-heading>p,.sanctuary-heading .landing-moons{display:none}
  .welcome{
    gap:3px;
    padding:calc(6px + env(safe-area-inset-top,0px)) 12px calc(6px + env(safe-area-inset-bottom,0px));
    overflow:hidden;
    justify-content:space-between;
  }
  .welcome .poem-one,.welcome .poem-two,
  .welcome-bottom .small-caps,.welcome .welcome-hint{display:none}
  .welcome-top{min-height:44px}
  .welcome .welcome-title{margin:0}
  .welcome-title .welcome-logo-crop{width:min(65vw,175px)}
  .welcome-bottom{margin:0}
  .welcome .enter-button{
    display:block;
    min-height:44px;
    margin:0 auto 2px;
    font-size:25px;
    line-height:1.2;
  }
  .welcome .sound-choice{min-height:40px;padding:4px 9px}
}
