/* -------------------------------------------------------------
   Tokens
   ------------------------------------------------------------- */
:root {
  --panel-width: 320px;
  --panel-bg: #F0E69B;
  --panel-fg: #1a1a1a;
  --panel-muted: #444;
  --panel-divider: rgba(0, 0, 0, 0.14);
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: "articulat-cf", "Articulat CF", "Articulat",
               -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--panel-fg);
}

/* -------------------------------------------------------------
   Canvas area — always shifted by panel width (panel is always open)
   ------------------------------------------------------------- */
#canvas-area {
  position: fixed;
  top: 0;
  left: var(--panel-width);
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: left 200ms ease;
}

.stage {
  position: relative;
  overflow: hidden;
}

/* -------------------------------------------------------------
   Layers
   ------------------------------------------------------------- */
.layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.layer.speaker {
  transition: transform 200ms ease-out;
  transform-origin: center center;
  will-change: transform;
}

/* -------------------------------------------------------------
   Side panel — always present, no slide-in.
   ------------------------------------------------------------- */
.panel {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--panel-width);
  height: 100vh;
  background: var(--panel-bg);
  z-index: 10;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* -------------------------------------------------------------
   Panel — back link (only visible in speaker mode)
   ------------------------------------------------------------- */
.panel-back {
  display: none;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  padding: 16px 24px 6px 24px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--panel-muted);
  cursor: pointer;
  text-align: left;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  transition: color 150ms ease;
}
.panel-back:hover,
.panel-back:focus-visible {
  color: #000;
  outline: none;
}
.panel-back-arrow { font-size: 14px; line-height: 1; }
.panel[data-mode="speaker"] .panel-back {
  display: flex;
}

/* -------------------------------------------------------------
   Panel — header (title + description)
   ------------------------------------------------------------- */
.panel-header {
  flex: 0 0 auto;
  padding: 28px 24px 8px 24px;
}
.panel[data-mode="speaker"] .panel-header {
  padding-top: 6px;
}

.c-title {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.panel[data-mode="intro"] .c-title {
  font-size: 26px;
}
.panel[data-mode="speaker"] .c-title {
  font-size: 17px;
}

.c-description {
  display: none;
  margin: 0 0 12px 0;
  font-size: 13px;
  color: var(--panel-muted);
  font-weight: 500;
}
.panel[data-mode="intro"] .c-description {
  display: block;
}

/* -------------------------------------------------------------
   Panel — body (scrollable)
   ------------------------------------------------------------- */
.panel-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px 24px 14px 24px;
}

.c-themes {
  margin: 0;
  font-size: 14px;
  color: #2a2a2a;
  line-height: 1.6;
}
.c-themes p { margin: 0 0 10px 0; }
.c-themes p:last-child { margin-bottom: 0; }

/* -------------------------------------------------------------
   Panel — footer (bio + link, pinned)
   ------------------------------------------------------------- */
.panel-footer {
  flex: 0 0 auto;
  padding: 14px 24px 24px 24px;
  border-top: 1px solid var(--panel-divider);
}

.c-about {
  margin: 0 0 10px 0;
  font-size: 13px;
  color: #2a2a2a;
  font-style: normal;
  line-height: 1.55;
}

.c-link {
  display: inline-block;
  font-size: 13.5px;
  font-weight: 500;
  color: #0a3a5c;
  text-decoration: none;
}
.c-link:hover,
.c-link:focus-visible {
  text-decoration: underline;
  outline: none;
}

/* -------------------------------------------------------------
   Speaker-mode stacking order (CSS-driven, DOM stays the same):
     back → title → themes → audio → (flex space) → bio + link
   The footer's `margin-top: auto` creates the breathing space
   between the audio bar and the pinned bio.
   ------------------------------------------------------------- */
.panel[data-mode="speaker"] .panel-back   { order: 0; }
.panel[data-mode="speaker"] .panel-header { order: 1; }
.panel[data-mode="speaker"] .panel-body   { order: 2; flex: 0 1 auto; }
.panel[data-mode="speaker"] #audio-player { order: 3; }
.panel[data-mode="speaker"] .panel-footer { order: 4; margin-top: auto; }

/* -------------------------------------------------------------
   Audio player — below the themes in speaker mode.
   Single row: small play button + scrubber line + time text.
   ------------------------------------------------------------- */
#audio-player {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 12px 24px 8px 24px;
  background: transparent;
}
.panel[data-mode="speaker"] #audio-player {
  display: flex;
}

.audio-play-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #1a1a1a;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 150ms ease, transform 150ms ease;
}
.audio-play-btn:hover { background: #000; transform: scale(1.05); }
.audio-play-btn:focus-visible {
  outline: 2px solid rgba(0, 0, 0, 0.4);
  outline-offset: 2px;
}

.audio-icon { width: 11px; height: 11px; fill: currentColor; }
.audio-icon-pause { display: none; }
#audio-player[data-playing="true"] .audio-icon-play { display: none; }
#audio-player[data-playing="true"] .audio-icon-pause { display: inline; }

.audio-progress {
  flex: 1;
  min-width: 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.20);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  overflow: visible;
}
.audio-progress:focus-visible {
  outline: 2px solid rgba(0, 0, 0, 0.4);
  outline-offset: 4px;
}

.audio-progress-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0%;
  background: #1a1a1a;
  border-radius: inherit;
  transition: width 100ms linear;
}

.audio-progress-fill::after {
  content: '';
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  background: #1a1a1a;
  border-radius: 50%;
  transition: width 150ms ease, height 150ms ease, right 150ms ease;
}
.audio-progress:hover .audio-progress-fill::after {
  width: 12px;
  height: 12px;
  right: -6px;
}

.audio-time {
  flex: 0 0 auto;
  font-size: 11px;
  color: #444;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.audio-time-sep { margin: 0 3px; color: #888; }

/* -------------------------------------------------------------
   Fullscreen toggle — floats over the artwork, subtle until hover.
   Travels with the page, so it works when embedded in an iframe too.
   ------------------------------------------------------------- */
.fullscreen-btn {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 20;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.45;
  transition: opacity 150ms ease, background-color 150ms ease, transform 150ms ease;
}
.fullscreen-btn:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.7);
  transform: scale(1.05);
}
.fullscreen-btn:focus-visible {
  opacity: 1;
  background: rgba(0, 0, 0, 0.7);
  outline: 2px solid rgba(255, 255, 255, 0.7);
  outline-offset: 2px;
}

.fs-icon { width: 18px; height: 18px; fill: currentColor; }
.fs-icon-compress { display: none; }
body.is-fullscreen .fs-icon-expand { display: none; }
body.is-fullscreen .fs-icon-compress { display: inline; }

/* -------------------------------------------------------------
   Mobile / narrow viewports — stack vertically instead of
   side-by-side. Illustration on top (height fitted to the
   artwork by JS), info panel below, whole page scrollable.
   ------------------------------------------------------------- */
@media (max-width: 768px) {
  html, body {
    overflow: visible;
    height: auto;
    min-height: 100%;
  }
  body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
  }

  /* Artwork: full width, in normal flow, height set by JS (fitStage). */
  #canvas-area {
    position: static;
    left: auto;
    width: 100%;
    flex: 0 0 auto;
    height: 50vh; /* fallback before JS sizes it to the artwork */
  }

  /* Panel: full width below the artwork, grows to fill the rest. */
  .panel {
    position: static;
    left: auto;
    top: auto;
    width: 100%;
    height: auto;
    flex: 1 1 auto;
  }

  /* Let the page scroll as one piece rather than scrolling inside the panel. */
  .panel-body { flex: 0 0 auto; overflow: visible; }
  .panel[data-mode="speaker"] .panel-body { flex: 0 0 auto; }
  .panel[data-mode="speaker"] .panel-footer { margin-top: 0; }
}
