/* ============================================================
   Business Owner's Playbook — Carousel Preview
   NK brand strict — palette + typography per c:/EA/projects/mia/brand/nk.md
   Three style variants Kai can switch between for direct PDF export.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400..900&family=Inter:wght@300..700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  /* NK palette — exact hex from brand guide, no invented tints */
  --midnight:  #0E1628;
  --parchment: #F4ECD8;
  --brass:     #B8892F;
  --ink:       #1A1A1A;
  --dove:      #E8E6E1;
  --fog:       #8B8B8B;
  --burgundy:  #5E2A2A;
  --moss:      #4F7942;
  --amber:     #C17817;

  --serif: 'Fraunces', 'Georgia', serif;
  --sans:  'Inter', -apple-system, system-ui, sans-serif;
  --mono:  'IBM Plex Mono', ui-monospace, monospace;

  --slide-w: 540px;   /* preview render width; export is full 1080x1350 */
  --slide-h: 675px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: #f5f5f4;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* =====================================================================
   Top bar
   ===================================================================== */
.topbar {
  background: var(--midnight);
  color: var(--parchment);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  gap: 18px;
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  flex-wrap: wrap;
}
.topbar h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: 18px; letter-spacing: 0.3px;
}
.topbar h1 .accent { color: var(--brass); }

.style-switcher {
  display: flex;
  background: rgba(244,236,216,0.08);
  border-radius: 4px;
  overflow: hidden;
}
.style-switcher button {
  background: transparent; border: 0; color: var(--parchment);
  padding: 8px 14px; font-size: 12px; cursor: pointer;
  font-family: var(--sans); letter-spacing: 0.5px;
}
.style-switcher button.active {
  background: var(--brass); color: var(--midnight); font-weight: 600;
}

.view-toggle {
  display: flex;
  background: rgba(244,236,216,0.08);
  border-radius: 4px;
  overflow: hidden;
}
.view-toggle button {
  background: transparent; border: 0; color: var(--parchment);
  padding: 8px 14px; font-size: 12px; cursor: pointer;
}
.view-toggle button.active {
  background: var(--brass); color: var(--midnight); font-weight: 600;
}

.export-btn {
  background: var(--brass); color: var(--midnight);
  border: 0; padding: 10px 18px; font-size: 12px;
  font-weight: 600; cursor: pointer; border-radius: 4px;
  letter-spacing: 0.5px; text-transform: uppercase;
}
.export-btn:disabled { opacity: 0.5; cursor: wait; }

.post-selector { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.post-selector label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--fog);
}
.post-selector select {
  background: var(--midnight); color: var(--parchment);
  border: 1px solid var(--fog); padding: 8px 14px;
  font-family: var(--sans); font-size: 13px; border-radius: 4px; min-width: 300px;
}
.post-meta { font-size: 11px; color: var(--fog); white-space: nowrap; }
.post-meta strong { color: var(--brass); }

/* =====================================================================
   Layouts (single + grid)
   ===================================================================== */
.viewer {
  display: grid; grid-template-columns: 1fr 320px; gap: 32px;
  padding: 32px; max-width: 1200px; margin: 0 auto;
}
.viewer-stage { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.slide-nav { display: flex; align-items: center; gap: 18px; }
.slide-nav button {
  background: var(--midnight); color: var(--parchment); border: 0;
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  font-size: 18px; display: flex; align-items: center; justify-content: center;
}
.slide-nav button:disabled { opacity: 0.3; cursor: not-allowed; }
.slide-nav .counter {
  font-family: var(--serif); font-size: 16px; color: var(--ink);
  min-width: 64px; text-align: center;
}

.brief-panel {
  background: white; border: 1px solid var(--dove);
  border-radius: 6px; padding: 22px; height: fit-content;
  position: sticky; top: 100px;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
}
.brief-panel h3 {
  font-family: var(--serif); font-size: 13px; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--brass); margin-bottom: 10px;
}

/* Panel tabs */
.panel-tabs {
  display: flex; border-bottom: 1px solid var(--dove);
  margin: -22px -22px 18px -22px; padding: 0 16px;
}
.panel-tab {
  background: none; border: 0; padding: 14px 14px;
  cursor: pointer; font-size: 11px; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--fog);
  border-bottom: 2px solid transparent;
  font-family: var(--sans); font-weight: 500;
}
.panel-tab.active { color: var(--brass); border-bottom-color: var(--brass); }

/* Style control groups */
.style-controls { display: flex; flex-direction: column; gap: 22px; }
.control-group {}
.control-group .label {
  display: block; font-size: 10px; text-transform: uppercase;
  letter-spacing: 1px; color: var(--fog); margin-bottom: 8px;
  font-weight: 500;
}
.control-group .label .current {
  text-transform: none; letter-spacing: 0;
  color: var(--ink); font-weight: 400;
  margin-left: 6px; font-family: var(--mono); font-size: 10px;
}
.swatch-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.swatch {
  width: 26px; height: 26px; border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.08); cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  position: relative;
}
.swatch:hover { transform: scale(1.08); }
.swatch.active { box-shadow: 0 0 0 2px var(--brass); }
.swatch-custom {
  width: 26px; height: 26px;
  border: 1px dashed var(--fog); border-radius: 4px;
  background: white; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--fog);
}
.swatch-custom input[type="color"] {
  position: absolute; opacity: 0; width: 26px; height: 26px;
  cursor: pointer;
}

.font-pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.font-pill {
  background: white; border: 1px solid var(--dove);
  color: var(--ink); padding: 8px 12px; font-size: 12px;
  border-radius: 4px; cursor: pointer; font-family: var(--sans);
}
.font-pill.serif { font-family: var(--serif); }
.font-pill.mono { font-family: var(--mono); }
.font-pill.active {
  background: var(--midnight); color: var(--parchment);
  border-color: var(--midnight);
}

.size-row { display: flex; align-items: center; gap: 10px; }
.size-row input[type="range"] {
  flex: 1; accent-color: var(--brass);
}
.size-row .size-value {
  font-family: var(--mono); font-size: 11px;
  color: var(--ink); min-width: 36px; text-align: right;
}

.reset-style-btn {
  background: transparent; border: 1px solid var(--fog);
  color: var(--ink); padding: 8px 14px; font-size: 11px;
  cursor: pointer; border-radius: 4px; text-transform: uppercase;
  letter-spacing: 1px; font-family: var(--sans); width: 100%;
  margin-top: 4px;
}
.reset-style-btn:hover { border-color: var(--burgundy); color: var(--burgundy); }
.brief-panel .brief-row {
  margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--dove);
}
.brief-panel .brief-row:last-child { border-bottom: 0; padding-bottom: 0; }
.brief-panel .label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--fog); margin-bottom: 4px;
}
.brief-panel .value {
  font-size: 12px; color: var(--ink); line-height: 1.55; white-space: pre-wrap;
}

.grid-view {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 24px; padding: 32px; max-width: 1400px; margin: 0 auto;
}
.grid-view .slide-tile { display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
.grid-view .slide {
  --slide-w: 100%; --slide-h: auto;
  aspect-ratio: 4 / 5; width: 100%; height: auto;
}
.grid-view .slide-meta {
  font-size: 10px; color: var(--fog); text-transform: uppercase;
  letter-spacing: 1px; text-align: center;
}

/* =====================================================================
   THE SLIDE — base structure (style-agnostic)
   ===================================================================== */
.slide {
  width: var(--slide-w); height: var(--slide-h);
  font-family: var(--sans); display: flex; flex-direction: column;
  position: relative; overflow: hidden; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(14,22,40,0.18);
}
.slide-inner {
  flex: 1; display: flex; flex-direction: column;
  justify-content: center; padding: 80px 64px; gap: 18px;
}
.slide-kicker {
  font-family: var(--sans); font-size: 10px; letter-spacing: 3px;
  text-transform: uppercase; font-weight: 500;
}
.slide-headline {
  font-family: var(--serif); font-weight: 600;
  font-size: 42px; line-height: 1.1; letter-spacing: -0.5px;
  /* Use Fraunces's display-optimized cut at headline scale */
  font-variation-settings: 'opsz' 144;
}
.slide-subhead {
  font-family: var(--sans); font-size: 16px; line-height: 1.5;
  font-weight: 400;
}
.slide-body {
  font-family: var(--sans); font-size: 15px; line-height: 1.65;
  white-space: pre-wrap; font-weight: 400;
}

/* type-specific tweaks (apply to all 3 styles) */
.slide[data-type="HOOK"] .slide-headline {
  font-size: 56px; font-weight: 700;
}
.slide[data-type="LESSON"] .slide-inner,
.slide[data-type="THE LESSON"] .slide-inner,
.slide[data-type="WHAT SURPRISED ME"] .slide-inner { align-items: center; text-align: center; }
.slide[data-type="LESSON"] .slide-headline,
.slide[data-type="THE LESSON"] .slide-headline,
.slide[data-type="WHAT SURPRISED ME"] .slide-headline { font-style: italic; font-weight: 400; }
.slide[data-type="FOLLOW"] .slide-inner,
.slide[data-type="FOLLOW + DISCLOSURE"] .slide-inner { align-items: center; text-align: center; }

/* ---------- Telegram handle (corner attribution on every slide) ---------- */
.slide-handle {
  position: absolute;
  bottom: 28px; left: 28px;
  font-family: var(--sans);
  font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
  font-weight: 500;
}
.style-editorial .slide-handle { color: var(--brass); }
.style-parchment .slide-handle { color: var(--burgundy); }
.style-silent .slide-handle { color: var(--brass); left: 50%; transform: translateX(-50%); bottom: 56px; opacity: 0.7; }

/* Style-tab input field */
.handle-input {
  width: 100%; padding: 8px 12px;
  background: white; border: 1px solid var(--dove);
  border-radius: 4px; font-family: var(--sans); font-size: 13px;
  color: var(--ink);
}
.handle-input:focus {
  outline: none; border-color: var(--brass);
  box-shadow: 0 0 0 2px rgba(184,137,47,0.15);
}

/* ---------- inline editing ---------- */
.editable {
  outline: 1px dashed transparent;
  outline-offset: 4px;
  cursor: text;
  transition: outline-color 0.15s, background-color 0.15s;
  border-radius: 2px;
}
.editable:hover { outline-color: rgba(184, 137, 47, 0.45); }
.editable:focus {
  outline-color: var(--brass);
  outline-style: solid;
  outline-offset: 3px;
  background-color: rgba(184, 137, 47, 0.06);
}
/* In grid view + export, disable the edit affordances */
.grid-view .editable, .export-mode .editable {
  outline: none !important;
  cursor: default;
  background: transparent !important;
}
.slide.edited {
  box-shadow: 0 8px 24px rgba(14,22,40,0.18), 0 0 0 2px var(--brass);
}
.edit-badge {
  display: inline-block;
  background: var(--brass); color: var(--midnight);
  font-size: 9px; letter-spacing: 1px; text-transform: uppercase;
  padding: 2px 8px; border-radius: 99px; font-weight: 600;
  margin-left: 8px;
  vertical-align: middle;
}
.editing-toolbar {
  display: flex; gap: 8px; align-items: center; margin-left: auto;
}
.editing-toolbar button {
  background: transparent; border: 1px solid var(--fog);
  color: var(--parchment); font-size: 11px;
  padding: 6px 12px; border-radius: 4px; cursor: pointer;
  font-family: var(--sans); letter-spacing: 0.3px;
}
.editing-toolbar button:hover {
  border-color: var(--brass); color: var(--brass);
}

/* visual-brief stripe — preview only */
.slide-visual-stripe {
  position: absolute; bottom: 56px; left: 64px; right: 64px;
  font-size: 9px; letter-spacing: 1px; text-transform: uppercase;
  font-style: italic; font-weight: 300; padding-top: 12px;
  display: none;
}
.show-briefs .slide-visual-stripe { display: block; }

/* =====================================================================
   STYLE 1 — "Editorial"
   Dark canvas, parchment text, brass ornament. Classic NK reading.
   ===================================================================== */
.style-editorial .slide {
  background: var(--midnight);
  color: var(--parchment);
}
.style-editorial .slide::before {
  content: ''; position: absolute; top: 28px; left: 28px;
  width: 32px; height: 2px; background: var(--brass);
}
.style-editorial .slide::after {
  content: attr(data-tag); position: absolute; bottom: 28px; right: 28px;
  font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--brass); font-family: var(--sans); font-weight: 500;
}
.style-editorial .slide-kicker { color: var(--brass); }
.style-editorial .slide-headline { color: var(--parchment); }
.style-editorial .slide-subhead { color: var(--parchment); opacity: 0.78; }
.style-editorial .slide-body { color: var(--parchment); opacity: 0.78; }
.style-editorial .slide-visual-stripe {
  color: var(--fog); border-top: 1px solid rgba(244,236,216,0.1);
}

/* =====================================================================
   STYLE 2 — "Parchment"
   Light book-page canvas. Midnight text. Brass column rule.
   ===================================================================== */
.style-parchment .slide {
  background: var(--parchment);
  color: var(--midnight);
}
.style-parchment .slide::before {
  content: ''; position: absolute; top: 28px; left: 28px;
  width: 2px; height: calc(100% - 56px); background: var(--brass);
}
.style-parchment .slide::after {
  content: attr(data-tag); position: absolute; bottom: 28px; right: 28px;
  font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--burgundy); font-family: var(--sans); font-weight: 500;
}
.style-parchment .slide-inner { padding-left: 80px; }
.style-parchment .slide-kicker { color: var(--burgundy); }
.style-parchment .slide-headline { color: var(--midnight); }
.style-parchment .slide-subhead { color: var(--midnight); opacity: 0.7; }
.style-parchment .slide-body { color: var(--ink); opacity: 0.85; }
.style-parchment .slide-visual-stripe {
  color: var(--fog); border-top: 1px solid rgba(14,22,40,0.12);
}

/* =====================================================================
   STYLE 3 — "Silent"
   Pure typography. No bars, no ornaments, no ghosted numbers.
   Midnight canvas, centered composition, brass appears only as a kicker
   hue and a single hairline rule under the headline.
   Inspired by editorial covers (The Economist, Monocle, A24 posters).
   ===================================================================== */
.style-silent .slide {
  background: var(--midnight);
  color: var(--parchment);
}
.style-silent .slide::after {
  content: attr(data-tag);
  position: absolute; bottom: 36px; left: 0; right: 0;
  text-align: center;
  font-size: 9px; letter-spacing: 3px; text-transform: uppercase;
  color: var(--fog); font-family: var(--sans); font-weight: 400;
}
.style-silent .slide-inner {
  align-items: center; justify-content: center; text-align: center;
  padding: 100px 80px 100px 80px; gap: 28px;
  max-width: 90%; margin: 0 auto;
}
.style-silent .slide-kicker {
  color: var(--brass); font-size: 10px; letter-spacing: 4px;
  font-weight: 500;
}
/* Brass hairline rule rendered as a real element (so it survives PDF export).
   See render.js — appended when currentStyle === "silent". */
.silent-rule {
  background: var(--brass);
}
.style-silent .slide-headline {
  font-size: 44px; line-height: 1.15; font-weight: 600;
  color: var(--parchment); letter-spacing: -0.5px;
}
.style-silent .slide[data-type="HOOK"] .slide-headline {
  font-size: 58px; font-weight: 700;
}
.style-silent .slide-subhead {
  color: var(--parchment); opacity: 0.72;
  font-size: 16px; font-weight: 400; max-width: 32em;
}
.style-silent .slide-body {
  color: var(--parchment); opacity: 0.72;
  font-size: 15px; font-weight: 400; max-width: 32em; text-align: left;
}
/* Body bullet slides should still be left-aligned for readability */
.style-silent .slide-body { text-align: left; }
.style-silent .slide-visual-stripe {
  color: var(--fog); border-top: 1px solid rgba(244,236,216,0.08);
  text-align: left;
}
