/* ============================================================================
   S9b · The office — THE NIGHT SHIFT — css/scenes/office.css
   Night, bone hairlines, the Signal. One sticky, transparent stage (the body is night): NIGHT / SHIFT in the
   left column (outline, then filled), the copy and the two pills bottom-left, Opis Tower on the right: a spire of
   290 × 1060 units (floor = 100), left wing floors 1–5 (EJ team), right wing 1–9 (LakbayBook team), the core to
   floor 10 with Shenna (9) and EJ (10). Sixteen windows are buttons; a lit window is a warm pane with the bust and
   a mono tag standing outside the wing (left wing and core: to the left; right wing: to the right).
   CSS default = the key pose (the still edition and the no-JS page): the tower drawn and fully lit, every tag
   readable, the word filled, both serif lines, the pills. js/scenes/office.js moves everything away from this
   pose with gsap.set and the scrub brings it back; it also writes --tower-h / --word-fs from measurement.
   Every class is office__ / office--.
   ========================================================================== */

.scene--office {
  --fg: var(--bone);
  --fg-2: color-mix(in srgb, var(--bone) 62%, transparent);
  --fg-3: color-mix(in srgb, var(--bone) 55%, transparent);
  --line: color-mix(in srgb, var(--bone) 18%, transparent);
  --focus: var(--signal);
  color: var(--bone);
  /* the lit pane (pale gold) and EJ's (the Signal itself: the one human); the dark window's frame */
  --office-pane: color-mix(in srgb, var(--signal) 52%, var(--bone));
  --office-frame: color-mix(in srgb, var(--bone) 42%, transparent);
  --office-glow: color-mix(in srgb, var(--signal) 26%, transparent);
  /* the tower: height from the header to the bottom gutter; width keeps the 290:1060 drawing square */
  --tower-top: calc(var(--header-h) + 28px);
  --tower-h: calc(100svh - var(--tower-top) - max(var(--gutter), 24px));
  --tower-w: calc(var(--tower-h) * 290 / 1060);
  /* the tower stands by its right-wing tags: --tag-room of air to the right gutter, whatever the width */
  --tag-room: 240px;
  --tower-cx: calc(100% - var(--gutter) - var(--tag-room) - var(--tower-w) / 2);
  --tag-gap: 14px;
  --tag-fs: var(--mono-s);
  /* NIGHT / SHIFT: two lines, fitted to the left column (JS refines from the real glyph widths) */
  --word-fs: min(calc((44vw - var(--gutter)) / 3.95), 20svh);
}
.scene--office .scene__stage {
  background: transparent;
}

/* ---------- corners ---------- */
.office__h {
  margin: 0;
}
.office__addr {
  z-index: 2;
  white-space: nowrap;
}
.office__addr .link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin: -14px 0;
}

/* ---------- NIGHT / SHIFT ---------- */
.office__word {
  position: absolute;
  z-index: 1;
  left: var(--gutter);
  top: calc(var(--header-h) + 76px);
  display: grid;
  margin: 0;
  font-size: var(--word-fs);
  line-height: 0.86;
  pointer-events: none;
}
.office__word > span {
  grid-area: 1 / 1;
  display: grid;
  font-size: inherit;
  line-height: inherit;
}
.office__wl {
  display: block;
  white-space: nowrap;
}
.office__word-outline {
  -webkit-text-stroke-width: 1px;
}

/* ---------- the copy, bottom-left ---------- */
.office__copy {
  position: absolute;
  z-index: 2;
  left: var(--gutter);
  bottom: max(var(--gutter), 24px);
  display: grid;
  gap: 10px;
  max-width: calc(48vw - var(--gutter));
}
.office__s1 {
  max-width: 28ch;
}
.office__s2 {
  max-width: 30ch;
}
.office__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

/* ---------- the tower ---------- */
.office__tower {
  position: absolute;
  z-index: 1;
  left: calc(var(--tower-cx) - var(--tower-w) / 2);
  top: var(--tower-top);
  width: var(--tower-w);
  height: var(--tower-h);
}
.office__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.office__p {
  fill: none;
  stroke: var(--bone);
  stroke-opacity: 0.8;
  stroke-width: 1px;
  stroke-linecap: butt;
  stroke-linejoin: miter;
  vector-effect: non-scaling-stroke;
}
.office__p--street {
  stroke-opacity: 0.45;
}
.office__p--lfloor,
.office__p--rfloor {
  stroke-opacity: 0.5;
}
.office__p--shaft {
  stroke-opacity: 0.4;
  stroke-dasharray: 2 6;
}

/* ---------- windows ---------- */
.office__windows {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.office__win {
  position: absolute;
  width: calc(70 / 290 * 100%);
  aspect-ratio: 1;
  top: calc((1065 - 100 * var(--f)) / 10.6 * 1%);
}
.office__win--l {
  left: calc(15 / 290 * 100%);
}
.office__win--c {
  left: calc(110 / 290 * 100%);
}
.office__win--r {
  left: calc(205 / 290 * 100%);
}
.office__btn {
  position: absolute;
  inset: 0;
  display: block;
  border: 1px solid var(--office-frame);
  background: transparent;
  cursor: pointer;
  /* a 48px target even for a small window */
}
.office__btn::before {
  content: "";
  position: absolute;
  inset: -8px;
}
.office__btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
.office__pane {
  position: absolute;
  inset: 0;
  overflow: clip;
  background: var(--office-pane);
  box-shadow: 0 0 22px 5px var(--office-glow);
  will-change: transform, opacity;
}
.office__pane img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.18) translateY(7%);
  transform-origin: 50% 40%;
}
.office__win--ej .office__pane {
  background: var(--signal);
  box-shadow: 0 0 30px 8px color-mix(in srgb, var(--signal) 40%, transparent);
}
/* the dark window of the motion edition (JS fades the pane in); on hover the frame brightens */
.office__btn:hover {
  border-color: var(--bone);
}

/* ---------- tags: outside the wing, level with the window ---------- */
.office__tag {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  font-size: var(--tag-fs);
  line-height: 1.3;
  letter-spacing: 0.04em;
  color: var(--fg-2);
  pointer-events: none;
  will-change: transform, opacity;
}
.office__tag-n {
  color: var(--bone);
}
.office__tag-rs {
  display: none;
}
.office__win--l .office__tag {
  right: calc(100% + var(--tower-w) * 0.0517 + var(--tag-gap));
  text-align: right;
}
.office__win--c .office__tag {
  right: calc(100% + var(--tower-w) * 0.3793 + var(--tag-gap));
  text-align: right;
}
.office__win--r .office__tag {
  left: calc(100% + var(--tower-w) * 0.0517 + var(--tag-gap));
  text-align: left;
}
.office__win--ej .office__tag {
  color: var(--bone);
}
.office__win--ej .office__tag-x {
  color: var(--signal);
}

/* ---------- the card (hover / tap / focus) ---------- */
.office__card {
  top: calc(100% + 12px);
  left: 0;
  width: min(320px, calc(100vw - 2 * var(--gutter)));
}
.office__card--up {
  top: auto;
  bottom: calc(100% + 12px);
}
.office__card strong {
  font-weight: 500;
  color: var(--bone);
}
.office__card .link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin: -10px 0;
}

/* ---------- big screens ---------- */
@media (min-width: 2200px) {
  .scene--office {
    --tag-gap: 20px;
  }
}

/* ---------- narrow landscape screens (768–1279): smaller tags, a narrower left column ---------- */
@media (min-width: 768px) and (max-width: 1279px) {
  .scene--office {
    --tag-fs: 11px;
    --tag-room: 200px;
    --word-fs: min(calc((40vw - var(--gutter)) / 3.95), 20svh);
  }
  .office__copy {
    max-width: calc(46vw - var(--gutter));
  }
}

/* ---------- portrait (phones < 768, and tablets up to 1023): the word on one line under the label, the tower centred, 2-line tags ---------- */
@media (max-width: 767px) and (min-height: 501px), (min-width: 768px) and (max-width: 1023px) and (orientation: portrait) {
  .scene--office {
    --tower-cx: 50%;
    --tag-fs: 11px;
    --tag-gap: 10px;
    --word-fs: calc((100vw - 2 * var(--gutter)) / 7.75);
    --copy-h: 168px; /* JS refines from the real copy height */
    --tower-top: calc(var(--header-h) + 8px + 22px + var(--word-fs) * 0.86 + 16px);
    --tower-h: calc(100svh - var(--tower-top) - var(--copy-h) - 30px);
  }
  /* the corner keeps the URL only: the label owns the rest of that line */
  .office__addr {
    font-size: 11px;
    letter-spacing: 0.03em;
    top: calc(var(--header-h) + 10px);
  }
  .office__addr-m {
    display: none;
  }
  .office__addr .link {
    min-height: 0;
    margin: 0;
  }
  .office__word {
    top: calc(var(--header-h) + 8px + 22px + 4px);
  }
  .office__word > span {
    display: flex;
    gap: 0.28em;
  }
  .office__copy {
    max-width: calc(100vw - 2 * var(--gutter));
    gap: 6px;
  }
  .office__s1,
  .office__s2 {
    max-width: none;
  }
  .office__pills {
    gap: 8px;
    margin-top: 6px;
  }
  .office__pill {
    min-height: 48px;
  }
  .office__tag {
    white-space: normal;
    display: grid;
    line-height: 1.25;
    max-width: calc((100vw - var(--tower-w)) / 2 - var(--gutter) - var(--tag-gap) - var(--tower-w) * 0.0517);
  }
  .office__win--c .office__tag {
    max-width: calc((100vw - var(--tower-w)) / 2 - var(--gutter) - var(--tag-gap) + var(--tower-w) * 0.3276);
  }
  .office__tag-s {
    display: none;
  }
  .office__tag-rf {
    display: none;
  }
  .office__tag-rs {
    display: block;
  }
  .office__win--ej .office__tag-x {
    display: block;
  }
  .office__card {
    width: min(300px, calc(100vw - 2 * var(--gutter)));
  }
}
@media (max-width: 359px) {
  .office__win--ej .office__tag-x {
    display: none;
  }
  .office__pills {
    gap: 6px;
  }
  .office__pill {
    padding: 0 13px;
    letter-spacing: 0.04em;
  }
}

/* ---------- landscape phones (height ≤ 500): everything smaller, name-only tags ---------- */
@media (max-height: 500px) and (orientation: landscape) {
  .scene--office {
    --tower-top: calc(var(--header-h) + 6px);
    --tower-h: calc(100svh - var(--tower-top) - 12px);
    --tower-cx: 76%;
    --tag-fs: 11px;
    --tag-gap: 10px;
    --word-fs: min(calc((42vw - var(--gutter)) / 3.95), 22svh);
    --serif-l: 18px;
    --serif-xl: 22px;
  }
  .office__word {
    top: calc(var(--header-h) + 34px);
  }
  .office__copy {
    max-width: calc(50vw - var(--gutter));
    gap: 4px;
    bottom: 14px;
  }
  .office__pills .pill {
    min-height: 40px;
  }
  .office__tag-s,
  .office__tag-r,
  .office__tag-x {
    display: none;
  }
  .office__card {
    width: min(280px, calc(100vw - 2 * var(--gutter)));
  }
}

/* ---------- the still edition: the stage may grow so the tower is never tiny ---------- */
html:not(.motion) .scene--office {
  --tower-h: max(calc(100svh - var(--tower-top) - max(var(--gutter), 24px)), 560px);
}
html:not(.motion) .scene--office .scene__stage {
  min-height: calc(var(--tower-top) + var(--tower-h) + max(var(--gutter), 24px));
}
@media (max-width: 767px) and (min-height: 501px), (min-width: 768px) and (max-width: 1023px) and (orientation: portrait) {
  html:not(.motion) .scene--office {
    --tower-h: max(calc(100svh - var(--tower-top) - var(--copy-h) - 30px), 520px);
  }
  html:not(.motion) .scene--office .scene__stage {
    min-height: calc(var(--tower-top) + var(--tower-h) + var(--copy-h) + 30px);
  }
}
@media (max-height: 500px) and (orientation: landscape) {
  html:not(.motion) .scene--office {
    --tower-h: max(calc(100svh - var(--tower-top) - 12px), 520px);
  }
  html:not(.motion) .scene--office .scene__stage {
    min-height: calc(var(--tower-top) + var(--tower-h) + 12px);
  }
}
