/* ===========================================================================
   The Viewing Room (templates/viewing-room.php): the room from the artwork
   pages filling the window, a bar across the top, and every painting along
   the foot. The room's own styles are artwork-new.css, under .artwork.
   =========================================================================== */

body.viewing {
  --strip: 108px;
  --top: 58px;
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  background: var(--color-1);
  color: var(--color-2);
}

/* --- the bar across the top ------------------------------------------------ */

.viewing__top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  height: var(--top);
  box-sizing: border-box;
  display: flex;
  /* On one baseline — the link, the title and the painting's name — rather
     than centred box by box, which the two typefaces' different ascents set
     a few pixels apart; and each a line the bar's height, which puts that
     baseline in its middle. */
  align-items: baseline;
  gap: 22px;
  padding: env(safe-area-inset-top) 20px 0;
  line-height: calc(var(--top) - env(safe-area-inset-top));
  border-bottom: 1px solid var(--color-3);
  background: var(--color-1);
  font-family: var(--font-family-2);
  font-size: var(--font-size-4);
}
.viewing__back {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  color: var(--color-2);
  text-decoration: none;
  white-space: nowrap;
}
.viewing__back:hover { color: var(--color-5); }
/* Important: global.css gives every h1 its margins so. */
.viewing__title {
  margin: 0 !important;
  font-family: var(--font-family-1);
  font-size: var(--font-size-2);
  font-weight: normal;
  color: var(--color-6);
  white-space: nowrap;
}
.viewing__now {
  display: flex;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
  margin: 0 0 0 auto;
}
.viewing__now span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: italic;
}
.viewing__now a { color: var(--color-2); white-space: nowrap; }
.viewing__now a:hover { color: var(--color-5); }

/* --- the room, between the bar and the strip ------------------------------- */

.viewing .room {
  position: fixed;
  top: var(--top);
  left: 0;
  right: 0;
  bottom: var(--strip);
  max-width: none;
  margin: 0;
  padding: 0;
  border: 0;
  box-sizing: border-box;
  display: flex;
}
.viewing .room[hidden] { display: none; }
/* Full bleed: the scene is the whole space between the bar and the strip,
   drawn to that space's shape (data-fill, artwork-room.js), with the room's
   controls in its corners. */
.viewing .room__frame {
  flex: 1;
  min-height: 0;
  display: flex;
}
.viewing .room__stage {
  flex: 1;
  width: 100%;
  height: 100%;
  aspect-ratio: auto !important;
  border: 0;
}

.viewing__none {
  position: fixed;
  top: 50%;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-family: var(--font-family-2);
  color: var(--color-7);
}
.viewing__none a { color: var(--color-2); }

/* --- every painting along the foot ----------------------------------------- */

.viewing__strip {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  height: var(--strip);
  padding-bottom: env(safe-area-inset-bottom);
  /* Brighter than the site's hairlines, so the strip stands apart from the
     room above it. */
  border-top: 1px solid var(--color-4);
  background: var(--color-1);
}
.viewing__strip ol {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 100%;
  margin: 0;
  padding: 0 20px;
  list-style: none;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
.viewing__strip li { flex: none; }
/* The arrows over its ends, as on an artwork page's row of formats. */
.viewing__strip { position: fixed; }
.viewing__arrow {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 38px;
  height: 38px;
  margin-top: -19px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 2px;
  border: 1px solid var(--color-3);
  border-radius: 50%;
  background: var(--color-1);
  color: var(--color-2);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.viewing__arrow:hover { border-color: var(--color-5); color: var(--color-5); }
.viewing__arrow--prev { left: 10px; }
.viewing__arrow--next { right: 10px; }
.viewing__arrow[hidden] { display: none; }
.viewing__strip a {
  display: block;
  padding: 3px;
  border: 1px solid transparent;
  border-radius: 3px;
}
.viewing__strip img {
  display: block;
  height: 72px;
  width: auto;
}
.viewing__strip a:hover { border-color: var(--color-4); }
.viewing__strip a[aria-current="true"] { border-color: var(--color-5); }

/* --- on a phone -------------------------------------------------------------
   The scene across the screen edge to edge, the way to buy it under it, and
   the room's controls folded under two reveals (viewing-room.js) — the
   format and size; the wall and the furniture — so that the scene is what a
   phone shows. The page scrolls under a bar of two short lines; the strip
   stays at the foot. */

@media (max-width: 700px) {
  body.viewing { height: auto; overflow: auto; --strip: 92px; }

  .viewing__top {
    position: sticky;
    height: auto;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
    line-height: 1.3;
  }
  .viewing__title { display: none; }
  .viewing__back { order: 1; }
  .viewing__ar { order: 2; margin-left: auto; }
  /* The painting's name goes into the scene instead (.viewing__caption). */
  .viewing__now { display: none; }
  .viewing .viewing__caption {
    display: block;
    position: absolute;
    left: 12px;
    bottom: 10px;
    z-index: 3;
    max-width: calc(100% - 24px);
    padding: 4px 9px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: rgba(11, 21, 30, 0.82);
    border-radius: 4px;
    color: #f0f0f0;
    font-family: var(--font-family-2);
    font-size: var(--font-size-4);
    font-style: italic;
    text-decoration: none;
  }

  .viewing .room {
    position: static;
    display: block;
    padding: 0 0 calc(var(--strip) + 20px);
  }
  .viewing .room__frame { flex-direction: column; gap: 0; }

  /* The scene: the screen's width, and about as tall as it is wide — taller
     only adds bare wall above the painting — drawn to that shape (data-fill). */
  .viewing .room__stage {
    order: 1;
    flex: none;
    width: 100%;
    height: min(105vw, 58dvh);
    aspect-ratio: auto !important;
    border: 0;
  }

  .viewing .room__next { order: 2; padding: 14px 14px 6px; }

  /* The format and size over the scene's top, side by side, as on a wide
     screen; and at the row's end the button for the wall and furniture. */
  .viewing .room__picker {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 6;
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    width: auto;
  }
  .viewing .room__picker .sizepicker { flex: 1 1 0; min-width: 0; width: auto; }
  .viewing__room-open {
    /* The row it sits in lets taps through its gaps to the scene
       (artwork-new.css); the button takes its own. */
    pointer-events: auto;
    display: flex;
    flex: none;
    align-self: stretch;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    width: 46px;
    padding: 0;
    background: var(--color-1);
    border: 1px solid var(--color-3);
    border-radius: 6px;
    color: var(--color-2);
    cursor: pointer;
  }
  .viewing__room-open svg {
    width: 26px;
    height: 13px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.4;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
  }

  /* In the scene's foot, at the right, opposite the painting's name. */
  .viewing .room__stage .room__note {
    position: absolute;
    right: 12px;
    bottom: 10px;
    left: auto;
    z-index: 3;
    max-width: 40%;
    margin: 0;
    padding: 4px 8px;
    background: rgba(11, 21, 30, 0.82);
    border: 0;
    border-radius: 4px;
    color: #c9d2db;
    font-size: 10px;
    line-height: 1.35;
    text-align: right;
  }
  /* The name the rest, less a gap; a long one ends in an ellipsis. */
  .viewing .viewing__caption { max-width: calc(60% - 36px); }

  .viewing__strip img { height: 58px; }
  .viewing__arrow { width: 32px; height: 32px; margin-top: -16px; font-size: 15px; }
}
}

/* The way to your own wall, at the bar's end, on a phone (artwork-ar.js shows
   it): smaller than on an artwork page, to share the bar. */
.viewing__ar { flex: none; padding: 5px 10px; font-size: var(--font-size-4); }
.viewing__ar svg { width: 16px; height: 16px; }

/* No rules down the window's sides here (global.css draws them round every
   other page's column): the room is the whole window, edge to edge. */
body.viewing::before,
body.viewing::after { display: none; }

/* One painting to the next by a cross-dissolve (viewing-room.js): the new one
   fades in where it hangs while a copy of the old fades out where it hung —
   no sliding between the two, which the room otherwise does as a size
   changes. */
/* body.viewing, to outweigh the room's own slide of the painting, its light
   and the furniture from one size to the next (artwork-new.css). */
body.viewing .room__art { transition: opacity 0.7s ease; }
body.viewing .room__art-light,
body.viewing .room__sofa { transition: none; }
body.viewing .room__art.is-arriving { opacity: 0; transition: none; }
.viewing .room__art--leaving { opacity: 1; transition: opacity 0.7s ease; pointer-events: none; }
.viewing .room__art--leaving.is-gone { opacity: 0; }

/* The painting's name in the scene: a phone's only (below). */
.viewing__caption { display: none; }

/* The sheet the wall and furniture open in, on a phone (viewing-room.js). */
.viewing__sheet {
  width: min(440px, calc(100vw - 24px));
  padding: 16px 16px 20px;
  background: var(--color-1);
  color: var(--color-2);
  border: 1px solid var(--color-3);
  border-radius: 8px;
}
.viewing__sheet::backdrop { background: rgba(5, 9, 13, 0.6); }
.viewing__sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.viewing__sheet-head h2 {
  margin: 0 !important;
  font-family: var(--font-family-1);
  font-size: var(--font-size-2);
  font-weight: normal;
  line-height: 1.2;
  color: var(--color-6);
}
.viewing__sheet-close {
  width: 36px;
  height: 36px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--color-7);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.viewing__sheet-body { display: flex; flex-direction: column; gap: 12px; }
.viewing__sheet .room__walls {
  display: flex;
  /* Its own height: in a column, the room's flex basis would be taken as one. */
  flex: none;
  justify-content: center;
  height: 46px;
  margin: 0;
}
.viewing__sheet .room__sofa-size {
  position: static;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 8px;
  margin: 0;
}
/* The furniture's own line; its size and the units under it. */
.viewing__sheet .room__pieces { flex: 1 1 100%; }
.viewing__sheet .room__pieces .sizebox { width: 100%; }

/* In the sheet the furniture's menu is out of the room, and so out of its
   compact styles (artwork-new.css, .artwork .room): set the same here — one
   to a row, a small sketch beside each name — and opened in the sheet's
   flow, rather than floating out past its edge to be cut off. */
.viewing__sheet .room__piece-grid {
  position: static;
  margin-top: 6px;
  grid-template-columns: 1fr;
  gap: 2px;
  padding: 5px;
  max-height: none;
}
.viewing__sheet .room__piece-grid .sizeopt {
  flex-direction: row;
  justify-content: flex-start;
  gap: 12px;
  padding: 8px 10px;
  color: var(--color-2);
  font-family: var(--font-family-2);
}
.viewing__sheet .room__piece-grid .sizeopt__slot { flex: 0 0 40px; height: 22px; }
.viewing__sheet .room__piece-grid .sizeopt__label {
  font-size: var(--font-size-4);
  line-height: 1.3;
  text-align: left;
}
.viewing__sheet .room__pieces .sizebox {
  gap: 8px;
  padding: 6px 10px;
  color: var(--color-2);
  font-family: var(--font-family-2);
}
.viewing__sheet .room__pieces .sizebox__slot { flex: 0 0 30px; height: 18px; }
.viewing__sheet .room__pieces .sizebox__primary { font-size: var(--font-size-8); padding: 0; margin: 0; border: 0; }

/* A short rule between the way back and the room's name, centred on the bar,
   14px from each: the bar's 22px gap drawn in by 8 on its left. */
.viewing__title {
  position: relative;
  padding-left: 14px;
  margin-left: -8px !important;
}
.viewing__title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 1px;
  height: 22px;
  margin-top: -11px;
  background: var(--color-4);
}
