/*
 * Narrow rooms keep the approved desktop composition.
 * The whole 1672x941 room scales uniformly and pans horizontally; text stays
 * attached to the same painted boards, pages and frames as on desktop.
 */
@media (max-width: 900px) {
  /* Match the unchanged book canvas target when the window emerges. */
  dialog.studio-detail.review-book-window {
    width: min(900px, 94vw);
    max-width: none;
    height: min(620px, 90dvh);
    max-height: 90dvh;
  }

  #room-dialog::after {
    content: "Перетаскивайте комнату влево или вправо";
    position: fixed;
    z-index: 20;
    left: 50%;
    top: 10px;
    bottom: auto;
    transform: translateX(-50%);
    width: min(310px, calc(100vw - 32px));
    box-sizing: border-box;
    padding: 7px 12px;
    border: 1px solid #c9a46588;
    border-radius: 5px;
    background: #09152bdb;
    color: #f3d9a4;
    font: 14px/1.25 Georgia, serif;
    text-align: center;
    pointer-events: none;
    text-shadow: 0 1px 4px #000;
    animation: hall-pan-hint 3s ease-in-out infinite;
  }

  .chamber-stage #chamber-content {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    container-type: size;
  }

  /* About: keep the copy on the projected blue board. */
  .chamber-stage[data-room="about"] .about-content {
    min-height: 0;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-rows: 8% 15% 8% 15% 25% 13% 16%;
    gap: 0;
    align-items: center;
    justify-items: center;
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  .chamber-stage[data-room="about"] #chamber-content .about-content h2 {
    font: normal 1.8cqw Georgia !important;
    margin: 0 !important;
  }
  .chamber-stage[data-room="about"] #chamber-content .about-content h3 {
    font: normal 2.35cqw Georgia !important;
    margin: 0 !important;
    white-space: nowrap;
  }
  .chamber-stage[data-room="about"] #chamber-content .about-content > p {
    margin: 0 !important;
    line-height: 1.3;
  }
  .chamber-stage[data-room="about"] #chamber-content .about-content > .subtitle {
    font-size: 1.05cqw !important;
    letter-spacing: .22em;
  }
  .chamber-stage[data-room="about"] #chamber-content .about-content > p:not(.subtitle):not(.steps) {
    font-size: 1.4cqw !important;
  }
  .chamber-stage[data-room="about"] .about-content .principles {
    width: 100%;
    margin: 0 !important;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .6cqw;
    align-self: center;
    align-content: center;
    font: 1.15cqw/1.3 Georgia !important;
  }
  .chamber-stage[data-room="about"] .about-content .principles span::before {
    width: 3.6cqw;
    height: 3.6cqw;
    margin: 0 auto .50652cqw;
    font-size: 2cqw;
    line-height: 1.7;
  }
  .chamber-stage[data-room="about"] .about-content .steps {
    width: 100%;
    margin: 0 !important;
    padding: .5628cqw 0 !important;
    font-size: .9cqw !important;
    line-height: normal;
  }
  .chamber-stage[data-room="about"] .about-content > .room-action {
    position: static;
    inset: auto;
    width: 73%;
    height: 65%;
    min-height: 0;
    margin: 0;
    padding: 0;
    font-size: 1.4cqw;
  }

  /* Price: keep the invitation and action on their projected parchment areas. */
  .chamber-stage[data-room="price"] .price-content {
    min-height: 0;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 10px;
    text-align: center;
    color: #352112;
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  .chamber-stage[data-room="price"] .ledger-heading {
    flex: none;
    gap: 22px;
    padding: 10px 0;
  }
  .chamber-stage[data-room="price"] #chamber-content .price-invitation h2 {
    margin: 0 !important;
    font: bold 58px/1.05 Georgia !important;
  }
  .chamber-stage[data-room="price"] #chamber-content .price-invitation .ledger-intro {
    margin: 0;
    font: 33px/1.2 Georgia;
  }
  .chamber-stage[data-room="price"] .ledger-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    flex: 1;
    align-items: center;
  }
  .chamber-stage[data-room="price"] .ledger-step {
    padding: 0 7px;
  }
  .chamber-stage[data-room="price"] .ledger-step + .ledger-step {
    border-top: 0;
    border-left: 1px solid #8e602955;
    padding-top: 0;
  }
  .chamber-stage[data-room="price"] .ledger-step svg {
    width: 82px;
    height: 64px;
  }
  .chamber-stage[data-room="price"] #chamber-content .ledger-step h3 {
    margin: 8px 0 !important;
    font-size: 31px !important;
    white-space: nowrap;
  }
  .chamber-stage[data-room="price"] #chamber-content .ledger-step p {
    margin: 0;
    font-size: 29px;
    line-height: 1.2;
  }
  .chamber-stage[data-room="price"] .price-surface-cta {
    min-height: 0;
    margin: 0;
    padding: 0 !important;
    display: grid;
    place-items: center;
    background: transparent url('./assets/ui-frame.svg') center/100% 100% no-repeat !important;
    border: 0;
    box-shadow: none !important;
    font-size: 32px !important;
    line-height: 1;
    white-space: nowrap;
  }

  /* Works: preserve all three frames and their labels in the desktop places. */
  .chamber-stage[data-room="works"] .gallery-sign {
    left: 30%;
    top: 15%;
    width: 40%;
    padding: 14px 18px;
    transform: none;
  }
  .chamber-stage[data-room="works"] #chamber-content .gallery-sign h2 {
    font-size: 2.5cqw !important;
  }
  .chamber-stage[data-room="works"] #chamber-content .gallery-sign p {
    font-size: 1.2cqw;
  }
  .chamber-stage[data-room="works"] .gallery-label {
    padding: 0;
    display: grid;
    place-items: center;
    margin: 0;
    font-size: 1.1cqw !important;
    line-height: 1.15;
  }
  .chamber-stage[data-room="works"] .gallery-caption {
    padding: 0;
    display: grid;
    place-items: center;
    margin: 0;
    font-size: 1.05cqw !important;
    line-height: normal !important;
    text-wrap: balance;
  }
  .chamber-stage[data-room="works"] .gallery-slot-left,
  .chamber-stage[data-room="works"] .gallery-slot-center,
  .chamber-stage[data-room="works"] .gallery-slot-right {
    display: block;
  }
  .chamber-stage[data-room="works"] .gallery-prev,
  .chamber-stage[data-room="works"] .gallery-next {
    top: 51%;
    width: 3.2%;
    height: 5.5%;
    font-size: 1.9cqw;
    transform: translate(-50%, -50%);
  }
  .chamber-stage[data-room="works"] .gallery-prev {
    left: 40%;
    right: auto;
  }
  .chamber-stage[data-room="works"] .gallery-next {
    left: 60%;
    right: auto;
  }
  .chamber-stage[data-room="works"] .gallery-cta {
    left: 38%;
    top: 77%;
    width: 24%;
    height: 6%;
    transform: none;
    font-size: 1.1cqw;
  }

  /* Reviews: both ink pages and the title follow the projected book surfaces. */
  .chamber-stage[data-room="reviews"] .reviews-content {
    position: absolute;
    left: 30%;
    top: 33%;
    width: 40%;
    height: 34%;
    min-height: 0;
    margin: 0;
    padding: 0;
    display: block;
    text-align: center;
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  .chamber-stage[data-room="reviews"] .book-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    color: #523217;
    mix-blend-mode: multiply;
    border: 0;
  }
  .chamber-stage[data-room="reviews"] .book-left {
    border-bottom: 0;
  }
  .chamber-stage[data-room="reviews"] .book-ink {
    width: 100%;
    height: 100%;
  }
  .chamber-stage[data-room="reviews"] #chamber-content .book-page h2 {
    margin: 0 0 1.01304cqw !important;
    font-size: 1.8cqw !important;
  }
  .chamber-stage[data-room="reviews"] #chamber-content .book-page p {
    max-width: 100%;
    margin: .5628cqw 0;
    font-size: 1.1cqw;
    line-height: 1.45;
  }
  .chamber-stage[data-room="reviews"] #chamber-content .book-page .fine {
    margin-top: 1.1256cqw;
    font-size: .85cqw !important;
    line-height: 1.45;
  }
  .chamber-stage[data-room="reviews"] .book-ornament {
    margin-bottom: .5628cqw;
    font-size: 2.5cqw;
    line-height: 1;
  }
  .chamber-stage[data-room="reviews"] .book-page .quote {
    margin: .5628cqw 0 1.1256cqw;
    font-size: 4cqw;
    line-height: .5;
  }
  .chamber-stage[data-room="reviews"] .reviews-heading {
    display: block;
    font: 4.8cqw/1.3 Georgia;
  }
  .chamber-stage[data-room="reviews"] .review-book-spine {
    display: block;
  }
  .chamber-stage[data-room="reviews"] .reviews-content .room-action {
    min-height: 0;
    margin: 0;
    font-size: 1.5cqw;
  }

  /* Contact: keep every field inside the projected writing area. */
  .chamber-stage[data-room="contact"] .contact-content {
    min-height: 0;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-rows: 12% 10% 14% 14% 23% 18% 9%;
    gap: 0;
    align-items: center;
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  .chamber-stage[data-room="contact"] #chamber-content .contact-content h2 {
    margin: 0 !important;
    font-size: 2.5cqw !important;
  }
  .chamber-stage[data-room="contact"] .contact-content > p {
    margin: 0;
    font-size: 1.35cqw !important;
    line-height: 1.45 !important;
  }
  .chamber-stage[data-room="contact"] .contact-content label {
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    display: flex;
    align-items: center;
  }
  .chamber-stage[data-room="contact"] .contact-content input,
  .chamber-stage[data-room="contact"] .contact-content textarea {
    box-sizing: border-box;
    width: 100%;
    height: 75%;
    margin: 0;
    padding: .67536cqw .8cqw;
    font: 1.15cqw Georgia;
  }
  .chamber-stage[data-room="contact"] .contact-content textarea {
    height: 85%;
  }
  .chamber-stage[data-room="contact"] .contact-content > .fine {
    position: static;
    width: 100%;
    margin: 0;
    align-self: end;
    font-size: .82cqw !important;
    line-height: 1.5;
  }
  .chamber-stage[data-room="contact"] .contact-content .form-status {
    position: absolute;
    left: 5%;
    top: auto;
    bottom: 0;
    width: 90%;
    font-size: .8cqw;
  }
  .chamber-stage[data-room="contact"] .contact-surface-cta {
    min-height: 0;
    margin: 0;
    padding: 0 !important;
    background: none !important;
    border: 0;
    box-shadow: none !important;
    font-size: 1.55cqw !important;
    transform: none;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  #room-dialog::after {
    display: none;
  }
}

/* About controls stay clear of the seated figure; the scene and motion are unchanged. */
@media (max-width: 340px) and (orientation: portrait) {
  #room-dialog[open]:has(> .chamber-stage[data-room="about"]) > .statistics-settings {
    bottom: 76px !important;
  }
  #room-dialog[open]:has(> .chamber-stage[data-room="about"]) > .chamber-toolbar > #room-back {
    position: fixed !important;
    left: 16px !important;
    right: auto !important;
    top: 60px !important;
    bottom: auto !important;
  }
}
@media (max-width: 700px) and (orientation: landscape) {
  #room-dialog[open]:has(> .chamber-stage[data-room="about"]) > .chamber-toolbar > #room-back {
    left: 16px !important;
  }
}
@media (min-width: 901px) and (max-width: 1100px) and (max-aspect-ratio: 1672/941) {
  #room-dialog[open]:has(> .chamber-stage[data-room="about"]) > .chamber-toolbar > #room-back {
    bottom: 6px !important;
  }
}
