/* Phones. Loaded after the other layout sheets and before prefs.css (player settings still win).
   Two problems on a phone: a portrait screen crops a 16:9 location down to its middle quarter (a lamp in a black void), and the noir grading
   that reads well on a monitor is murky on a small, dim, glare-prone screen. So: frame scenes and the versus screen for portrait, and lift
   the dark end everywhere on small screens. Silhouettes stay silhouettes; what changes is the light behind them. */

/* ---------- small screens, either orientation: brighter grading, a softer vignette, clearer board ---------- */
@media (max-width:820px), (max-height:500px){
  /* each mood a little brighter and a little less contrasty (contrast is what crushes the darks); the colour of each mood is unchanged */
  #cinema[data-mood="noir"] .bgs{filter:grayscale(.85) contrast(1.08) brightness(1.2)}
  #cinema[data-mood="warm"] .bgs{filter:sepia(.45) saturate(1.25) contrast(1.04) brightness(1.24)}
  #cinema[data-mood="gold"] .bgs{filter:sepia(.75) saturate(1.7) contrast(1.08) brightness(1.3)}
  #cinema[data-mood="blue"] .bgs{filter:grayscale(.7) contrast(1.12) brightness(1.2)}
  #cinema[data-mood="red"] .bgs{filter:grayscale(1) contrast(1.4) brightness(1.12)}
  #cinema[data-mood="sick"] .bgs{filter:grayscale(.8) contrast(1.2) brightness(1.12)}
  #cinema[data-mood="violet"] .bgs{filter:grayscale(.85) contrast(1.12) brightness(1.2)}
  #vig{background:radial-gradient(ellipse at 50% 45%,transparent 45%,rgba(0,0,0,.62) 100%)}
  /* a soft fill light where people stand: lifts the near-blacks in the middle of the frame, leaves the edges dark */
  .bgs::after{content:'';position:absolute;inset:0;pointer-events:none;mix-blend-mode:screen;
    background:radial-gradient(ellipse 75% 42% at 50% 44%,rgba(150,152,168,.17),transparent 72%)}
  #cinema[data-mood="red"] #vig{background:radial-gradient(ellipse at 50% 45%,transparent 38%,rgba(30,0,0,.75) 100%)}
  /* the speaker's panel: a brighter wash of their colour behind the silhouette, so the shape reads */
  .portrait::before{opacity:.82}
  .portrait::after{opacity:.5}
  .portrait svg{filter:drop-shadow(-3px -2px 0 var(--c)) drop-shadow(2px 0 0 var(--c)) drop-shadow(0 0 18px var(--c))}
  .dbox{background:rgba(8,8,11,.93);color:#f6f0e2}
  #narr{color:#fbf6ea;background:linear-gradient(90deg,transparent,rgba(0,0,0,.72) 8%,rgba(0,0,0,.72) 92%,transparent)}
  /* the desk behind the board, and the title/menu street */
  #backdrop.dim svg{filter:grayscale(.7) contrast(1.05) brightness(.6) blur(2px)}
  #backdrop.title svg{filter:grayscale(.5) contrast(1.08) brightness(.9)}
  #backdrop::after{background:radial-gradient(ellipse at 50% 45%,transparent 40%,rgba(0,0,0,.7) 100%)}
  /* empty tiles you can actually see, and the dimmed rows during a reveal still legible */
  .tile{border-color:rgba(232,225,209,.42);background:rgba(14,14,18,.72)}
  #board.interrogate .row:not(.focus){opacity:.3}
  .memo{color:#f0e9d9}
  .caseno,.clock span{color:#bdb7ab}
  .heavy p{text-shadow:0 0 30px rgba(255,60,60,.5),0 2px 0 #000}
  .heavy.blue p{text-shadow:0 0 30px rgba(100,160,255,.55),0 2px 0 #000}
}

/* ---------- portrait screens: frame each location instead of cropping it ---------- */
/* The set is shown whole-height in a 16:9 window across the upper screen (about half its width shows, centred), fading into black at the top
   and bottom, above the dialogue box. `translate` (not transform) centres it, so the slow Ken Burns drift on `transform` still runs. */
@media (max-aspect-ratio:4/5){
  .bg svg{--sh:min(60svh,132vw);inset:auto;top:calc(var(--lb) + 5svh);left:50%;translate:-50% 0;height:var(--sh);width:calc(var(--sh) * 16 / 9);
    -webkit-mask:linear-gradient(180deg,transparent,#000 12%,#000 82%,transparent);mask:linear-gradient(180deg,transparent,#000 12%,#000 82%,transparent)}
  #narr{font-size:clamp(19px,5.2vw,26px)}
  .dbox{font-size:clamp(15px,4.2vw,19px)}

  /* versus: stacked instead of side by side. The detective comes down from the top (blue), the word comes up from the bottom (red),
     split by a shallow diagonal; each bust is sized to its half so the faces are in frame. */
  .vs-l{clip-path:polygon(0 0,100% 0,100% 45%,0 57%);transform:translateY(-100%)}
  .vs-r{clip-path:polygon(0 57%,100% 45%,100% 100%,0 100%);transform:translateY(100%)}
  .vs-half svg{height:min(40svh,96vw);width:auto}
  .vs-l svg{left:-2vw;bottom:43svh}
  .vs-r svg{right:-2vw;left:auto;bottom:0}
  .vs-name{font-size:clamp(28px,9vw,52px);max-width:54vw}
  .vs-tag{font-size:clamp(11px,3vw,15px)}
  .vs-l .vs-name{left:auto;right:5vw;top:calc(var(--lb) + 4svh);text-align:right}
  .vs-r .vs-name{right:auto;left:5vw;bottom:calc(var(--lb) + 6svh);text-align:left}
  .vs-line .land{display:none}
  .vs-line .port{display:inline}

  /* cut-in eyes: a little shorter so the band and the scene both fit */
  .ci-eyes{height:clamp(80px,15svh,150px)}
}

/* ---------- landscape phones: the board side by side (the grid on the left, the clock, memo and keyboard on the right) ---------- */
/* A 400-px-tall screen can't stack the header, six rows and a keyboard, so the keyboard used to fall off the bottom. */
@media (max-height:500px) and (orientation:landscape){
  #board{display:grid;grid-template-columns:auto minmax(260px,480px);grid-template-rows:auto auto auto 1fr;grid-template-areas:"bar bar" "grid status" "grid memo" "grid kb";
    column-gap:clamp(16px,4vw,40px);row-gap:6px;justify-content:center;align-content:stretch;padding-top:calc(env(safe-area-inset-top,0px) + 6px);
    --tile:clamp(28px,calc((100dvh - 92px) / 6.6),54px);--keyh:clamp(30px,10.5dvh,44px)}
  #board .bar{grid-area:bar;justify-self:center;padding-block:2px 6px}
  #grid{grid-area:grid;align-self:center}
  #board .status{grid-area:status;width:100%}
  #board .memo{grid-area:memo;min-height:0;font-size:15px}
  #kb{grid-area:kb;width:100%;align-self:end;margin-top:0;gap:5px}
  .clock b{font-size:28px}
}
