/* Case Closed: a stamped dossier under a narrowing pool of attention.
   All clocks, secrecy and folding remain owned by the existing engine.
   Never flatten the folder, desk or rotating cover: light lives behind them. */
@media (forced-colors: none) {
  html #zineCaseApp {
    --case-alert-ink: #ad382d;
    --case-light-ink: #19213a;
  }
  /* The stationary backboard is flat cardboard, not a second complete front
     photograph. Sample only the uncreased centre of the existing material:
     its left spine, top wear and curled lower-right corner are all outside
     the crop. Only the rotating front retains those distinctive features. */
  html #zineCaseApp .case-folder-base {
    /* Cropping removes the photo's transparent border too: compensate here
       so the backing remains a thin rim rather than an oversized placemat. */
    inset: 12px 13px 10px 2%;
  }
  html #zineCaseApp .case-folder-base .case-folder-stock {
    background-color: var(--folder);
    background-size: 125% 128%;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 18px 24px 22px 14px;
    clip-path: polygon(.1% 3%, .8% .6%, 25% .1%, 56% .3%, 82% 0, 99% .5%, 100% 3%, 99.8% 72%, 100% 96%, 99.2% 99.6%, 73% 100%, 40% 99.7%, .9% 100%, 0 97%);
    box-shadow: inset 1px 1px 1px #fff0af66, inset -1px -2px 1px #80602266;
  }
  html #zineCaseApp .case-folder-base .case-folder-stock::after { content: none; }
  html #zineCaseApp .moment-wing { display: none; }
  html #zineCaseApp:not([data-moment-event="case-reveal"]) .moment-cut { display: none; }
  html #zineCaseApp .moment-world {
    --case-dim: 0;
    --case-pool: 0;
  }
  html #zineCaseApp[data-moment-world-pressure="1"] .moment-world { --case-dim: .32; --case-pool: .18; }
  html #zineCaseApp[data-moment-world-pressure="2"] .moment-world { --case-dim: .60; --case-pool: .30; }
  html #zineCaseApp[data-moment-world-pressure="3"] .moment-world { --case-dim: .82; --case-pool: .42; }
  html #zineCaseApp .moment-world::before,
  html #zineCaseApp .moment-world::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    /* Existing carrier owns the final 280ms fade. These fields keep their
       last intensity while it exits; no shrinking or disappearing edges. */
    transition: opacity 300ms steps(3, end);
  }
  html #zineCaseApp .moment-world::before {
    background: var(--case-light-ink);
    opacity: var(--case-dim);
  }
  html #zineCaseApp .moment-world::after {
    background: radial-gradient(ellipse 59% 55% at 50% 47%, #ffe8ae 0%, #dbc78680 40%, transparent 78%);
    opacity: var(--case-pool);
  }
  /* Completion has its own finite paper cue on this carrier. Old retained
     pressure must not relight the study scene during that unrelated cue. */
  html #zineCaseApp:not(:is([data-phase="memorize"], [data-phase="closing"], [data-phase="recall"])) .moment-world::before,
  html #zineCaseApp:not(:is([data-phase="memorize"], [data-phase="closing"], [data-phase="recall"])) .moment-world::after {
    opacity: 0;
    transition: none;
  }
  html #zineCaseApp[data-moment-active="true"][data-phase="memorize"][data-moment-pressure] .case-folder-tab {
    translate: none;
    rotate: none;
  }
  /* One quiet coloured stamp, not a second shaking object. */
  html #zineCaseApp[data-phase="memorize"][data-moment-urgency="1"] .case-phase,
  html #zineCaseApp[data-phase="memorize"][data-moment-urgency="2"] .case-phase,
  html #zineCaseApp[data-phase="memorize"][data-moment-urgency="1"] .case-seconds,
  html #zineCaseApp[data-phase="memorize"][data-moment-urgency="2"] .case-seconds {
    color: var(--case-alert-ink);
  }
  html #zineCaseApp .case-countdown {
    height: 18px;
    clip-path: none;
    mask-image: repeating-linear-gradient(90deg, #000 0 calc(5% - 3px), transparent calc(5% - 3px) 5%);
    mask-size: 100% 100%;
    mask-position: 0 0;
    background: #25253624;
  }
  html #zineCaseApp .case-countdown span {
    background: var(--ink);
    /* The controller already fills exactly twenty whole cells. */
    transition: none;
  }
  html #zineCaseApp[data-phase="memorize"][data-moment-urgency="1"] .case-countdown span,
  html #zineCaseApp[data-phase="memorize"][data-moment-urgency="2"] .case-countdown span {
    background: var(--case-alert-ink);
  }
}

@media (min-width: 901px) and (min-height: 561px) {
  html #zineCaseApp .case-cover-copy,
  html #zineCaseApp[data-cover-content="setup"] .case-cover-copy {
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: clamp(28px, 4vh, 48px) 8%;
    gap: clamp(18px, 2.7vh, 28px);
  }
  html #zineCaseApp[data-cover-content="setup"] #caseCoverTitle {
    font-size: clamp(48px, 4.5vw, 68px);
    line-height: 1;
    align-self: center;
    margin: 0;
  }
  html #zineCaseApp .case-hint { max-width: 32ch; text-align: center; }
  html #zineCaseApp[data-cover-content="setup"] .case-levels {
    width: min(100%, 780px);
    min-width: 0;
    margin: clamp(12px, 2vh, 22px) 0 0;
    gap: clamp(16px, 1.6vw, 24px);
  }
  html #zineCaseApp .case-levels button {
    min-height: 94px;
    padding: 20px 16px 23px;
  }
  html #zineCaseApp .case-levels small { margin-top: 9px; }
  html #zineCaseApp .case-levels button[aria-pressed="true"]::after { bottom: 13px; }
  html #zineCaseApp .case-folder-tab { width: clamp(165px, 16.5%, 210px); right: 5%; }
  html #zineCaseApp .case-interior {
    padding: clamp(30px, 4vh, 44px) 5% clamp(24px, 3.5vh, 38px) 6%;
    grid-template-rows: minmax(0, 1fr) 56px;
    gap: clamp(16px, 2.5vh, 26px);
  }
  html #zineCaseApp .case-words { gap: clamp(16px, 2.6vh, 26px) 24px; }
  html #zineCaseApp[data-word-count="3"] .case-words { grid-template-rows: minmax(130px, 176px); }
  html #zineCaseApp[data-word-count="5"] .case-words { grid-template-rows: repeat(2, minmax(100px, 152px)); }
  html #zineCaseApp[data-word-count="7"] .case-words { grid-template-rows: repeat(3, minmax(0, 1fr)); }
  html #zineCaseApp .case-note { padding: 24px 28px; }
  html #zineCaseApp .case-clock {
    position: relative;
    height: 56px;
    width: min(100%, 630px);
    justify-self: center;
    gap: 24px;
  }
  html #zineCaseApp .case-countdown { width: min(76%, 440px); flex: 0 1 440px; }
  html #zineCaseApp .case-seconds {
    font-size: 38px;
    min-width: 2ch;
    text-align: center;
  }
  html #zineCaseApp #caseReviewHint { font-size: clamp(22px, 1.9vw, 28px); }
  html #zineCaseApp #caseReviewScore { font-size: 36px; }
  html #zineCaseApp .case-check-mark { width: 21px; height: 21px; right: 19px; bottom: 17px; }
  html #zineCaseApp .case-check-mark::after { left: 5px; top: -2px; width: 9px; height: 15px; }
  html #zineCaseApp[data-cover-content="result"] .case-cover-copy { gap: 16px; }
  html #zineCaseApp[data-cover-content="result"] #caseCoverTitle { font-size: clamp(36px, 3.5vw, 52px); }
  html #zineCaseApp .case-result { font-size: clamp(92px, 10vw, 144px); }
  html #zineCaseApp .case-controls {
    grid-template-columns: minmax(110px, 1fr) minmax(300px, 430px) minmax(110px, 1fr);
    column-gap: 22px;
    width: min(88%, 1160px);
  }
}

@media (min-width: 901px) and (min-height: 561px) and (max-height: 760px) {
  html #zineCaseApp .case-cover-copy,
  html #zineCaseApp[data-cover-content="setup"] .case-cover-copy { gap: 16px; padding-block: 22px; }
  html #zineCaseApp[data-cover-content="setup"] #caseCoverTitle { font-size: 50px; }
  html #zineCaseApp[data-cover-content="setup"] .case-levels { margin-top: 6px; }
  html #zineCaseApp .case-levels button { min-height: 82px; padding-block: 17px 20px; }
  html #zineCaseApp .case-interior { padding-block: 25px 19px; grid-template-rows: minmax(0, 1fr) 44px; gap: 16px; }
  html #zineCaseApp .case-clock { height: 44px; }
  html #zineCaseApp .case-words { row-gap: 15px; }
  html #zineCaseApp .case-note { padding: 18px 24px; }
  html #zineCaseApp[data-word-count="3"] .case-words { grid-template-rows: minmax(110px, 145px); }
  html #zineCaseApp[data-word-count="5"] .case-words { grid-template-rows: repeat(2, minmax(0, 126px)); }
  html #zineCaseApp .case-result { font-size: 104px; }
  html #zineCaseApp .case-check-mark { width: 18px; height: 18px; bottom: 9px; right: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  html #zineCaseApp .moment-world::before,
  html #zineCaseApp .moment-world::after { transition: none; }
}
