/* =========================================================================
   ql-theme.css — the quantumlayers.com site look (v2 homepage design system)
   for every page in free-tools/.

   Loaded AFTER each page's own <style>, so it:
     1. defines the site's --ql-* tokens (copied from quantumlayers.com's
        custom CSS: same names and values), and
     2. remaps each tool's own tokens (--bg, --text, --accent, --meter-*…, and
        whats-in-this-csv's --ink/--paper/--amber…) onto them, then restyles
        the shared components (buttons, panels, CTA band, KIND tag, meter)
        and the site header.
   Tools keep working without it; it only changes appearance.

   Dark only, like the site. A later plain :root rule beats the tools'
   earlier @media (prefers-color-scheme: light) token blocks, which is what
   keeps light-mode visitors on the site palette.
   ========================================================================= */

:root {
  color-scheme: dark;

  /* --- quantumlayers.com tokens (v2) --- */
  --ql-font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --ql-font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ql-font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --ql-bg: #0b0a12;
  --ql-veil: rgba(11, 10, 18, 0.6);
  --ql-surface: #15121f;
  --ql-surface-2: #1c1830;
  --ql-band: rgba(91, 75, 216, 0.08);
  --ql-border: rgba(196, 181, 253, 0.14);
  --ql-border-strong: rgba(196, 181, 253, 0.28);
  --ql-text: #eceaf5;
  --ql-muted: #a9a6bc;
  --ql-faint: #8a869f;
  --ql-primary: #8b7cf6;
  --ql-primary-strong: #5b4bd8;
  --ql-primary-soft: #c4b5fd;
  --ql-accent: #22d3ee;
  --ql-radius: 16px;
  --ql-card: linear-gradient(180deg, var(--ql-surface-2), var(--ql-surface));
  --ql-card-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 24px 60px -24px rgba(0, 0, 0, 0.6);
  --ql-btn-gradient: linear-gradient(135deg, #5b4bd8 0%, #6d5deb 100%);
  --ql-btn-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset, 0 10px 30px -8px rgba(109, 93, 235, 0.65);
  --ql-btn-shadow-hover: 0 0 0 1px rgba(255, 255, 255, 0.18) inset, 0 14px 36px -8px rgba(109, 93, 235, 0.8);
  --ql-wave-bg: url("https://quantumlayers.com/wp-content/uploads/2025/12/1000013672-purple.png");
  --ql-wave-bg-mobile: var(--ql-wave-bg);

  /* --- free-tools tokens, remapped --- */
  --font-display: var(--ql-font-display);
  --font-body: var(--ql-font-body);
  --font-mono: var(--ql-font-mono);
  --bg: var(--ql-bg);
  --bg-raised: var(--ql-surface);
  --bg-inset: #110e1a;
  --border: var(--ql-border);
  --grid: rgba(196, 181, 253, 0.08);
  --text: var(--ql-text);
  --text-dim: var(--ql-muted);
  --text-faint: var(--ql-faint);
  --accent: var(--ql-primary);
  --accent-dim: var(--ql-primary-soft);
  /* strength meter: violet ramp instead of amber */
  --meter-empty: rgba(196, 181, 253, 0.12);
  --meter-1: #3a2f7a;
  --meter-2: #4838a8;
  --meter-3: #5b4bd8;
  --meter-4: #6d5deb;
  --meter-5: #8b7cf6;
  --meter-6: #c4b5fd;
  --ok: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  /* correlation-matrix diverging ends */
  --neg: #22d3ee;
  --pos: #8b7cf6;

  /* --- whats-in-this-csv tokens, remapped --- */
  --ink: var(--ql-text);
  --slate: var(--ql-muted);
  --slate-2: var(--ql-faint);
  --paper: #110e1a;
  --card: var(--ql-surface);
  --line: var(--ql-border);
  --line-2: rgba(196, 181, 253, 0.08);
  --amber: var(--ql-primary);
  --amber-ink: var(--ql-primary-soft);
  --amber-soft: rgba(139, 124, 246, 0.16);
  --panel: var(--ql-band);
  --panel-line: var(--ql-border);
  --panel-slate: var(--ql-muted);
}

/* --- page ground: the site's animated waves ---------------------------
   The block between the BEGIN/END markers is copied verbatim from the QL
   plugin's assets/common-dark.css (the same rules quantumlayers.com runs):
   two copies of the wave image drifting at different speeds, touch and
   portrait variants, and a prefers-reduced-motion opt-out. Re-copy it when
   that file changes. */
html { background: #000; }
body {
  background: transparent !important;
  background-image: none !important;
  color: var(--ql-text);
  font-family: var(--ql-font-body);
}

/* BEGIN copied from QuantumLayers assets/common-dark.css */
body {
    position: relative; /* Essential for positioning the pseudo-element */
    overflow-x: hidden; /* Prevent scrollbar from scaled background */
}

/* Two overlapping, semi-transparent copies of the same wave image drifting
   at different speeds/angles create a more complex, layered motion than a
   single background could, without needing extra image assets. */
body::before,
body::after {
    content: "";
    position: fixed;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    background-image: var(--ql-wave-bg);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
    will-change: transform;
    pointer-events: none;
}

body::before {
    opacity: 1;
    animation: ql-bg-drift-3 26s ease-in-out infinite;
}

body::after {
    position: fixed;
    inset: -15%;
    background-image: var(--ql-wave-bg);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.3;
    mix-blend-mode: lighten;
    filter: blur(1px) hue-rotate(24deg) saturate(1.35);
    animation: ql-bg-drift-1 32s ease-in-out infinite;
    will-change: transform;
    pointer-events: none;
}

@keyframes ql-bg-drift-1 {
    0%   { transform: scale(1)    translate(0%, 0%)    rotate(180deg); }
    33%  { transform: scale(1.12) translate(-2%, 1.5%)  rotate(182deg); }
    66%  { transform: scale(1.2)  translate(2%, -1%)    rotate(178deg); }
    100% { transform: scale(1)    translate(0%, 0%)    rotate(180deg); }
}

@keyframes ql-bg-drift-2 {
    0%   { transform: scaleX(-2) scale(1.15) translate(0%, 0%)    rotate(0deg); }
    50%  { transform: scaleX(-1) scale(1.3)  translate(3%, -2%)  rotate(1.2deg); }
    100% { transform: scaleX(-2) scale(1.15) translate(0%, 0%)    rotate(0deg); }
}

@keyframes ql-bg-drift-3 {
    0%   { transform: scale(1.25) translate(0%, 0%)   rotate(0deg); }
    50%  { transform: scale(1.4)  translate(-3%, 2%)  rotate(-2deg); }
    100% { transform: scale(1.25) translate(0%, 0%)   rotate(0deg); }
}

@media (prefers-reduced-motion: reduce) {
    body::before,
    body::after {
        animation: none !important;
    }
}

/* ===== Touch devices (phones/tablets, any orientation) =====
   Why the desktop rules look magnified and soft on a phone:
   - The wave image is only 1536x1024 px. Phones render at 2-3 device pixels
     per CSS pixel, so even with no zoom at all a landscape iPhone
     (844 CSS px = 2532 device px wide) already upscales it ~1.65x.
   - The desktop drift then scales the layer by up to 1.4x on top of the
     120% oversizing, i.e. ~2.8x upscaling (vs ~1.6x on a 1x laptop).
     The old mobile override only applied below 600px, so landscape phones
     (640-930px wide) got the full desktop zoom.
   - Animating scale() on a will-change layer makes mobile GPUs rasterise
     the layer once and stretch that bitmap while zooming, which softens it
     further (mobile browsers also cap raster resolution of big layers).
   - The layers were sized in %, i.e. relative to the fixed containing
     block, which mobile browsers can enlarge beyond the visible screen
     (e.g. when page content overflows horizontally). Explicit viewport
     units pin the size to the actual screen.

   So on touch devices: size the layers explicitly in vw/lvh with a small
   overscan, never scale() (pan + tiny sway only, so the texture is never
   stretched), drop the blur filter, and allow a separate, higher-
   resolution source via --ql-wave-bg-mobile (set it to a ~3072px-wide
   version of the image for sharp results on 3x screens). */
:root {
    --ql-wave-bg-mobile: var(--ql-wave-bg);
}

@media (hover: none) and (pointer: coarse), (max-width: 600px) {
    body::before,
    body::after {
        inset: auto;
        top: -5vh;
        top: -5lvh;
        left: -5vw;
        width: 110vw;
        height: 110vh;
        height: 110lvh;
        margin: 0;
        background-image: var(--ql-wave-bg-mobile);
        background-size: cover;
        background-position: center;
        transform-origin: center center;
    }

    body::before {
        transform: rotate(0deg);
        animation: ql-bg-pan-mobile 16s ease-in-out infinite;
    }

    body::after {
        filter: hue-rotate(24deg) saturate(1.35);
        transform: rotate(180deg);
        animation: ql-bg-pan-mobile-alt 22s ease-in-out infinite;
    }

    /* Movement stays inside the 5% overscan on each side. */
    @keyframes ql-bg-pan-mobile {
        0%   { transform: translate(0%, 0%)       rotate(0deg); }
        33%  { transform: translate(-4%, 2.5%)    rotate(-0.5deg); }
        66%  { transform: translate(4%, -2%)      rotate(0.5deg); }
        100% { transform: translate(0%, 0%)       rotate(0deg); }
    }

    @keyframes ql-bg-pan-mobile-alt {
        0%   { transform: translate(0%, 0%)       rotate(180deg); }
        50%  { transform: translate(4%, -2.5%)    rotate(179.5deg); }
        100% { transform: translate(0%, 0%)       rotate(180deg); }
    }
}

/* Portrait touch screens: a 3:2 landscape image under `cover` would only
   show ~30% of its width. Swap the layer's width/height (width = screen
   height, height = screen width, +15% overscan), centre it and rotate it
   90deg so the whole wave fits the tall screen. */
@media (hover: none) and (pointer: coarse) and (orientation: portrait),
       (max-width: 600px) and (orientation: portrait) {
    body::before,
    body::after {
        top: 50%;
        left: 50%;
        width: 115vh;
        width: 115lvh;
        height: 115vw;
    }

    body::before {
        transform: translate(-50%, -50%) rotate(90deg);
        animation-name: ql-bg-pan-mobile-portrait;
    }

    body::after {
        transform: translate(-50%, -50%) rotate(270deg);
        animation-name: ql-bg-pan-mobile-portrait-alt;
    }

    /* The trailing translate is in the rotated frame: its first value moves
       the layer up/down the screen, its second left/right. */
    @keyframes ql-bg-pan-mobile-portrait {
        0%   { transform: translate(-50%, -50%) rotate(90deg)   translate(0%, 0%); }
        33%  { transform: translate(-50%, -50%) rotate(88.5deg) translate(-4%, 2%); }
        66%  { transform: translate(-50%, -50%) rotate(91.5deg) translate(4%, -2%); }
        100% { transform: translate(-50%, -50%) rotate(90deg)   translate(0%, 0%); }
    }

    @keyframes ql-bg-pan-mobile-portrait-alt {
        0%   { transform: translate(-50%, -50%) rotate(270deg)   translate(0%, 0%); }
        50%  { transform: translate(-50%, -50%) rotate(268.5deg) translate(4%, -2%); }
        100% { transform: translate(-50%, -50%) rotate(270deg)   translate(0%, 0%); }
    }
}

/* If the animation still doesn't run on a phone, check whether "Reduce
   motion" (iOS) / "Remove animations" (Android, also enabled by some
   battery-saver modes) is on: the prefers-reduced-motion rule above
   deliberately stops it. */
/* END copied from QuantumLayers assets/common-dark.css */

/* Tools put dense text and tables on top of the waves, so a fixed veil sits
   between them and the content: lighter at the top (the hero shows the waves
   like the homepage does), darker further down. html::after is painted after
   body's pseudo-elements at the same z-index, i.e. above the waves and below
   the page content. */
html::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(11, 10, 18, 0.3) 0%, rgba(11, 10, 18, 0.74) 42%, rgba(11, 10, 18, 0.88) 100%);
}
a { color: var(--ql-primary-soft); }
::selection { background: rgba(139, 124, 246, 0.35); }

/* --- top bar: brand on the left, link buttons on the right ------------- */
/* One page width everywhere, so the bar never jumps between tools. */
.wrap { max-width: 1080px !important; padding-left: 20px !important; padding-right: 20px !important; }

.ql-toplinks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 26px 0 18px;
  border-bottom: 1px solid var(--ql-border);
  font-family: var(--ql-font-body);
}
.ql-toplinks a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 7px;
  font: 600 14px/1 var(--ql-font-body);
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.ql-toplinks a:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--ql-border-strong); color: #fff; }
.ql-toplinks a:focus-visible { outline: 2px solid var(--ql-primary-soft); outline-offset: 3px; }

/* brand: logo + wordmark, no button chrome, pushes the buttons right */
.ql-toplinks a.ql-brand {
  margin-right: auto;
  padding: 0;
  background: none;
  border: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  font: 700 19px/1 var(--ql-font-display);
  letter-spacing: -0.02em;
}
.ql-toplinks a.ql-brand::before {
  content: "";
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: url("https://quantumlayers.com/wp-content/uploads/2026/08/cropped-image-rounded.png") center / cover no-repeat;
  box-shadow: 0 0 0 1px rgba(196, 181, 253, 0.18);
}
.ql-toplinks a.ql-brand:hover { background: none; }

/* primary action, last in the row: same gradient button as the site */
.ql-toplinks a[href*="ql-register"] {
  order: 10;
  background: var(--ql-btn-gradient);
  border-color: transparent;
  box-shadow: var(--ql-btn-shadow);
}
.ql-toplinks a[href*="ql-register"]:hover { box-shadow: var(--ql-btn-shadow-hover); transform: translateY(-1px); }

@media (max-width: 680px) {
  .ql-toplinks { padding-top: 18px; gap: 8px; }
  .ql-toplinks a { height: 36px; padding: 0 12px; font-size: 13px; }
  .ql-toplinks a.ql-brand { flex: 1 0 100%; margin: 0 0 6px; justify-content: flex-start; font-size: 18px; }
  .ql-toplinks a:not(.ql-brand) { flex: 1 1 0; }
  .ql-toplinks a[href*="ql-register"] { flex: 1 0 100%; }
}

/* breadcrumb → the homepage's violet pill (sits where its "AI-native analytics" pill does) */
.crumbs, .ql-subbar .crumbs {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 6px;
  width: fit-content;
  max-width: 100%;
  margin: 44px 0 0;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--ql-border-strong);
  border-radius: 999px;
  background: rgba(139, 124, 246, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--ql-primary-soft);
  font: 500 0.8rem/1.4 var(--ql-font-body);
  letter-spacing: 0.04em;
}
.crumbs a { color: #fff; text-decoration: none; }
.crumbs a:hover { color: var(--ql-primary-soft); }
.ql-subbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ql-subbar .auth-status { margin-top: 44px; }
@media (max-width: 680px) { .crumbs, .ql-subbar .crumbs, .ql-subbar .auth-status { margin-top: 28px; } }

/* hero spacing under the pill */
.hero { padding: 18px 0 8px !important; }
.hero h1, .hero + * h1 { margin-top: 0; }
.lede { max-width: 64ch; }

/* --- interface text in Inter, like the site; mono stays for data only --- */
label.lbl, .ctl-l, .tile .l, .chip, .btn-ghost, .seg button, .tabs button,
.sec-label, .filebar, .filebar .again, .zone .sample, .zone .s, .status,
.legend, .export-row button, .dict-actions button, .auth-status, .auth-status button,
.btn-link, .invite-bar a, .rec-chip .label, .recs .label, .grp h3, .field label,
.dataset-row .meta, .terms, .tabs, .ql-subbar, footer, footer a, .related, .note, .hint,
.privacy-line, .privacy, .cap-note, .empty-note, .skeleton, details.paste summary,
details.profile summary, .settings dt, .ds-list span, table.t th, .tbl th, .dict th,
.cta .ladder .from, figcaption {
  font-family: var(--ql-font-body) !important;
}
label.lbl, .ctl-l, .tile .l, .grp h3, .field label, .settings dt, .sec-label,
table.t th, .tbl th, .dict th {
  letter-spacing: 0.08em;
}
.tile .l { font-size: 0.7rem; font-weight: 600; color: var(--ql-faint); }
.chip, .btn-ghost, .export-row button, .dict-actions button { font-weight: 500; letter-spacing: 0.01em; }
.btn-ghost, a.btn-ghost { display: inline-flex; align-items: center; }
.auth-status button {
  border-radius: 7px; padding: 8px 14px; font-weight: 600 !important;
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.16); color: #fff;
}
footer { font-size: 13px; padding-top: 18px; border-top: 1px solid var(--ql-border); }

/* --- typography --- */
.hero h1, h1 {
  font-family: var(--ql-font-display);
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(#fff 30%, #d9d2ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--ql-text);
  text-wrap: balance;
}
h2, h3 { font-family: var(--ql-font-display); color: var(--ql-text); }
.lede { color: #d9d6e8; }
.privacy-line, .privacy { font-family: var(--ql-font-body); color: var(--ql-muted); }
/* whats-in-this-csv's highlighted phrase */
h1 .hl { background: none; -webkit-text-fill-color: var(--ql-primary-soft); color: var(--ql-primary-soft); padding: 0; }

/* --- buttons --- */
.btn, .btn-primary, a.btn, a.btn-primary {
  background: var(--ql-btn-gradient) !important;
  color: #fff !important;
  border: 1px solid transparent;
  border-radius: 7px;
  box-shadow: var(--ql-btn-shadow);
  font-family: var(--ql-font-body);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 0.2s, box-shadow 0.2s;
}
.btn:hover, .btn-primary:hover:not(:disabled), a.btn:hover, a.btn-primary:hover {
  background: var(--ql-btn-gradient) !important;
  box-shadow: var(--ql-btn-shadow-hover);
  transform: translateY(-1px);
}
.btn-ghost, .filebar .again, .zone .sample, .chip, .dict-actions button, .export-row button {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  border-radius: 7px;
}
.btn-ghost:hover, .filebar .again:hover, .zone .sample:hover, .chip:hover, .dict-actions button:hover, .export-row button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--ql-border-strong);
}
.chip.active { border-color: var(--ql-primary); color: var(--ql-primary-soft); }

/* --- surfaces --- */
.panel, .card, figure.chart, .findings .f, .filebar, .maker .picker, .maker .chart-panel, .col-card {
  background: var(--ql-card);
  border: 1px solid var(--ql-border);
  border-radius: var(--ql-radius);
  box-shadow: var(--ql-card-shadow);
}
.tile, .grp, .col, .zone, .rec-chip, ul.findings li, ul.notes li, ul.pairs li, .dataset-row {
  background: rgba(11, 10, 18, 0.55);
  border-color: var(--ql-border);
}
.zone:hover, .zone:focus-within, .zone.drag { background: rgba(139, 124, 246, 0.08); border-color: var(--ql-primary); }
input[type=text], input[type=url], input[type=email], input[type=password], input[type=number], select, textarea {
  background: rgba(11, 10, 18, 0.7);
  border-color: var(--ql-border-strong);
  color: var(--ql-text);
  font-family: var(--ql-font-body);
}
input:focus, select:focus, textarea:focus { border-color: var(--ql-primary) !important; box-shadow: 0 0 0 3px rgba(139, 124, 246, 0.2); outline: none; }

/* tables: site-style header row */
table.t th, .tbl th, table.dict th, table.mx th { color: var(--ql-primary-soft); }

/* --- labels: KIND tag and type tags as violet pills --- */
.kind-tag, .kind, .tag {
  font-family: var(--ql-font-body);
  font-weight: 600;
  color: var(--ql-primary-soft);
  background: rgba(139, 124, 246, 0.12);
  border: 1px solid var(--ql-border-strong);
  border-radius: 999px;
}
.meter i.on { background: var(--ql-primary); }
.meter i { background: rgba(196, 181, 253, 0.12); }

/* --- tabs / segmented controls --- */
.tabs button.on { color: #fff; border-bottom-color: var(--ql-primary); }
.seg { border-color: var(--ql-border); border-radius: 999px; padding: 3px; background: rgba(255, 255, 255, 0.02); }
.seg button { border-radius: 999px; }
.seg button.on { background: var(--ql-primary-strong); color: #fff; box-shadow: 0 6px 20px -6px rgba(109, 93, 235, 0.7); }

/* --- CTA band --- */
.cta {
  background: var(--ql-band) !important;
  border: 1px solid var(--ql-border) !important;
  border-radius: var(--ql-radius);
  color: var(--ql-text);
}
.cta .eyebrow {
  font-family: var(--ql-font-body);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: var(--ql-primary-soft);
}
.cta .ladder div { color: #d9d6e8; }
.cta .ladder .arrow { color: var(--ql-primary); }

/* --- states --- */
.err, .err-box {
  background: rgba(248, 113, 113, 0.1) !important;
  border: 1px solid rgba(248, 113, 113, 0.35) !important;
  color: var(--ql-text) !important;
}
.sugg { background: rgba(139, 124, 246, 0.1); border-color: var(--ql-border-strong); }
.summary { border-left-color: var(--ql-primary); }

footer { color: var(--ql-faint); }
footer a { color: var(--ql-muted); border-bottom-color: var(--ql-border); }
footer a:hover { color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .btn:hover, .btn-primary:hover { transform: none; }
}
