/* ═══════════════════════════════════════════════════════════════════
   DESIGN V4 — Warm Editorial (per MASTER.md, redesign mode)
   Token replacement + serif display + component refinements.
   Loads after portal.css (base), portal-v2 (motion), portal-v3 (polish).
   ═══════════════════════════════════════════════════════════════════ */

/* ── Light tokens (MASTER.md) ── */
:root {
  --paper: #FCFBF8;
  --paper-2: #F3F1EA;
  --paper-3: #EBE8E0;
  --ink: #1F1E1D;
  --body: #45423D;
  --muted: #6E6B62;
  --line: #E8E5DC;
  --line-2: #D9D5C9;
  /* primary accent: terracotta (old var names kept, values replaced) */
  --petrol: #B84F33;
  --petrol-900: #A8482E;
  --teal: #A8482E;
  --sky: #B84F33;
  --sky-wash: #F6E9E3;
  --sky-line: #EBD5CB;
  --urgent: #8E2F3C;
  --urgent-bg: #F5E9EB;
  --ok: #3D7A54;
  --teal-weak: #F6E9E3;
  /* display serif */
  --serif-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font: 'Instrument Sans', 'SamsungOne', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --head: 'Instrument Sans', 'Samsung Sharp Sans', -apple-system, sans-serif;
}

/* ── Dark tokens (MASTER.md) ── */
[data-theme="dark"] {
  --paper: #201E1B;
  --paper-2: #171614;
  --paper-3: #232120;
  --ink: #ECEAE4;
  --body: #B9B5AC;
  --muted: #8F8B82;
  --line: #2E2C29;
  --line-2: #3B3835;
  --petrol: #E07B5F;
  --petrol-900: #E9967E;
  --teal: #D4694C;
  --sky: #E07B5F;
  --sky-wash: #2A211D;
  --sky-line: #3D2E28;
  --teal-weak: #2A211D;
  --urgent: #C96A75;
  --urgent-bg: #2A1E20;
  --sh: 0 1px 3px rgba(0,0,0,.4);
  --sh-lg: 0 8px 24px rgba(0,0,0,.5);
}

/* ── Display serif: h1-level moments only (MASTER.md) ── */
h1,
#viewTitle,
.auth-inst-title,
.dash-hello,
.e2ee-encryption-pill ~ .wa-date-pill {
  font-family: var(--serif-display);
  letter-spacing: -0.02em;
}
h1 { font-size: clamp(27px, 2.8vw, 36px); font-weight: 600; }

/* v3 gradient button → MASTER.md accent solid with warm shadow */
.btn {
  background: var(--petrol);
  border-color: transparent;
  box-shadow: 0 1px 2px rgba(31, 30, 29, 0.18),
              0 4px 12px -4px color-mix(in oklch, var(--petrol) 55%, transparent);
}
.btn:hover {
  background: var(--petrol-900);
  box-shadow: 0 2px 4px rgba(31, 30, 29, 0.2),
              0 8px 20px -6px color-mix(in oklch, var(--petrol) 60%, transparent);
  transform: translateY(-1px);
}
.btn.soft { background: var(--sky-wash); color: var(--petrol-900); border-color: var(--sky-line); }
.btn.soft:hover { background: color-mix(in oklch, var(--sky-wash) 88%, var(--petrol)); }
[data-theme="dark"] .btn.soft { color: var(--petrol); }

/* Input focus: accent ring (v3 glow → warm) */
input:focus, select:focus, textarea:focus {
  border-color: var(--petrol);
  box-shadow: 0 0 0 3px var(--sky-wash);
}

/* Stat numerals: serif, per MASTER.md */
.stat-cell .v { font-family: var(--serif-display); font-weight: 600; }
.stat-cell::before {
  background: linear-gradient(90deg, var(--petrol), color-mix(in oklch, var(--petrol) 40%, transparent));
}

/* Chat: my bubbles go terracotta (4.5:1 with white) */
[data-theme="dark"] .bub.me { background: var(--teal); color: #fff; }
[data-theme="dark"] .bub.me { background: #B0552F; }
.bub.me { background: var(--teal); color: #fff; }
[data-theme="dark"] .bub.me { background: #B0552F; }

/* ── Login: replace colored blur blobs with a warm paper vignette
      (tell-blob failed the thesis; static vignette is the calm fix) ── */
.auth::before,
.auth::after {
  animation: none;
  filter: none;
  opacity: 1;
  border-radius: 0;
  width: 100%;
  height: 100%;
  top: 0; left: 0; right: 0; bottom: 0;
}
.auth::before {
  background: radial-gradient(120% 90% at 20% 0%,
    color-mix(in oklch, var(--accent-wash) 70%, transparent), transparent 60%);
}
.auth::after { content: none; }
[data-theme="dark"] .auth::before {
  background: radial-gradient(120% 90% at 20% 0%,
    color-mix(in oklch, var(--accent) 10%, transparent), transparent 60%);
}

/* Kicker/chips: accent wash + deep text (MASTER.md component) */
.kicker-chip, .doc-tab.on, .sem-tab.on {
  background: var(--sky-wash);
  color: var(--petrol-900);
  border-color: var(--sky-line);
}
[data-theme="dark"] .kicker-chip { color: var(--petrol); }

/* Nav indicator + selection: accent */
.nav-ind { background: var(--sky-wash); border-color: var(--sky-line); }
@media (max-width: 940px) {
  .nav-ind { display: none !important; }
}
::selection { background: color-mix(in oklch, var(--accent-wash) 80%, var(--petrol) 20%); }
:not([data-theme="dark"]) ::selection { color: var(--ink); }

/* Card sheen: warm instead of blue-gray */
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.65), transparent 42%), var(--paper);
}
[data-theme="dark"] .card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 42%), var(--paper);
}
:root { --e1: 0 0 0 1px rgba(31, 30, 29, 0.05), 0 1px 2px -1px rgba(31, 30, 29, 0.06), 0 2px 6px rgba(31, 30, 29, 0.04); }
:root { --e2: 0 0 0 1px rgba(31, 30, 29, 0.06), 0 2px 4px -1px rgba(31, 30, 29, 0.07), 0 8px 20px -4px rgba(31, 30, 29, 0.08); }
:root { --e3: 0 0 0 1px rgba(31, 30, 29, 0.06), 0 4px 8px -2px rgba(31, 30, 29, 0.08), 0 18px 44px -8px rgba(31, 30, 29, 0.18); }

/* Toast bar + readall accents follow the token automatically (petrol vars) */

/* Serif empty-state headlines */
.empty { font-family: var(--serif-display); font-size: 15px; }

/* Fine print: mono kickers stay, warm muted */
body { background-color: var(--paper-2); }
[data-theme="dark"] body { background-color: var(--paper-2); }

/* ── Mobile: lift the composer above the fixed tab bar ── */
@media (max-width: 940px) {
  body.in-chat-view .main {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important;
  }
  /* serif display tunes down a notch on small screens */
  h1 { font-size: 24px; }
  .stat-cell .v { font-size: 28px; }
  /* FAB sits clear of the composer zone */
  .notif-fab { bottom: calc(132px + env(safe-area-inset-bottom, 0px)); }
}

/* ── Smoothness pass (perf audit): paint less, animate cheaper ── */
/* Long lists: skip layout/paint of off-screen rows (630-doc library) */
#docList .mod-folder,
#annonces .doc {
  content-visibility: auto;
  contain-intrinsic-size: auto 96px;
}
/* Hover lift/shadow transitions only where a real pointer exists */
@media (hover: none) {
  .bub-action-btn { opacity: 0.45; }
  .card, .doc-card { transition: none; }
  .card:hover, .doc-card:hover { box-shadow: var(--e1); transform: none; }
}

/* ── Chat: WhatsApp-style bottom anchoring + scroll-to-bottom ── */
#msgs > :first-child { margin-top: auto; }
.wa-scroll-bottom {
  position: absolute;
  right: 18px;
  bottom: 86px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--e2);
  z-index: 30;
  transition: opacity var(--d2) var(--ease-out), transform var(--d2) var(--ease-out);
}
.wa-scroll-bottom.on { display: flex; animation: notifDotIn var(--d2) var(--ease-out); }
.wa-scroll-bottom:hover { transform: translateY(-2px); }
@media (max-width: 940px) {
  .wa-scroll-bottom { bottom: 148px; right: 14px; }
}
