/* Blank Page Writer Mode — /write, /stats, login modal (2026-08-11) */
/* Minimal paper feel — follows homepage theme.css variables so dark mode matches. */

:root {
  --wm-text-dim: #999999;
  --wm-accent: #111111;
  --wm-green-1: #d7f5dc;
  --wm-green-2: #9be9a8;
  --wm-green-3: #40c463;
  --wm-green-4: #30a14e;
  --wm-green-5: #216e39;
}

html, body { margin: 0; padding: 0; }

body.wm {
  background: var(--bg-color, #e8e6e3);
  color: var(--text-color, #333333);
  /* font-family intentionally NOT set — inherits fonts.css (Verdana, same as homepage) */
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── top bar ─────────────────────────────── */
.wm-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-color, rgba(0,0,0,0.1));
  background: var(--modal-bg, #e8e6e3);
  flex-shrink: 0;
  position: relative;
  z-index: 30;
}
.wm-topbar a {
  color: var(--text-color, #333333);
  text-decoration: none;
}
.wm-brand { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.wm-brand span { color: var(--wm-text-dim); font-weight: 400; }

.wm-nav { display: flex; align-items: center; gap: 16px; font-size: 14px; }
.wm-nav a { color: var(--text-color, #333); opacity: 0.75; }
.wm-nav a:hover { opacity: 1; }
.wm-nav .wm-active { opacity: 1; font-weight: 600; }

.wm-site-footer {
  width: 100%; max-width: 768px; margin: auto auto 0; padding: 24px 20px;
  border-top: 1px solid var(--border-color, rgba(0,0,0,0.1));
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  color: var(--wm-text-dim); font-size: 12px;
}
.wm-site-footer > a { color: var(--text-color, #333); font-weight: 600; text-decoration: none; }
.wm-site-footer nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; }
.wm-site-footer nav a { color: inherit; text-decoration: none; }
.wm-site-footer nav a:hover { color: var(--text-color, #333); }

.wm-right { display: flex; align-items: center; gap: 14px; font-size: 14px; }

/* ── date navigation (write page) ────────── */
.wm-datenav { display: flex; align-items: center; gap: 10px; }
.wm-datenav button {
  background: none; border: 1px solid var(--border-color, rgba(0,0,0,0.15)); color: var(--text-color, #333);
  border-radius: 6px; min-width: 30px; height: 30px; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
}
.wm-datenav button:hover:not(:disabled) { background: var(--button-hover, rgba(0,0,0,0.05)); }
.wm-datenav button:disabled { opacity: 0.35; cursor: default; }
.wm-date-label { font-size: 14px; min-width: 92px; text-align: center; }
.wm-date-label.today { font-weight: 600; }
.wm-today-btn {
  border-radius: 6px; padding: 0 12px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--border-color, rgba(0,0,0,0.15)); color: var(--text-color, #333);
  background: var(--button-hover, rgba(0,0,0,0.05)); height: 30px; cursor: pointer;
  font-family: inherit;
}
.wm-today-btn:hover { opacity: 0.8; }

/* ── save indicator ──────────────────────── */
.wm-savestatus { font-size: 12px; color: var(--wm-text-dim); margin-left: 12px; }
.wm-savestatus.saving { color: #b58900; }
.wm-savestatus.saved { color: #2e8b57; }
.wm-savestatus.offline { color: #c0392b; }

/* ── user menu (top right) ───────────────── */
.wm-userwrap { position: relative; }
.wm-userbtn {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border-color, rgba(0,0,0,0.15));
  background: var(--button-hover, rgba(0,0,0,0.05));
  color: var(--text-color, #333333);
  font-size: 15px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.wm-userbtn:hover { opacity: 0.8; }
.wm-usermenu {
  display: none; position: absolute; right: 0; top: 42px; min-width: 190px;
  background: var(--modal-bg, #e8e6e3); border: 1px solid var(--border-color, rgba(0,0,0,0.12));
  border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  padding: 6px; z-index: 40;
}
.wm-usermenu.open { display: block; }
.wm-usermenu-email {
  font-size: 12px; color: var(--wm-text-dim); padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border-color, rgba(0,0,0,0.08)); margin-bottom: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wm-usermenu-plan {
  font-size: 11px; font-weight: 600; color: var(--text-color, #333333);
  padding: 6px 10px 8px; border-bottom: 1px solid var(--border-color, rgba(0,0,0,0.08));
  margin-bottom: 4px;
}
.wm-usermenu-planbadge {
  padding: 2px 10px 6px; margin-bottom: 4px;
}
.wm-usermenu-upgrade {
  display: inline-block; font-size: 11px; font-weight: 600;
  color: #fff; background: var(--wm-accent, #333); border-radius: 10px;
  padding: 2px 10px; text-decoration: none;
}
.wm-usermenu-upgrade:hover { opacity: 0.85; }
.wm-usermenu-item {
  display: block; padding: 9px 10px; font-size: 14px; border-radius: 6px;
  color: var(--text-color, #333333); text-decoration: none;
}
.wm-usermenu-item:hover { background: var(--button-hover, rgba(0,0,0,0.05)); }
.wm-usermenu-danger { color: #c0392b; }
.wm-usermenu-danger:hover { background: rgba(192,57,43,0.08); }

/* ── "Let's write" button (stats header) ─── */
.wm-write-btn {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--border-color, rgba(0,0,0,0.15)); border-radius: 999px;
  background: var(--button-hover, rgba(0,0,0,0.05)); color: var(--text-color, #333);
  font-size: 14px; font-weight: 500; height: 34px; padding: 0 14px;
  text-decoration: none; font-family: inherit;
}
.wm-write-btn:hover { opacity: 0.85; }

/* ── editor (write page) ─────────────────── */
.wm-main { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 0 20px 40px; }
.wm-editor-wrap { width: 100%; max-width: 720px; flex: 1; display: flex; flex-direction: column; padding-top: 28px; }
.wm-editor {
  flex: 1; width: 100%; border: none; outline: none; resize: none;
  background: transparent; color: var(--text-color, #333);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 19px; line-height: 1.85;
  padding: 8px 4px;
}
.wm-editor::placeholder { color: #cccccc; }
.wm-wordcount { text-align: right; font-size: 12px; color: var(--wm-text-dim); padding-top: 8px; }

.wm-empty-hint {
  position: absolute; color: #cccccc; font-size: 19px; pointer-events: none;
  font-family: Georgia, serif;
}

/* banner (expired link etc.) */
.wm-banner {
  max-width: 720px; margin: 16px auto 0; padding: 10px 14px; border-radius: 8px;
  background: #fff8e6; border: 1px solid #f0e0b0; color: #8a6d1a; font-size: 14px;
  display: none;
}

/* ── stats page ──────────────────────────── */
.wm-stats-main { flex: 1; width: 100%; max-width: 860px; margin: 0 auto; padding: 36px 20px 60px; }
.wm-stats-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 40px;
}
.wm-stat { background: var(--bg-color, #e8e6e3); border: 1px solid var(--border-color, rgba(0,0,0,0.1)); border-radius: 10px; padding: 18px 16px; text-align: center; }
.wm-stat-num { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.wm-stat-label { font-size: 12px; color: var(--wm-text-dim); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; }

/* ── writing time row ── */
.wm-writetime {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--wm-text-dim);
  margin: -22px 0 24px; justify-content: flex-end;
}
.wm-writetime b { color: var(--text-color, #333); font-variant-numeric: tabular-nums; }
.wm-writetime .dot { opacity: 0.5; }

.wm-calendar { background: var(--bg-color, #e8e6e3); border: 1px solid var(--border-color, rgba(0,0,0,0.1)); border-radius: 10px; padding: 22px 20px; }
.wm-cal-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.wm-cal-months { display: flex; gap: 2px; margin-bottom: 4px; padding-left: 0; }
.wm-cal-month { flex: 1; min-width: 0; font-size: 8px; color: var(--wm-text-dim); line-height: 1; overflow: visible; white-space: nowrap; }
.wm-cal-month-empty { visibility: hidden; }
.wm-cal-scroll { overflow: hidden; } /* desktop: flex fills container, no scroll */
.wm-cal-body { display: flex; gap: 2px; padding-bottom: 4px; }
.wm-cal-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wm-cell {
  width: 100%; aspect-ratio: 1; border-radius: 2px; background: #ebedf0;
  cursor: pointer; transition: transform 0.05s ease; flex-shrink: 0;
}
.wm-cell:hover { transform: scale(1.25); }
.wm-cell.l1 { background: var(--wm-green-1); }
.wm-cell.l2 { background: var(--wm-green-2); }
.wm-cell.l3 { background: var(--wm-green-3); }
.wm-cell.l4 { background: var(--wm-green-4); }
.wm-cell.l5 { background: var(--wm-green-5); }
.wm-cal-legend { display: flex; align-items: center; gap: 4px; margin-top: 14px; font-size: 11px; color: var(--wm-text-dim); }
.wm-cal-legend .wm-cell { width: 10px !important; height: 10px !important; flex: none; cursor: default; }

.wm-stats-empty { text-align: center; padding: 60px 0; color: var(--wm-text-dim); font-size: 15px; line-height: 1.8; }
.wm-stats-empty .big { font-size: 20px; color: var(--text-color, #333); margin-bottom: 8px; }

.wm-achievements { margin-top: 24px; padding: 16px; border: 1px dashed var(--border-color, rgba(0,0,0,0.15)); border-radius: 12px; }
.wm-ach-title { font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.wm-ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.wm-ach {
  background: var(--button-hover, rgba(0,0,0,0.04)); border-radius: 10px; padding: 12px;
  text-align: center; opacity: 0.45; transition: opacity 0.2s ease;
}
.wm-ach.unlocked { opacity: 1; }
.wm-ach-ico { font-size: 24px; margin-bottom: 4px; }
.wm-ach-name { font-size: 13px; font-weight: 600; }
.wm-ach-desc { font-size: 11px; color: var(--wm-text-dim); margin: 3px 0 8px; line-height: 1.4; }
.wm-ach-bar { height: 4px; background: rgba(0,0,0,0.08); border-radius: 2px; overflow: hidden; }
.wm-ach-bar-fill { height: 100%; background: #2e8b57; border-radius: 2px; transition: width 0.3s ease; }
.wm-ach-prog { font-size: 10px; color: var(--wm-text-dim); margin-top: 5px; }

/* ── bottom: achievements full-width (2026-08-11: stats = numbers + graph + achievements only) ── */
.wm-achievements { margin-top: 24px; padding: 16px; border: 1px dashed var(--border-color, rgba(0,0,0,0.15)); border-radius: 12px; }
/* ── login modal ─────────────────────────── */
.wm-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 100;
  display: none; align-items: center; justify-content: center;
}
.wm-modal-overlay.open { display: flex; }
.wm-modal {
  background: var(--bg-color, #e8e6e3); border-radius: 12px; padding: 28px 26px; width: 340px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.18); position: relative;
}
.wm-modal h2 { margin: 0 0 6px; font-size: 18px; }
.wm-modal p.sub { margin: 0 0 18px; font-size: 13px; color: var(--wm-text-dim); line-height: 1.6; }
.wm-modal input[type="email"] {
  width: 100%; box-sizing: border-box; padding: 11px 12px; font-size: 15px;
  border: 1px solid var(--wm-border); border-radius: 8px; outline: none;
}
.wm-modal input[type="email"]:focus { border-color: var(--wm-accent); }
.wm-modal .wm-modal-btn {
  width: 100%; margin-top: 10px; padding: 11px; font-size: 15px; font-weight: 600;
  background: var(--wm-accent); color: #fff; border: none; border-radius: 8px; cursor: pointer;
}
.wm-modal .wm-modal-btn { background: var(--wm-accent); }
.wm-modal .wm-modal-btn:hover { opacity: 0.9; }
.wm-modal .wm-modal-btn:disabled { opacity: 0.5; cursor: default; }
.wm-modal .wm-modal-btn-danger { background: #c0392b; }
.wm-modal .wm-modal-error { color: #c0392b; font-size: 13px; margin-top: 10px; display: none; }
.wm-modal .wm-modal-sent { display: none; text-align: center; padding: 6px 0; }
.wm-modal .wm-modal-sent .ico { font-size: 30px; margin-bottom: 8px; }
.wm-modal .wm-modal-sent p { font-size: 14px; margin: 0 0 4px; }
.wm-modal .wm-modal-sent .small { font-size: 12px; color: var(--wm-text-dim); margin-bottom: 14px; }

/* ── paid wall (2026-08-16) ─────────────────────────────── */
.wm-modal.wm-paywall { width: 640px; max-width: 94vw; }
.wm-modal.wm-paywall h2 { font-size: 20px; }
.wm-plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 12px; }
.wm-plan {
  border: 1px solid var(--wm-border); border-radius: 10px; padding: 16px 12px;
  text-align: center; position: relative; display: flex; flex-direction: column; justify-content: space-between;
}
.wm-plan-featured { border-color: var(--wm-accent); box-shadow: 0 0 0 1px var(--wm-accent); }
.wm-plan-tag {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--wm-accent); color: #fff; font-size: 10px; font-weight: 700;
  padding: 2px 10px; border-radius: 20px; white-space: nowrap;
}
.wm-plan-name { font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-color, #333); }
.wm-plan-price { font-size: 22px; font-weight: 700; margin-bottom: 4px; color: var(--text-color, #333); }
.wm-plan-price span { font-size: 12px; font-weight: 400; opacity: 0.7; }
.wm-plan .wm-modal-btn { margin-top: 8px; padding: 8px 10px; font-size: 13px; }
.wm-plan-features { list-style: none; margin: 10px 0 8px; padding: 0; font-size: 12px; color: var(--wm-text-dim); line-height: 1.9; }
.wm-plan-features li::before { content: '✓ '; color: var(--wm-accent); }
.wm-upgrade-main .wm-plan { padding-top: 20px; }
.wm-upgrade-main .wm-plan-price { margin-bottom: 2px; }
.wm-upgrade-main .wm-plans { margin-bottom: 30px; }
.wm-paywall-foot { margin: 8px 0 0; font-size: 12px; text-align: center; color: var(--wm-text-dim); }
.wm-paywall-foot a { color: var(--text-color, #333); text-decoration: underline; }
@media (max-width: 560px) {
  .wm-plans { grid-template-columns: 1fr; }
  .wm-plan { padding: 12px; }
}
.wm-modal .wm-modal-resend {
  background: none; border: none; color: var(--text-color, #333); text-decoration: underline;
  font-size: 13px; cursor: pointer; padding: 6px 0;
}
.wm-modal-close {
  position: absolute; top: 12px; right: 14px; background: none; border: none;
  font-size: 18px; color: var(--wm-text-dim); cursor: pointer; padding: 4px;
}
.wm-modal-close:hover { color: var(--text-color, #333); }

/* ── editor dark mode: follow theme (2026-08-11) — homepage editor is "light paper"
   by design, but the writer workspace must adapt to dark theme */
body.dark-theme #editor {
  background-color: #3a3a3a !important;
  background-image: none !important;
  color: #e8e6e3 !important;
  caret-color: #e8e6e3 !important;
  box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.35) !important;
}
body.dark-theme #editor::placeholder { color: rgba(232, 230, 227, 0.22) !important; }
/* light theme: the copied homepage editor carries placeholder:text-gray-200 (tailwind),
   which is nearly invisible on the light paper background (#e8e6e3) — force a readable
   placeholder on /write and /stats only (writer.css is not loaded on the homepage) (2026-08-13) */
#editor::placeholder { color: #a0a0a0 !important; opacity: 1 !important; }
body.dark-theme #editor.e-ink-texture::before { display: none !important; }

/* responsive */
/* Tablet / medium widths had no definite height in the flex chain: the
   textarea's h-full resolved close to its intrinsic two-row height. Scope a
   viewport-height flex container to /write only; public and stats pages keep
   their normal document scrolling. Desktop xl and mobile retain their
   existing, separately tuned heights. */
@media (min-width: 641px) and (max-width: 1279px) {
  body.wm-write-page {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
  }
  body.wm-write-page #editor-container {
    height: auto;
    min-height: 0;
  }
  body.wm-write-page #editor {
    height: 100% !important;
    min-height: 0;
  }
}

@media (max-width: 640px) {
  .wm-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .wm-topbar { padding: 0 14px; }
  .wm-brand span { display: none; }
  .wm-stat-num { font-size: 24px; }
  .wm-nav { gap: 10px; font-size: 12px; }
  .wm-site-footer { align-items: flex-start; flex-direction: column; }
  .wm-site-footer nav { justify-content: flex-start; }

  /* mobile editor: explicit height (h-full % of flex parent is unreliable) */
  #editor {
    height: calc(100dvh - 118px) !important;
    min-height: 320px;
  }

  /* mobile calendar: fixed-size cells, months+body scroll together (GitHub-style) */
  .wm-cal-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .wm-cal-body { overflow: visible; }
  .wm-cal-col { flex: none; }
  .wm-cal-month { flex: none; width: 10px; font-size: 8px; }
  .wm-cell { width: 10px !important; height: 10px !important; flex: none; }
}

/* zen mode (fullscreen) hides the writer header for immersive writing */
body.zen-mode .wm-topbar { display: none; }

/* zen editor: fill the viewport with EQUAL top/bottom gaps matching the normal
   page top gap — desktop 24px (container p-4 16 + xl:mt-2 8), smaller screens 16px
   (p-4 only). Without this the editor keeps its fixed 86vh height and rides high,
   leaving a large bottom gap (Ada 2026-08-13). */
body.zen-mode #editor {
  height: calc(100vh - 32px) !important;   /* 16px top + 16px bottom (p-4 only) */
}
@media (min-width: 1280px) {  /* matches tailwind xl:mt-2 on the editor */
  body.zen-mode #editor {
    height: calc(100vh - 48px) !important; /* 24px top (16+8) + 24px bottom (16+8) */
    margin-bottom: 8px !important;         /* mirror xl:mt-2 → symmetric */
  }
}
@media (max-width: 640px) {
  body.zen-mode #editor {
    height: calc(100dvh - 32px) !important; /* dvh: mobile URL bar safe */
    min-height: 320px;
  }
}
