/* ============================================================
   WriteHive — app.css
   Hive gold on dark ink chrome, paper-white page.
   100% local. No external fonts, scripts, or images.
   ============================================================ */

:root {
  --gold: #f5b301;
  --amber: #ffb703;
  --ink: #0e1116;
  --panel: #161b22;
  --panel-2: #1d242e;
  --border: rgba(255, 255, 255, 0.09);
  --text: #e8eaee;
  --muted: #8b93a1;
  --page-bg: #ffffff;
  --page-text: #1a1a1a;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
  --radius: 8px;
  --ui-font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

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

html, body { height: 100%; }

body {
  display: flex;
  flex-direction: column;
  font-family: var(--ui-font);
  font-size: 14px;
  color: var(--text);
  background-color: var(--ink);
  /* subtle honeycomb motif */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='48' viewBox='0 0 28 48'%3E%3Cg fill='none' stroke='%23f5b301' stroke-opacity='0.045'%3E%3Cpath d='M14 0L28 8v16L14 32 0 24V8z'/%3E%3Cpath d='M0 24l14 8v16L0 56z'/%3E%3Cpath d='M28 24L14 32v16l14-8z'/%3E%3C/g%3E%3C/svg%3E");
  overflow: hidden;
}

button { font-family: inherit; }
input, select { font-family: inherit; }

::selection { background: rgba(245, 179, 1, 0.35); }

/* ---------- scrollbars (webkit) ---------- */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a323e; border-radius: 6px; border: 3px solid var(--ink); }
::-webkit-scrollbar-thumb:hover { background: #39434f; }

/* ============================================================
   Buttons — shared
   ============================================================ */
.wh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.wh-btn svg { width: 16px; height: 16px; flex: 0 0 auto; }
.wh-btn:hover { background: rgba(255, 255, 255, 0.07); }
.wh-btn:active { background: rgba(245, 179, 1, 0.18); }
.wh-btn.on {
  background: rgba(245, 179, 1, 0.16);
  color: var(--gold);
  border-color: rgba(245, 179, 1, 0.35);
}
.wh-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.wh-icon-btn { padding: 0 7px; }
.wh-fmt { min-width: 30px; justify-content: center; font-size: 14px; }
.wh-fmt b, .wh-fmt i, .wh-fmt u, .wh-fmt s { font-family: Georgia, serif; }
.wh-fmt sub, .wh-fmt sup, #whClearFmt sub { font-size: 9px; }

.wh-btn-primary {
  background: var(--gold);
  color: #14100a;
  font-weight: 600;
  border-color: var(--gold);
}
.wh-btn-primary:hover { background: var(--amber); }
.wh-btn-primary:active { background: #e0a400; }

.wh-btn-label { display: inline; }

/* ============================================================
   Top bar
   ============================================================ */
.wh-topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  row-gap: 5px;
  min-height: 48px;
  padding: 6px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  z-index: 40;
}

.wh-logo {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}
.wh-logo svg { width: 26px; height: 26px; }
.wh-wordmark {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text);
}
.wh-wordmark em { font-style: normal; color: var(--gold); }

.wh-title {
  flex: 1 1 auto;
  min-width: 80px;
  max-width: 420px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}
.wh-title:hover { border-color: var(--border); }
.wh-title:focus { outline: none; border-color: var(--gold); background: var(--ink); }

.wh-status {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--muted);
  min-width: 90px;
}

/* module tool cluster (right) */
.wh-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-wrap: wrap;
}
.wh-tools .wh-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.wh-tools .wh-tool-btn svg { width: 15px; height: 15px; }
.wh-tools .wh-tool-btn:hover {
  color: var(--gold);
  border-color: rgba(245, 179, 1, 0.45);
  background: rgba(245, 179, 1, 0.08);
}

/* ============================================================
   Menu / actions row
   ============================================================ */
.wh-menubar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 5px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  z-index: 30;
}
.wh-menugroup { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.wh-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin: 0 4px 0 2px;
}
.wh-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
  flex: 0 0 auto;
}

/* dropdown */
.wh-dropdown { position: relative; }
.wh-caret { width: 11px !important; height: 11px !important; opacity: 0.7; }
.wh-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 175px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 5px;
  z-index: 100;
}
.wh-menu[hidden] { display: none; }
.wh-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.wh-menu button:hover { background: rgba(245, 179, 1, 0.14); color: var(--gold); }

/* ============================================================
   Format toolbar
   ============================================================ */
.wh-toolbar {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
  padding: 5px 12px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  z-index: 20;
}

.wh-select {
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.wh-select:hover { border-color: rgba(245, 179, 1, 0.4); }
.wh-select:focus { outline: none; border-color: var(--gold); }
.wh-select option, .wh-select optgroup { background: var(--panel); color: var(--text); }
.wh-select-font { width: 160px; }
.wh-select-size { width: 58px; }
.wh-select-block { width: 118px; }
.wh-select-spacing { width: 62px; }

/* locked (Pro) font options — lock glyph suffix */
#whFont option.wh-locked { color: var(--muted); }
#whFont optgroup { font-style: normal; font-weight: 700; color: var(--gold); }

/* color pickers */
.wh-color {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
}
.wh-color:hover { background: rgba(255, 255, 255, 0.07); }
.wh-color-glyph { font-size: 14px; font-weight: 700; line-height: 1; font-family: Georgia, serif; }
.wh-color svg { width: 15px; height: 15px; }
.wh-color-bar { width: 16px; height: 3px; border-radius: 2px; margin-top: 2px; }
.wh-color input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: 0;
  padding: 0;
}

/* ============================================================
   Find / replace bar
   ============================================================ */
.wh-findbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px 12px;
  background: var(--panel);
  border-bottom: 1px solid rgba(245, 179, 1, 0.35);
  flex: 0 0 auto;
  z-index: 15;
}
.wh-findbar[hidden] { display: none; }
.wh-findbar-ico { width: 15px; height: 15px; color: var(--gold); flex: 0 0 auto; }
.wh-findbar input[type="text"] {
  height: 29px;
  width: 190px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--ink);
  color: var(--text);
  font-size: 13px;
}
.wh-findbar input[type="text"]:focus { outline: none; border-color: var(--gold); }
.wh-find-count { font-size: 12px; color: var(--muted); min-width: 70px; text-align: center; }

/* match highlights inside the page */
#whPage mark.wh-find { background: rgba(245, 179, 1, 0.45); color: inherit; border-radius: 2px; padding: 0 1px; }
#whPage mark.wh-find-current { background: var(--amber); outline: 2px solid #e08900; }

/* ============================================================
   Docs drawer
   ============================================================ */
.wh-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 11, 0.6);
  z-index: 90;
}
.wh-drawer-overlay[hidden] { display: none; }

.wh-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 310px;
  max-width: 88vw;
  background: var(--panel);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateX(-102%);
  transition: transform 0.22s ease;
  z-index: 95;
  display: flex;
  flex-direction: column;
}
.wh-drawer.open { transform: translateX(0); }

.wh-drawer-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
}
.wh-drawer-head svg { width: 22px; height: 22px; }
.wh-drawer-head h2 { font-size: 15px; font-weight: 700; flex: 1; }

.wh-drawer-new { margin: 12px 14px 6px; justify-content: center; }

.wh-doclist {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 6px 8px;
}
.wh-doclist li {
  border-radius: 8px;
  padding: 9px 10px;
  margin-bottom: 2px;
  cursor: pointer;
  border: 1px solid transparent;
}
.wh-doclist li:hover { background: rgba(255, 255, 255, 0.05); }
.wh-doclist li.current {
  background: rgba(245, 179, 1, 0.1);
  border-color: rgba(245, 179, 1, 0.35);
}
.wh-doc-title {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wh-doc-date { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.wh-doc-actions { display: flex; gap: 4px; margin-top: 7px; }
.wh-doc-actions button {
  height: 22px;
  padding: 0 8px;
  font-size: 11.5px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.wh-doc-actions button:hover { color: var(--gold); border-color: rgba(245, 179, 1, 0.45); }
.wh-doc-actions button.wh-doc-del:hover { color: #ff7a6e; border-color: rgba(255, 122, 110, 0.5); }

.wh-drawer-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}

/* ============================================================
   Main — the paper page
   ============================================================ */
.wh-main {
  flex: 1 1 auto;
  overflow: auto;
  padding: 36px 16px 80px;
}

.wh-page-wrap {
  width: 816px;           /* 8.5in @ 96dpi */
  max-width: 100%;
  margin: 0 auto;
}

#whPage {
  width: 100%;
  min-height: 1056px;     /* 11in @ 96dpi */
  padding: 96px;          /* 1in margins */
  background: var(--page-bg);
  color: var(--page-text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;        /* 12pt */
  line-height: 1.5;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5), 0 18px 60px rgba(0, 0, 0, 0.55);
  border-radius: 2px;
  outline: none;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
#whPage:focus { outline: none; }
#whPage ::selection { background: rgba(245, 179, 1, 0.4); }

#whPage h1 { font-size: 2em; margin: 0.6em 0 0.35em; line-height: 1.25; }
#whPage h2 { font-size: 1.55em; margin: 0.7em 0 0.35em; line-height: 1.3; }
#whPage h3 { font-size: 1.28em; margin: 0.7em 0 0.3em; }
#whPage h4 { font-size: 1.1em; margin: 0.7em 0 0.3em; }
#whPage p { margin: 0 0 0.65em; }
#whPage ul, #whPage ol { margin: 0 0 0.65em; padding-left: 2em; }
#whPage blockquote {
  margin: 0.8em 0;
  padding: 0.4em 1em;
  border-left: 3px solid var(--gold);
  background: #faf6ea;
  color: #444;
}
#whPage pre {
  margin: 0.8em 0;
  padding: 0.8em 1em;
  background: #f3f4f6;
  border: 1px solid #e0e2e6;
  border-radius: 4px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.88em;
  white-space: pre-wrap;
}
#whPage img { max-width: 100%; height: auto; }
#whPage a { color: #0b63ce; }
#whPage table { border-collapse: collapse; max-width: 100%; }
#whPage hr { border: 0; border-top: 1px solid #c9cdd3; margin: 1em 0; }

/* page break marker — on screen a dashed rule; in print a real break */
.page-break {
  page-break-after: always;
  break-after: page;
  border-top: 1px dashed #ccc;
  margin: 24px -48px;
  height: 0;
  position: relative;
}

/* ============================================================
   Status bar
   ============================================================ */
.wh-statusbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 30px;
  padding: 0 14px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  flex: 0 0 auto;
  z-index: 30;
}
.wh-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); opacity: 0.6; }
.wh-status-spacer { flex: 1; }
.wh-zoom-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.wh-select-zoom { height: 22px; font-size: 12px; padding: 0 3px; }

.wh-plan {
  font-weight: 700;
  font-size: 11.5px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.wh-plan.pro {
  color: #14100a;
  background: var(--gold);
  border-color: var(--gold);
}

/* ============================================================
   Toasts
   ============================================================ */
#whToastHost {
  position: fixed;
  left: 50%;
  bottom: 46px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 1100;
  pointer-events: none;
}
.wh-toast {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: 420px;
}
.wh-toast.show { opacity: 1; transform: translateY(0); }

/* ============================================================
   Modal base — REUSED by license.js / skills.js / hubclient.js
   ============================================================ */
.wh-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 8, 11, 0.72);
  z-index: 1000;
}
.wh-modal[hidden] { display: none; }
.wh-modal-card {
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 26px;
  color: var(--text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}
.wh-modal-card h3 { font-size: 18px; margin-bottom: 8px; }
.wh-modal-card h3 em { font-style: normal; color: var(--gold); }
.wh-modal-card p { font-size: 13.5px; line-height: 1.55; color: var(--muted); margin-bottom: 12px; }
.wh-modal-card ul { margin: 0 0 14px 18px; font-size: 13.5px; line-height: 1.7; }
.wh-modal-card ul li::marker { color: var(--gold); }
.wh-modal-card input[type="text"] {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--ink);
  color: var(--text);
  font-size: 13px;
  margin-bottom: 10px;
}
.wh-modal-card input[type="text"]:focus { outline: none; border-color: var(--gold); }
.wh-modal-card .wh-btn, .wh-modal-card .wh-btn-primary { height: 36px; }
.wh-modal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
  .wh-btn-label { display: none; }
  .wh-group-label { display: none; }
  .wh-title { max-width: 180px; }
  .wh-status { min-width: 0; }
  .wh-main { padding: 18px 8px 60px; }
  #whPage { padding: 48px 28px; min-height: 640px; }
  .page-break { margin-left: -14px; margin-right: -14px; }
}
@media (max-width: 560px) {
  .wh-topbar { padding: 6px 8px; }
  .wh-tools { margin-left: 0; }
  .wh-select-font { width: 118px; }
  .wh-findbar input[type="text"] { width: 130px; }
}

/* ============================================================
   Print — this IS the PDF export path.
   Hide all chrome; only the document page prints.
   ============================================================ */
@page { margin: 1in; }

@media print {
  html, body { height: auto; overflow: visible; background: #fff; }
  body { display: block; background-image: none; }

  .wh-topbar, .wh-menubar, .wh-toolbar, .wh-findbar, .wh-statusbar,
  .wh-drawer, .wh-drawer-overlay, #whToastHost, .wh-modal { display: none !important; }

  .wh-main { overflow: visible; padding: 0; height: auto; }
  .wh-page-wrap {
    width: auto;
    margin: 0;
    zoom: 1 !important;
    transform: none !important;
  }
  #whPage {
    width: auto;
    min-height: 0;
    padding: 0;
    margin: 0;
    box-shadow: none;
    border-radius: 0;
    background: #fff;
    color: #000;
  }

  #whPage mark.wh-find, #whPage mark.wh-find-current {
    background: none;
    outline: none;
    color: inherit;
  }

  .page-break {
    border: 0;
    margin: 0;
    height: 0;
    page-break-after: always;
    break-after: page;
  }
}
