* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;      /* menu screen never scrolls */
  background: #000;
  cursor: default;
}

/* ---- Menu (p5 canvas) ---- */
#menu {
  position: fixed;
  inset: 0;              /* fills the entire viewport */
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: #000000;
  z-index: 1;
}

#menu canvas {
  display: block;
  margin: 0;
  padding: 0;
  border: none;
  outline: none;
}

#menuControls {
  position: fixed;
  left: 12px;
  bottom: 7px;
  z-index: 5;
  display: flex;
  gap: 10px;
}

#radioMenuBtn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 5;
}

.menu-link {
  appearance: none;
  border: none;
  background: transparent;
  color: #ffffff;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1;
  padding: 8px;
  cursor: pointer;
}

.menu-link.is-active {
  color: #828282;
}

.menu-link:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.7);
  outline-offset: 2px;
}

/* ---- Radio screen: fullscreen YouTube video ---- */
#radio {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: #000000;
  z-index: 20;
  display: none;
}

#radio.visible {
  display: block;
}

#radioVideo {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

#radioCloseBtn {
  position: absolute;
  top: 16px;
  right: 22px;
  z-index: 21;
  background: transparent;
  border: none;
  color: #ffffff;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 34px;
  line-height: 1;
  padding: 6px 10px;
  cursor: pointer;
  opacity: 0.85;
}

#radioCloseBtn:hover {
  opacity: 1;
}

/* ---- Story screen ---- */
#story {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background-color: #000000;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 2;
  display: none;         /* hidden until Start is clicked */
}

#story.visible {
  display: block;
}

/* soft white flash overlay: sits BEHIND .story-content (lower z-index), so it
   only shows through the black gaps between rows -- it never washes out an
   image or a block of text, both of which are fully opaque on top of it */
#flashOverlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}

/* ---- Story content: alternating photo/text rows over the black screen ---- */
.story-content {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 12vh 6vw 10vh;
  box-sizing: border-box;
  color: #f2f2f2;
  font-family: Helvetica, Arial, sans-serif;
}

/* the fragment of the closing line that opens the piece, echoing its own ending */
.story-epigraph {
  max-width: 640px;
  margin: 0 0 16vh;
  font-size: clamp(13px, 1.4vw, 17px);
  font-style: italic;
  line-height: 1.6;
  color: #9a9a9a;
}

.story-epigraph p {
  margin: 0;
}

.story-row {
  display: flex;
  align-items: center;
  justify-content: space-between; /* pins the two children to opposite edges of the row */
  gap: 3vw; /* minimum gap if both children are already at max-width */
  margin-bottom: 14vh;
  flex-wrap: wrap;
}

.story-row.row-left {
  flex-direction: row;
}

.story-row.row-right {
  flex-direction: row-reverse;
}

/* two photos, no text -- pure visual breathing room between passages */
.story-row.story-row--double {
  flex-direction: row;
}

.story-media {
  flex: 1 1 420px;
  max-width: 520px;
}

.story-row--double .story-media {
  flex: 0 1 480px;
}

.story-img {
  display: block;
  width: 100%;
  height: auto;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  filter: saturate(0.95) contrast(1.02);
  transition: opacity 0.15s ease, transform 0.25s ease, filter 0.4s ease, box-shadow 0.4s ease;
}

.story-img:hover {
  opacity: 0.92;
}

.story-img:active {
  transform: scale(0.995);
}

/* plasticobject.png becomes a freely draggable, resizable object once double-clicked.
   It's positioned absolutely *within* .story-content (not the viewport), so it scrolls
   naturally along with the rest of the page instead of staying pinned in place. */
.story-img.is-plastic {
  position: absolute;
  z-index: 50;
  cursor: grab;
  filter: none;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  transition: box-shadow 0.3s ease;
  touch-action: none; /* let pointer events drive the drag, not native scroll/gesture */
}

.story-img.is-plastic.is-dragging {
  cursor: grabbing;
  transition: none;
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.7);
}

/* small square handle at the plastic object's bottom-right corner --
   drag it to stretch/squash the object (changes both its size and its shape) */
.plastic-resize-handle {
  position: absolute;
  z-index: 51;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.4);
  cursor: nwse-resize;
  display: none;
  touch-action: none;
}

.plastic-resize-handle.visible {
  display: block;
}

/* on touch devices the visible 18px handle is too small to reliably grab --
   this invisibly extends its tappable area without changing its look or
   the JS math that positions it at the image's corner */
@media (pointer: coarse) {
  .plastic-resize-handle::before {
    content: "";
    position: absolute;
    inset: -12px;
  }
}

.story-text {
  flex: 1 1 320px;
  max-width: 480px;
  font-size: clamp(14px, 1.6vw, 19px);
  line-height: 1.6;
  color: #e8e8e8;
}

.story-text p {
  margin: 0 0 1.1em;
}

.story-text p:last-child {
  margin-bottom: 0;
}

/* stand-alone text passages, not paired with an image */
.story-text-block {
  max-width: 640px;
  margin: 0 0 14vh;
  font-size: clamp(14px, 1.6vw, 19px);
  line-height: 1.6;
  color: #e8e8e8;
}

.story-text-block p {
  margin: 0 0 1.1em;
}

.story-text-block p:last-child {
  margin-bottom: 0;
}

.story-text-block.centered {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.story-text-block.closing {
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.story-text-block.closing-final {
  margin-top: -6vh;
  margin-bottom: 6vh;
}

/* stack image over text on narrow screens */
@media (max-width: 720px) {
  .story-row,
  .story-row.row-right,
  .story-row.story-row--double {
    flex-direction: column;
    align-items: flex-start;
    gap: 4vh;
  }
  .story-media {
    max-width: 100%;
  }
}

/* invisible spacer that just gives the story screen a little extra scroll room at the end */
#story-spacer {
  height: 20vh;
  width: 100%;
}
