/* ==========================================================
   Demo page. Builds on styles.css (load that first).
   ========================================================== */

[hidden] {
  display: none !important;
}

.page--wide {
  max-width: 1680px;
}

.before {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 48px;
  padding-block: 24px 8px;
}

/* ---------- the stack of original files ---------- */

.stack {
  position: relative;
  padding-bottom: 88px;
}

/* Reserves height for the cascade: one card (62% wide, 16:9) plus three offsets. */
.stack::before {
  content: "";
  display: block;
  padding-top: calc(62% * 9 / 16 + 3 * 7%);
}

.file {
  position: absolute;
  top: calc(var(--i) * 7%);
  left: calc(var(--i) * 12.6%);
  width: 62%;
  border: 3px solid var(--frame);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: 7px 7px 0 var(--hard-shadow);
  transition: transform 0.2s ease, filter 0.2s ease;
}

.file:not(.is-front) {
  filter: brightness(0.62);
  cursor: pointer;
}

.file:not(.is-front):hover {
  filter: brightness(0.85);
  transform: translate(-3px, -3px);
}

.file-tab {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 7px 12px;
  border: 0;
  border-bottom: 2px solid var(--frame);
  background: var(--panel-raised);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  text-align: left;
  cursor: pointer;
}

.file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  flex: none;
  color: var(--dim);
}

.is-front .file-tab {
  color: var(--lavender);
  cursor: default;
}

.file-view {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg);
}

.file-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.is-front .file-slide {
  cursor: pointer;
}

.file-missing {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--dim);
  font-family: var(--hand);
  font-size: 1.2rem;
}

.file-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px;
  border-top: 2px solid var(--frame);
  color: var(--dim);
  font-size: 0.75rem;
}

.file-nav button {
  width: 30px;
  height: 26px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.file-nav button:hover:not(:disabled) {
  color: var(--lavender);
}

.file-nav button:disabled {
  opacity: 0.3;
  cursor: default;
}

/* ---------- intro text + arrow ---------- */

.intro {
  position: relative;
  align-self: start;
  padding-top: 8px;
}

.intro-eyebrow {
  color: var(--dim);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

.intro h1 {
  margin-top: 14px;
  font-size: clamp(1.6rem, 2.8vw, 2.4rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.intro-hint {
  margin-top: 18px;
  color: var(--mustard);
  font-family: var(--hand);
  font-size: 1.15rem;
}

.hint-narrow {
  display: none;
}

.swoop {
  display: block;
  width: 84px;
  height: auto;
  margin: 16px 0 0 18%;
  fill: none;
  stroke: var(--mustard);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.swoop-label {
  position: absolute;
  bottom: 50px;
  left: calc(18% + 96px);
  color: var(--mustard);
  font-family: var(--hand);
  font-size: 1.3rem;
  transform: rotate(-6deg);
}

/* ---------- the interactive lesson ---------- */

.after {
  padding: 8px 0 clamp(56px, 8vw, 96px);
}

/* As wide as the page allows, but never taller than the screen. */
.lesson {
  width: min(100%, calc((100vh - 120px) * 16 / 9));
  margin-inline: auto;
  border: var(--border) solid var(--navy);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 10px 10px 0 var(--hard-shadow);
  overflow: hidden;
}

.lesson-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-bottom: var(--border) solid var(--frame);
  background: var(--panel-raised);
  font-size: 0.82rem;
}

.lesson-dots {
  display: inline-flex;
  gap: 6px;
}

.lesson-dots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--frame);
}

.lesson-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--dim);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lesson-bar a {
  color: var(--lavender);
  white-space: nowrap;
}

.lesson-bar a:hover {
  text-decoration: underline wavy var(--squiggle);
  text-underline-offset: 5px;
}

.lesson iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  background: #fff;
}

.footer a {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--dim) 50%, transparent);
  text-underline-offset: 4px;
}

/* ---------- smaller screens ---------- */

@media (max-width: 860px) {
  .before {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }

  .intro {
    order: -1;
  }

  .swoop,
  .swoop-label,
  .hint-wide {
    display: none;
  }

  .hint-narrow {
    display: inline;
  }

  .intro-hint {
    margin-top: 10px;
  }

  .stack::before {
    padding-top: calc(100% * 9 / 16 + 3 * 9.5%);
  }

  .file {
    top: calc(var(--i) * 9.5%);
    left: calc(var(--i) * 8%);
    width: 76%;
    transition: left 0.25s ease, width 0.25s ease, filter 0.2s ease;
  }

  .file.is-front {
    left: 0;
    width: 100%;
  }

}

@media (max-width: 640px) {
  .lesson iframe {
    aspect-ratio: 4 / 3;
  }

  .lesson-name {
    display: none;
  }

  .lesson-bar {
    justify-content: space-between;
  }
}
