:root {
  --bg-color: #ffffff;
  --accent-color: #090909;
  --font-family: 'Roboto', sans-serif;
  --header-height: 70px;
  /* Maximum body width — nothing is wider than this */
  --wrapper-width: 744px;
  /* Side padding inside the column — applied on each side */
  --col-padding: 90px;
  /* Text area height = top half below the header */
  --text-height: calc(50vh - var(--header-height) - 20px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-color);
  color: var(--accent-color);
  font-family: var(--font-family);
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100vh;
  overflow: hidden;
}

/* Header Styling */
.app-header {
  position: absolute; /* Changed from fixed to absolute to prevent layout shifts */
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(100vw - 8px), var(--wrapper-width));
  height: var(--header-height);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 45px 0 50px;
  border-bottom: 1px solid var(--accent-color);
  background: var(--bg-color);
  z-index: 1000;
  font-size: 16px;
  white-space: nowrap;
}

#chapter {  border-bottom: 1px solid var(--bg-color);
  background: var(--accent-color);}

#header-left, #header-right {
  display: flex;
  align-items: center;
}

#header-right button {
  background: none;
  border: none;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
  padding: 0;
  margin: 0;
  text-decoration: none;
}

#header-right button:hover {
  text-decoration: underline;
}

/* Main Content Layout */
#story-column {
  margin-top: var(--header-height);
  /* Fill viewport, min 4px gap each side, hard cap at wrapper-width */
  width: min(calc(100vw - 8px), var(--wrapper-width));
  height: calc(100vh - var(--header-height));
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Content is narrower by col-padding on each side */
  padding: 0 var(--col-padding);
  overflow: hidden;
  position: relative;
}

#texts-container {
  width: 100%;
  height: var(--text-height);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  font-size: 24px;
  line-height: 1.25;
  margin-bottom: 20px;
}

#texts-content-wrapper {
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.story-event {
  margin-bottom: 1.5em;
  text-align: left;
  width: 100%;
  position: relative;
}

/* Figure Wrapper — inherits column content width, maintains aspect-ratio */
.figure-wrapper {
  position: absolute;
  top: calc(50vh - var(--header-height));
  left: 50%;
  transform: translateX(-50%);
  aspect-ratio: 561 / 490;
  /* Width matches the column's inner content width */
  width: calc(min(100vw - 8px, var(--wrapper-width)) - 2 * var(--col-padding));
  /* Height is capped at the available bottom half */
  max-height: calc(50vh - 40px);
  border: 1px solid var(--accent-color);
  background-color: var(--bg-color);
  display: flex;
  flex-direction: column;
}

/* #app-figure-wrapper { 
  
} */

#canvas-container {
  flex: 1;
  width: 100%;
  position: relative;
  overflow: hidden;
}

canvas {
  display: block;
}

/* Pitch Engine Integration in Box */
#pitch-app {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  display: none; /* Controlled by sketch.js */
  z-index: 20;
}

/* Static Label at bottom of Figure Box */
#interactive-label {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 50%);
  background: var(--bg-color);
  padding: 0 15px;
  font-size: 20px;
  z-index: 30;
  pointer-events: none;
  white-space: nowrap;
}

/* Media styles */
.media-container {
  margin: 1rem 0 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.story-media {
  max-width: 100%;
  max-height: 400px;
  border: 1px solid var(--accent-color);
}

.story-audio {
  width: 100%;
}

/* Text Reveal Animation Styles */
.story-event .word {
  display: inline-block;
}

/* ─── Mobile Breakpoint ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
  :root {
    /* No side padding on mobile — content fills 100% width */
    --col-padding: 0px;
  }

  /* Tighten header padding to match */
  #app-header {
    padding: 0 12px;
  }
}

/* ─── Static Pages Styles ───────────────────────────────────────────────── */
body.static-page-body {
  background-color: var(--bg-color); /* White for intro by default */
  color: var(--accent-color);
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
  overflow: hidden;
}

body.dark-theme {
  background-color: var(--accent-color); /* Black */
  color: var(--bg-color); /* White */
}

.static-page-wrapper {
  width: 100%;
  max-width: var(--wrapper-width, 744px);
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

#run-chapter {
  color: var(--bg-color);
}

/* Base link styles for static CTAs */
.static-page-wrapper a {
  text-decoration: none;
  font-family: inherit;
  font-size: clamp(16px, 4vw, 20px);
  cursor: pointer;
}

/* Intro Screen */
.intro-wrapper {
  justify-content: space-between;
}

.intro-nav {
  margin-top: 50px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 16px;
}
.intro-nav p { margin: 0; }

.intro-center-block {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: url('/media/pitch_in_menu.svg');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  color: var(--bg-color);
}

.intro-bg-rect {
  width: 100%;
  max-width: 666px;
  
  /*transform: rotate(-30deg);*/
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
}

.intro-title {
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 900;
  font-size: clamp(32px, 8vw, 64px);
  line-height: 1;
  letter-spacing: -1.28px;

  margin: 0;
  transform: rotate(-30deg);
}

.intro-cta {
  color: var(--bg-color);
  align-self: flex-end;
  transform: rotate(-30deg);
}

.intro-footer {
  margin-bottom: 50px;
  display: flex;
  justify-content: flex-end;
}
.intro-subtitle {
  font-size: 16px;
  text-align: right;
  max-width: 250px;
}

/* Chapter Intro Screen */
.chapter-wrapper {
  padding-top: 50px;
  gap: 40px;
}

.chapter-header-row {
  display: flex;
  flex-direction: column; /* Stack button above titles */
  align-items: center;    /* Center the titles block horizontally */
  gap: 30px;              /* Space between button and titles */
  width: 100%;
  position: relative;     /* Ensure positioning context if needed */
}

/* Target the button container or the button itself to push it to the top-right */
/* Assuming the button is wrapped in a div or is the first child, we can use: */
.chapter-cta {
  align-self: flex-end; /* Pushes the button to the right side of the row */
  margin-bottom: 0;
}

/* If .chapter-cta isn't the direct child, you might need to target the wrapper 
   containing the button inside .chapter-header-row. 
   If the HTML structure is: <div class="chapter-header-row"><button>...</button><div class="chapter-titles">...</div></div>
   Then the above .chapter-cta rule works if the button has that class. 
   If the button is just a direct element, we might need:
   
   .chapter-header-row > :first-child {
       align-self: flex-end;
   }
*/

.chapter-titles {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center; /* Center text within this column */
  width: 100%;         /* Ensure it spans full width for centering to work */
  text-align: center;
}

.chapter-label {
  font-size: 20px;
  margin: 0;
  text-align: center;
  text-transform: uppercase; /* All Caps */
  letter-spacing: 1px;
}

.chapter-title {
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 900;
  font-size: clamp(40px, 10vw, 96px);
  line-height: 1;
  margin: 0;
  text-align: center;
  text-transform: uppercase; /* All Caps */
  letter-spacing: -1px;
}

.chapter-cta {
  color: var(--bg-color);
  font-size: 16px;
}

.chapter-content-row {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

.chapter-notes {
  font-size: 24px;
  line-height: 1.25;
  white-space: pre-wrap;
}

.video-placeholder {
  width: 100%;
  aspect-ratio: 560/492;
  border: 1px solid var(--bg-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  position: relative;
}
.video-placeholder video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Outro Screen */
.outro-wrapper {
  justify-content: center;
  align-items: center;
  gap: 40px;
}

.outro-cta-wrapper {
  display: flex;
  justify-content: flex-end;
  width: 100%;
}

.outro-cta {
  color: var(--bg-color);
}
