/**
 * Events Tool (DTV Judging Hall) — host chrome
 *
 * DESIGN CONTRACT
 * ---------------
 * This page used to carry its own design system: a navy gradient header, a
 * bespoke button, its own card and its own grid, all capped at 1180px and
 * centred. Two things went wrong with that.
 *
 *   1. The header was navy and relied on the heading INHERITING white. But
 *      dtv-theme.css loads LAST on every shell and contains
 *          body h1, body h2, body h3, body h4 { color: var(--text) }
 *      which targets the element directly and beats any inherited colour. The
 *      title therefore rendered in dark ink on navy — effectively invisible.
 *      Patching it with `color:#fff` would work until the next theme change, so
 *      instead the header is now the SAME light header every other page uses
 *      (SME Directory, Mentors, Ventures Building): .dtv-head on the page
 *      surface, dark ink on white. There is no contrast to fight because there
 *      is no dark background.
 *
 *   2. A 1180px centred column reads as a card floating in a wider page. Every
 *      other surface in the app is full-bleed inside #page-content's own 24px
 *      gutters, so this page now does the same: no max-width, no auto margin.
 *
 * Everything below is therefore scoped to what the shared layers do NOT give
 * us: the tab strip, the compact handout rows, and the QR well. Colour and
 * spacing come from the design tokens (dtv-theme.css / skin.css) so a future
 * re-theme reaches this page for free. Literal fallbacks are kept because this
 * stylesheet loads before the theme and must not depend on load order.
 */

/* ── Page shell ───────────────────────────────────────────────────────────── */

/* Matches .dtv-page in skin.css. Declared here too so the page stays correct
   even if that stylesheet is split or reordered: full width, no centring. */
#events-tool {
  width: 100%;
  max-width: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */

/* One tab strip for the whole "before the event" region. Two panels instead of
   two stacked sections: the links are used repeatedly on event day and stay
   first, while the run-of-show is reference material an organizer reads once
   and is one click away rather than always on screen. */
#events-tool .evt-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--skin-border, #D3DBDF);
  overflow-x: auto;
  scrollbar-width: none;
}

#events-tool .evt-tabs::-webkit-scrollbar { display: none; }

#events-tool .evt-tab {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  margin-bottom: -1px;
  padding: 9px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--skin-muted, #55636F);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

#events-tool .evt-tab:hover { color: var(--skin-text, #12202F); }

#events-tool .evt-tab[aria-selected="true"] {
  color: var(--primary, #14304A);
  border-bottom-color: var(--primary, #14304A);
}

#events-tool .evt-tab:focus-visible {
  outline: 2px solid var(--tech, #1F6672);
  outline-offset: -2px;
}

#events-tool .evt-tab-count {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--skin-surface-alt, #EEF2F3);
  color: var(--skin-muted, #55636F);
}

#events-tool .evt-tab[aria-selected="true"] .evt-tab-count {
  background: var(--primary, #14304A);
  color: #fff;
}

#events-tool .evt-panel { display: block; }
#events-tool .evt-panel[hidden] { display: none; }

/* ── Handout links ────────────────────────────────────────────────────────── */

/* Three compact rows rather than three tall cards. The old card layout spent a
   third of the page on padding and repeated the same URL twice; this keeps the
   live URL, the two actions an organizer needs and an on-demand QR in one row
   at desktop width. */
#events-tool .evt-links {
  display: grid;
  gap: 10px;
}

#events-tool .evt-link {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--skin-border, #DCE3E7);
  background: var(--skin-surface, #fff);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#events-tool .evt-link:hover {
  border-color: var(--tech, #1F6672);
  box-shadow: 0 2px 10px rgba(15, 27, 38, 0.06);
}

#events-tool .evt-link-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--tech-t, #E3F1EF);
  color: var(--tech, #1F6672);
  font-size: 14px;
}

#events-tool .evt-link-body { min-width: 0; }

#events-tool .evt-link-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

#events-tool .evt-link-title h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--skin-text, #0F1B26);
}

#events-tool .evt-link-who {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--tech, #1F6672);
}

#events-tool .evt-link-hint {
  margin: 3px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--skin-muted, #5B6B77);
}

/* The URL stays visible and selectable: it is the only fallback when the
   clipboard API is unavailable (plain http on a hotspot rehearsal). */
#events-tool .evt-link-url {
  display: block;
  margin-top: 5px;
  font-family: var(--font-mono, ui-monospace, "IBM Plex Mono", monospace);
  font-size: 11px;
  line-height: 1.5;
  color: var(--skin-muted, #5B6B77);
  overflow-wrap: anywhere;
  user-select: all;
}

#events-tool .evt-link-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ── Shared small button ──────────────────────────────────────────────────── */

#events-tool .evt-mini {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 7px;
  border: 1px solid var(--skin-border, #DCE3E7);
  background: var(--skin-surface-alt, #F7FAFA);
  color: var(--skin-text, #0F1B26);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

#events-tool .evt-mini:hover {
  background: var(--tech-t, #E3F1EF);
  border-color: var(--tech, #1F6672);
}

#events-tool .evt-mini[aria-expanded="true"] {
  background: var(--tech-t, #E3F1EF);
  border-color: var(--tech, #1F6672);
}

#events-tool .evt-mini:focus-visible {
  outline: 2px solid var(--tech, #1F6672);
  outline-offset: 2px;
}

/* ── QR well ──────────────────────────────────────────────────────────────── */

/* Rendered on demand, not up front: three always-on QR codes dominate the page
   and only one is ever needed at a time. The stage screen shows its own. */
#events-tool .evt-qr {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px;
  border-radius: 10px;
  border: 1px dashed var(--skin-border, #DCE3E7);
  background: var(--skin-surface-alt, #F7FAFA);
}

#events-tool .evt-qr[hidden] { display: none; }

#events-tool .evt-qr svg {
  width: 148px;
  height: 148px;
  flex: 0 0 148px;
  display: block;
  border-radius: 6px;
  background: #fff;
}

#events-tool .evt-qr-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--skin-muted, #5B6B77);
}

#events-tool .evt-qr-note b { color: var(--skin-text, #0F1B26); }

#events-tool .evt-qr-url {
  display: block;
  margin-top: 6px;
  font-family: var(--font-mono, ui-monospace, "IBM Plex Mono", monospace);
  font-size: 10.5px;
  color: var(--skin-muted, #5B6B77);
  overflow-wrap: anywhere;
  user-select: all;
}

/* ── Run of show ──────────────────────────────────────────────────────────── */

/* A step strip, not five cards: numbered pills the organizer reads one at a
   time, with the detail for the selected step beneath. */
#events-tool .evt-steps {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

#events-tool .evt-step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--skin-border, #DCE3E7);
  background: var(--skin-surface, #fff);
  color: var(--skin-muted, #55636F);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

#events-tool .evt-step:hover {
  border-color: var(--primary, #14304A);
  color: var(--skin-text, #12202F);
}

#events-tool .evt-step[aria-selected="true"] {
  background: var(--primary, #14304A);
  border-color: var(--primary, #14304A);
  color: #fff;
}

#events-tool .evt-step:focus-visible {
  outline: 2px solid var(--tech, #1F6672);
  outline-offset: 2px;
}

#events-tool .evt-step-n {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--skin-surface-alt, #EEF2F3);
  color: var(--primary, #14304A);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 10.5px;
  font-weight: 800;
}

#events-tool .evt-step[aria-selected="true"] .evt-step-n {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

#events-tool .evt-step-body {
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid var(--skin-border, #DCE3E7);
  border-inline-start: 3px solid var(--primary, #14304A);
  background: var(--skin-surface, #fff);
}

#events-tool .evt-step-body h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
  color: var(--skin-text, #0F1B26);
}

#events-tool .evt-step-body p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--skin-muted, #5B6B77);
  max-width: 88ch;
}

#events-tool .evt-step-hint {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--skin-border, #DCE3E7);
  font-size: 12px;
  line-height: 1.6;
  color: var(--skin-muted, #5B6B77);
}

/* ── Console frame ────────────────────────────────────────────────────────── */

/* The console is a full page with its own header, so it needs real height.
   dvh (with a vh fallback) keeps it correct on mobile browsers whose toolbars
   change the viewport height mid-scroll. */
#events-tool .evt-frame-wrap {
  position: relative;
  border-radius: 14px;
  border: 1px solid var(--skin-border, #DCE3E7);
  background: var(--skin-surface, #fff);
  overflow: hidden;
  min-height: 640px;
  height: calc(100vh - 340px);
  height: calc(100dvh - 340px);
}

#events-tool .evt-frame-wrap iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

#events-tool .evt-frame-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-direction: column;
  font-size: 13px;
  font-weight: 600;
  color: var(--skin-muted, #5B6B77);
  background: var(--skin-surface, #fff);
  z-index: 1;
}

#events-tool .evt-frame-loading i {
  font-size: 22px;
  color: var(--tech, #1F6672);
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 820px) {
  /* Two columns: icon plus text on the first row, actions beneath. A three
     column grid at this width squeezes the URL into an unreadable ribbon. */
  #events-tool .evt-link {
    grid-template-columns: auto minmax(0, 1fr);
  }

  #events-tool .evt-link-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  #events-tool .evt-qr {
    flex-direction: column;
    align-items: flex-start;
  }

  #events-tool .evt-frame-wrap {
    min-height: 460px;
    height: calc(100dvh - 300px);
  }
}

@media (prefers-reduced-motion: reduce) {
  #events-tool .evt-mini,
  #events-tool .evt-link,
  #events-tool .evt-tab,
  #events-tool .evt-step {
    transition: none;
  }
}
