/* ==========================================================================
   SlideDrop — design system
   Palette  ink #10131C · paper #F2F4F8 · beam (projector amber) #FFB224
   Type     Bricolage Grotesque (display) · Instrument Sans (body)
            Spline Sans Mono (PINs, counters, data)
   Motif    the 16:9 slide frame + the warm beam of a projector
   ========================================================================== */

:root {
  --ink: #10131C;
  --ink-soft: #2A3040;
  --slate: #5B6478;
  --paper: #F2F4F8;
  --surface: #FFFFFF;
  --line: #E1E5EE;
  --beam: #FFB224;
  --beam-deep: #C98C00;
  --beam-ink: #2B1F02;
  --danger: #E5484D;
  --ok: #2F9E62;
  --stage: #0C0E15;
  --stage-2: #161B29;
  --stage-line: #262D40;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 19, 28, .05), 0 12px 32px -12px rgba(16, 19, 28, .18);
  --font-display: "Bricolage Grotesque", "Segoe UI", sans-serif;
  --font-body: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "Spline Sans Mono", "Consolas", monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
}
img { max-width: 100%; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--beam); outline-offset: 2px; border-radius: 4px; }

/* ---------- nav ---------- */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px clamp(20px, 5vw, 56px);
  max-width: 1240px; margin: 0 auto;
}
.nav-brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark {
  height: 40px;
  width: auto;
  max-width: none;
  display: block;
  flex: none;
  object-fit: contain;
}
.brand-word { font-family: var(--font-display); font-weight: 700; font-size: 21px; letter-spacing: -.01em; }
.brand-word em { font-style: normal; color: var(--beam-deep); }
.nav-links { display: flex; align-items: center; gap: clamp(12px, 2.5vw, 26px); }
.nav-links a { text-decoration: none; font-weight: 500; color: var(--ink-soft); font-size: 15px; }
.nav-links a:hover { color: var(--ink); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-body); font-weight: 600; font-size: 15px;
  padding: 11px 20px; border-radius: 999px; border: 1.5px solid transparent;
  cursor: pointer; text-decoration: none; line-height: 1;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--beam); color: var(--beam-ink);
  box-shadow: 0 6px 18px -8px rgba(217, 142, 0, .8);
}
.btn-primary:hover { background: #FFC04A; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-soft); }
.btn-ghost:hover { border-color: var(--slate); color: var(--ink); }
.btn-danger { background: transparent; border-color: #F3C4C6; color: var(--danger); }
.btn-danger:hover { background: #FDF1F1; border-color: var(--danger); }
.btn-sm { padding: 8px 14px; font-size: 14px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn[disabled] { opacity: .55; cursor: default; pointer-events: none; }

/* ---------- page scaffolding ---------- */
.page { max-width: 1240px; margin: 0 auto; padding: 0 clamp(20px, 5vw, 56px) 80px; }
.narrow { max-width: 660px; margin: 40px auto 0; }
.wide { margin-top: 40px; }
.centered { text-align: center; }
.centered .row-gap { justify-content: center; }
.row-gap { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }

.eyebrow {
  font-family: var(--font-mono); font-size: 12.5px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--beam-deep);
  margin: 0 0 14px;
}
.page-title {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(30px, 4.5vw, 44px); line-height: 1.06;
  letter-spacing: -.02em; margin: 0 0 14px;
}
.lede { color: var(--slate); font-size: 17px; max-width: 56ch; margin: 0 0 26px; }
.centered .lede { margin-inline: auto; }

.footer {
  max-width: 1240px; margin: 0 auto; padding: 26px clamp(20px, 5vw, 56px);
  color: var(--slate); font-size: 13.5px; border-top: 1px solid var(--line);
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  gap: clamp(28px, 5vw, 72px); align-items: center;
  padding: clamp(36px, 7vh, 84px) 0 clamp(40px, 7vh, 84px);
}
.hero-beam {
  position: absolute; inset: -120px -40vw auto auto;
  width: 110vw; height: 130%; pointer-events: none; z-index: -1;
  background:
    radial-gradient(58% 46% at 78% 30%, rgba(255, 178, 36, .22), transparent 70%),
    radial-gradient(40% 36% at 64% 64%, rgba(255, 178, 36, .10), transparent 70%);
  filter: blur(2px);
}
.hero-copy h1 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(38px, 5.6vw, 64px); line-height: 1.02;
  letter-spacing: -.025em; margin: 0 0 18px;
}
.hero-copy .accent {
  color: var(--beam-deep);
  background: linear-gradient(transparent 68%, rgba(255, 178, 36, .45) 68%);
  border-radius: 2px; padding: 0 .06em;
}

/* ---------- PIN input (the signature) ---------- */
.pin-join { margin-top: 30px; }
.pin-label {
  display: block; font-size: 13.5px; font-weight: 600; color: var(--slate);
  margin-bottom: 10px; letter-spacing: .02em;
}
.pin-row { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.pin-cell {
  width: 48px; height: 58px; text-align: center;
  font-family: var(--font-mono); font-size: 26px; font-weight: 600;
  color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-bottom-width: 3px;
  border-radius: var(--radius-sm);
  transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
  caret-color: var(--beam-deep);
}
.pin-cell:focus { outline: none; border-color: var(--beam); box-shadow: 0 0 0 4px rgba(255,178,36,.22); }
.pin-cell.filled { border-bottom-color: var(--beam); }
.pin-row.shake { animation: pin-shake .4s ease; }
@keyframes pin-shake {
  20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(3px); }
}
.pin-go { margin-left: 6px; }
.pin-error { color: var(--danger); font-size: 14px; font-weight: 500; margin: 10px 0 0; }
.pin-join-page { display: flex; flex-direction: column; align-items: center; gap: 22px; margin-top: 34px; }
.pin-row-big { justify-content: center; }
.pin-cell-big { width: clamp(44px, 12vw, 60px); height: clamp(56px, 15vw, 74px); font-size: 32px; }

/* ---------- hero drop frame ---------- */
.hero-frame { position: relative; }
.drop-frame {
  position: relative; display: block; aspect-ratio: 16 / 9;
  background: var(--surface); border: 2px dashed #C8CEDC;
  border-radius: var(--radius); text-decoration: none;
  transition: border-color .15s ease, transform .2s ease, box-shadow .2s ease;
  box-shadow: var(--shadow);
}
.drop-frame:hover { border-color: var(--beam); transform: translateY(-3px); }
.drop-frame-inner {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 20px;
}
.drop-glyph { width: 42px; height: 42px; color: var(--beam-deep); }
.drop-frame:hover .drop-glyph { animation: bob 1.1s ease infinite; }
@keyframes bob { 50% { transform: translateY(5px); } }
.drop-frame-inner strong { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.drop-frame-inner span { color: var(--slate); font-size: 13.5px; }
.frame-tab {
  position: absolute; top: -11px; right: 18px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; letter-spacing: .08em;
  background: var(--ink); color: var(--beam); padding: 3px 9px; border-radius: 6px;
}
.frame-shadow {
  position: absolute; inset: auto 8% -16px 8%; height: 26px; z-index: -1;
  background: radial-gradient(50% 100% at 50% 0, rgba(16,19,28,.22), transparent 70%);
}

/* ---------- feature cards ---------- */
.features {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
  padding-bottom: 24px;
}
.feature-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px 22px 22px; position: relative; overflow: hidden;
}
.feature-card::before {
  content: ""; position: absolute; top: 0; left: 22px; right: 22px; height: 3px;
  border-radius: 0 0 4px 4px; background: var(--line);
}
.feature-card:hover::before { background: var(--beam); }
.feature-key {
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  letter-spacing: .12em; color: var(--beam-deep);
}
.feature-card h3 { font-family: var(--font-display); font-size: 19px; font-weight: 700; margin: 8px 0 8px; }
.feature-card p { color: var(--slate); font-size: 14.5px; margin: 0; }

/* ---------- forms / create ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.form-card { padding: clamp(20px, 4vw, 32px); display: flex; flex-direction: column; gap: 22px; }
.field { display: block; }
.field-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.input {
  width: 100%; padding: 12px 14px; font: inherit; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--paper);
}
.input:focus { outline: none; border-color: var(--beam); box-shadow: 0 0 0 4px rgba(255,178,36,.2); background: var(--surface); }

.dropzone {
  display: block; border: 2px dashed #C8CEDC; border-radius: var(--radius-sm);
  background: var(--paper); padding: 34px 18px; text-align: center; cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover, .dropzone.drag { border-color: var(--beam); background: #FFF8EA; }
.dz-idle { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--ink-soft); }
.dz-idle svg { width: 34px; height: 34px; color: var(--beam-deep); }
.dz-idle strong { font-weight: 600; }
.dz-idle span { font-size: 13px; color: var(--slate); }
.dz-picked { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dz-name { font-family: var(--font-mono); font-weight: 600; font-size: 14.5px; word-break: break-all; }
.dz-size { color: var(--slate); font-size: 13px; }

.upload-progress { display: flex; align-items: center; gap: 14px; }
.upload-bar {
  flex: 1; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden;
}
.upload-bar span { display: block; height: 100%; width: 0; background: var(--beam); border-radius: 99px; transition: width .2s ease; }
.upload-pct { font-family: var(--font-mono); font-size: 13px; font-weight: 600; min-width: 42px; text-align: right; }
.form-error { color: var(--danger); font-weight: 500; font-size: 14.5px; margin: 0; }

/* ---------- processing loader ---------- */
.projector-loader {
  display: flex; gap: 10px; justify-content: center; margin: 48px 0 30px; perspective: 300px;
}
.loader-slide {
  width: 64px; height: 40px; border-radius: 6px; background: var(--surface);
  border: 1.5px solid var(--line); border-top: 4px solid var(--beam);
  animation: shuffle 1.4s ease-in-out infinite;
}
.loader-slide:nth-child(2) { animation-delay: .18s; }
.loader-slide:nth-child(3) { animation-delay: .36s; }
@keyframes shuffle {
  0%, 100% { transform: translateY(0); opacity: .55; }
  50% { transform: translateY(-14px); opacity: 1; box-shadow: 0 14px 18px -10px rgba(16,19,28,.3); }
}
.loader-dead .loader-slide { animation: none; opacity: .35; border-top-color: var(--danger); }

/* ---------- rooms dashboard ---------- */
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 18px; margin-top: 8px; }
.room-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow);
}
.room-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.room-title { font-family: var(--font-display); font-size: 18.5px; font-weight: 700; margin: 0; line-height: 1.2; word-break: break-word; }
.status-pill {
  flex: none; font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; padding: 4px 10px; border-radius: 99px;
}
.pill-active { background: #E5F6EC; color: var(--ok); }
.pill-ended { background: #FDF3DB; color: #9A6A00; }
.pill-processing { background: #FFF3DA; color: var(--beam-deep); }
.pill-failed, .pill-expired { background: #FBEAEA; color: var(--danger); }
.btn-end-session { border-color: #E8CC93; color: #8F6200; }
.btn-end-session:hover { background: #FFF7E7; border-color: #D7B16A; color: #7B5400; }
.room-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin: 0; }
.room-meta dt { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--slate); }
.room-meta dd { margin: 2px 0 0; font-size: 14px; font-weight: 500; word-break: break-all; }
.room-meta dd [data-countdown] { font-family: var(--font-mono); }
.room-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

.empty-state, .error-frame-wrap { text-align: center; padding: 40px 0; }
.empty-frame, .error-frame {
  width: 150px; aspect-ratio: 16/9; margin: 28px auto 22px;
  border: 2px dashed #C8CEDC; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.empty-frame span { width: 36%; height: 5px; border-radius: 3px; background: var(--line); }
.error-frame span { font-family: var(--font-display); font-weight: 800; font-size: 30px; color: var(--beam-deep); }
.empty-state h3 { font-family: var(--font-display); font-size: 21px; margin: 0 0 6px; }
.empty-state p { color: var(--slate); margin: 0 0 18px; }
.narrow .error-frame { margin-top: 56px; }

/* ---------- toasts ---------- */
#toast-root { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: #fff; font-size: 14.5px; font-weight: 500;
  padding: 11px 18px; border-radius: 99px; box-shadow: 0 10px 30px -8px rgba(16,19,28,.5);
  animation: toast-in .25s ease;
}
.toast-error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; background: rgba(12, 14, 21, .55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade-in .18s ease; backdrop-filter: blur(3px);
}
@keyframes fade-in { from { opacity: 0; } }
.modal {
  background: var(--surface); color: var(--ink); border-radius: var(--radius);
  max-width: 420px; width: 100%; padding: 26px; box-shadow: 0 30px 70px -20px rgba(0,0,0,.45);
  animation: pop .2s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.modal h3 { font-family: var(--font-display); font-size: 20px; margin: 0 0 8px; }
.modal p { color: var(--slate); margin: 0 0 18px; font-size: 15px; }
.modal .row-gap { margin-top: 0; justify-content: flex-end; }

.share-panel { text-align: center; }
.share-sub { font-size: 14.5px; }
.share-pin {
  font-family: var(--font-mono); font-size: 40px; font-weight: 600; letter-spacing: .22em;
  background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 6px 12px 16px; margin: 14px 0;
}
.share-qr img { width: 168px; height: 168px; border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; }
.share-panel .row-gap { justify-content: center; margin-top: 16px; }

/* ==========================================================================
   THE STAGE (presenter + viewer)
   ========================================================================== */
.stage-body { background: var(--stage); color: #E7EAF3; }
.stage { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.presenter, .viewer-shell { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.stage-top {
  display: flex; align-items: center; gap: 18px;
  flex-wrap: wrap;
  padding: 12px clamp(14px, 3vw, 28px); border-bottom: 1px solid var(--stage-line);
}
.stage-brand {
  display: flex; align-items: center; gap: 9px; text-decoration: none;
  font-family: var(--font-display); font-weight: 700; font-size: 16px; color: #B9C0D4;
}
.stage-title {
  font-family: var(--font-display); font-size: 16px; font-weight: 600; margin: 0;
  min-width: 0;
  color: #E7EAF3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; text-align: center;
}
.stage-top-right { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.presenter .stage-top-right .presenter-exit-btn { display: inline-flex; flex: none; position: relative; z-index: 1; }
.viewer-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 14px; color: #B9C0D4;
  border: 1px solid var(--stage-line); border-radius: 99px; padding: 6px 13px;
}
.viewer-chip svg { width: 16px; height: 16px; }
.viewer-chip strong { color: var(--beam); }

.btn-stage {
  background: var(--stage-2); color: #DDE2EF; border-color: var(--stage-line);
}
.btn-stage:hover { border-color: #3B445F; background: #1B2133; }
.btn-stage.is-on { background: var(--beam); color: var(--beam-ink); border-color: var(--beam); }

.stage-main {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  padding: clamp(10px, 2.5vw, 26px);
}
.stage-slide {
  position: relative; margin: 0; max-width: 100%; max-height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.stage-slide img {
  max-width: 100%; max-height: calc(100dvh - 230px);
  border-radius: 8px; box-shadow: 0 0 0 1px var(--stage-line), 0 30px 80px -20px rgba(0,0,0,.8);
  background: #fff; user-select: none;
}
.viewer-shell .stage-slide img { max-height: calc(100dvh - 130px); }

.laser-dot {
  position: absolute; width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle, #FF5A5A 0 35%, rgba(255,90,90,.45) 60%, transparent 70%);
  box-shadow: 0 0 14px 4px rgba(255, 70, 70, .55);
  transform: translate(-50%, -50%); pointer-events: none; z-index: 5;
}
.blackout-veil {
  position: fixed; inset: 0; z-index: 40; background: #000;
  display: none; align-items: flex-end; justify-content: center; cursor: pointer;
}
.blackout-veil.is-active { display: flex; }
.blackout-veil span { color: #4A5168; font-size: 13.5px; padding: 22px; font-family: var(--font-mono); }
.viewer-veil { cursor: default; }
.viewer-veil span { color: #39405A; }

/* filmstrip */
.filmstrip {
  display: flex; gap: 10px; overflow-x: auto; padding: 10px clamp(14px, 3vw, 28px);
  border-top: 1px solid var(--stage-line); scrollbar-width: thin;
}
.thumb {
  flex: none; width: 104px; aspect-ratio: 16/9; border-radius: 6px; overflow: hidden;
  border: 2px solid var(--stage-line); background: var(--stage-2);
  cursor: pointer; padding: 0; position: relative; transition: border-color .12s ease;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-n {
  position: absolute; bottom: 3px; right: 5px; font-family: var(--font-mono);
  font-size: 10.5px; color: #fff; background: rgba(12,14,21,.75); border-radius: 4px; padding: 1px 5px;
}
.thumb:hover { border-color: #3B445F; }
.thumb.current { border-color: var(--beam); box-shadow: 0 0 0 3px rgba(255,178,36,.25); }

/* controls */
.stage-controls {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 12px clamp(14px, 3vw, 28px) 16px; border-top: 1px solid var(--stage-line);
}
.ctrl-cluster { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.slide-counter { font-family: var(--font-mono); font-size: 15px; color: #B9C0D4; }
.slide-counter strong { color: var(--beam); font-weight: 600; }
.key-hints { font-family: var(--font-mono); font-size: 11.5px; color: #4A5168; margin: 0; width: 100%; text-align: center; }

/* viewer chrome */
.viewer-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px clamp(14px, 3vw, 28px);
}
.viewer-room-title { font-family: var(--font-display); font-weight: 600; font-size: 15.5px; color: #B9C0D4; }
.conn-pill {
  font-family: var(--font-mono); font-size: 12px; padding: 5px 12px; border-radius: 99px;
  border: 1px solid var(--stage-line); color: #8A93AC;
}
.conn-pill.ok { color: var(--ok); border-color: rgba(47,158,98,.5); }
.conn-pill.bad { color: var(--danger); border-color: rgba(229,72,77,.5); }
.viewer-bottom {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px clamp(14px, 3vw, 28px) 14px;
}

/* ---------- responsive ---------- */
@media (max-width: 920px) {
  .hero { grid-template-columns: 1fr; padding-top: 24px; }
  .features { grid-template-columns: 1fr; }
  .stage-title { display: none; }
  .stage-top { gap: 10px; }
  .stage-top-right { width: 100%; }
}
@media (max-width: 560px) {
  .brand-mark { height: 34px; }
  .nav-links a:not(.btn) { display: none; }
  .pin-cell { width: 42px; height: 52px; font-size: 22px; }
  .pin-go { width: 100%; margin: 6px 0 0; }
  .room-grid { grid-template-columns: 1fr; }
  .key-hints { display: none; }
  .stage-top-right { gap: 8px; }
}

/* ---------- accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
