/* InfoProxy - multi-theme shared stylesheet
   Default: light. Also: dark, depth, infonet, infolight.
   Pattern ported from infonet.co. Keeps InfoProxy's amber+coral brand accents.

   Layered on top of each HTML file's inline <style> block. The inline block
   declares the base (dark) tokens under :root{}; this file's [data-theme="X"]
   selectors override with matching specificity but later cascade, so the
   chosen theme wins across all pages.
*/

/* ---- CSS custom property layer ---- */
html[data-theme="light"] {
    --bg-deep: #FAFBFC;
    --bg-surface: #F1F3F5;
    --bg-elevated: #FFFFFF;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-card-solid: #FFFFFF;

    --amber: #D4922E;
    --amber-light: #E6A756;
    --amber-dark: #B5791F;
    --amber-glow: rgba(212, 146, 46, 0.2);
    --coral: #D16A4A;
    --coral-glow: rgba(209, 106, 74, 0.2);
    --ice: #0EA5E9;
    --ice-glow: rgba(14, 165, 233, 0.15);

    --text: #0F172A;
    --text-primary: #0F172A;
    --text-secondary: rgba(15, 23, 42, 0.7);
    --text-muted: rgba(15, 23, 42, 0.5);
    --slate: #64748B;
    --slate-light: #475569;

    --border: rgba(15, 23, 42, 0.1);
    --border-strong: rgba(15, 23, 42, 0.18);
    --border-hover: rgba(15, 23, 42, 0.22);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.1);

    --grid-opacity: 0.04;
    --noise-opacity: 0.012;
    --orb-opacity: 0.35;
    --gradient: linear-gradient(135deg, #D4922E 0%, #D16A4A 100%);
}

html[data-theme="depth"] {
    --bg-deep: #0F1923;
    --bg-surface: #162231;
    --bg-elevated: #1C2C3E;
    --bg-card: rgba(28, 44, 62, 0.7);
    --bg-card-solid: #1C2C3E;

    --amber: #E6A756;
    --amber-light: #F2C87D;
    --amber-dark: #C4863A;
    --amber-glow: rgba(230, 167, 86, 0.2);
    --coral: #E07B5A;
    --coral-glow: rgba(224, 123, 90, 0.25);
    --ice: #38BDF8;
    --ice-glow: rgba(56, 189, 248, 0.2);

    --text: #E8EDF2;
    --text-primary: #E8EDF2;
    --text-secondary: rgba(232, 237, 242, 0.7);
    --text-muted: rgba(232, 237, 242, 0.45);
    --slate: #7B8FA3;
    --slate-light: #9BB0C4;

    --border: rgba(232, 237, 242, 0.1);
    --border-strong: rgba(232, 237, 242, 0.18);
    --border-hover: rgba(232, 237, 242, 0.22);

    --grid-opacity: 0.035;
    --noise-opacity: 0.02;
    --orb-opacity: 0.5;
    --gradient: linear-gradient(135deg, #E6A756 0%, #E07B5A 100%);
}

html[data-theme="infonet"] {
    --bg-deep: #0F1923;
    --bg-surface: #162231;
    --bg-elevated: #1C2C3E;
    --bg-card: rgba(28, 44, 62, 0.7);
    --bg-card-solid: #1C2C3E;

    --amber: #0EA5E9;
    --amber-light: #38BDF8;
    --amber-dark: #0284C7;
    --amber-glow: rgba(14, 165, 233, 0.2);
    --coral: #06B6D4;
    --coral-glow: rgba(6, 182, 212, 0.25);
    --ice: #67E8F9;
    --ice-glow: rgba(103, 232, 249, 0.2);

    --text: #E8EDF2;
    --text-primary: #E8EDF2;
    --text-secondary: rgba(232, 237, 242, 0.7);
    --text-muted: rgba(232, 237, 242, 0.45);
    --slate: #7B8FA3;
    --slate-light: #9BB0C4;

    --border: rgba(232, 237, 242, 0.1);
    --border-strong: rgba(232, 237, 242, 0.18);
    --border-hover: rgba(232, 237, 242, 0.22);

    --grid-opacity: 0.035;
    --noise-opacity: 0.02;
    --orb-opacity: 0.5;
    --gradient: linear-gradient(135deg, #0EA5E9 0%, #06B6D4 100%);
}

html[data-theme="infolight"] {
    --bg-deep: #F4F7FB;
    --bg-surface: #EAF0F7;
    --bg-elevated: #FFFFFF;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-solid: #FFFFFF;

    --amber: #0E7FC7;
    --amber-light: #38A0E0;
    --amber-dark: #075E96;
    --amber-glow: rgba(14, 127, 199, 0.14);
    --coral: #0891B2;
    --coral-glow: rgba(8, 145, 178, 0.14);
    --ice: #0284C7;
    --ice-glow: rgba(2, 132, 199, 0.12);

    --text: #0C1929;
    --text-primary: #0C1929;
    --text-secondary: rgba(12, 25, 41, 0.72);
    --text-muted: rgba(12, 25, 41, 0.48);
    --slate: #5B7085;
    --slate-light: #3E5468;

    --border: rgba(12, 25, 41, 0.1);
    --border-strong: rgba(12, 25, 41, 0.18);
    --border-hover: rgba(12, 25, 41, 0.22);

    --shadow-sm: 0 2px 8px rgba(14, 127, 199, 0.08);
    --shadow-md: 0 4px 24px rgba(14, 127, 199, 0.1);
    --shadow-lg: 0 8px 40px rgba(14, 127, 199, 0.12);

    --grid-opacity: 0.04;
    --noise-opacity: 0.012;
    --orb-opacity: 0.3;
    --gradient: linear-gradient(135deg, #0E7FC7 0%, #0891B2 100%);
}

/* Dark theme (explicitly opt-in) uses the inline :root values, nothing
   extra to override here. */

/* ---- Body background + decorations ---- */
body {
    background: var(--bg-deep);
    color: var(--text);
    transition: background-color 0.5s ease, color 0.5s ease;
    position: relative;
    overflow-x: hidden;
}

/* Grid pattern backdrop */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(var(--slate) 1px, transparent 1px),
        linear-gradient(90deg, var(--slate) 1px, transparent 1px);
    background-size: 60px 60px;
    opacity: var(--grid-opacity, 0.03);
    pointer-events: none;
    z-index: 0;
    transition: opacity 0.5s ease;
}

/* Fine noise texture on top - just enough to kill banding */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: var(--noise-opacity, 0.02);
    pointer-events: none;
    z-index: 1;
    transition: opacity 0.5s ease;
}

/* Ambient drifting orbs */
.orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(60px);
    pointer-events: none;
    z-index: 0;
    opacity: var(--orb-opacity, 0.5);
    transition: opacity 0.5s ease;
    will-change: transform;
    transform: translateZ(0);
    contain: strict;
}
.orb-1 { width: 700px; height: 700px; background: radial-gradient(circle, var(--amber-glow) 0%, transparent 70%); top: -300px; right: -200px; animation: orb1 30s ease-in-out infinite; }
.orb-2 { width: 500px; height: 500px; background: radial-gradient(circle, var(--ice-glow) 0%, transparent 70%); bottom: 10%; left: -150px; animation: orb2 25s ease-in-out infinite; }
.orb-3 { width: 400px; height: 400px; background: radial-gradient(circle, var(--coral-glow) 0%, transparent 70%); top: 60%; right: 5%; animation: orb3 20s ease-in-out infinite; }

@keyframes orb1 { 0%,100%{transform:translate(0,0) rotate(0)} 50%{transform:translate(-40px,60px) rotate(180deg)} }
@keyframes orb2 { 0%,100%{transform:translate(0,0) rotate(0)} 50%{transform:translate(80px,-40px) rotate(-180deg)} }
@keyframes orb3 { 0%,100%{transform:translate(0,0) rotate(0)} 50%{transform:translate(-50px,-50px) rotate(180deg)} }

/* Elevate page content above the decorations */
body > *:not(.orb) { position: relative; z-index: 2; }

/* ---- Theme picker UI (top nav) ---- */
.theme-picker-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.theme-toggle:hover {
    border-color: var(--amber);
    color: var(--text);
    background: rgba(0,0,0,0.02);
}
html[data-theme=""] .theme-toggle:hover,
html:not([data-theme="light"]):not([data-theme="infolight"]) .theme-toggle:hover {
    background: rgba(255,255,255,0.04);
}
.theme-toggle svg {
    position: absolute;
    width: 20px;
    height: 20px;
    transition: opacity 0.25s ease, transform 0.3s ease;
}

/* By default (dark) show the moon icon */
.theme-toggle .icon-sun,
.theme-toggle .icon-moon,
.theme-toggle .icon-depth,
.theme-toggle .icon-infonet,
.theme-toggle .icon-infolight {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}
html[data-theme=""] .theme-toggle .icon-moon,
html:not([data-theme]) .theme-toggle .icon-moon {
    opacity: 1;
    transform: rotate(0) scale(1);
}
html[data-theme="light"] .theme-toggle .icon-sun { opacity: 1; transform: rotate(0) scale(1); }
html[data-theme="depth"] .theme-toggle .icon-depth { opacity: 1; transform: rotate(0) scale(1); }
html[data-theme="infonet"] .theme-toggle .icon-infonet { opacity: 1; transform: rotate(0) scale(1); }
html[data-theme="infolight"] .theme-toggle .icon-infolight { opacity: 1; transform: rotate(0) scale(1); }

.theme-picker {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 160px;
    background: var(--bg-card-solid, var(--bg-elevated));
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 6px;
    box-shadow: var(--shadow-md, 0 4px 24px rgba(0,0,0,0.25));
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.18s ease, visibility 0.18s ease, transform 0.22s ease;
    z-index: 100;
}
.theme-picker.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.theme-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 10px;
    transition: background 0.18s ease, color 0.18s ease;
    text-align: left;
    white-space: nowrap;
}
.theme-option:hover {
    background: color-mix(in srgb, var(--amber) 12%, transparent);
    color: var(--text);
}
.theme-option.active {
    background: color-mix(in srgb, var(--amber) 18%, transparent);
    color: var(--amber);
}
.theme-option svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    flex-shrink: 0;
}

/* ---- Lighthouse sweep on section titles ---- */
/* Target common section-heading tags used in InfoProxy pages. */
h1.sweep, h2.sweep, .section-title, section h2 {
    position: relative;
    display: inline-block;
    isolation: isolate;
}
h1.sweep::after, h2.sweep::after, .section-title::after, section h2::after {
    content: '';
    position: absolute;
    top: -30%;
    left: -40%;
    width: 40%;
    height: 160%;
    background: radial-gradient(
        ellipse 100% 100% at center,
        var(--amber-glow, rgba(230, 167, 86, 0.18)) 0%,
        color-mix(in srgb, var(--amber-glow, rgba(230,167,86,0.1)) 70%, transparent) 35%,
        transparent 70%
    );
    filter: blur(25px);
    pointer-events: none;
    opacity: 0;
    z-index: -1;
    animation: sectionSweep 11s ease-in-out 0.5s infinite;
}
@keyframes sectionSweep {
    0%   { left: -40%; opacity: 0; }
    6%   { opacity: 1; }
    44%  { left: 110%; opacity: 0.8; }
    51%  { left: 110%; opacity: 0; }
    100% { left: -40%; opacity: 0; }
}

/* ---- Micro-interactions ---- */
/* Hover-rise on primary buttons (in case the inline style didn't already) */
.btn {
    transition: transform 0.18s cubic-bezier(0.16,1,0.3,1), box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.btn:hover { transform: translateY(-1px); }

/* Soft card hover */
.card, .feature-card, article.post, .pricing-card, .step-card, .plan-card {
    transition: transform 0.2s cubic-bezier(0.16,1,0.3,1), box-shadow 0.2s ease, border-color 0.2s ease;
}
.card:hover, .feature-card:hover, article.post:hover, .pricing-card:hover, .step-card:hover, .plan-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md, 0 10px 30px rgba(0,0,0,0.15));
    border-color: var(--border-hover, var(--border-strong));
}

/* Nav link underline micro-interaction */
.site-nav ul a {
    position: relative;
    padding: 6px 0;
}
.site-nav ul a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 2px;
    width: 100%;
    height: 1.5px;
    background: var(--gradient);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.3s cubic-bezier(0.16,1,0.3,1);
    opacity: 0.85;
}
.site-nav ul a:hover::after,
.site-nav ul a.active::after {
    transform: scaleX(1);
    transform-origin: left;
}

/* Light-mode overrides for nav background (sticky nav looks wrong dark-on-light) */
html[data-theme="light"] .site-nav,
html[data-theme="infolight"] .site-nav {
    background: rgba(255, 255, 255, 0.85);
    border-bottom: 1px solid var(--border);
}

/* Light-mode body text contrast */
html[data-theme="light"] body,
html[data-theme="infolight"] body {
    color: var(--text);
}

/* Button text color fix for light */
html[data-theme="light"] .btn-primary,
html[data-theme="infolight"] .btn-primary {
    color: #FFFFFF;
}
html[data-theme="light"] .btn-ghost,
html[data-theme="infolight"] .btn-ghost {
    color: var(--text);
    border-color: var(--border-strong);
}
html[data-theme="light"] .btn-ghost:hover,
html[data-theme="infolight"] .btn-ghost:hover {
    background: rgba(0, 0, 0, 0.03);
    border-color: var(--amber);
}

/* Mobile: hide orbs (heavy paint + small screens don't benefit) */
@media (max-width: 768px) {
    .orb { display: none; }
    body::before { background-size: 40px 40px; }
}

/* Reduced motion: kill the sweep animation so it doesn't distract */
@media (prefers-reduced-motion: reduce) {
    .section-title::after, h1.sweep::after, h2.sweep::after { animation: none; }
    .orb { animation: none; }
}
