/* Phone edition of the threshold and the Triune Sanctuary. Keep the moon row
   in normal flow so the director can measure the same centers on both sides
   of the cinematic hand-off. */
@media (max-width:760px){
  .welcome{
    min-height:0;
    height:100svh;
  }
  .welcome-art,.cinematic-source{background-image:url('assets/anime-welcome-1200.webp')}
  .welcome-top{
    top:calc(13px + env(safe-area-inset-top,0px));
    left:16px;
    right:16px;
    gap:12px;
  }
  .welcome-top .small-caps{
    max-width:180px;
    font-size:clamp(10px,2.7vw,12px);
    line-height:1.3;
    letter-spacing:.08em;
  }
  .welcome-top .text-button{
    flex:none;
    min-height:44px;
    padding:8px 0 8px 8px;
    font-size:13px;
    white-space:nowrap;
  }
  .welcome .poem{
    max-width:min(86vw,360px);
    padding:5px 10px;
    font-size:clamp(17px,4.6vw,21px);
    line-height:1.29;
    background:linear-gradient(90deg,#090713c7,#09071350 73%,transparent);
    text-shadow:0 2px 8px #000,0 0 18px #000;
  }
  .welcome .poem-one{top:clamp(76px,13svh,116px);left:4%}
  .welcome .poem-two{
    top:55svh;
    right:4%;
    bottom:auto;
    text-align:right;
    background:linear-gradient(270deg,#090713d4,#09071355 75%,transparent);
  }
  .welcome-title{
    top:clamp(172px,32svh,306px);
    left:3%;
    right:3%;
    filter:none;
  }
  .welcome-title span{
    font-size:clamp(32px,9.8vw,50px);
    letter-spacing:.01em;
    white-space:nowrap;
    text-shadow:0 2px 6px #000,0 0 18px #080611;
  }
  .welcome-title::before{font-size:19px;line-height:1.1}
  .welcome-title::after{font-size:14px;margin-top:3px;line-height:1}
  .welcome-bottom{
    bottom:calc(26px + env(safe-area-inset-bottom,0px));
    left:5%;
    right:5%;
  }
  .welcome-bottom .small-caps{font-size:11px;line-height:1.35;letter-spacing:.11em}
  .welcome .enter-button{
    min-height:48px;
    margin-top:6px;
    padding:2px 14px;
    font-size:clamp(29px,8vw,35px);
    line-height:1.3;
  }
  .welcome-hint{font-size:17px;line-height:1.3;margin:4px 0 10px}
  .sound-choice{
    min-height:47px;
    padding:8px 13px;
    font-size:13px;
    line-height:1.25;
    text-align:left;
  }
  .sound-choice small{font-size:11px}
  .welcome-corner{bottom:8px;left:16px}
  .welcome-corner.right{right:16px}
  .moon-touch{left:8%;width:84%;top:24%;height:31%;touch-action:manipulation}

  /* One soft moon pulse remains; the painted backdrop, lettering, grain,
     arc shadows and temple overlays do not repaint every animation frame. */
  body::before{display:none}
  .welcome .welcome-art{animation:none;transform:none}
  .welcome-celestial{filter:none}
  .welcome-lunar-aura{
    box-shadow:none!important;
    transform:translate(-50%,-50%);
    animation:mobileMoonBreath 7s ease-in-out infinite alternate;
    will-change:transform;
  }
  .welcome-arc,.welcome-sigil,.welcome-stardust,.welcome .poem,
  .welcome-title span,.moon-touch-ring{animation:none!important}
  .welcome-arc{box-shadow:none}
  .welcome-sigil{box-shadow:none}
  .welcome-gleam{animation:none;opacity:.48}
  .welcome-gleam.gleam-a{animation:mobileStarBreath 8s ease-in-out infinite alternate}
  #eclipse .cinematic-camera::before{animation:none;transform:none;opacity:.5}
  #eclipse .cinematic-camera::after,
  #eclipse .lunar-stage::before,#eclipse .lunar-stage::after{display:none}
  #eclipse .lunar-stage{filter:none}
  .sanctuary::before{animation:none;opacity:.55}
  .sanctuary::after{display:none}
  .sanctuary .dust,.sanctuary .energy-ribbon,.sanctuary .petal{display:none}

  .site-header{
    height:calc(70px + env(safe-area-inset-top,0px));
    padding:env(safe-area-inset-top,0px) 12px 0;
    gap:4px;
  }
  .site-header .wordmark{font-size:clamp(14px,4.15vw,18px);letter-spacing:0;gap:4px;white-space:nowrap}
  .site-header .brand-symbol{font-size:23px}
  .header-actions{gap:0}
  .header-actions>.icon-button[data-route=settings]{display:none}
  .site-header .theme-toggle,.site-header .mobile-menu,
  .header-actions>.icon-button[data-route=search]{width:44px;min-width:44px;flex-basis:44px;min-height:44px}

  .sanctuary{
    display:block;
    height:auto;
    min-height:0;
    max-height:none;
    padding:calc(88px + env(safe-area-inset-top,0px)) 16px 42px;
  }
  .temple-bg{
    bottom:auto;
    height:min(850px,100svh);
    background-size:auto 100%;
    background-position:center top;
  }
  /* The paired plates share the same arches and moon centers. Fade the daylight
     plate over the real night painting instead of darkening a daytime sky. */
  .temple-bg.night{background-image:none;filter:brightness(.82) saturate(1.03)}
  .temple-bg.day{background-image:none}
  .sanctuary .temple-shade,body.daylight .sanctuary .temple-shade{
    background:linear-gradient(180deg,#080713a8 0%,#080713b7 38%,#090d17 80%);
  }
  .sanctuary .temple-shade::after{
    background:linear-gradient(180deg,#fff6e5aa 0%,#fff6e5d8 38%,#f8f0e5 80%);
  }
  .sanctuary-heading,
  body.daylight .sanctuary-heading{
    position:relative;
    top:auto;
    left:auto;
    right:auto;
    width:100%;
    margin:0 auto;
    padding:20px 14px 18px;
    border:1px solid #dbcb9d6e;
    border-radius:3px;
    background:linear-gradient(155deg,#100c1ce8,#101321dd);
    box-shadow:0 18px 45px #0008,inset 0 0 0 4px #d6b97912;
    filter:none;
    text-shadow:0 2px 12px #000;
  }
  .sanctuary-heading::before{display:none}
  .sanctuary-heading .eyebrow.ornament{
    font-size:clamp(11px,3vw,13px);
    line-height:1.35;
    letter-spacing:.11em;
  }
  .sanctuary-heading .ornament::before,
  .sanctuary-heading .ornament::after{width:clamp(10px,4vw,25px);margin-inline:7px}
  .sanctuary-heading h1{
    margin:12px 0 9px;
    font-size:clamp(37px,10.5vw,52px);
    line-height:1.04;
    letter-spacing:-.035em;
    text-wrap:balance;
  }
  .sanctuary-heading>p{
    max-width:32ch;
    margin:0 auto;
    font-size:clamp(15px,3.9vw,18px);
    line-height:1.45;
    color:#f5eaf1;
    font-weight:600;
  }
  .landing-moons{gap:clamp(11px,3.5vw,18px);margin:18px auto 0;filter:none}
  .landing-moons>span{width:clamp(62px,18.5vw,78px);flex:none}

  /* The three moons stay together above three generous, illustrated doors.
     No card contains a 100px text column on a 320px screen. */
  .portals{
    display:grid;
    grid-template-columns:minmax(0,1fr);
    width:100%;
    max-width:540px;
    margin:20px auto 24px;
    gap:14px;
  }
  .sanctuary .portal,
  body.daylight .sanctuary .portal{
    min-width:0;
    min-height:230px;
    height:auto;
    padding:102px 19px 15px;
    align-items:flex-start;
    justify-content:flex-end;
    text-align:left;
    border-radius:4px!important;
    clip-path:none!important;
    overflow:hidden;
    background-color:#0c0b18;
    background-image:linear-gradient(180deg,#09081608 0%,#09081678 35%,#090816eb 57%,#090816 100%),var(--portal-art,var(--portal-art-fallback));
    background-size:100% 100%,cover;
    background-repeat:no-repeat;
    background-position:center,center 35%;
    box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--accent) 33%,transparent),0 12px 28px #0008;
    touch-action:manipulation;
  }
  .sanctuary .portal.azure{--portal-art-fallback:url('assets/azure-spire-v1-1200.webp')}
  .sanctuary .portal.golden{--portal-art-fallback:url('assets/golden-citadel-v1-1200.webp')}
  .sanctuary .portal.crimson{--portal-art-fallback:url('assets/crimson-bastion-v1-1200.webp')}
  .portal::before{display:none}
  .portal .portal-daywash{border-radius:inherit}
  .portal .portal-symbol{display:none!important}
  .portal .portal-index{
    order:1;
    min-height:0;
    margin:0 0 4px;
    padding:0;
    justify-content:flex-start;
    font-size:12px;
    line-height:1.3;
    letter-spacing:.11em;
    text-shadow:0 1px 5px #000;
  }
  .portal h2{
    order:2;
    min-height:0;
    max-width:100%;
    margin:0;
    font-size:clamp(27px,8vw,36px);
    line-height:1.08;
    color:#fff6ec;
    text-wrap:balance;
    overflow-wrap:normal;
  }
  .portal p{
    order:3;
    margin:6px 0 0;
    max-width:30ch;
    font-size:clamp(16px,4vw,18px);
    line-height:1.3;
    font-weight:600;
    color:#f3e7ee;
  }
  .portal .portal-action{
    order:4;
    min-height:40px;
    margin-top:3px;
    padding:8px 0 0;
    justify-content:flex-start;
    font:700 14px/1.25 Body,Symbols,sans-serif;
    letter-spacing:.02em;
    color:var(--accent);
  }
  .portal-action::before{content:none}
  .portal-action span{font-size:19px}
  .portal:hover{transform:none}
  .portal:active{transform:scale(.995)}

  .sanctuary-foot{
    grid-template-columns:minmax(0,1fr);
    gap:10px;
    padding:18px 12px 0;
    text-align:center;
  }
  .sanctuary-foot blockquote{
    grid-column:auto;
    grid-row:auto;
    margin:0;
    font-size:clamp(20px,5.7vw,25px);
    line-height:1.3;
  }
  .sanctuary-foot>.small-caps{font-size:11px;letter-spacing:.08em;line-height:1.4}
  .sanctuary-foot .archive-scroll{
    justify-self:center;
    min-height:44px;
    padding:7px 10px;
    font-size:12px;
    line-height:1.3;
  }
  body.daylight .sanctuary-heading{
    color:#30212b;
    background:linear-gradient(155deg,#fff9edeb,#f3e9ddef);
    border-color:#a8753d88;
    box-shadow:0 15px 36px #51351f28,inset 0 0 0 4px #b8783e16;
    text-shadow:none;
  }
  body.daylight .sanctuary-heading>p{color:#3a2b39;text-shadow:none}
  body.daylight .sanctuary .portal{
    color:#fff5ec;
    background-color:#0b0b18;
    background-image:linear-gradient(180deg,#080b1618 0%,#080b1688 35%,#080b16ef 55%,#080b16 100%),var(--portal-art,var(--portal-art-fallback))!important;
    box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--accent) 60%,transparent),0 12px 28px #2b203a6b;
  }
  body.daylight .portal h2{color:#fff8ee;text-shadow:0 2px 10px #000,0 0 20px #000}
  body.daylight .portal p{color:#fff1e9;text-shadow:0 2px 8px #000}
  body.daylight .portal-index{text-shadow:0 1px 5px #000}

  /* The post-cinematic invitation clears either player height and stays
     scrollable on short devices. */
  .story-invite{
    left:12px;
    right:12px;
    bottom:calc(20px + env(safe-area-inset-bottom,0px));
    width:auto;
    max-height:calc(100svh - 36px - env(safe-area-inset-bottom,0px));
    overflow:auto;
  }
  body:has(.music-player:not([hidden]).compact) .story-invite{
    bottom:var(--mobile-player-clearance,calc(112px + env(safe-area-inset-bottom,0px)));
    max-height:calc(100svh - var(--mobile-player-clearance,112px) - 16px);
  }
  body:has(.music-player:not([hidden]):not(.compact)) .story-invite{
    bottom:var(--mobile-player-clearance,calc(230px + env(safe-area-inset-bottom,0px)));
    max-height:calc(100svh - var(--mobile-player-clearance,230px) - 16px);
  }
}
@keyframes mobileMoonBreath{
  from{transform:translate(-50%,-50%) scale(.96)}
  to{transform:translate(-50%,-50%) scale(1.025)}
}
@keyframes mobileStarBreath{from{opacity:.22}to{opacity:.6}}
@media (max-width:760px) and (max-height:650px){
  .welcome-corner{display:none}
  .welcome .poem-one{top:clamp(68px,12svh,82px)}
  .welcome-title{top:30svh}
  .welcome .poem-two{top:52svh}
  .welcome-bottom{bottom:calc(18px + env(safe-area-inset-bottom,0px))}
  .welcome .enter-button{min-height:43px;margin-top:2px;font-size:clamp(26px,7vw,31px)}
  .welcome-hint{margin-bottom:5px;font-size:15px}
  .sound-choice{min-height:42px;padding-block:5px}
}
@media (max-width:360px){
  .site-header .wordmark{font-size:14px}
  .site-header .brand-symbol{font-size:19px}
  .site-header .theme-toggle,.site-header .mobile-menu,
  .header-actions>.icon-button[data-route=search]{width:42px;min-width:42px;flex-basis:42px}
  .sanctuary{padding-inline:12px}
  .sanctuary-heading{padding-inline:11px}
  .sanctuary-heading h1{font-size:clamp(35px,10.2vw,38px)}
  .sanctuary .portal{padding-inline:16px}
  #eclipse .cinematic-names{left:2%;right:2%;gap:3px}
  #eclipse .cinematic-names strong{font-size:clamp(18px,5.8vw,21px);letter-spacing:0;white-space:nowrap}
  #eclipse .cinematic-names span{font-size:10px;line-height:1.25;overflow-wrap:normal}
  #eclipse .cinematic-line{left:6%;right:6%;font-size:clamp(19px,6vw,22px);line-height:1.3}
}
@media (max-width:760px) and (max-height:550px){
  .welcome{min-height:0;overflow:hidden}
  .welcome .poem-two{top:52svh}
  .welcome-title{top:clamp(142px,30svh,168px)}
  .welcome-bottom{bottom:calc(9px + env(safe-area-inset-bottom,0px))}
  .welcome-corner{display:none}
}
@media (max-width:760px) and (max-height:440px){
  .welcome .poem-two{display:none}
}
@media (max-width:760px) and (max-height:380px){
  .welcome-bottom .small-caps,.welcome-hint{display:none}
  .welcome .enter-button{margin-bottom:7px}
}
@media (max-width:760px) and (prefers-reduced-motion:reduce){
  .welcome-lunar-aura,.welcome-gleam.gleam-a{animation:none;will-change:auto}
  .portal:active{transform:none}
}
body.reduced-motion .welcome-lunar-aura,
body.quality-lite .welcome-lunar-aura{animation:none;will-change:auto}

/* The two poems frame the lunar title on shorter desktop windows. The older
   percentage placement put the second poem across the wordmark, while the
   invitation kicker rose into the final line of the title. */
@media (min-width:761px) and (max-height:820px){
  .welcome .poem-one{
    top:clamp(75px,12svh,112px);
    max-width:min(29vw,360px);
  }
  .welcome .poem-two{
    top:clamp(75px,12svh,112px);
    bottom:auto;
    max-width:min(30vw,380px);
    font-size:clamp(20px,1.8vw,23px);
    line-height:1.3;
  }
  .welcome-title{
    top:clamp(125px,25svh,205px);
  }
  .welcome-title span{
    font-size:clamp(48px,6.5vw,92px);
  }
  .welcome-bottom{
    bottom:clamp(20px,3svh,35px);
  }
}
@media (min-width:761px) and (max-height:570px){
  .welcome .poem-two{display:none}
  .welcome-bottom .small-caps{display:none}
  .welcome-title:after{display:none}
}
/* A landscape phone or an unusually short browser cannot hold four absolute
   text bands. Let the threshold itself scroll, keeping the moon and entry
   controls usable without placing type on top of type. */
@media (max-height:430px){
  .welcome{
    box-sizing:border-box;
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:6px;
    height:100svh;
    min-height:0;
    padding:calc(8px + env(safe-area-inset-top,0px)) 14px calc(20px + env(safe-area-inset-bottom,0px));
    overflow-y:auto;
    overscroll-behavior:contain;
  }
  .welcome-top{
    position:relative;
    inset:auto;
    order:1;
    width:100%;
    flex:none;
  }
  .welcome .poem-one{
    position:relative;
    inset:auto;
    order:2;
    align-self:flex-start;
    max-width:min(90vw,500px);
    margin:4px 0 0;
    font-size:clamp(16px,3vw,20px);
    line-height:1.25;
    padding:5px 10px;
  }
  .welcome .poem-two,.welcome .moon-touch,.welcome-corner{display:none}
  .welcome-title{
    position:relative;
    inset:auto;
    order:3;
    width:100%;
    margin:2px 0;
    flex:none;
  }
  .welcome-title::before,.welcome-title::after{display:none}
  .welcome-title span{font-size:clamp(30px,6.8vw,60px);line-height:1.05}
  .welcome-bottom{
    position:relative;
    inset:auto;
    order:4;
    width:100%;
    max-width:620px;
    margin:0 auto;
    flex:none;
  }
  .welcome-bottom .small-caps,.welcome-hint{display:block}
  .welcome-bottom .small-caps{font-size:10px;line-height:1.25}
  .welcome .enter-button{min-height:40px;margin:2px 0;padding:0 12px;font-size:clamp(24px,4.5vw,30px);line-height:1.25}
  .welcome-hint{margin:2px 0 6px;font-size:14px;line-height:1.25}
  .sound-choice{min-height:40px;padding:5px 10px}
}
