/* presenter — design tokens and components. See docs/design.md.
   Dark by default, light via prefers-color-scheme: the same tokens, so both
   exist from day one. No web fonts and no external CDNs (house rule). */

:root {
  --bg: #0b0d12;
  --bg-2: #131722;
  --line: #242b3a;
  --ink: #e8ecf4;
  --ink-2: #9aa6bd;
  --accent: #5b7cfa;
  --accent-2: #19c6a6;
  --warn: #e6a23c;
  --danger: #ef5f5f;

  --radius-card: 14px;
  --radius-btn: 10px;
  --shadow: 0 1px 0 rgba(255, 255, 255, .04), 0 12px 32px rgba(0, 0, 0, .35);
  --font: -apple-system, 'Segoe UI', Inter, Roboto, 'Helvetica Neue', Arial, sans-serif;
  --fast: 120ms ease-out;
  --slow: 180ms ease-out;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f8fb;
    --bg-2: #ffffff;
    --line: #e3e7ef;
    --ink: #141824;
    --ink-2: #5b6478;
    --shadow: 0 1px 0 rgba(0, 0, 0, .02), 0 12px 32px rgba(20, 24, 36, .10);
  }
}

*, *::before, *::after { box-sizing: border-box; }

/* `clip`, not `hidden` — `hidden` kills position: sticky (house rule). */
html {
  overflow-x: clip;
  background: var(--bg);
  color-scheme: dark light;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Declared BEFORE any display rule, so [hidden] always wins (house rule). */
[hidden] { display: none !important; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { letter-spacing: -0.01em; margin: 0 0 .4em; font-weight: 600; }
h1 { font-size: 32px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
p { margin: 0 0 1em; }
small, .small { font-size: 13px; color: var(--ink-2); }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------------------------------------------------------------- AppBar */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  flex: 0 0 auto;
}
.logo:hover { text-decoration: none; }
.logo-glyphs { display: inline-flex; align-items: center; gap: 7px; }
.logo-words { display: flex; flex-direction: column; line-height: 1.05; }
.logo-name { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.logo-by {
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: none;
  color: var(--ink-2);
}

.nav { display: flex; gap: 4px; flex: 1 1 auto; }
.navlink {
  padding: 7px 12px;
  border-radius: var(--radius-btn);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
}
.navlink:hover { background: var(--bg-2); color: var(--ink); text-decoration: none; }
.navlink[aria-current='page'] { background: var(--bg-2); color: var(--ink); }
.appbar-end { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

/* --------------------------------------------------------------- Layout */
.wrap { max-width: 1240px; margin: 0 auto; padding: 32px 24px 80px; }
.wrap.narrow { max-width: 520px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }

/* -------------------------------------------------------------- Buttons */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--fast), filter var(--fast), background-color var(--fast);
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; filter: none; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--bg-2); filter: none; }
.btn.danger { background: transparent; border-color: var(--line); color: var(--danger); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); filter: none; }
.btn.small { min-height: 32px; padding: 6px 11px; font-size: 13px; }

/* ---------------------------------------------------------------- Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.chip.quiet { background: var(--bg-2); color: var(--ink-2); border: 1px solid var(--line); }
.chip.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.chip.good { background: color-mix(in srgb, var(--accent-2) 16%, transparent); color: var(--accent-2); }

/* -------------------------------------------------------------- Gallery */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform var(--slow), border-color var(--slow);
}
.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

.card-cover {
  display: block;
  width: 100%;
  /* height: auto is REQUIRED. The <img> carries width/height attributes so the
     browser can reserve the box before the poster loads (no jumping cards),
     but a presentational height would otherwise win over aspect-ratio and the
     16:9 poster would be cropped inside a near-square box. */
  height: auto;
  aspect-ratio: 16 / 9;
  background: var(--bg);
  object-fit: cover;
  border-bottom: 1px solid var(--line);
  transition: transform var(--slow);
}
.card:hover .card-cover { transform: scale(1.02); }

.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1 1 auto; }
.card-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.card-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.card-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; flex-wrap: wrap; }

/* ------------------------------------------------------------- DropZone */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 44px 24px;
  border: 2px dashed var(--line);
  border-radius: var(--radius-card);
  color: var(--ink-2);
  text-align: center;
  transition: border-color var(--fast), background-color var(--fast);
}
.dropzone.hot {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--ink);
}
.dropzone strong { color: var(--ink); font-size: 17px; }

/* ---------------------------------------------------------------- Forms */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
input[type='text'], input[type='email'], input[type='password'], textarea, select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  background: var(--bg-2);
  color: var(--ink);
  font: inherit;
  /* 16px minimum, or iOS zooms on focus (house rule). */
  font-size: 16px;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.field { margin-bottom: 16px; }

.panel {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 22px;
  box-shadow: var(--shadow);
}

.notice {
  padding: 11px 14px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--line);
  background: var(--bg-2);
  font-size: 14px;
}
.notice.bad { border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); color: var(--danger); }
.notice.good { border-color: color-mix(in srgb, var(--accent-2) 50%, var(--line)); color: var(--accent-2); }

.empty { padding: 64px 24px; text-align: center; color: var(--ink-2); }

/* ---------------------------------------------------------------- Toast */
.toasts {
  position: fixed;
  inset: auto 0 24px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 60;
}
.toast {
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: toast-in var(--slow);
}
.toast.bad { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- Modal */
.modal-back {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, .6);
  z-index: 50;
}
.modal { width: min(520px, 100%); max-height: 80vh; overflow: auto; }

/* ---------------------------------------------------------------- Editor */
.editor { display: grid; grid-template-columns: 220px 1fr 300px; height: 100vh; }
.editor-col { border-right: 1px solid var(--line); overflow: auto; padding: 16px; }
.editor-col:last-child { border-right: 0; border-left: 1px solid var(--line); }
.editor-stage { display: flex; flex-direction: column; background: #000; }
.editor-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.editor-frame { flex: 1 1 auto; width: 100%; border: 0; background: #000; }
.slide-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  margin-bottom: 4px;
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.slide-btn:hover { background: var(--bg-2); color: var(--ink); }
.slide-btn[aria-current='true'] { background: var(--bg-2); color: var(--ink); border-color: var(--accent); }

.field-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.field-row:last-child { border-bottom: 0; }
.field-row .field-el { font-size: 11px; letter-spacing: .06em; color: var(--ink-2); text-transform: uppercase; }
.field-row textarea { margin-top: 5px; min-height: 60px; resize: vertical; font-size: 16px; }
.field-row.dirty textarea { border-color: var(--accent); }

.version-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.version-row:last-child { border-bottom: 0; }

@media (max-width: 1000px) {
  .editor { grid-template-columns: 1fr; height: auto; }
  .editor-col { border: 0; border-bottom: 1px solid var(--line); max-height: 40vh; }
  .editor-col:last-child { border-left: 0; }
  .editor-frame { height: 60vh; }
}

/* ---------------------------------------------------------------- Viewer */
.viewer { margin: 0; background: #000; height: 100vh; overflow: hidden; }
.viewer-frame { position: fixed; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.viewer-bar {
  position: fixed;
  inset: 0 0 auto 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(8, 10, 16, .82);
  backdrop-filter: blur(10px);
  color: #e8ecf4;
  z-index: 5;
  transition: opacity var(--slow), transform var(--slow);
}
.viewer-bar.away { opacity: 0; transform: translateY(-100%); pointer-events: none; }

/* The presentation fills the viewport, and it is cross-origin — so once the
   bar hides, a mousemove or a tap goes to the IFRAME and the shell never hears
   it. Without this handle the bar could never come back. It is deliberately
   small: everything else on screen belongs to the presentation. */
.viewer-peek {
  position: fixed;
  top: 10px;
  right: 12px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 30px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  background: rgba(8, 10, 16, .55);
  color: #e8ecf4;
  font: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  opacity: .4;
  transition: opacity var(--fast), background-color var(--fast);
}
.viewer-peek:hover, .viewer-peek:focus-visible { opacity: 1; background: rgba(8, 10, 16, .85); }
.viewer-bar .grow { flex: 1 1 auto; font-size: 14px; }
.viewer-bar .btn.ghost { color: #e8ecf4; border-color: rgba(255, 255, 255, .25); }

/* Phone. The app bar is a flex row with three children — logo, nav and the
   log-out button — and at 390px they do not fit (the house lesson about flex
   rows breaking on a third child). Wrap the nav onto its own line rather than
   letting "Log ud" slide off the screen. */
@media (max-width: 720px) {
  .appbar {
    flex-wrap: wrap;
    gap: 10px 14px;
    padding: 10px 14px;
  }
  .nav {
    order: 3;
    flex: 1 0 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .appbar-end { margin-left: auto; }
  .wrap { padding: 20px 14px 64px; }
  h1 { font-size: 26px; }
  .page-head { margin-bottom: 18px; }
  .gallery { grid-template-columns: 1fr; gap: 16px; }
  .viewer-bar { padding: 8px 12px; gap: 8px; }
  .viewer-bar .grow { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
  .card:hover { transform: none; }
  .card:hover .card-cover { transform: none; }
}
