/* ============================================================================
   PERGAMINO — light "parchment" theme for the Search /app screen ONLY.
   Replaces tesoro-remap.css on index.html. Mirrors the same legacy token names
   (so every component built on var(--…) re-themes automatically), but with the
   light Pergamino palette from design_handoff_tesoro/SEARCH-PERGAMINO.md.
   Values are lifted verbatim from "Search - Pergamino.dc.html".
   ========================================================================== */

:root {
  /* Surfaces */
  --surface-0: #FBF7EF;   /* pageBg — warm parchment */
  --surface-1: #F7F2E8;
  --surface-2: #F4EEE2;   /* surfaceAlt / well — toggle track, icon tiles */
  --surface-3: #E5DCCB;   /* border */
  --surface-raised: #FFFFFF; /* surface — cards, prompt box, modal panel */

  /* Ink */
  --ink-primary: #1F1B16;
  --ink-secondary: #5A5248;
  --ink-tertiary: #9A8E7C;
  --ink-faint: #B8AC98;

  /* Accent: burnt amber (replaces gold so it has contrast on cream) */
  --accent: #B45309;
  --accent-soft: #C2710C;
  --accent-text: #FFFFFF;
  --accent-wash: rgba(180, 83, 9, 0.08);
  --accent-wash-strong: rgba(180, 83, 9, 0.15);
  --tag-bg: #F7E9D8;          /* amber-tinted pill background (active) */
  --border-soft: #EFE7D8;     /* inner dividers (tool list rows) */

  /* Semantic */
  --positive: #15803D;
  --positive-wash: rgba(21, 128, 61, 0.10);
  --info: #1D4ED8;
  --info-wash: rgba(29, 78, 216, 0.08);
  --danger: #B91C1C;

  /* Layout / shadow */
  --panel-border: #E5DCCB;
  --shadow-card: 0 1px 3px rgba(40,30,18,0.08), 0 1px 2px rgba(40,30,18,0.05);
  --shadow-elevated: 0 24px 50px -30px rgba(40,30,18,0.45);
}

html, body { background: var(--surface-0); }

.tesoro-ribbon {
  height: 5px; width: 100%;
  background: linear-gradient(90deg,#D52B1E 0 33.33%,#FFFFFF 33.33% 66.66%,#0038A8 66.66% 100%);
}

/* Inputs on light parchment */
input::placeholder, textarea::placeholder { color: #9A8E7C; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(180,83,9,0.12);
}
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ── Reusable Pergamino components ─────────────────────────────────────────
   Shared chrome lifted from "Search - Pergamino.dc.html". Used by the mode
   toggle, depth selector, suggestion cards, and every Pergamino modal. */

/* Tricolor ribbon (modal/header top edge) */
.pg-ribbon {
  height: 4px; width: 100%;
  background: linear-gradient(90deg,#D52B1E 0 33.33%,#FFFFFF 33.33% 66.66%,#0038A8 66.66% 100%);
}

/* Estándar / Investigación toggle */
.pg-toggle {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface-2); border: 1px solid var(--surface-3);
  border-radius: 100px; padding: 3px;
}
.pg-toggle-pill {
  border: none; cursor: pointer; white-space: nowrap;
  font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 500;
  padding: 5px 14px; border-radius: 100px; transition: all .15s;
  background: transparent; color: var(--ink-secondary);
}
.pg-toggle-pill.is-active { background: var(--accent); color: var(--accent-text); }

/* Suggestion cards (Estándar) */
.pg-suggestion {
  text-align: left; border: 1px solid var(--surface-3); background: var(--surface-raised);
  border-radius: 10px; padding: 14px 16px; cursor: pointer;
  display: flex; gap: 12px; align-items: flex-start; font-family: inherit;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
.pg-suggestion:hover { border-color: var(--accent); box-shadow: var(--shadow-card); }
.pg-suggestion-icon { margin-top: 1px; flex: none; color: var(--accent); display: flex; }
.pg-suggestion-text { font-size: 14px; line-height: 1.45; color: var(--ink-primary); }

/* Depth selector (Investigación) */
.pg-depth-card {
  text-align: left; cursor: pointer; width: 100%; font-family: inherit;
  border: 1px solid var(--surface-3); background: var(--surface-raised);
  border-radius: 12px; padding: 16px 18px; display: flex; align-items: center; gap: 16px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.pg-depth-card.is-active { border-color: var(--accent); }
.pg-depth-icon {
  width: 38px; height: 38px; flex: none; border-radius: 9px;
  background: var(--surface-2); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.pg-depth-card.is-active .pg-depth-icon { background: var(--accent); color: var(--accent-text); }
.pg-depth-main { flex: 1; }
.pg-depth-row { display: flex; align-items: center; gap: 10px; }
.pg-depth-name { font-family: 'Fraunces', serif; font-weight: 600; font-size: 17px; color: var(--ink-primary); }
.pg-depth-tag {
  font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; letter-spacing: 0.04em;
  color: var(--ink-tertiary); background: var(--surface-2); border-radius: 100px; padding: 2px 9px;
}
.pg-depth-card.is-active .pg-depth-tag { color: var(--accent); background: var(--tag-bg); }
.pg-depth-desc { display: block; font-size: 13.5px; line-height: 1.5; color: var(--ink-secondary); margin-top: 3px; }
.pg-depth-chevron { flex: none; color: #C9BDA8; }
.pg-depth-card.is-active .pg-depth-chevron { color: var(--accent); }

/* Config chips (inside tool modals) */
.pg-chip {
  cursor: pointer; font-family: inherit; font-size: 13.5px; font-weight: 500;
  color: var(--ink-secondary); background: var(--surface-raised);
  border: 1px solid var(--surface-3); border-radius: 100px; padding: 8px 16px;
}
.pg-chip.is-active { font-weight: 600; color: var(--accent-text); background: var(--accent); border-color: var(--accent); }

/* Pergamino modal shell */
.pg-modal-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(40,30,18,0.42); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; padding: 40px;
}
.pg-modal-overlay.open { display: flex; animation: pgFade .16s ease; }
.pg-modal {
  width: 100%; max-width: 560px; background: var(--surface-raised);
  border: 1px solid var(--surface-3); border-radius: 16px; overflow: hidden;
  box-shadow: 0 50px 100px -30px rgba(40,30,18,0.5);
  animation: pgPop .2s cubic-bezier(.2,.8,.2,1);
  max-height: calc(100vh - 80px); display: flex; flex-direction: column;
}
@keyframes pgPop { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes pgFade { from { opacity: 0; } to { opacity: 1; } }
.pg-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 24px 26px 18px; }
.pg-modal-head-left { display: flex; gap: 15px; }
.pg-modal-icon {
  width: 46px; height: 46px; flex: none; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--surface-3); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.pg-modal-kicker { font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.pg-modal-title { font-family: 'Fraunces', serif; font-weight: 600; font-size: 23px; line-height: 1.15; margin: 0; color: var(--ink-primary); }
.pg-modal-x {
  cursor: pointer; flex: none; width: 32px; height: 32px; color: var(--ink-secondary);
  background: var(--surface-2); border: 1px solid var(--surface-3); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 0; line-height: 0;
}
.pg-modal-body { padding: 0 26px 8px; overflow-y: auto; }
.pg-modal-desc { font-size: 14.5px; line-height: 1.6; color: var(--ink-secondary); margin: 0 0 22px; }
.pg-group { margin-bottom: 20px; }
.pg-group-label { font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-tertiary); margin-bottom: 10px; }
.pg-chip-row { display: flex; gap: 9px; flex-wrap: wrap; }
.pg-source-strip {
  display: flex; align-items: center; gap: 13px;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: 11px; padding: 14px 16px; margin-top: 4px;
}
.pg-source-icon {
  width: 34px; height: 34px; flex: none; border-radius: 8px;
  background: var(--surface-raised); border: 1px solid var(--surface-3); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.pg-source-line { font-size: 13.5px; font-weight: 500; color: var(--ink-primary); }
.pg-source-sub { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--ink-tertiary); margin-top: 2px; }
.pg-modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 26px 24px; }
.pg-btn-ghost {
  cursor: pointer; background: transparent; border: 1px solid var(--surface-3); color: var(--ink-secondary);
  font-family: inherit; font-weight: 500; font-size: 14px; padding: 11px 20px; border-radius: 100px;
}
.pg-btn-cta {
  cursor: pointer; background: var(--accent); border: none; color: var(--accent-text);
  font-family: 'Fraunces', serif; font-weight: 600; font-size: 15px; padding: 12px 24px; border-radius: 100px;
  display: flex; align-items: center; gap: 9px; box-shadow: 0 10px 24px -10px rgba(180,83,9,0.5);
}
.pg-btn-cta:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

/* ── Piece 4: Pergamino chrome for the app's existing dialogs ────────────────
   Panels already use the light tokens, so this only warms the scrim and adds
   the signature top tricolor ribbon (CSS-only — no markup changes). */

/* Warm parchment scrim + blur on every dialog overlay */
.studio-modal-overlay, .viewer-overlay, .charts-overlay,
.bio-overlay, .compare-overlay, .network-overlay {
  background: rgba(40,30,18,0.42) !important;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
/* Inline-styled scrims (ids) — !important overrides the element's inline style */
#help-scrim, #preflight-scrim {
  background: rgba(40,30,18,0.42) !important;
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}

/* Signature tricolor ribbon across the top edge of each dialog panel.
   Panels have overflow:hidden + radius, so the bar clips cleanly to the top. */
.studio-modal, .viewer-dialog, .charts-modal,
.bio-modal, .compare-modal, .network-modal {
  position: relative;
  border: 1px solid var(--surface-3);
}
.studio-modal::before, .viewer-dialog::before, .charts-modal::before,
.bio-modal::before, .compare-modal::before, .network-modal::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; z-index: 3;
  background: linear-gradient(90deg,#D52B1E 0 33.33%,#FFFFFF 33.33% 66.66%,#0038A8 66.66% 100%);
}
