/* ============================================================
   Salah Abdelhady — shared design system
   Used by: case-studies.html, notes.html, notes/*.html, changelog.html
   ============================================================ */

:root {
    --brand-1: #38bdf8;
    --brand-2: #4f7ff0;
    --accent: #f5a524;
    --c-violet: #a78bfa;
    --c-teal: #2dd4bf;
    --c-amber: #fbbf24;
    --c-rose: #fb7185;
    --c-emerald: #34d399;
    --c-sky: #38bdf8;
    --c-blue: #4f7ff0;

    --brand-grad: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 100%);

    --radius: 16px;
    --radius-sm: 10px;
    --radius-lg: 24px;
    --container: 1080px;
    --header-h: 64px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --mono: 'Cascadia Code', Consolas, 'Courier New', monospace;
    --font: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

html[data-theme='dark'] {
    --bg: #0a1020;
    --bg-2: #0c1428;
    --surface: rgba(255, 255, 255, 0.045);
    --surface-2: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --text: #eaefff;
    --muted: #a3aecd;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    --code-bg: rgba(56, 189, 248, 0.08);
}

html[data-theme='light'] {
    --bg: #f4f7fc;
    --bg-2: #ffffff;
    --surface: #ffffff;
    --surface-2: #f1f5fc;
    --border: #e2e8f4;
    --border-strong: #cdd9ec;
    --text: #0c1426;
    --muted: #536180;
    --shadow: 0 16px 34px rgba(15, 32, 66, 0.10);
    --code-bg: rgba(37, 99, 235, 0.07);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--font);
    line-height: 1.68;
    color: var(--text);
    background:
        radial-gradient(55rem 36rem at 8% -8%, color-mix(in srgb, var(--c-sky) 14%, transparent), transparent 60%),
        radial-gradient(48rem 32rem at 96% 2%, color-mix(in srgb, var(--c-violet) 12%, transparent), transparent 60%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
    background-attachment: fixed;
    min-height: 100vh;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--brand-1); }
:focus-visible { outline: 2px solid var(--brand-1); outline-offset: 3px; border-radius: 6px; }

.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: 20px; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; left: -9999px; top: 0; z-index: 3000;
    background: var(--brand-1); color: #06121f; padding: 0.7rem 1.2rem;
    font-weight: 700; border-radius: 0 0 10px 0; text-decoration: none;
}
.skip-link:focus { left: 0; }

/* ---------- header ---------- */
.site-header {
    position: sticky; top: 0; z-index: 1000;
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: blur(14px) saturate(150%);
    border-bottom: 1px solid var(--border);
}

.nav { display: flex; align-items: center; gap: 1rem; min-height: var(--header-h); }

.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--text); text-decoration: none; font-weight: 750; white-space: nowrap; }

.brand-mark {
    display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px;
    background: var(--brand-grad); color: #06121f; font-size: 0.8rem; font-weight: 800;
}

.nav-links { display: flex; gap: 0.15rem; margin: 0 0 0 auto; padding: 0; list-style: none; }

.nav-links a {
    display: block; padding: 0.45rem 0.7rem; border-radius: 8px;
    color: var(--muted); font-size: 0.92rem; font-weight: 600; text-decoration: none;
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); }
.nav-links a[aria-current='page'] { color: var(--brand-1); }

.nav-actions { display: flex; align-items: center; gap: 0.45rem; }

.icon-btn {
    display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
    cursor: pointer; font-size: 0.95rem; font-family: inherit;
}
.icon-btn:hover { border-color: var(--brand-1); }

html[data-theme='dark'] .theme-toggle .fa-sun { display: block; }
html[data-theme='dark'] .theme-toggle .fa-moon { display: none; }
html[data-theme='light'] .theme-toggle .fa-sun { display: none; }
html[data-theme='light'] .theme-toggle .fa-moon { display: block; }

.nav-toggle { display: none; }

/* ---------- hero ---------- */
.page-head { padding: clamp(2.5rem, 6vw, 4.5rem) 0 1.5rem; }

.eyebrow {
    display: inline-flex; align-items: center; gap: 0.5rem; margin-bottom: 0.8rem;
    padding: 0.35rem 0.9rem; border-radius: 999px; background: var(--surface-2);
    border: 1px solid var(--border); color: var(--muted);
    font-size: 0.78rem; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase;
}

.page-head h1 {
    margin: 0 0 0.7rem; font-size: clamp(1.9rem, 1.3rem + 2.6vw, 3rem);
    line-height: 1.12; letter-spacing: -0.025em;
}

.page-head .lead { margin: 0; color: var(--muted); max-width: 72ch; font-size: 1.05rem; }

.gradient-text {
    background: linear-gradient(135deg, var(--brand-1), var(--c-violet), var(--c-teal));
    background-size: 220% 220%; -webkit-background-clip: text; background-clip: text;
    color: transparent; animation: gradient-pan 9s ease infinite;
}
@keyframes gradient-pan { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

/* ---------- cards & grids ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: clamp(1.25rem, 3vw, 1.75rem);
    transition: transform 0.3s var(--ease), border-color 0.3s, box-shadow 0.3s;
}
.card:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--accent-c, var(--brand-1)) 50%, transparent); }

.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.card h2 { margin: 0 0 0.5rem; font-size: 1.25rem; }
.card h3 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.card p { margin: 0 0 0.85rem; color: var(--muted); }
.card p:last-child { margin-bottom: 0; }

.card-icon {
    display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 1rem;
    border-radius: 13px; font-size: 1.1rem;
    color: var(--accent-c, var(--brand-1));
    background: color-mix(in srgb, var(--accent-c, var(--brand-1)) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent-c, var(--brand-1)) 32%, transparent);
}

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.chip {
    display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.28rem 0.72rem;
    border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
    color: var(--muted); font-size: 0.82rem; font-weight: 600;
}
.chip-accent {
    color: var(--chip-text, var(--brand-1));
    border-color: color-mix(in srgb, var(--brand-1) 38%, transparent);
    background: color-mix(in srgb, var(--brand-1) 12%, transparent);
}
html[data-theme='light'] .chip-accent { --chip-text: #1e40af; }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.68rem 1.25rem; border-radius: 999px; border: 1px solid var(--border-strong);
    background: var(--surface-2); color: var(--text); font: inherit; font-weight: 650;
    font-size: 0.94rem; cursor: pointer; text-decoration: none;
    transition: transform 0.25s var(--ease), border-color 0.25s;
}
.btn:hover { transform: translateY(-2px); border-color: var(--brand-1); }
.btn-primary { background: var(--brand-grad); color: #06121f; border-color: transparent; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.65rem; }

/* ---------- prose ---------- */
.prose { max-width: 78ch; }
.prose h2 { margin: 2.5rem 0 0.75rem; font-size: 1.5rem; letter-spacing: -0.01em; }
.prose h3 { margin: 1.75rem 0 0.6rem; font-size: 1.12rem; }
.prose p { color: var(--muted); margin: 0 0 1rem; }
.prose ul, .prose ol { color: var(--muted); margin: 0 0 1.1rem; padding-inline-start: 1.25rem; }
.prose li { margin-bottom: 0.45rem; }
.prose strong { color: var(--text); }
.prose a { font-weight: 600; }

code {
    font-family: var(--mono); font-size: 0.88em; padding: 0.12em 0.4em;
    border-radius: 6px; background: var(--code-bg); color: var(--text);
}

pre {
    font-family: var(--mono); font-size: 0.85rem; line-height: 1.6;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 1rem; overflow-x: auto; margin: 0 0 1.25rem;
}
pre code { background: none; padding: 0; }

.callout {
    padding: 1rem 1.15rem; margin: 0 0 1.25rem;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    border-left: 3px solid var(--accent-c, var(--brand-1));
    background: color-mix(in srgb, var(--accent-c, var(--brand-1)) 8%, var(--surface));
}
.callout p:last-child { margin-bottom: 0; }
.callout strong { color: var(--text); }

/* ---------- case study ---------- */
.study-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-bottom: 0.75rem; }
.study-badge {
    display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.28rem 0.75rem;
    border-radius: 999px; font-size: 0.78rem; font-weight: 700;
    color: var(--accent-c, var(--brand-1));
    background: color-mix(in srgb, var(--accent-c, var(--brand-1)) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent-c, var(--brand-1)) 34%, transparent);
}

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.85rem; margin: 1.5rem 0; }

.metric {
    padding: 0.95rem 1.05rem; border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--border);
}
.metric span { display: block; font-size: 0.72rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.metric strong { display: block; margin-top: 0.2rem; font-family: var(--mono); font-size: 1.05rem; color: var(--accent-c, var(--brand-1)); }
.metric strong.pending { font-size: 0.85rem; font-family: var(--font); color: var(--accent); }

.flow {
    display: flex; flex-wrap: wrap; align-items: stretch; gap: 0.6rem; margin: 1.25rem 0 1.5rem;
}
.flow-node {
    flex: 1 1 130px; padding: 0.85rem 0.9rem; border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--border);
    border-top: 3px solid var(--accent-c, var(--brand-1));
}
.flow-node strong { display: block; font-size: 0.92rem; }
.flow-node span { color: var(--muted); font-size: 0.8rem; }
.flow-arrow { align-self: center; color: var(--muted); font-size: 0.9rem; }

.toc { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.5rem 0; }
.toc a {
    padding: 0.35rem 0.8rem; border-radius: 999px; font-size: 0.86rem; font-weight: 600;
    text-decoration: none; color: var(--muted);
    background: var(--surface-2); border: 1px solid var(--border);
}
.toc a:hover { color: var(--text); border-color: var(--brand-1); }

/* ---------- meta / notes list ---------- */
.meta-row { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; color: var(--muted); font-size: 0.88rem; margin-bottom: 1rem; }

.post-card { display: grid; gap: 0.6rem; }
.post-card h2 { margin: 0; font-size: 1.2rem; }
.post-card h2 a { color: var(--text); text-decoration: none; }
.post-card h2 a:hover { color: var(--brand-1); }

/* ---------- changelog ---------- */
.release { display: grid; gap: 0.6rem; padding: 1.1rem 0; border-bottom: 1px solid var(--border); }
.release:last-child { border-bottom: 0; }
.release-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.6rem 1rem; }
.release-version { font-family: var(--mono); font-weight: 700; color: var(--brand-1); }
.release-date { color: var(--muted); font-size: 0.88rem; }
.release ul { margin: 0; padding-inline-start: 1.2rem; color: var(--muted); }
.release li { margin-bottom: 0.3rem; }

/* ---------- footer ---------- */
.site-footer { margin-top: 3.5rem; padding: 2rem 0; border-top: 1px solid var(--border); text-align: center; color: var(--muted); font-size: 0.9rem; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--brand-1); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
    .nav-links {
        position: absolute; top: calc(var(--header-h) + 8px); right: 16px; left: 16px;
        display: none; flex-direction: column; gap: 0.15rem; padding: 0.6rem;
        border-radius: var(--radius); background: color-mix(in srgb, var(--bg) 97%, transparent);
        border: 1px solid var(--border); box-shadow: var(--shadow);
    }
    .nav-links.is-open { display: flex; }
    .nav-toggle { display: grid; }
    .lang-btn { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
    .gradient-text { animation: none; }
}

/* ---------- print ---------- */
@media print {
    body { background: #fff; color: #000; }
    .site-header, .site-footer, .btn-row, .toc { display: none; }
}
