/* ═══════════════════════════════════════════════════════════════════════════
   Slide Notes — Public Viewer Stylesheet
   Supports light (default) and dark mode via data-theme="dark" on <html>
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Custom Properties (Light Theme) ──────────────────────────────────────── */
:root {
  --bg:           #f8f9fc;
  --surface:      #ffffff;
  --surface-2:    #f1f3f8;
  --border:       #e2e6ef;
  --text:         #1a1d2e;
  --text-muted:   #6b7280;
  --accent:       #4361ee;
  --accent-hover: #3451d1;
  --accent-light: #eff2fd;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:    0 4px 16px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);
  --shadow-lg:    0 8px 32px rgba(0,0,0,.14), 0 4px 12px rgba(0,0,0,.08);
  --radius:       12px;
  --header-h:     64px;
  --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Dark Theme ───────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:           #0e0f1a;
  --surface:      #161726;
  --surface-2:    #1e2035;
  --border:       #2a2d45;
  --text:         #e8eaf6;
  --text-muted:   #8b90b8;
  --accent:       #7b9cff;
  --accent-hover: #96b0ff;
  --accent-light: #1a1f3a;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.3);
  --shadow-md:    0 4px 16px rgba(0,0,0,.4);
  --shadow-lg:    0 8px 32px rgba(0,0,0,.5);
}

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background .25s, color .25s;
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: background .25s, border-color .25s;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-shrink: 0;
  text-decoration: none;
}

.brand-icon { width: 32px; height: 32px; flex-shrink: 0; }

.brand-name {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .01em;
}

.header-meta {
  flex: 1;
  min-width: 0;
}

.pres-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.pres-meta-line {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin-top: .05rem;
  line-height: 1.2;
}

.pres-campus {
  font-size: .78rem;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.pres-meta-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  opacity: .6;
}

.pres-date {
  font-size: .78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
}

.slide-count {
  font-size: .8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Icon Button (theme toggle) ───────────────────────────────────────────── */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
}
.btn-icon:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }
.btn-icon svg { width: 18px; height: 18px; }

/* Sun/Moon toggle */
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun  { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* ── Print Button ─────────────────────────────────────────────────────────── */
.btn-print {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
  white-space: nowrap;
}
.btn-print:hover  { background: var(--accent-hover); }
.btn-print:active { transform: scale(.97); }
.btn-print svg    { width: 16px; height: 16px; }

/* ── Floating Action Button ───────────────────────────────────────────────── */
.fab-print {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 99;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .2s, transform .2s, opacity .3s;
  opacity: 0;
  pointer-events: none;
}
.fab-print.visible { opacity: 1; pointer-events: all; }
.fab-print:hover   { background: var(--accent-hover); transform: scale(1.05); }
.fab-print svg     { width: 22px; height: 22px; }

/* ── Main Content ─────────────────────────────────────────────────────────── */
.viewer-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 6rem;
}

/* ── Empty State ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 5rem 2rem;
  color: var(--text-muted);
}

/* ── Slide Item ───────────────────────────────────────────────────────────── */
.slide-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s;
}
.slide-item:last-child { margin-bottom: 0; }

.slide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.slide-number {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
}
.of-total { color: var(--text-muted); font-weight: 400; }

/* ── Slide Image ──────────────────────────────────────────────────────────── */
.slide-frame {
  background: #000;
  position: relative;
  line-height: 0;
}

.slide-img {
  width: 100%;
  height: auto;
  display: block;
  max-height: 70vh;
  object-fit: contain;
  background: #000;
}

/* ── Notes Section ────────────────────────────────────────────────────────── */
.notes-section {
  padding: 1.25rem;
  position: relative;
}

.notes-label {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .6rem;
  user-select: none;
}
.notes-label svg { width: 14px; height: 14px; flex-shrink: 0; }

.notes-input {
  min-height: 100px;
  padding: .75rem;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: var(--font);
  font-size: .95rem;
  color: var(--text);
  line-height: 1.6;
  outline: none;
  transition: border-color .2s, background .2s;
  position: relative;
  z-index: 1;
  white-space: pre-wrap;
  word-break: break-word;
}
.notes-input:focus {
  border-color: var(--accent);
  background: var(--surface);
}
.notes-input:empty { color: transparent; }

/* Placeholder via sibling element */
.notes-placeholder {
  position: absolute;
  top: calc(1.25rem + .8rem + 1em + .6rem + .75rem); /* approx label height */
  left: calc(1.25rem + .75rem);
  font-size: .95rem;
  color: var(--text-muted);
  pointer-events: none;
  opacity: .6;
  transition: opacity .15s;
  user-select: none;
}
.notes-input:focus ~ .notes-placeholder,
.notes-input:not(:empty) ~ .notes-placeholder {
  opacity: 0;
}

/* ── Print-only area ──────────────────────────────────────────────────────── */
.print-area { display: none; }

/* ═══════════════════════════════════════════════════════════════════════════
   PRINT STYLES
   ═══════════════════════════════════════════════════════════════════════════ */
@media print {
  /* Page setup: portrait letter, decent margins */
  @page { size: letter portrait; margin: 0.45in; }

  /* Reset colours */
  html, body { background: #fff !important; color: #000 !important; }

  /* Hide chrome */
  .site-header,
  .fab-print,
  .btn-print,
  .btn-icon,
  .slide-header,
  .notes-label,
  .notes-placeholder { display: none !important; }

  /* Reset layout */
  .viewer-main { padding: 0; margin: 0; max-width: 100%; }

  /* ── 2-slides-per-page layout ──────────────────────────────────────────── */
  /* Each slide item takes up roughly half a page height */
  .slide-item {
    border: 1px solid #e0e0e0;
    border-radius: 0;
    box-shadow: none;
    page-break-inside: avoid;
    break-inside: avoid;
    /* ~4.55in each: (11in page - 0.9in margins) ÷ 2 slides - 0.1in gap */
    height: 4.55in;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin: 0 0 0.1in;
    padding: 0.1in;
  }

  /* Page break after every 2nd slide */
  .slide-item:nth-child(2n) {
    page-break-after: always;
    break-after: page;
    margin-bottom: 0;
  }

  /* Slide image — constrained so there's room for notes */
  .slide-frame {
    background: #fff;
    flex: 0 0 auto;
    line-height: 0;
  }

  .slide-img {
    width: 100%;
    height: 3.1in;
    object-fit: contain;
    display: block;
    background: #fff;
  }

  /* Notes — fixed height beneath each image */
  .notes-section {
    padding: 0.08in 0 0;
    flex: 1;
    overflow: hidden;
  }

  .notes-input {
    height: 1.05in;
    min-height: 0 !important;
    border: 1px solid #ccc !important;
    border-radius: 3px;
    background: #fff !important;
    color: #000 !important;
    font-size: .82rem;
    line-height: 1.4;
    padding: .25rem .4rem;
    overflow: hidden;
  }

  /* Show placeholder text if notes are empty */
  .notes-input:empty::before {
    content: attr(data-placeholder);
    color: #bbb;
  }

  /* Slide number label — small, visible in print */
  .slide-header {
    display: flex !important;
    padding: 0 0 0.05in;
    border-bottom: none;
  }
  .slide-number {
    font-size: .7rem;
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    letter-spacing: .05em;
  }
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .brand-name, .slide-count { display: none; }
  .header-inner { gap: .5rem; }
  .btn-print span { display: none; }
  .viewer-main { padding: 1.5rem 1rem 5rem; }
  .slide-item { margin-bottom: 1.5rem; border-radius: 8px; }
  .pres-title { font-size: .9rem; }
}
