/* Committee page: the "3D world" view and the switch that turns it on and off. Builds on site.css. */

/* ---- The switch in the header ---- */

.header-tools { display: flex; align-items: center; gap: 0.75rem 1.1rem; flex-wrap: wrap; }
.view-switch {
  display: inline-flex; align-items: center; gap: 0.55rem;
  color: #fff; font-weight: 700; font-size: 0.95rem; user-select: none;
}
.view-switch[hidden] { display: none; }
.view-switch-text { cursor: pointer; opacity: 0.7; }
.view-switch-text.is-on { opacity: 1; text-decoration: underline; text-decoration-color: var(--gold); text-decoration-thickness: 3px; text-underline-offset: 5px; }
.view-switch-button {
  position: relative; flex: none; width: 3.8rem; height: 2.1rem; padding: 0; cursor: pointer;
  border-radius: 999px; border: 2px solid #fff; background: rgba(0, 0, 0, 0.3);
}
.view-switch-thumb {
  position: absolute; top: 3px; left: 3px; width: calc(2.1rem - 10px); height: calc(2.1rem - 10px);
  border-radius: 50%; background: #fff; transition: transform 0.2s ease;
}
.view-switch-button[aria-checked="true"] { background: var(--gold); border-color: var(--gold); }
.view-switch-button[aria-checked="true"] .view-switch-thumb { transform: translateX(1.7rem); background: #1b1315; }
.view-switch-button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* ---- The page while the 3D world is showing ---- */

html.world-mode { background: #241330; overscroll-behavior: none; }
body.world-mode { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; overscroll-behavior: none; }
/* The classic page keeps clear of the iPhone's notch when turned sideways. */
body.admin:not(.world-mode) { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
body.world-mode > main { display: none; }
body.world-mode .site-header { flex: none; }
.world { position: relative; flex: 1 1 auto; min-height: 0; background: #241330; color: #fff7e8; }
.world[hidden] { display: none; }

.world-root { position: absolute; inset: 0; overflow: hidden; }
.world-stage { position: absolute; inset: 0; }
.world-canvas { display: block; width: 100%; height: 100%; outline: none; }
.world-hud { position: absolute; inset: 0; pointer-events: none; }
.world-hud > * { pointer-events: auto; }

.world-btn, .world-nav-btn, .world-stop, .world-card-action, .world-select {
  font: inherit; color: #fff7e8; cursor: pointer;
  background: rgba(24, 14, 18, 0.78); border: 2px solid rgba(214, 167, 43, 0.65);
  border-radius: 12px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.world-btn {
  display: inline-flex; align-items: center; gap: 0.45rem; text-decoration: none;
  font-weight: 700; font-size: 0.95rem; padding: 0.5rem 0.85rem; min-height: 2.75rem;
}
.world-btn:hover, .world-nav-btn:hover:not(:disabled), .world-stop:hover { background: rgba(140, 28, 34, 0.9); border-color: var(--gold); color: #fff; }
.world-btn:focus-visible, .world-nav-btn:focus-visible, .world-stop:focus-visible, .world-card-action:focus-visible, .world-select:focus-visible {
  outline: 3px solid var(--gold); outline-offset: 3px;
}
.world-icon { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.world-nav-tour .world-icon { fill: currentColor; stroke-width: 1.5; }

/* Title (top left) and the Refresh / Download / Sign out buttons (bottom right, out of the scene's way) */
.world-bar { position: absolute; inset: 0; pointer-events: none; }
.world-bar > * { pointer-events: auto; }
.world-bar-title { position: absolute; top: 12px; left: 16px; }
.world-bar-actions { position: absolute; right: 16px; bottom: 16px; }
.world-bar-title {
  display: flex; flex-direction: column; padding: 0.4rem 0.9rem; border-radius: 12px;
  background: rgba(24, 14, 18, 0.62); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.world-bar-title strong { font-family: "Libre Baskerville", Georgia, serif; font-size: 1.15rem; color: var(--gold); }
.world-updated { font-size: 0.85rem; opacity: 0.9; }
.world-bar-actions { display: flex; gap: 0.5rem; flex-wrap: nowrap; justify-content: flex-end; white-space: nowrap; }

/* List of stops (wide screens): a slim column of numbers that opens to show names
   when the mouse is over it or a stop button has keyboard focus. */
.world-stops {
  position: absolute; right: 16px; top: 12px; width: 3.6rem; max-height: calc(100% - 104px); overflow: hidden auto;
  padding: 0.5rem 0.4rem; border-radius: 16px; transition: width 0.25s ease;
  background: rgba(24, 14, 18, 0.62); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.world-stops:hover, .world-stops:focus-within { width: 15.5rem; }
.world-stops-title { margin: 0 0 0.5rem; font-weight: 700; font-size: 0.85rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: clip; }
.world-stops:not(:hover):not(:focus-within) .world-stops-title { text-align: center; font-size: 0; }
.world-stops:not(:hover):not(:focus-within) .world-stops-title::before { content: "Stops"; font-size: 0.7rem; }
.world-stop-name { white-space: nowrap; }
.world-stops:not(:hover):not(:focus-within) .world-stop-name {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.world-stops-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.15rem; }
.world-stop {
  width: 100%; display: flex; align-items: center; gap: 0.6rem; text-align: left;
  padding: 0.25rem 0.45rem; min-height: 2.35rem; font-size: 0.95rem; border-color: transparent; background: transparent;
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.world-stop-num {
  flex: none; width: 1.7rem; height: 1.7rem; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 0.85rem; background: rgba(255, 247, 232, 0.14);
}
.world-stop.is-current { background: rgba(140, 28, 34, 0.92); border-color: var(--gold); font-weight: 700; }
.world-stop.is-current .world-stop-num { background: var(--gold); color: #1b1315; }

/* Info card */
.world-card {
  position: absolute; left: 16px; bottom: 96px; width: min(31rem, calc(100% - 32px));
  padding: 1.1rem 1.3rem 1.2rem; border-radius: 18px;
  background: rgba(24, 14, 18, 0.82); border: 2px solid rgba(214, 167, 43, 0.55);
  -webkit-backdrop-filter: blur(12px) saturate(1.2); backdrop-filter: blur(12px) saturate(1.2);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
/* Wide screens: a slimmer card leaves more room beside it for the exhibits. */
@media (min-aspect-ratio: 21/20) {
  .world-card { width: min(31rem, 36vw, calc(100% - 32px)); }
}
.world-card.is-in { animation: world-card-in 0.55s ease both; }
@keyframes world-card-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.world-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.world-card-step { margin: 0; font-size: 0.85rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }
.world-select { display: none; font-size: 0.95rem; padding: 0.35rem 0.5rem; min-height: 2.6rem; max-width: 60%; }
.world-card-title { margin: 0.25rem 0 0.4rem; font-family: "Libre Baskerville", Georgia, serif; font-size: 1.55rem; line-height: 1.25; color: #fff; }
.world-card-big { margin: 0 0 0.45rem; display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.world-card-num { font-size: clamp(2.3rem, 4.6vw, 3.2rem); font-weight: 700; line-height: 1; color: #f6d27a; }
.world-card-lbl { font-size: 1.05rem; font-weight: 700; }
.world-card-text { margin: 0; font-size: 1.05rem; line-height: 1.55; }
.world-card-action {
  margin-top: 0.85rem; font-weight: 700; font-size: 1rem; padding: 0.55rem 1rem; min-height: 2.9rem;
  background: var(--gold); color: #1b1315; border-color: var(--gold);
}
.world-card-action:hover { background: #f3cf6a; }
.world-card-action[hidden] { display: none; }
.world-card-more { display: none; }
.world-menu-btn, .world-menu-tour { display: none; }

/* Previous / tour / next */
.world-nav { position: absolute; left: 16px; bottom: 16px; display: flex; gap: 0.6rem; }
.world-nav-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-weight: 700; font-size: 1.1rem; padding: 0.7rem 1.25rem; min-height: 3.4rem; min-width: 8.5rem;
}
.world-nav-btn:disabled { opacity: 0.45; cursor: default; }
.world-nav-next { background: rgba(140, 28, 34, 0.92); border-color: var(--gold); }
.world-nav-tour[aria-pressed="true"] { background: var(--gold); color: #1b1315; border-color: var(--gold); }

/* Tip, hint, fade */
.world-tip {
  position: absolute; left: 0; top: 0; max-width: 20rem; pointer-events: none;
  padding: 0.55rem 0.8rem; border-radius: 10px; font-size: 1rem; line-height: 1.4;
  background: #fff7e8; color: #1b1315; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.world-tip strong { color: var(--red); }
.world-tip[hidden] { display: none; }
.world-help {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); margin: 0; max-width: min(32rem, calc(100% - 32px)); text-align: center;
  padding: 0.6rem 0.95rem; border-radius: 12px; font-size: 0.95rem;
  background: rgba(24, 14, 18, 0.78); border: 1px solid rgba(214, 167, 43, 0.5);
  animation: world-card-in 0.6s ease both;
}
.world-help[hidden] { display: none; }
.world-fade { position: absolute; inset: 0; background: #120a0c; opacity: 0; pointer-events: none; }
.world-fade.is-on { animation: world-fade 0.6s ease; }
@keyframes world-fade { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }

/* Loading screen */
.world-loading {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 5;
  background: radial-gradient(ellipse at 50% 85%, #ffb347 0%, #e0573f 22%, #7b2c55 48%, #241330 78%);
  transition: opacity 0.8s ease;
}
.world-loading.is-done { opacity: 0; pointer-events: none; }
.world-loading[hidden] { display: none; }
.world-loading-inner { text-align: center; padding: 1.5rem; max-width: 28rem; }
.world-loading-mark {
  display: inline-grid; place-items: center; width: 4.6rem; height: 4.6rem; border-radius: 50%;
  background: var(--gold); color: #1b1315; font-family: "Libre Baskerville", Georgia, serif; font-weight: 700; font-size: 1.6rem;
  box-shadow: 0 0 40px rgba(255, 200, 100, 0.6);
}
.world-loading-title { margin: 0.8rem 0 0.2rem; font-family: "Libre Baskerville", Georgia, serif; font-size: 1.6rem; color: #fff; }
.world-loading-text { margin: 0 0 1rem; font-size: 1.1rem; }
.world-progress { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.25); overflow: hidden; }
.world-progress span { display: block; height: 100%; width: 0; background: #fff7e8; transition: width 0.5s ease; }
.world-loading.is-error .world-progress { display: none; }
.world-loading-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.world-loading-actions[hidden] { display: none; }
.world-btn-big { font-size: 1.05rem; padding: 0.7rem 1.1rem; min-height: 3.2rem; }

/* ---- Phones and narrow windows ---- */
@media (max-width: 1260px) {
  .world-bar-actions { bottom: auto; top: 12px; }
  .world-btn span { display: none; }
  .world-btn { padding: 0.45rem; min-width: 2.9rem; justify-content: center; }
  .world-stops { top: 76px; max-height: calc(100% - 160px); }
}
/* With "Larger text" on, everything is bigger, so switch to the compact buttons sooner. */
@media (max-width: 1540px) {
  html.text-larger .world-bar-actions { bottom: auto; top: 12px; }
  html.text-larger .world-btn span { display: none; }
  html.text-larger .world-btn { padding: 0.45rem; min-width: 2.9rem; justify-content: center; }
  html.text-larger .world-stops { top: 76px; max-height: calc(100% - 160px); }
}
@media (max-width: 900px) {
  .world-stops { display: none; }
  .world-select { display: block; }
}
/* ---- Phones (held upright or sideways) ----
   The 3D world fills the whole screen, edge to edge. A slim, see-through header with the
   Classic / 3D switch sits on top, the card starts short ("More" shows the rest), and the
   buttons stay clear of the iPhone's home bar. */
@media (max-width: 640px), (max-height: 520px) and (orientation: landscape) {
  body.world-mode .site-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 20;
    background: rgba(110, 20, 26, 0.82); border-bottom-width: 3px;
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    padding-top: env(safe-area-inset-top);
  }
  body.world-mode .site-header .wrap-wide {
    padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right));
  }
  body.world-mode .header-inner { flex-wrap: nowrap; padding-top: 0.3rem; padding-bottom: 0.3rem; gap: 0.5rem; }
  body.world-mode .brand { display: none; }
  body.world-mode .header-tools { flex: 1; flex-wrap: nowrap; justify-content: space-between; gap: 0.5rem; }
  body.world-mode .view-switch { font-size: 0.9rem; gap: 0.45rem; }
  body.world-mode .view-switch-button { width: 3.3rem; height: 1.85rem; }
  body.world-mode .view-switch-thumb { width: calc(1.85rem - 10px); height: calc(1.85rem - 10px); }
  body.world-mode .view-switch-button[aria-checked="true"] .view-switch-thumb { transform: translateX(1.45rem); }
  body.world-mode .text-size-toggle { font-size: 0.8rem; padding: 0.3rem 0.75rem; min-height: 2.4rem; }
  body.world-mode .world { position: fixed; inset: 0; z-index: 10; }

  .world-hud { --top: calc(env(safe-area-inset-top) + 3rem + 14px); --bottom: env(safe-area-inset-bottom); }
  .view-switch-long { display: none; }
  .world-bar-title, .world-stops, .world-help { display: none !important; }
  /* Bottom row: Previous, Next, Menu (Menu holds Play tour, Refresh, Download and Sign out). */
  .world-menu-btn {
    display: inline-flex; position: absolute; bottom: calc(8px + var(--bottom)); right: max(8px, env(safe-area-inset-right));
    width: 5.4rem; justify-content: center; font-size: 0.95rem; font-weight: 700; padding: 0.55rem 0.4rem; min-height: 3.1rem; gap: 0.35rem;
  }
  .world-menu-btn[aria-expanded="true"] { background: var(--gold); color: #1b1315; border-color: var(--gold); }
  .world-menu-btn span { display: inline; }
  .world-menu-tour { display: inline-flex; }
  .world-nav .world-nav-tour { display: none; }
  .world-bar-actions {
    display: none; bottom: calc(3.1rem + 18px + var(--bottom)); top: auto; right: max(8px, env(safe-area-inset-right)); z-index: 3;
    flex-direction: column; align-items: stretch; gap: 0.4rem; padding: 0.5rem; border-radius: 14px;
    background: rgba(24, 14, 18, 0.9); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  }
  .world-bar.is-menu-open .world-bar-actions { display: flex; }
  .world-bar-actions .world-btn { justify-content: flex-start; font-size: 1rem; padding: 0.55rem 0.9rem; min-height: 3rem; }
  .world-bar-actions .world-btn span { display: inline; }
  .world-select { display: block; }

  .world-nav {
    left: max(8px, env(safe-area-inset-left)); right: calc(max(8px, env(safe-area-inset-right)) + 5.4rem + 0.4rem);
    bottom: calc(8px + var(--bottom)); gap: 0.4rem;
  }
  .world-nav-btn { flex: 1; min-width: 0; font-size: 0.95rem; padding: 0.55rem 0.25rem; min-height: 3.1rem; white-space: nowrap; gap: 0.3rem; }
  /* With "Larger text" on, the arrows alone (bigger) keep everything on one row. */
  html.text-larger .world-nav-btn > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  html.text-larger .world-nav-btn .world-icon { width: 1.6em; height: 1.6em; }

  .world-card {
    left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); width: auto;
    bottom: calc(3.1rem + 18px + var(--bottom)); padding: 0.75rem 0.95rem 0.8rem;
    max-height: calc(100% - var(--top) - 3.1rem - 30px - var(--bottom) - 3.5rem); overflow: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  }
  .world-card-head { gap: 0.5rem; }
  .world-card-step { font-size: 0.78rem; white-space: nowrap; }
  .world-select { max-width: 62%; font-size: 0.9rem; min-height: 2.5rem; }
  /* The stop's name is already in the menu at the top of the card. */
  .world-card-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }
  .world-card-big { margin-top: 0.45rem; }
  .world-card-big { margin-bottom: 0.3rem; gap: 0.45rem; }
  .world-card-num { font-size: 2.1rem; }
  .world-card-lbl { font-size: 0.98rem; }
  .world-card-text { font-size: 1rem; line-height: 1.45; }
  .world-card:not(.is-open) .world-card-text {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  }
  .world-card:not(.is-open) .world-card-action { display: none; }
  .world-card-more {
    display: inline-block; margin-top: 0.35rem; padding: 0.3rem 0; min-height: 2.4rem;
    font: inherit; font-weight: 700; font-size: 0.95rem; color: #f6d27a; background: none; border: 0; cursor: pointer;
    text-decoration: underline; text-underline-offset: 4px;
  }
  .world-card-more:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
  .world-card-more[hidden] { display: none; }
  .world-card-action { margin-top: 0.5rem; width: 100%; }
}

/* Phones turned sideways: the card moves to the left, the scene shows on the right. */
@media (max-height: 520px) and (orientation: landscape) {
  .world-card { right: auto; width: min(24rem, 44%); max-height: calc(100% - var(--top) - 3.1rem - 30px - var(--bottom)); padding: 0.55rem 0.8rem 0.6rem; }
  .world-card-big { margin-top: 0.3rem; margin-bottom: 0.2rem; }
  .world-card-num { font-size: 1.8rem; }
  .world-card-more { margin-top: 0.15rem; min-height: 2.2rem; }
  .world-nav { right: auto; width: calc(min(24rem, 44%) - 5.8rem); }
  .world-menu-btn { right: auto; left: calc(max(8px, env(safe-area-inset-left)) + min(24rem, 44%) - 5.4rem); }
  .world-bar-actions { right: auto; left: max(8px, env(safe-area-inset-left)); }
}

@media (prefers-reduced-motion: reduce) {
  .world-card.is-in, .world-help { animation: none; }
  .view-switch-thumb, .world-loading, .world-progress span { transition: none; }
}
