/*
 * vps.css: Virtual Poster Session stylesheet, loaded on every page
 *
 * This file holds everything a session VISITOR needs: the session listing and
 * the pages in front of it (password, demo notice, not available, errors).
 * Pages load one more file on top of this one when they need it:
 *   vps-manage.css  presenters, organizers and admin (forms, lists, dialogs)
 *   vps-talk.css    the poster discussion pages
 *
 * Hand-written, no framework. Structure:
 *   tokens      design values as custom properties (edit here first)
 *   reset/base  element defaults
 *   layout      page container + the two-column split used across pages
 *   components  one block per UI piece; children are styled contextually
 *               (".poster dt") so templates don't repeat classes per element
 *   utilities   the handful of helpers that are genuinely reusable
 *
 * Templates must keep the JavaScript hooks (ids, .poster-con, .with-chat, ...)
 * covered by the Go tests; those classes carry no styling here unless noted.
 */

@layer reset, base, layout, components, utilities;

/* ------------------------------------------------------------------ tokens */
:root {
  --brand: #4f46e5;
  --brand-hover: #4338ca;
  --brand-soft: #eef2ff;
  --brand-line: #c7d2fe;

  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --line-soft: #f1f5f9;
  --surface: #fff;
  --page: #f8fafc;

  --success: #059669;
  --success-hover: #047857;
  --danger: #e11d48;
  --danger-ink: #9f1239;
  --notice-bg: #fffbeb;
  --notice-line: #fde68a;
  --notice-ink: #78350f;
  --highlight: #fde68a;
  --star: #f59e0b;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: .5rem;
  --radius-lg: 1rem;
  --shadow: 0 1px 2px rgb(15 23 42 / .06);
  --shadow-lift: 0 8px 24px -6px rgb(15 23 42 / .14);
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand);
  --gutter: clamp(1rem, 3vw, 2rem);
  --max: 80rem;
}

/* ------------------------------------------------------------------ reset */
@layer reset {
  *, ::before, ::after { box-sizing: border-box; }
  body, h1, h2, h3, p, dl, dd, figure { margin: 0; }
  img, svg, iframe { display: block; max-width: 100%; }
  img { height: auto; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { cursor: pointer; }
  [x-cloak], [hidden] { display: none !important; }
}

/* ------------------------------------------------------------------ base */
@layer base {
  html { -webkit-text-size-adjust: 100%; }
  body {
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--ink);
    background: var(--page);
    -webkit-font-smoothing: antialiased;
  }
  a { color: inherit; text-decoration: none; }
  :focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius); }
  mark { background: var(--highlight); color: inherit; border-radius: 2px; padding: 0 1px; }
  h1, h2, h3 { line-height: 1.25; letter-spacing: -.01em; }

  input[type=search], input[type=password], input[type=text], input[type=email], textarea {
    width: 100%;
    padding: .55rem .75rem;
    font-size: .875rem;
    background: var(--surface);
    border: 1px solid #cbd5e1;
    border-radius: var(--radius);
  }
  input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
  ::placeholder { color: var(--faint); }
  input[type=checkbox], input[type=radio] { width: 1rem; height: 1rem; margin: 0; accent-color: var(--brand); }
  label { font-size: .875rem; }
}

/* ------------------------------------------------------------------ layout */
@layer layout {
  .wrap { max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }
  main { min-height: 70vh; }
  .split { display: grid; gap: 1.5rem; }
  @media (min-width: 64rem) {
    .split { grid-template-columns: 1fr 1fr; gap: 2.5rem; align-items: start; }
  }
}

/* ------------------------------------------------------------------ components */
@layer components {

  /* icons from the page's inline sprite, see {{sprite}} and {{icon}} in the assets package */
  .i { width: 1.25em; height: 1.25em; flex: none; fill: currentColor; }

  /* --- site bar --------------------------------------------------------- */
  .sitebar { background: var(--surface); border-bottom: 1px solid var(--line); }
  .sitebar .wrap { display: flex; align-items: center; gap: .6rem; min-height: 3.25rem; font-size: .875rem; color: var(--muted); }
  .sitebar .i { width: 1.75rem; height: 1.75rem; padding: .25rem; border-radius: .4rem; background: var(--brand); fill: #fff; }
  .sitebar b { color: var(--ink); font-weight: 600; }
  .sitebar a:hover { color: var(--ink-2); }

  /* --- banners & alerts ------------------------------------------------- */
  .banner { background: var(--danger); color: #fff; font-size: .875rem; font-weight: 500; }
  .banner .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding-block: .6rem; }
  .banner p { display: flex; align-items: center; gap: .5rem; }
  .banner a { background: #fff; color: var(--danger); padding: .35rem .8rem; border-radius: var(--radius); font-weight: 600; }

  .alert {
    position: relative; display: flex; gap: .75rem;
    margin-top: 1rem; padding: 1rem 2.75rem 1rem 1rem;
    font-size: .875rem; color: var(--notice-ink);
    background: var(--notice-bg); border: 1px solid var(--notice-line); border-radius: var(--radius-lg);
  }
  .alert > .i { color: var(--star); margin-top: .1rem; }
  .alert strong { display: block; }
  .alert a { font-weight: 500; text-decoration: underline; text-underline-offset: 2px; }
  .alert button { position: absolute; top: .5rem; right: .5rem; padding: .35rem; border: 0; border-radius: var(--radius); background: none; color: inherit; }
  .alert button:hover { background: var(--notice-line); }
  .alert p + p { margin-top: .25rem; }

  /* --- event header ----------------------------------------------------- */
  .event { padding-top: 2.5rem; }
  .event .date {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .2rem .65rem; border-radius: 99px;
    font-size: .75rem; font-weight: 500;
    color: var(--brand-hover); background: var(--brand-soft); border: 1px solid var(--brand-line);
  }
  .event h1 { margin-top: .75rem; font-size: clamp(1.75rem, 3.5vw, 2.25rem); font-weight: 700; letter-spacing: -.02em; }
  .event h2 { margin-top: .35rem; font-size: 1.125rem; font-weight: 500; color: var(--muted); }
  .event .banner-img { max-height: 12rem; width: auto; margin: 0 auto 1.5rem; object-fit: contain; }
  @media (max-width: 63.99rem) { .banner-img.wide { display: none; } }
  @media (min-width: 64rem) { .banner-img.tall { display: none; } }
  .event .split { margin-top: 1.5rem; }

  .prose { max-width: 65ch; font-size: .95rem; line-height: 1.65; color: var(--ink-2); }
  .prose > * + * { margin-top: .75rem; }
  .prose a { color: var(--brand-hover); text-decoration: underline; text-decoration-color: var(--brand-line); text-underline-offset: 2px; }
  .prose a:hover { text-decoration-color: var(--brand); }
  .prose ul, .prose ol { padding-left: 1.25rem; }
  .prose h3 { font-size: 1.25rem; font-weight: 600; }
  .prose h4 { font-size: 1.1rem; font-weight: 600; }

  /* --- cards (filters, track nav) --------------------------------------- */
  .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 1.25rem; }
  .label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

  .search { position: relative; }
  .search .i { position: absolute; left: .75rem; top: 50%; translate: 0 -50%; color: var(--faint); }
  .search input { padding-left: 2.5rem; padding-block: .65rem; background: var(--page); }
  .search input:focus { background: var(--surface); }

  .filters .label { margin-top: 1rem; }
  .filters .toggles { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line-soft); }
  .filters .toggles .label { margin: 0; }
  .filters .toggles label { display: inline-flex; align-items: center; gap: .5rem; color: var(--ink-2); }

  .chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
  .chips a, .chips span {
    padding: .2rem .65rem; border-radius: 99px;
    font-size: .75rem; font-weight: 500; color: var(--ink-2); background: var(--line-soft);
  }
  .chips a:hover { color: var(--brand-hover); background: var(--brand-soft); }
  .chips small { color: var(--faint); font-size: inherit; }
  .chips .more { background: none; color: var(--brand-hover); }

  .tracknav { margin-top: 2.5rem; }
  .tracknav .chips a { font-size: .875rem; padding: .35rem .8rem; border-radius: var(--radius); }
  .tracknav .chips a:hover { color: #fff; background: var(--brand); }

  /* --- tracks ----------------------------------------------------------- */
  /* .track-con and .permalink are JS hooks; the h3 must stay the first child */
  .track-con { margin-top: 3rem; }
  .track-con > h3 {
    display: flex; align-items: center; gap: .5rem;
    padding-bottom: .5rem; border-bottom: 1px solid var(--line);
    font-size: clamp(1.25rem, 2.5vw, 1.5rem); font-weight: 600;
  }
  .track-con > h3 .permalink { flex: 1; }
  .track-con > h3 .top { font-size: .75rem; font-weight: 500; color: var(--faint); }
  .track-con > h3 .top:hover { color: var(--ink-2); }
  .toggle { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: var(--radius); color: var(--faint); }
  .toggle:hover { background: var(--line-soft); color: var(--ink-2); }
  .toggle .i { transition: rotate .15s; }
  .is-collapsed .toggle .i { rotate: -90deg; }

  /* --- poster card ------------------------------------------------------ */
  .poster {
    display: grid; margin-top: 1.5rem; overflow: hidden;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
    box-shadow: var(--shadow); transition: box-shadow .2s;
  }
  .poster:hover { box-shadow: var(--shadow-lift); }
  @media (min-width: 64rem) { .poster { grid-template-columns: 1fr 1fr; } }

  .poster .thumb { position: relative; display: grid; place-items: center; padding: clamp(1rem, 2vw, 1.5rem); background: var(--line-soft); }
  @media (min-width: 64rem) { .poster .thumb { border-right: 1px solid var(--line); } }
  .poster .thumb a { display: block; overflow: hidden; border-radius: var(--radius); box-shadow: 0 0 0 1px rgb(15 23 42 / .06); }
  .poster .thumb img { width: 100%; min-height: 50px; transition: scale .3s; }
  .poster .thumb:hover img { scale: 1.02; }
  .poster .thumb a::after {
    content: "View full poster"; position: absolute; right: 2rem; bottom: 2rem;
    padding: .25rem .5rem; border-radius: .35rem; font-size: .75rem; font-weight: 500;
    color: #fff; background: rgb(15 23 42 / .75); opacity: 0; transition: opacity .2s; pointer-events: none;
  }
  .poster .thumb:hover a::after { opacity: 1; }

  .poster .body { display: flex; flex-direction: column; padding: clamp(1.25rem, 2vw, 1.5rem); }
  .poster header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
  .poster header > :not(div) { flex: none; }
  .poster h3 { font-size: 1.125rem; font-weight: 600; line-height: 1.35; }
  .poster header p { margin-top: .25rem; font-size: .875rem; color: var(--muted); }

  .poster dl { display: grid; gap: 1.25rem 1.5rem; margin-top: 1.25rem; }
  @media (min-width: 40rem) { .poster dl { grid-template-columns: 1fr 1fr; } }
  .poster dl .wide { grid-column: 1 / -1; }
  .poster dt { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
  .poster dd { margin-top: .25rem; font-size: .875rem; overflow-wrap: anywhere; }
  .poster dd.abstract { line-height: 1.6; color: var(--ink-2); }
  .poster dd.abstract a { border-bottom: 1px solid var(--line); }
  .poster dd small { color: var(--muted); font-size: inherit; }
  .poster dd.chips { margin-top: .35rem; }
  .poster dd.chips span { border-radius: .35rem; }

  .actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .75rem; margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line-soft); }
  .actions small { display: block; margin-top: .25rem; font-size: .75rem; color: var(--muted); }

  /* --- buttons ---------------------------------------------------------- */
  .btn {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .5rem .9rem; border: 1px solid transparent; border-radius: var(--radius);
    font-size: .875rem; font-weight: 600; line-height: 1.25;
    color: #fff; background: var(--brand); box-shadow: var(--shadow); transition: background .15s;
  }
  .btn:hover { background: var(--brand-hover); }
  .btn.go { background: var(--success); }
  .btn.go:hover { background: var(--success-hover); }
  .btn.alt { color: var(--ink-2); background: var(--surface); border-color: #cbd5e1; }
  .btn.alt:hover { background: var(--page); }
  .btn.block { display: flex; justify-content: center; width: 100%; padding-block: .65rem; }
  .btn.off { color: var(--faint); background: var(--line-soft); border-color: var(--line); box-shadow: none; cursor: not-allowed; }

  /* --- voting (X) and ratings (R) --------------------------------------- */
  .vote button { padding: .35rem; border: 0; border-radius: 99px; background: none; color: #cbd5e1; }
  .vote button:hover { background: var(--notice-bg); }
  .vote .i { width: 1.75rem; height: 1.75rem; }
  .voted, .vote .voted { color: var(--star); }
  img.badge { width: 3.75rem; height: 5rem; object-fit: contain; }

  .rating { padding: .5rem .75rem; border-radius: var(--radius); background: var(--page); border: 1px solid var(--line); }
  .rate-star { display: flex; gap: .1rem; margin-top: .25rem; }
  .rate-star button { padding: 0; border: 0; background: none; color: #cbd5e1; }
  .rate-star .hover { color: var(--star); }
  .rate-star .on { color: var(--brand); }

  /* --- modal ------------------------------------------------------------ */
  .modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; padding: 1rem; }
  @media (min-width: 40rem) { .modal { align-items: center; } }
  .modal .scrim { position: fixed; inset: 0; background: rgb(15 23 42 / .6); backdrop-filter: blur(3px); }
  .modal .panel { position: relative; display: flex; flex-direction: column; width: 100%; max-width: 72rem; overflow: hidden; border-radius: var(--radius-lg); background: var(--surface); box-shadow: 0 25px 50px -12px rgb(0 0 0 / .35); }
  .modal .panel.narrow { max-width: 48rem; }
  .modal iframe { width: 100%; height: 75vh; border: 0; }
  .modal .panel > div { display: flex; justify-content: flex-end; padding: .75rem 1rem; border-top: 1px solid var(--line); background: var(--page); }

  /* --- gate pages (password, demo notice, not available) ---------------- */
  .gate { max-width: 34rem; margin-inline: auto; padding: 4rem var(--gutter) 0; }
  .gate.wide { max-width: 48rem; }
  .gate h1 { font-size: 1.75rem; font-weight: 700; text-align: center; letter-spacing: -.02em; }
  .gate .card { margin-top: 2rem; padding: 2rem; }
  .gate .card p { font-size: .875rem; color: var(--muted); }
  .gate .card p + p { margin-top: .75rem; }
  .gate h1 + h2 { margin-top: 1rem; font-size: 1.125rem; font-weight: 600; text-align: center; }
  .gate > p { margin-top: 1.25rem; color: var(--ink-2); }
  .gate ul { margin: .5rem 0 0; padding-left: 1.25rem; font-size: .875rem; color: var(--ink-2); }
  .gate .lead { font-size: 1.25rem; text-align: center; }
  .gate .lead + p { font-size: 1rem; text-align: center; }
  .gate p a, .gate small a { color: var(--ink); border-bottom: 1px solid var(--line); }
  .gate .warning { font-size: 1rem; font-weight: 600; color: var(--danger-ink); }
  .gate .legal { margin-top: 1.5rem; font-size: .875rem; color: var(--muted); }
  .gate small { display: block; margin-top: .5rem; font-size: .75rem; color: var(--muted); }
  .gate .field { margin-top: 1.25rem; }
  .gate .field:first-child { margin-top: 0; }
  .gate .notice { margin: 0 0 1rem; padding: .5rem 1rem; border-radius: var(--radius); font-size: .875rem; font-weight: 500; text-align: center; color: #fff !important; background: var(--danger); }
  .gate .center { text-align: center; }
  .gate .btn { margin-top: 1.5rem; }
  .gate > svg { width: 100%; height: auto; max-width: 28rem; margin: 2rem auto 0; }

  /* --- the password field (other form styles are in vps-manage.css) ----- */
  .field label { display: block; margin-bottom: .3rem; font-weight: 500; color: var(--ink-2); }
  .field p.error { margin-top: .4rem; font-size: .875rem; color: var(--danger); }
  .field input.bad { border-color: var(--danger); }
  .with-icon { position: relative; }
  .with-icon .i { position: absolute; left: .75rem; top: 50%; translate: 0 -50%; color: var(--faint); }
  .with-icon input { padding-left: 2.5rem; }

  /* --- footer ----------------------------------------------------------- */
  .powered { margin-top: 3rem; padding: .75rem; text-align: center; font-size: .875rem; color: var(--muted); }
  .powered strong { color: var(--ink-2); }
  .powered + .sitefoot { margin-top: 0; }
  .sitefoot { margin-top: 4rem; background: var(--surface); border-top: 1px solid var(--line); font-size: .875rem; color: var(--muted); }
  .sitefoot .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; padding-block: 2rem; }
  .sitefoot p a:hover { color: var(--ink-2); text-decoration: underline; }
  .sitefoot nav { display: flex; gap: 1.25rem; color: var(--faint); }
  .sitefoot nav a:hover { color: var(--muted); }
}

/* ------------------------------------------------------------------ utilities */
@layer utilities {
  .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  @media (max-width: 47.99rem) { .md-only { display: none; } }
  @media (min-width: 48rem) { .sm-only { display: none; } }
}

@media print {
  .sitebar, .banner, .alert, .filters, .tracknav, .toggle, .actions, .vote, .rating, .powered, .sitefoot nav { display: none !important; }
  .poster { break-inside: avoid; box-shadow: none; }
}
