@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@600;700&family=Inter:wght@400;500;600&family=Monoton&family=Asimovian&display=swap');

:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece4;
  --border: #ddd8cc;
  --text: #1d1b16;
  --muted: #6b665b;
  --accent: #1f3a68;
  --accent-text: #ffffff;
  --gold: #b8912f;
  --live: #c0392b;
  --yes: #2e7d4f;
  --no: #8a6d1f;
  --radius: 12px;

  /* Projected slide – replace --slide-bg-image with url('/assets/background.jpg') when ready */
  --slide-bg-image: none;
  --slide-bg: radial-gradient(1200px 800px at 15% 20%, #2b4a86 0%, transparent 60%),
              radial-gradient(1000px 700px at 90% 90%, #5a1f3d 0%, transparent 55%),
              linear-gradient(135deg, #0f1d3a 0%, #172b55 50%, #2a1430 100%);
  --slide-text: #ffffff;
  --slide-accent: #e2c36b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15161a; --surface: #1e2026; --surface-2: #262931; --border: #343844;
    --text: #ecebe6; --muted: #a09d94; --accent: #8fb0ea; --accent-text: #0e1420;
    --gold: #d9b45a; --yes: #6cc191; --no: #d6b35c;
  }
}
:root[data-theme="dark"] {
  --bg: #15161a; --surface: #1e2026; --surface-2: #262931; --border: #343844;
  --text: #ecebe6; --muted: #a09d94; --accent: #8fb0ea; --accent-text: #0e1420;
  --gold: #d9b45a; --yes: #6cc191; --no: #d6b35c;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 Inter, system-ui, 'Segoe UI', sans-serif;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

button, .btn {
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
button:hover, .btn:hover { border-color: var(--muted); }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.live { background: var(--live); color: #fff; border-color: var(--live); }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .card:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%;
}
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 14px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 20px; }
.brand { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 24px; font-weight: 700; margin-right: auto; }
.brand small { font-family: Inter, sans-serif; font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 8px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 20px; }
.toolbar .search { max-width: 260px; }
.count { color: var(--muted); font-size: 13px; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.segmented button { border: 0; border-radius: 0; padding: 7px 12px; background: transparent; }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 1fr 360px; gap: 0; align-items: start; }
.side {
  position: sticky; top: 64px; padding: 16px 20px; border-left: 1px solid var(--border);
  height: calc(100vh - 64px); overflow: auto; display: flex; flex-direction: column; gap: 14px;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-left: 0; border-top: 1px solid var(--border); order: -1; }
}

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.room-code { font: 700 32px/1 ui-monospace, Consolas, monospace; letter-spacing: .15em; color: var(--accent); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.on::before { background: var(--yes); }
.mini-preview { aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #000; }
.nav-row { display: flex; gap: 8px; }
.nav-row button { flex: 1; justify-content: center; }

/* ---------- grid ---------- */
.grid {
  display: grid; gap: 14px; padding: 4px 20px 40px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
.card {
  position: relative; text-align: left; padding: 10px; border-radius: var(--radius);
  background: var(--surface); border: 2px solid var(--border);
  display: flex; flex-direction: column; gap: 8px; cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.card:hover { transform: translateY(-2px); border-color: var(--muted); }
.card.live { border-color: var(--live); box-shadow: 0 0 0 3px color-mix(in srgb, var(--live) 25%, transparent); }
.card img, .card .ph { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--surface-2); display: block; }
.card .name { font-weight: 600; line-height: 1.25; }
.card .prog { font-size: 12px; color: var(--muted); }
.card .num {
  position: absolute; top: 18px; left: 18px; min-width: 34px; padding: 4px 9px; border-radius: 999px;
  background: rgba(0,0,0,.72); color: #fff; font: 700 17px/1.2 ui-monospace, Consolas, monospace; text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.35); backdrop-filter: blur(2px);
}
.badge { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; align-self: flex-start; }
.badge.yes { color: var(--yes); background: color-mix(in srgb, var(--yes) 14%, transparent); }
.badge.no { color: var(--no); background: color-mix(in srgb, var(--no) 14%, transparent); }
.card .live-tag { position: absolute; top: 16px; right: 16px; background: var(--live); color: #fff; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 6px; }
.card-foot { display: flex; gap: 6px; align-items: center; margin-top: auto; }
.card .edit { padding: 5px 9px; font-size: 12px; }
.att-toggle { display: inline-flex; flex: 1; border: 1px solid var(--border); border-radius: 999px; padding: 2px; background: var(--surface-2); }
.att-toggle button {
  flex: 1; justify-content: center; border: 0; border-radius: 999px; padding: 5px 6px;
  font-size: 12px; font-weight: 600; background: transparent; color: var(--muted); min-height: 30px;
}
.att-toggle button.yes[aria-pressed="true"] { background: var(--yes); color: var(--surface); }
.att-toggle button.no[aria-pressed="true"] { background: var(--no); color: var(--surface); }

/* ---------- forms / centred pages ---------- */
.center-wrap { max-width: 440px; margin: 8vh auto; padding: 0 16px; }
.center-wrap.wide { max-width: 980px; }
.center-wrap h1 { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 36px; margin-bottom: 6px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.err { color: var(--live); font-size: 14px; min-height: 1.2em; }
.devnote { background: color-mix(in srgb, var(--gold) 15%, transparent); border: 1px dashed var(--gold); padding: 8px 10px; border-radius: 8px; font-size: 13px; }

.profile { display: grid; grid-template-columns: 1fr 1.3fr; gap: 24px; align-items: start; }
@media (max-width: 800px) { .profile { grid-template-columns: 1fr; } }
.photo-row { display: flex; gap: 12px; align-items: center; }
.photo-row img { width: 84px; height: 84px; border-radius: 12px; object-fit: cover; background: var(--surface-2); }

dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 20px; width: min(560px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { font-size: 18px; margin-bottom: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.changes { width: 100%; border-collapse: collapse; font-size: 13px; }
.changes td, .changes th { border-bottom: 1px solid var(--border); padding: 6px; text-align: left; vertical-align: top; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; transition: .2s; z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--live); color: #fff; }

/* ---------- projected slide (1920×1080 stage) ---------- */
@property --beam { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

.slide-host { position: relative; overflow: hidden; background: #000; }
.stage { position: absolute; left: 50%; top: 50%; width: 1920px; height: 1080px; transform-origin: center; overflow: hidden; }
.stage-bg { position: absolute; inset: 0; background: var(--slide-bg); }
.stage-bg::after { content: ''; position: absolute; inset: 0; background: var(--slide-bg-image) center / cover no-repeat; }

/* ambient floating lights */
.particles { position: absolute; inset: 0; pointer-events: none; }
.particles span {
  position: absolute; bottom: -40px; border-radius: 50%; opacity: 0;
  background: radial-gradient(circle, rgba(255, 233, 168, .95), rgba(255, 233, 168, 0) 70%);
  animation: rise var(--dur) linear var(--delay) infinite;
}
@keyframes rise {
  0%   { transform: translate(0, 0); opacity: 0; }
  12%  { opacity: var(--o); }
  85%  { opacity: var(--o); }
  100% { transform: translate(var(--drift), -1180px); opacity: 0; }
}

.slide { position: absolute; inset: 0; display: flex; align-items: center; gap: 160px; padding: 0 110px 0 220px; }

/* photo and its decorations */
.slide-visual { position: relative; width: 620px; height: 620px; flex: none; perspective: 2400px; }

/* two-sided photo card: front = graduate, back = SEMI logo on blue */
.card3d { position: relative; z-index: 2; width: 100%; height: 100%; transform-style: preserve-3d; }
.face {
  position: absolute; inset: 0; border-radius: 46px; overflow: hidden;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5), 0 0 0 6px rgba(255, 255, 255, .1);
}
.face.back {
  transform: rotateY(180deg); display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #2f6fe0, #1546a8 55%, #0b2c75);
}
.face.back img { width: 74%; height: 74%; object-fit: contain; }
.face .prev { position: absolute; inset: 0; z-index: 1; display: none; }
.slide-photo { display: block; width: 100%; height: 100%; object-fit: cover; }

/* old photo → logo → new photo. The old photo covers the front until the card is edge-on. */
.slide.flip .card3d { animation: flip-twice 1.5s both; }
.slide.flip .face .prev { display: block; animation: hide-prev 1.5s step-end both; }
@keyframes flip-twice {
  0%   { transform: rotateY(0deg);   animation-timing-function: cubic-bezier(.55, 0, .45, 1); }
  50%  { transform: rotateY(180deg) scale(1.04); animation-timing-function: cubic-bezier(.55, 0, .45, 1); }
  100% { transform: rotateY(360deg); }
}
@keyframes hide-prev { 0% { opacity: 1; } 50%, 100% { opacity: 0; } }
.slide-photo-empty {
  display: grid; place-items: center; background: rgba(255, 255, 255, .08);
  color: var(--slide-text); font: 700 200px 'Cormorant Garamond', Georgia, serif;
}

.halo {
  position: absolute; inset: -140px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--slide-accent) 55%, transparent) 20%, transparent 66%);
  animation: breathe 5s ease-in-out infinite;
}
@keyframes breathe { 50% { transform: scale(1.1); } }

/* light sweeping around the photo frame */
.beam {
  position: absolute; inset: -18px; z-index: 1; border-radius: 62px; padding: 6px;
  background: conic-gradient(from var(--beam), transparent 0 45%, color-mix(in srgb, var(--slide-accent) 45%, transparent) 60%,
              #fff6d6 78%, var(--slide-accent) 84%, color-mix(in srgb, var(--slide-accent) 35%, transparent) 92%, transparent 100%);  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: beam 6s linear infinite;
}
.beam::before { content: ''; position: absolute; inset: 0; border-radius: inherit; border: 2px solid color-mix(in srgb, var(--slide-accent) 30%, transparent); }
@keyframes beam { to { --beam: 360deg; } }

/* sparkles orbiting the photo */
.orbit { position: absolute; left: 50%; top: 50%; width: 0; height: 0; --r: 450px; animation: spin 46s linear infinite; }
.orbit.o2 { --r: 492px; animation-duration: 32s; animation-direction: reverse; }
.orbit::before {
  content: ''; position: absolute; left: calc(-1 * var(--r)); top: calc(-1 * var(--r));
  width: calc(2 * var(--r)); height: calc(2 * var(--r)); border-radius: 50%;
  border: 1.5px dashed rgba(255, 255, 255, .12);
}
.orbit i {
  position: absolute; left: -6px; top: -6px; width: 12px; height: 12px; border-radius: 50%;
  background: #fff3c8; box-shadow: 0 0 14px 4px color-mix(in srgb, var(--slide-accent) 70%, transparent);
  transform: rotate(var(--a)) translateX(var(--r));
  animation: twinkle 2.2s ease-in-out calc(-1 * var(--d)) infinite alternate;
}
.orbit.o2 i { left: -4px; top: -4px; width: 8px; height: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes twinkle { from { opacity: .25; } to { opacity: 1; } }

/* text */
.slide-text { color: var(--slide-text); min-width: 0; flex: 1; }
.slide-name {
  font-family: Monoton, 'Cormorant Garamond', Georgia, serif; font-weight: 400; line-height: 1.2; word-spacing: .3em;
  text-shadow: 0 0 28px rgba(255, 255, 255, .25), 0 4px 24px rgba(0, 0, 0, .35);
}
.slide-name .w { display: inline-block; }
.slide-rule {
  position: relative; width: 420px; height: 3px; margin-top: 44px; border-radius: 2px;
  background: linear-gradient(90deg, #ffd76a, #ff7eb6 30%, #b69cff 55%, #7ee8fa 80%, transparent);
  filter: drop-shadow(0 0 5px rgba(255, 255, 255, .55));   /* glow for the line and its stars */
}
/* a white gleam that runs along the line */
.slide-rule::after {
  content: ''; position: absolute; top: -2px; left: 0; width: 90px; height: 7px; border-radius: 4px;
  background: radial-gradient(closest-side, #fff, transparent);
  animation: gleam 3.2s ease-in-out infinite;
}
@keyframes gleam { 0% { transform: translateX(-60px); opacity: 0; } 15%, 75% { opacity: 1; } 100% { transform: translateX(400px); opacity: 0; } }

/* four-point star sparkles */
.slide-rule i {
  position: absolute; top: 50%; width: var(--s); height: var(--s); margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2);
  background: var(--c);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: sparkle var(--dur) ease-in-out var(--d) infinite;
}
@keyframes sparkle {
  0%, 100% { transform: translateY(0) scale(0) rotate(0deg); opacity: 0; }
  45%      { transform: translateY(var(--y)) scale(1) rotate(90deg); opacity: 1; }
  70%      { transform: translateY(calc(var(--y) * 1.3)) scale(.5) rotate(140deg); opacity: .7; }
}
.slide-prog { margin-top: 26px; font: 400 46px/1.3 Asimovian, Inter, sans-serif; color: var(--slide-accent); letter-spacing: .01em; }
/* City, State under the institute: same entrance as the institute, a beat later, quieter */
.slide-prog.slide-loc { margin-top: 10px; font-size: 32px; color: rgba(255,255,255,.78); }
.slide .slide-prog.slide-loc { transition-delay: calc(.8s + var(--words) * .1s); }
.slide.flip.in .slide-prog.slide-loc { transition-delay: calc(1.25s + var(--words) * .1s); }
.slide.out .slide-prog.slide-loc { transition-delay: 0s; }

/* ---------- entry (.in) ---------- */
.slide .slide-visual {
  opacity: 0; transform: translateX(-140px) scale(.88) rotate(-4deg);
  transition: transform 1.1s cubic-bezier(.16, 1, .3, 1), opacity .7s ease;
}
.slide .halo, .slide .orbit, .slide .beam { opacity: 0; transition: opacity 1.2s ease .45s; }
.slide .w {
  opacity: 0; transform: translateY(70px) rotate(4deg); filter: blur(10px);
  transition: transform 1s cubic-bezier(.16, 1, .3, 1), opacity .7s ease, filter .8s ease;
  transition-delay: calc(.3s + var(--i) * .1s);
}
.slide .slide-rule {
  transform: scaleX(0); transform-origin: left;
  transition: transform .9s cubic-bezier(.16, 1, .3, 1) calc(.5s + var(--words) * .1s);
}
.slide .slide-prog {
  opacity: 0; transform: translateY(24px); letter-spacing: .18em;
  transition: opacity .8s ease, transform .9s cubic-bezier(.16, 1, .3, 1), letter-spacing 1.1s cubic-bezier(.16, 1, .3, 1);
  transition-delay: calc(.65s + var(--words) * .1s);
}
.slide.in .slide-visual { opacity: 1; transform: none; }
.slide.in .halo, .slide.in .orbit, .slide.in .beam { opacity: 1; }
.slide.in .w { opacity: 1; transform: none; filter: none; }
.slide.in .slide-rule { transform: scaleX(1); }
.slide.in .slide-prog { opacity: 1; transform: none; letter-spacing: .01em; }

/* ---------- exit (.out) – quicker, no long delays ---------- */
.slide.out .slide-visual { opacity: 0; transform: translateX(-80px) scale(.94); transition: transform .5s ease-in, opacity .45s ease-in; }
.slide.out .halo, .slide.out .orbit, .slide.out .beam { opacity: 0; transition: opacity .35s ease; }
.slide.out .w { opacity: 0; transform: translateY(-50px); filter: blur(8px); transition-duration: .45s; transition-timing-function: ease-in; transition-delay: calc(var(--i) * .03s); }
.slide.out .slide-rule { transform: scaleX(0); transform-origin: right; transition: transform .4s ease-in; }
.slide.out .slide-prog { opacity: 0; transform: translateY(-20px); transition: opacity .35s ease-in, transform .4s ease-in; }

/* ---------- flip hand-over: the card never leaves, only the text changes ---------- */
.slide.flip .slide-visual, .slide.flip .halo, .slide.flip .orbit, .slide.flip .beam { opacity: 1; transform: none; transition: none; }
.slide.flip-out .slide-visual { opacity: 0; transition: none; }
/* new name arrives as the card turns from the logo to the new photo */
.slide.flip.in .w { transition-delay: calc(.75s + var(--i) * .1s); }
.slide.flip.in .slide-rule { transition-delay: calc(.95s + var(--words) * .1s); }
.slide.flip.in .slide-prog { transition-delay: calc(1.1s + var(--words) * .1s); }

@media (prefers-reduced-motion: reduce) {
  .slide *, .particles span { animation: none !important; }
  .face .prev { display: none !important; }
  .slide .slide-visual, .slide .w, .slide .slide-prog { transform: none !important; filter: none !important; }
}

/* ---------- photo cropper ---------- */
dialog.crop-dialog { width: min(980px, 96vw); }
.crop-layout { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: start; }
@media (max-width: 720px) { .crop-layout { grid-template-columns: 1fr; } }
.crop-view {
  position: relative; width: min(320px, 80vw); aspect-ratio: 1; overflow: hidden; margin: 0 auto;
  background: #000; border-radius: 8px; cursor: grab; touch-action: none; user-select: none;
}
.crop-view:active { cursor: grabbing; }
.crop-img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; pointer-events: none; }
/* matches the slide's rounded corners (46px on a 620px photo) */
.crop-guide {
  position: absolute; inset: 0; z-index: 1; pointer-events: none; border-radius: 7.4%;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, .55); outline: 2px solid rgba(255, 255, 255, .85); outline-offset: -2px;
}
.crop-slide { aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; margin-bottom: 6px; }
