/* ==========================================================================
   Converge-Con — Responsive Overrides
   Desktop styles in layout.css already flex with clamp()/min()/aspect-ratio;
   these breakpoints reflow the structures that are grid/absolute-based on
   desktop into stacked, document-flow layouts for tablet and mobile.
   ========================================================================== */

/* ---------------- Tablet: ≤ 1024px ---------------- */
@media (max-width: 1024px) {
  .site-header__inner {
    padding: 0.85rem clamp(0.75rem, 3vw, 1.5rem);
    gap: var(--space-4);
  }

  .logo-mark {
    width: clamp(8rem, 42vw, 20rem);
    max-width: calc(100vw - 13rem);
    height: clamp(1.5rem, 6.2vw, 3rem);
  }

  .site-header__tagline {
    font-size: clamp(0.5rem, 1.5vw, 0.75rem);
  }

  .hero-tagline-star {
    left: 0;
    right: auto;
    width: clamp(12rem, 48vw, 36rem);
    max-width: min(36rem, 88vw);
    /* Hang toward the left edge on tablet */
    transform: translate(calc(-20% + 2vw), calc(-55% + 4vh))
      rotate(var(--star-rot, 36deg));
  }

  /* Drop the enlarged logo mark toward page center on tablet */
  .site-header__brand {
    top: calc(50% + (1 - var(--brand-progress)) * clamp(10rem, 28vh, 18rem));
  }

  .btn-rsvp {
    font-size: clamp(0.95rem, 2.6vw, 1.35rem);
  }

  .star-menu {
    width: clamp(52px, 9vw, 80px);
    height: clamp(52px, 9vw, 80px);
    --star-radius: clamp(4rem, 9vw, 5.5rem);
  }

  .star-nav__item {
    font-size: clamp(0.95rem, 2.2vw, 1.25rem);
  }

  .speakers__grid {
    grid-template-columns: 1fr;
    row-gap: clamp(2rem, 6vw, 2.75rem);
  }

  .speaker-card {
    padding-top: clamp(1.5rem, 4vw, 2.25rem) !important;
  }

  .speaker-card .speaker-card__divider {
    display: block !important;
  }

  .speaker-card:first-child {
    padding-top: 0 !important;
  }

  .speaker-card:first-child .speaker-card__divider {
    display: none !important;
  }

  .hero__meta {
    grid-template-columns:
      minmax(0, 1fr)
      var(--hero-eye-size)
      minmax(0, 1fr);
  }
}

/* ---------------- Mobile: ≤ 768px ---------------- */
@media (max-width: 768px) {
  :root {
    --header-height: 88px;
    --font-size-body: 0.875rem;
  }

  .brand-band {
    /* Full-bleed to the screen edges */
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    height: 15vh;
    overflow: hidden;
  }

  /*
    Size the photo to the screen width (not zoomed via cover-to-band-height).
    Height follows the image aspect ratio; the band clips top/bottom.
  */
  .brand-band__photo {
    position: absolute;
    left: 0;
    top: 50%;
    right: auto;
    bottom: auto;
    width: 100%;
    max-width: none;
    height: auto;
    transform: translateY(-50%);
    object-fit: fill;
    object-position: center;
  }

  .site-header__inner {
    gap: var(--space-3);
    padding: 0.7rem clamp(0.65rem, 3vw, 1rem);
  }

  .logo-mark {
    width: clamp(5.75rem, 36vw, 9rem);
    max-width: calc(100vw - 11rem);
    height: clamp(1.1rem, 5.5vw, 1.75rem);
  }

  .site-header__tagline {
    font-size: clamp(0.45rem, 1.8vw, 0.625rem);
  }

  .hero-tagline-star {
    left: 0;
    right: auto;
    width: clamp(9rem, 58vw, 18rem);
    max-width: min(18rem, 78vw);
    top: calc(var(--header-height) * 0.55 + 2.5rem);
    /* Hang toward the left edge on mobile */
    transform: translate(calc(-22% + 2vw), calc(-50% + 3vh))
      rotate(var(--star-rot, 36deg));
  }

  .site-header__brand {
    /* Compact header mark; fades in on scroll (hero wordmark fades out) */
    top: 50%;
    transform: translate(-50%, -50%);
    opacity: var(--brand-progress, 0);
    pointer-events: none;
  }

  .site-header.is-scrolled .site-header__brand {
    pointer-events: auto;
  }

  .site-header__actions {
    gap: var(--space-3);
  }

  .btn-rsvp {
    font-size: clamp(0.95rem, 3.8vw, 1.25rem);
  }

  .rsvp-modal {
    width: 90vw;
    height: auto;
    max-width: 90vw;
    max-height: 85vh;
  }

  .rsvp-modal__panel {
    padding: 1.75rem 1.25rem 1.35rem;
    justify-content: flex-start;
  }

  .rsvp-modal__close {
    top: 0.75rem;
    right: 0.75rem;
    width: 2.25rem;
    height: 2.25rem;
    font-size: 2rem;
  }

  .rsvp-modal__form {
    flex-direction: column;
  }

  .rsvp-modal__submit {
    width: 100%;
  }

  .star-menu {
    width: clamp(56px, 14vw, 76px);
    height: clamp(56px, 14vw, 76px);
    --star-radius: clamp(3.75rem, 14vw, 5rem);
  }

  .star-nav__item {
    font-size: clamp(0.9rem, 3.4vw, 1.15rem);
  }

  .hero {
    min-height: 100svh;
  }

  .hero > .wrapper {
    justify-content: center;
    align-items: center;
    min-height: 100svh;
    box-sizing: border-box;
    padding-top: var(--header-height);
    padding-bottom: clamp(0.75rem, 2vh, 1.5rem);
    gap: 0.35rem;
  }

  .hero__wordmark {
    display: block;
    width: 90vw;
    max-width: 90vw;
    height: calc(90vw * 0.155);
    object-fit: cover;
    object-position: center;
    margin: 0 auto;
    flex: 0 0 auto;
    opacity: calc(1 - var(--brand-progress, 0));
    pointer-events: none;
  }

  .hero__slogan {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    width: min(92vw, 100%);
    max-width: min(92vw, 100%);
    box-sizing: border-box;
    padding-inline: 0.25rem;
    margin: 0 auto;
    white-space: normal;
    font-size: clamp(2.35rem, 12vw, 4.75rem);
    line-height: 0.95;
    letter-spacing: -0.03em;
    flex: 0 0 auto;
    z-index: 3;
  }

  .hero__slogan-br {
    display: block;
  }

  .hero__bottom {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding-inline: clamp(0.75rem, 4vw, 1.25rem);
    margin-top: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.2rem;
    pointer-events: auto;
    z-index: 2;
  }

  .hero__meta {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    grid-template-columns: minmax(0, 1fr);
    /* Star above date + location */
    grid-template-areas:
      "logo"
      "dates"
      "institution";
    row-gap: 0.25rem;
    align-items: start;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    margin-top: 0;
    box-sizing: border-box;
    overflow-x: clip;
  }

  .hero__meta-col--logo {
    grid-area: logo;
    justify-self: center;
    width: min(62vw, 34vh, 18rem);
    min-width: 0;
    max-width: 100%;
    height: auto;
    z-index: 1;
  }

  .hero__meta-col--dates,
  .hero__meta-col--institution {
    justify-self: stretch;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    text-align: center;
    box-sizing: border-box;
    position: relative;
    z-index: 4;
  }

  .hero__meta-col--dates {
    grid-area: dates;
    padding-bottom: 0.2rem;
    margin-bottom: 0;
  }

  .hero__meta-col--institution {
    grid-area: institution;
    padding-bottom: 0.2rem;
    margin-bottom: 0;
  }

  .hero__dates,
  .hero__institution {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    padding-inline: 0;
  }

  .hero__dates {
    /* ~2× prior mobile size */
    font-size: clamp(1.25rem, 6.4vw, 3rem);
  }

  .hero__institution {
    font-size: clamp(0.85rem, 3.8vw, 1.55rem);
    text-align: center;
  }

  .hero__squiggle {
    height: 3px;
    margin-top: 0.25rem;
  }

  .hero-eye {
    position: relative;
    left: auto;
    bottom: auto;
    width: 100%;
    min-width: 0;
    max-width: none;
    transform: none;
    margin-inline: auto;
    margin-top: 0;
    margin-bottom: 0;
  }

  .feelings {
    height: auto;
    min-height: 0;
    max-height: none;
    padding-block: clamp(1.25rem, 4vh, 2rem);
  }

  .feelings__inner {
    padding-block: 0;
  }

  .feelings__prompt {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    justify-items: center;
    align-items: center;
    column-gap: 0;
    row-gap: 0.12em;
    font-size: clamp(1.85rem, 9.5vw, 3.25rem);
  }

  .feelings__static--before,
  .feelings__static--after {
    justify-self: center;
    text-align: center;
  }

  .feelings__blank {
    justify-self: center;
    width: min(11ch, 85vw);
  }

  /* Schedule: date label moves above its events */
  .schedule__day {
    flex-direction: column;
    gap: 1rem;
  }

  .event {
    gap: 0.85rem;
  }

  .event__divider {
    flex-basis: 8px;
    width: 8px;
  }

  .schedule__key {
    position: static;
    top: auto;
    gap: 0.15rem 0.85rem;
    padding: 0.45rem 0.75rem;
    margin-bottom: 1.5rem;
  }

  .schedule__key .key-item {
    line-height: 1;
    gap: 0.3rem;
  }

  .event__row {
    flex-wrap: wrap;
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }

  .event__name {
    flex: 1 1 auto;
    width: 100%;
  }

  .event__when-where {
    flex-wrap: wrap;
    width: auto;
    max-width: 100%;
    margin-inline-start: auto;
  }

  /* Speaker cards stack photo above bio on narrow screens */
  .speaker-card {
    flex-direction: column;
  }

  .speaker-card__photo-wrap {
    width: min(239px, 60vw);
  }

  /* Glossary: restore stacked terms + shared empty definition slot */
  .glossary-box {
    border-top: none;
    padding-block: clamp(1.25rem, 3vw, 1.75rem);
    padding-top: calc(clamp(1.25rem, 3vw, 1.75rem) + 0.75rem);
  }

  .glossary-box::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background-color: var(--color-teal);
    pointer-events: none;
  }

  .glossary-row {
    display: block;
    background-color: transparent;
  }

  .glossary-row + .glossary-row {
    border-top: none;
  }

  .glossary-term {
    display: block;
    border-right: none;
    padding: 0.7rem 0;
    align-items: initial;
  }

  .glossary-term:hover,
  .glossary-term:focus-visible,
  .glossary-term[aria-pressed="true"] {
    background-color: transparent;
    color: var(--color-lime);
  }

  .glossary-row + .glossary-row .glossary-term {
    margin-top: 0.5rem;
    padding-top: calc(0.7rem + 4px);
  }

  .glossary-row + .glossary-row .glossary-term::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background-color: var(--color-teal);
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 8' preserveAspectRatio='none'%3E%3Cpath d='M0 4 L200 4' fill='none' stroke='black' stroke-width='8' stroke-linecap='butt'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 8' preserveAspectRatio='none'%3E%3Cpath d='M0 4 L200 4' fill='none' stroke='black' stroke-width='8' stroke-linecap='butt'/%3E%3C/svg%3E");
    -webkit-mask-size: 100% 100%;
    mask-size: 100% 100%;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    pointer-events: none;
  }

  /* Mobile: hide per-row defs until the term is tapped (AI stays open) */
  .glossary-box__definition--inline {
    display: none;
  }

  .glossary-row--ai .glossary-box__definition--inline,
  .glossary-row:has(.glossary-term[aria-pressed="true"]) .glossary-box__definition--inline {
    display: block;
    padding: 0.35rem 0 0.85rem;
    align-items: initial;
  }

  @media (hover: hover) {
    .glossary-row:has(.glossary-term:hover) .glossary-box__definition--inline,
    .glossary-row:has(.glossary-term:focus-visible) .glossary-box__definition--inline {
      display: block;
      padding: 0.35rem 0 0.85rem;
      align-items: initial;
    }
  }

  /* Unused on mobile — defs expand under each word instead */
  .glossary-box__definition--shared {
    display: none;
  }

  .site-footer {
    padding-bottom: max(1.75rem, env(safe-area-inset-bottom, 0px));
  }

  .site-footer__stage {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "center center"
      "hussman instagram";
    row-gap: 1rem;
    align-items: center;
  }

  .site-footer__center {
    grid-area: center;
    --footer-star-size: min(80vw, 26.5rem);
  }

  .site-footer__logo {
    width: min(80vw, 26.5rem);
    margin-inline: auto;
  }

  .site-footer__hussman {
    grid-area: hussman;
    justify-self: start;
    width: min(70vw, 18rem);
    max-width: none;
    margin-bottom: 0;
  }

  .site-footer__instagram {
    grid-area: instagram;
    justify-self: end;
    margin-bottom: 0;
  }
}

/* ---------------- Small mobile: ≤ 420px ---------------- */
@media (max-width: 420px) {
  :root {
    --font-size-body: 0.8125rem;
  }

  .key-item__swatch,
  .event__pin {
    width: 60px;
    height: 60px;
  }
}
