/* The event page: the deck on the left (on top on a phone), the sections beside it (below it). */

/* the bar on top, the event filling the rest of the window */
.event-page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}
.event {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ------------------------------------------------------------------ the deck */
.stage {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  min-width: 0;
  padding: 20px 24px;
  container-type: size;

  /* as wide as fits: the frame keeps 16:9 in the stage's height, less the line under it */
  & .frame,
  & .follow,
  & .sessions {
    width: min(100%, calc((100cqh - 70px) * 16 / 9));
    margin-inline: auto;
  }
  &:has(.sessions:not([hidden])) {
    & .frame,
    & .follow,
    & .sessions {
      width: min(100%, calc((100cqh - 120px) * 16 / 9));
    }
  }
}

/* an event's programme: its sessions, the one showing marked, the presenter's with a pulsing dot */
.sessions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;

  & .session {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 4px 12px;
    font-size: 0.875rem;

    & .time {
      color: var(--muted);
      font-variant-numeric: tabular-nums;
    }
    & .dot {
      color: var(--live);
    }
    &.is-current {
      color: var(--on-tint);
      background: var(--tint);
      border-color: var(--accent);
    }
  }
}

.frame {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--stage);
  box-shadow: var(--shadow);

  & iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
  }
}
.frame-note {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 16px;
  color: var(--on-stage);
  font-size: 0.9375rem;
  text-align: center;
  pointer-events: none;
}

.follow {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
}
.where {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 12px;
  min-width: 0;
  margin: 0;
  font-size: 0.9375rem;

  & .state {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 650;

    & .dot {
      color: var(--live);
    }
  }
  & .slide {
    min-width: 0;
    overflow: hidden;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ------------------------------------------------------------------ the sections */
.panel {
  flex: 0 0 clamp(340px, 30vw, 420px);
  min-width: 0;
  overflow-y: auto;
  padding: 0 20px 48px;
  background: var(--surface);
  border-left: 1px solid var(--line);
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 -20px 6px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);

  & button {
    position: relative;
    flex: 1;
    padding: 9px 10px;
    white-space: normal; /* a long name takes two lines rather than cut the next tab off */
  }
  & .count {
    min-width: 20px;
    padding: 0 6px;
    font-size: 0.75rem;
    line-height: 20px;
    background: color-mix(in srgb, currentColor 16%, transparent);
  }
  & .nudge {
    position: absolute;
    top: 6px;
    right: 10px;
    width: 9px;
    height: 9px;
    background: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent);
    animation: pulse 1.6s ease-in-out infinite;
  }
}

.tabpanel {
  padding-top: 8px;

  & .card h2 {
    display: flex;
    align-items: center;
    gap: 10px;
  }
}
.group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.intro {
  margin: 10px 0 0;
  color: var(--muted);
}

/* links */
.links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;

  & a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--line);

    &:hover {
      border-color: var(--accent);
    }
  }
  & .tx {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
  & .host {
    overflow: hidden;
    color: var(--muted);
    font-size: 0.8125rem;
    font-weight: 400;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  & .go {
    margin-left: auto;
    color: var(--muted);
  }
}
.share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 18px;
  padding-top: 16px;
  color: var(--muted);
  font-size: 0.875rem;
  border-top: 1px solid var(--line);

  & p {
    margin: 0;
  }
  /* a long address shortens with an ellipsis instead of leaving the page */
  & button {
    max-width: 100%;

    & span {
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
}

/* FAQ */
.faq {
  & details {
    border-bottom: 1px solid var(--line);
  }
  & summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    font-weight: 600;
    list-style: none;
    cursor: pointer;

    &::-webkit-details-marker {
      display: none;
    }
    &::after {
      content: "+";
      color: var(--muted);
      font-weight: 400;
    }
  }
  & details[open] summary::after {
    content: "–";
  }
  & p {
    margin: 0 0 14px;
    color: var(--muted);
    white-space: pre-wrap;
  }
}

/* questions */
.questions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.question {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);

  & .vote {
    flex-direction: column;
    gap: 0;
    min-width: 50px;
    padding: 7px 8px;
    font-size: 0.875rem;

    &[aria-pressed="true"] {
      color: var(--on-brand);
      background: var(--brand);
      border-color: transparent;
    }
  }
  & .body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
  }
  & .text {
    margin: 4px 0 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }
  & .meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    color: var(--muted);
    font-size: 0.8125rem;
  }
  & .answer {
    margin: 0;
    padding: 10px 12px;
    font-size: 0.9375rem;
    white-space: pre-wrap;
    background: var(--surface-2);
    border-left: 3px solid var(--brand);
  }
}

/* the session's rating, under the title (js/feedback.js) */
.rate {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 10px;
  margin-top: 2px;

  /* at the end of the talk, until this browser has rated */
  &.asking .stars {
    animation: pulse 1.6s ease-in-out infinite;
  }
}
.stars {
  display: flex;

  & button {
    padding: 2px;
    color: var(--muted);
    background: none;
    border: 0;

    &:hover,
    &.on {
      color: var(--brand-deep);
    }
    &.on .icon {
      fill: var(--brand);
    }
  }
  & .icon {
    width: 20px;
    height: 20px;
    stroke-width: 1.6;
  }
  /* the stars up to the one under the pointer light up */
  &:hover button:has(~ button:hover) {
    color: var(--brand-deep);
  }
}
.rate-note {
  color: var(--muted);
  font-size: 0.8125rem;
}

/* asking: the question, then the name beside the button */
.ask .row > .field {
  flex: 1;
}

/* the legal links: a slim line under the deck and the sections, always in view */
.event-page > .legal {
  padding: 7px 20px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.closed {
  margin: 0;
  padding: 14px 16px;
  color: var(--warn);
  background: var(--warn-tint);
}

/* ------------------------------------------------------------------ no such event */
.missing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 480px;
  margin: 12vh auto 0;
  padding: 24px 16px;
  text-align: center;

  & .logo img {
    width: auto;
    height: 44px;
  }
  & h1 {
    margin: 12px 0 0;
  }
  & p {
    margin: 0 0 12px;
    color: var(--muted);
  }
}

/* ------------------------------------------------------------------ phones and narrow windows */
@media (max-width: 900px) {
  .bar {
    min-height: 52px;
    padding: 8px 16px;

    & .logo img {
      height: 24px;
    }
  }
  .event-page {
    display: block;
    height: auto;
  }
  .event {
    flex-direction: column;
  }
  /* the deck stays in view while the sections scroll below it */
  .stage {
    position: sticky;
    top: 0;
    z-index: 3;
    gap: 6px;
    padding: 8px 12px 6px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    container-type: normal;

    & .frame,
    & .follow,
    & .sessions {
      width: 100%;
    }
  }
  /* one row that scrolls sideways, so the deck keeps its room */
  .sessions {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;

    & .session {
      flex: none;
    }
  }
  .frame {
  }
  .follow {
    min-height: 32px;
  }
  .where {
    font-size: 0.875rem;
  }
  .panel {
    flex: none;
    overflow: visible;
    padding: 0 16px 48px;
    border-left: 0;
  }
  .tabs {
    position: static;
    margin: 0 -16px 6px;
    padding: 10px 16px;
  }
}

/* a phone held sideways: the deck alone, as large as it gets */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  .bar {
    display: none;
  }
  .sessions {
    display: none;
  }
  .stage {
    position: static;
    height: 100dvh;

    & .frame,
    & .follow {
      width: min(100%, calc((100dvh - 56px) * 16 / 9));
    }
  }
}
