/*
 * 13th Forum release surface
 *
 * Loaded last, after the brand, responsive, UI-lock, and speaker-launch
 * layers. This file owns only launch-state behavior: the scheduled program and
 * embedded game remain usable at every width, and final phone/touch
 * safeguards apply without changing the established visual system.
 */

html,
body {
  max-width: 100%;
}

main,
main > section,
.section-shell,
.speaker-session,
.speaker-card,
.game-section__inner,
.game-frame-shell,
.game-frame {
  min-width: 0;
}

main :is(h1, h2, h3, h4, p, a),
.site-footer a {
  overflow-wrap: break-word;
}

.primary-nav a,
.site-footer a[href^="#"],
.site-footer a[href^="mailto:"] {
  min-height: 44px;
}

.site-footer a[href^="mailto:"] {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
}

/* -------------------------------------------------------------------------
   Buzz to Bloom
   ------------------------------------------------------------------------- */

.game-section {
  position: relative;
  overflow: clip;
  background:
    radial-gradient(circle at 88% 13%, rgba(241, 168, 31, .16), transparent 26rem),
    linear-gradient(180deg, rgba(255, 255, 255, .34), rgba(235, 235, 235, .92));
}

.game-section::after {
  content: "";
  position: absolute;
  inset: auto -8rem -9rem auto;
  width: 23rem;
  aspect-ratio: 1;
  pointer-events: none;
  opacity: .32;
  background: url("butterfly-mark.svg") center / contain no-repeat;
  transform: rotate(-12deg);
}

.game-section__inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(240px, 330px) minmax(0, 1fr);
  align-items: start;
  gap: clamp(24px, 4vw, 56px);
}

.game-intro {
  position: sticky;
  top: 92px;
  padding: clamp(22px, 3vw, 32px);
  color: var(--color-text);
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(10, 87, 163, .16);
  border-top: 6px solid var(--brand-yellow);
  border-radius: 24px;
  box-shadow: var(--shadow-md);
}

.game-eyebrow {
  margin: 0 0 8px;
  color: #9f2943;
  font: 700 12px/1.4 var(--font-heading);
  letter-spacing: .13em;
  text-transform: uppercase;
}

.game-intro h2 {
  max-width: 12ch;
  color: var(--brand-blue-dark);
  text-wrap: balance;
}

.game-intro__lead {
  margin: 18px 0 0;
  color: color-mix(in srgb, var(--color-text) 78%, transparent);
  font-size: 15px;
  line-height: 1.6;
}

.game-loop {
  display: grid;
  gap: 8px;
  margin: 22px 0;
  padding: 0;
  list-style: none;
  counter-reset: game-step;
}

.game-loop li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--brand-blue-dark);
  font: 600 14px/1.35 var(--font-heading);
  counter-increment: game-step;
}

.game-loop li::before {
  content: counter(game-step);
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #ffffff;
  background: var(--brand-blue-dark);
  border-radius: 50%;
  font-size: 12px;
}

.game-loop li:nth-child(2)::before { background: var(--brand-blue-mid); }
.game-loop li:nth-child(3)::before { background: var(--brand-red); }
.game-loop li:nth-child(4)::before { background: #956000; }

.game-intro__rule {
  margin: 0 0 14px;
  padding: 12px 14px;
  color: #4d3500;
  background: rgba(241, 168, 31, .15);
  border-left: 4px solid var(--brand-yellow);
  border-radius: 0 10px 10px 0;
  font-size: 13px;
  line-height: 1.55;
}

.game-new-page,
.game-frame-link {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--brand-blue-dark);
  border-radius: 10px;
  font: 600 14px/1.3 var(--font-heading);
  text-underline-offset: 4px;
}

.game-new-page:focus-visible,
.game-frame-link:focus-visible {
  outline: 3px solid var(--brand-yellow);
  outline-offset: 3px;
}

.game-frame-shell {
  overflow: hidden;
  background: #fffdf8;
  border: 1px solid rgba(10, 87, 163, .18);
  border-radius: clamp(16px, 2vw, 26px);
  box-shadow: var(--shadow-lg);
}

.game-frame-toolbar,
.game-frame-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-inline: clamp(14px, 2vw, 22px);
}

.game-frame-toolbar {
  min-height: 48px;
  color: var(--brand-blue-dark);
  background: rgba(72, 152, 211, .11);
  border-bottom: 1px solid rgba(10, 87, 163, .13);
  font: 700 12px/1.3 var(--font-heading);
  letter-spacing: .07em;
  text-transform: uppercase;
}

.game-frame-toolbar__status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #4f5d6a;
  font-size: 11px;
  letter-spacing: .02em;
  text-transform: none;
}

.game-frame-toolbar__status::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: none;
  background: #28785c;
  border-radius: 50%;
}

.game-frame {
  width: 100%;
  background: #f8f4eb;
}

.game-frame iframe {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 760px;
  min-width: 0;
  border: 0;
  background: #f8f4eb;
}

.game-frame-footer {
  min-height: 58px;
  color: #4f5d6a;
  background: #ffffff;
  border-top: 1px solid rgba(10, 87, 163, .12);
  font-size: 12px;
  line-height: 1.5;
}

.game-frame-link {
  flex: none;
}

/* The embedded game remains intentionally light for legibility in Night
   mode; its surrounding panel adopts the page palette and keeps AA contrast. */
html[data-thinking-mode="ultra"] .game-section {
  background:
    radial-gradient(circle at 88% 13%, rgba(241, 168, 31, .11), transparent 26rem),
    var(--ultra-section) !important;
}

html[data-thinking-mode="ultra"] .game-intro,
html[data-thinking-mode="ultra"] .game-frame-shell {
  color: var(--ultra-ink) !important;
  background: var(--ultra-card) !important;
  border-color: var(--ultra-border) !important;
  box-shadow: none;
}

html[data-thinking-mode="ultra"] .game-intro h2,
html[data-thinking-mode="ultra"] .game-intro__lead {
  color: var(--ultra-ink) !important;
}

html[data-thinking-mode="ultra"] .game-loop li,
html[data-thinking-mode="ultra"] .game-new-page,
html[data-thinking-mode="ultra"] .game-frame-link {
  color: var(--ultra-link) !important;
}

html[data-thinking-mode="ultra"] .game-intro__rule {
  color: #fff0c8 !important;
  background: rgba(241, 168, 31, .12) !important;
}

@media (max-width: 1024px) {
  .game-section__inner {
    grid-template-columns: minmax(0, 1fr);
  }

  .game-intro {
    position: static;
  }

  .game-intro h2 {
    max-width: 18ch;
  }

  .game-loop {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 880px) {
  /* The bundled mobile layer pads both the item wrapper and the row. Keep
     the row padding (the touch target) and remove the duplicate outer band. */
  #program .section-shell > .program-item {
    padding-block: 0 !important;
  }
}

@media (max-width: 600px) {
  .primary-nav.is-open {
    gap: 8px;
  }

  .primary-nav a {
    min-height: 48px;
  }

  .speaker-launch__timeline,
  .speaker-launch__filters {
    scroll-padding-inline: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .speaker-session h3 {
    font-size: clamp(20px, 6.5vw, 24px);
    line-height: 1.18;
  }

  /* Phone agenda: retain the desktop schedule's time rail and title/meta
     column, but tighten the gutter for 320-430px screens. */
  #program .section-shell > .program-item::before {
    display: none !important;
  }

  #program .section-shell .program-row {
    grid-template-columns: 52px minmax(0, 1fr) !important;
    grid-template-rows: auto auto !important;
    gap: 6px 14px !important;
    min-width: 0;
    min-height: 70px !important;
    padding: 12px 10px !important;
    align-items: start !important;
  }

  #program .section-shell .program-row::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 69px;
    width: 1px;
    background: var(--line-soft);
  }

  #program .section-shell .program-row::after {
    display: block !important;
    top: 23px !important;
    left: 69px !important;
  }

  .program-row__time {
    grid-column: 1 !important;
    grid-row: 1 / 3 !important;
    align-self: start !important;
    padding: 1px 10px 0 0 !important;
    text-align: right !important;
    color: var(--brand-blue-dark) !important;
    font-size: .875rem;
    font-weight: 700;
  }

  .program-row__title {
    grid-column: 2 !important;
    grid-row: 1 !important;
    min-width: 0;
    font-size: clamp(1rem, 4.25vw, 1.08rem);
    line-height: 1.32 !important;
    text-wrap: pretty;
  }

  .program-row__meta {
    grid-column: 2 !important;
    grid-row: 2 !important;
    min-width: 0;
    justify-self: stretch !important;
    justify-content: flex-start !important;
    gap: 10px !important;
  }

  .program-row__meta .tag {
    min-width: 0 !important;
  }

  .program-row--plain .program-row__meta::after {
    display: none !important;
  }

  .program-row__meta > span[aria-hidden="true"] {
    margin-left: auto;
  }

  .program-panel {
    min-width: 0;
    margin-bottom: 20px !important;
    padding: 10px 12px 24px !important;
  }

  .program-panel .track-grid,
  .program-panel .track-card {
    min-width: 0;
    width: 100%;
  }

  .program-panel__actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 8px !important;
  }

  .program-panel__actions .btn,
  .program-panel__actions .text-link {
    display: inline-flex;
    align-items: center;
    width: 100%;
    max-width: 100%;
    min-height: 46px;
    justify-content: center;
    text-align: center;
  }

  .program-heading__actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px !important;
  }

  .program-heading__actions .btn {
    width: 100%;
    min-width: 0;
    padding-inline: 10px !important;
  }

  /* Let the four numbered themes size to their real content on phones. */
  .theme-card {
    min-height: 0 !important;
  }

  /* The locked-state arrow no longer consumes a permanent desktop column. */
  .notes-section .brandcard[style*="display: flex"] {
    align-items: flex-start !important;
    flex-direction: column;
    gap: 12px !important;
  }

  .notes-section .brandcard[style*="display: flex"] > div:first-child {
    font-size: 32px !important;
  }

  .notes-section .coming-soon .btn {
    width: 100%;
    white-space: normal;
  }

  /* A participant already viewing this site on a phone needs the room action,
     not a QR code displayed on the same device. Desktop keeps both. */
  #qa .qa-layout > div:first-child > .brandcard:first-child > div:nth-of-type(2) {
    display: block !important;
  }

  #qa .qa-layout > div:first-child > .brandcard:first-child > div:nth-of-type(2) > div:last-child {
    display: none !important;
  }

  #qa .qa-layout > div:first-child > .brandcard:first-child > div:nth-of-type(3) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 8px !important;
  }

  #qa .qa-layout > div:first-child > .brandcard:first-child > div:nth-of-type(3) > .btn {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    white-space: normal;
    text-align: center;
  }

  #qa .qa-layout > .brandcard > div:first-child {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 6px 10px !important;
  }

  #qa .qa-layout > .brandcard > div:first-child > span:nth-child(2) {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  #qa .qa-layout > .brandcard > div:first-child > .tag {
    grid-column: 2;
    justify-self: start;
  }

  #qa .qa-layout > .brandcard > div:first-child > span:last-child {
    grid-column: 1 / -1;
    margin-left: 0 !important;
    padding-top: 4px;
  }

  .game-section__inner {
    gap: 18px;
  }

  .game-intro {
    padding: 20px;
    border-radius: 18px;
  }

  .game-intro h2 {
    font-size: clamp(30px, 9vw, 38px) !important;
  }

  .game-loop {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    margin-block: 18px;
  }

  .game-new-page {
    width: 100%;
    padding-inline: 12px;
    border: 1px solid rgba(10, 87, 163, .2);
  }

  .game-frame-shell {
    margin-inline: -3px;
    border-radius: 16px;
  }

  .game-frame-toolbar {
    min-height: 44px;
    padding-block: 8px;
  }

  .game-frame-toolbar__status {
    max-width: 17ch;
    text-align: right;
  }

  .game-frame iframe {
    height: 880px;
  }

  .game-frame-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
    padding-block: 10px;
  }

  .game-frame-link {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 880px) {
  main section[id] {
    scroll-margin-top: calc(var(--mobile-masthead, 62px) + 12px);
  }
}

@media (max-width: 390px) {
  .primary-nav.is-open {
    grid-template-columns: minmax(0, 1fr);
  }

  .speaker-wave {
    flex-basis: min(254px, 82vw);
  }

  .speaker-session {
    padding: 16px;
  }

  .speaker-session .speaker-card {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .game-frame-toolbar__status {
    display: none;
  }

  .game-frame iframe {
    height: 920px;
  }
}

@media (max-width: 340px) {
  /* Three compact units scan faster and use less vertical space than the
     inherited two-row countdown at the narrowest supported width. */
  .countdown {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  .countdown__cell {
    min-height: 60px !important;
    padding-inline: 4px !important;
  }

  .countdown__cell:nth-child(3) {
    grid-column: auto !important;
    border-top: 0 !important;
    border-left: 1px solid var(--brand-line) !important;
  }

  .countdown__value {
    font-size: 1.35rem !important;
  }

  .countdown__label {
    font-size: .625rem !important;
    letter-spacing: .045em !important;
  }
}

@media (max-width: 350px) {
  .speaker-session .speaker-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .speaker-session .speaker-card__avatar {
    width: 76px;
    min-height: 92px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .game-section::after,
  .speaker-launch__timeline,
  .speaker-launch__filters,
  .game-frame {
    scroll-behavior: auto !important;
  }

  .game-section::after {
    transform: none;
  }
}
