/* ============================================================
   DESIGN SYSTEM — Vitor Schiavo Portfolio
   Dark-first, refined, senior engineer aesthetic
   ============================================================ */

:root {
    /* Brand */
    --primary:        #3b82f6;
    --primary-dark:   #2563eb;
    --primary-light:  #60a5fa;
    --primary-glow:   rgba(59, 130, 246, 0.15);
    --secondary:      #8b5cf6;
    --secondary-light: #a78bfa;
    --accent:         #06b6d4;
    --success:        #10b981;
    --success-glow:   color-mix(in srgb, var(--success) 15%, transparent);
    --warning:        #f59e0b;
    --danger:         #ef4444;
    --before-label-color: #fca5a5;
    --before-bg:      rgba(239,68,68,0.15);
    --before-border:  rgba(239,68,68,0.25);
    --after-label-color:  #6ee7b7;
    --after-bg:       rgba(16,185,129,0.15);
    --after-border:   rgba(16,185,129,0.25);

    /* Dark Surface Palette */
    --bg-base:        #0a0f1e;
    --bg-surface:     #0f172a;
    --bg-elevated:    #1e293b;
    --bg-card:        #162032;
    --bg-hover:       #1e2d42;
    --bg-subtle:      rgba(255,255,255,0.03);
    --bg-topbar:      rgba(15,23,42,0.92);

    /* Text */
    --text-primary:   #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted:     #7c8db0;
    --text-inverse:   #0f172a;

    /* Borders */
    --border:         rgba(255,255,255,0.07);
    --border-hover:   rgba(59,130,246,0.4);
    --border-active:  var(--primary);

    /* Shadows */
    --shadow-sm:   0 1px 3px rgba(0,0,0,0.4);
    --shadow-md:   0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg:   0 8px 24px rgba(0,0,0,0.5);
    --shadow-xl:   0 20px 48px rgba(0,0,0,0.6);
    --glow-primary: 0 0 24px rgba(59,130,246,0.2);

    /* Spacing */
    --space-xs:  0.5rem;
    --space-sm:  0.75rem;
    --space-md:  1rem;
    --space-lg:  1.5rem;
    --space-xl:  2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Radius */
    --radius-sm:   0.375rem;
    --radius-md:   0.5rem;
    --radius-lg:   0.75rem;
    --radius-xl:   1rem;
    --radius-2xl:  1.5rem;
    --radius-full: 9999px;

    /* Transitions */
    --t-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --t-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --t-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Layout */
    --sidebar-w:   240px;
    --content-max: 900px;
    --header-h:    64px;
    --mobile-tabs-h: 45px;
}

/* ── Light theme overrides ─────────────────────────────────── */

[data-theme="light"] {
    /* Surface Palette */
    --bg-base:        #f8fafc;
    --bg-surface:     #f1f5f9;
    --bg-elevated:    #e2e8f0;
    --bg-card:        #ffffff;
    --bg-hover:       #e2e8f0;
    --bg-subtle:      rgba(0,0,0,0.03);
    --bg-topbar:      rgba(248,250,252,0.92);

    /* Text */
    --text-primary:   #0f172a;
    --text-secondary: #475569;
    --text-muted:     #556578;
    --text-inverse:   #f1f5f9;

    /* Borders */
    --border:         rgba(0,0,0,0.1);
    --border-hover:   rgba(59,130,246,0.4);

    /* Shadows */
    --shadow-sm:   0 1px 3px rgba(0,0,0,0.08);
    --shadow-md:   0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg:   0 8px 24px rgba(0,0,0,0.1);
    --shadow-xl:   0 20px 48px rgba(0,0,0,0.12);
    --glow-primary: 0 0 24px rgba(59,130,246,0.1);

    /* Brand adjustments for light bg */
    --primary-glow:   rgba(59, 130, 246, 0.1);
    --success-glow:   color-mix(in srgb, var(--success) 10%, transparent);

    /* Before/After card labels — darker for light bg readability */
    --before-label-color:   #dc2626;
    --before-bg:            rgba(239,68,68,0.08);
    --before-border:        rgba(239,68,68,0.25);
    --after-label-color:    #059669;
    --after-bg:             rgba(16,185,129,0.08);
    --after-border:         rgba(16,185,129,0.25);
}

/* ============================================================
   RESET & BASE
   ============================================================ */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Eliminate 300ms tap delay on all interactive elements */
a, button, [role="tab"], [data-tab], input, select, textarea, label {
    touch-action: manipulation;
}

/* Remove iOS default tap highlight flash */
a, button {
    -webkit-tap-highlight-color: transparent;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
    border-radius: 3px;
}

/* Skip navigation — visually hidden until focused by keyboard users */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-md);
    z-index: 9999;
    padding: var(--space-sm) var(--space-md);
    background: var(--primary);
    color: #ffffff;
    font-weight: 600;
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: top 0.15s;
}

.skip-link:focus {
    top: var(--space-md);
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;

    /* Prevent iOS font size inflation in landscape */
    text-size-adjust: 100%;

    /* Prevent horizontal overflow on mobile — content that extends past the
       viewport (e.g. wide SVG diagrams, long unbroken text) must not create
       a horizontal scrollbar on the root element.  clip (not hidden) avoids
       creating a scroll container that interferes with vertical scrolling. */
    overflow-x: clip;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    min-height: 100vh;

    /* Prevent horizontal scroll on any viewport */
    max-width: 100vw;
}

p, li, td, th {
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color var(--t-fast);
}

a:hover {
    color: var(--primary);
}

/* ============================================================
   READING PROGRESS BAR
   ============================================================ */

.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    z-index: 2000;
}

.reading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
    width: 0%;
    transition: width 0.1s ease-out;
}

/* ============================================================
   SCROLL TO TOP
   ============================================================ */

.scroll-to-top {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 44px;
    height: 44px;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 1.125rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: color var(--t-base), background-color var(--t-base), border-color var(--t-base), opacity var(--t-base), transform var(--t-base), box-shadow var(--t-base);
    box-shadow: var(--shadow-lg);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-to-top:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: var(--shadow-xl), var(--glow-primary);
}

@media (hover: hover) {
    .scroll-to-top:hover {
        transform: translateY(-3px);
    }
}

/* ── Theme Toggle ─────────────────────────────────────────── */

.theme-toggle {
    position: fixed;
    bottom: 32px;
    right: 88px;
    width: 44px;
    height: 44px;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 1.125rem;
    cursor: pointer;
    transition: color var(--t-base), background-color var(--t-base), border-color var(--t-base), transform var(--t-base), box-shadow var(--t-base);
    box-shadow: var(--shadow-lg);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: var(--shadow-xl), var(--glow-primary);
}

@media (hover: hover) {
    .theme-toggle:hover {
        transform: translateY(-3px);
    }
}

/* ============================================================
   LAYOUT — SHELL
   ============================================================ */

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR NAV (desktop)
   ============================================================ */

.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
    scrollbar-width: none;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.sidebar::-webkit-scrollbar {
    display: none;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
    z-index: 1;
}

/* Sidebar brand block */
.sidebar-brand {
    padding: var(--space-xl) var(--space-lg);
    border-bottom: 1px solid var(--border);
}

.sidebar-avatar {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
    font-weight: 800;
    color: white;
    margin-bottom: var(--space-md);
    box-shadow: var(--glow-primary), 0 4px 12px rgba(59,130,246,0.25);
    flex-shrink: 0;
    transition: box-shadow var(--t-base), transform var(--t-base);
}

@media (hover: hover) {
    .sidebar-avatar:hover {
        transform: scale(1.05);
        box-shadow: var(--glow-primary), 0 6px 20px rgba(59,130,246,0.35);
    }
}

.sidebar-name {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 4px;
}

.sidebar-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    line-height: 1.4;
}

.sidebar-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: var(--space-sm);
    padding: 4px 10px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--success);
    letter-spacing: 0.02em;
}

.status-dot {
    width: 7px;
    height: 7px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.5; transform: scale(0.85); }
}

/* Sidebar nav links */
.sidebar-nav {
    padding: var(--space-md) var(--space-sm);
    flex: 1;
}

.sidebar-nav-label {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: var(--space-sm) var(--space-sm) var(--space-xs);
    margin-top: var(--space-sm);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px var(--space-sm);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--t-fast), background-color var(--t-fast), border-color var(--t-fast), opacity var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item:active {
    background: var(--primary-glow);
}

.nav-item.active {
    background: var(--primary-glow);
    color: var(--primary-light);
    font-weight: 600;
    box-shadow: inset 0 0 12px rgba(59,130,246,0.08);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    height: 60%;
    width: 3px;
    background: var(--primary);
    border-radius: 0 2px 2px 0;
}

.nav-icon {
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.nav-label {
    flex: 1;
}

.nav-badge {
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 2px 7px;
    background: var(--bg-elevated);
    color: var(--text-muted);
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    transition: color var(--t-fast), background-color var(--t-fast), border-color var(--t-fast), opacity var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}

.nav-item.active .nav-badge {
    background: var(--primary-glow);
    color: var(--primary-light);
    border-color: rgba(59,130,246,0.3);
}

/* Sidebar footer */
.sidebar-footer {
    padding: var(--space-lg);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.sidebar-contact-link {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 8px var(--space-sm);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    transition: color var(--t-fast), background-color var(--t-fast), border-color var(--t-fast), opacity var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}

.sidebar-contact-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-contact-link .nav-icon {
    font-size: 0.875rem;
}

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================================
   HERO SECTION
   ============================================================ */

.hero {
    padding: var(--space-2xl) var(--space-2xl);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

/* Subtle grid background */
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(59,130,246,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59,130,246,0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    -webkit-mask-image: linear-gradient(180deg, transparent, rgba(0,0,0,0.5) 30%, rgba(0,0,0,0.5) 70%, transparent);
    mask-image: linear-gradient(180deg, transparent, rgba(0,0,0,0.5) 30%, rgba(0,0,0,0.5) 70%, transparent);
    pointer-events: none;
}

/* Animated glow orbs */
.hero::after {
    content: '';
    position: absolute;
    top: 0;
    right: -10%;
    width: 60%;
    height: 100%;
    background:
        radial-gradient(ellipse at 30% 50%, rgba(59,130,246,0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 50%, rgba(139,92,246,0.08) 0%, transparent 60%);
    pointer-events: none;
    animation: heroShimmer 12s ease-in-out infinite alternate;
}

@keyframes heroShimmer {
    0%   { transform: translate(0, 0) scale(1); opacity: 0.7; }
    100% { transform: translate(-3%, 3%) scale(1.05); opacity: 1; }
}

.hero-inner {
    position: relative;
    z-index: 1;
    max-width: var(--content-max);
}

.hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 5px 14px;
    background: var(--primary-glow);
    border: 1px solid rgba(59,130,246,0.25);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-light);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: var(--space-md);
}

.hero h1 {
    font-size: clamp(1.75rem, 3.5vw, 2.75rem);
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.hero h1 span {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary) 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: clamp(1rem, 1.5vw, 1.125rem);
    color: var(--text-secondary);
    font-weight: 400;
    line-height: 1.6;
    max-width: 640px;
    margin-bottom: var(--space-lg);
}

.hero-cta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 11px 22px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: color var(--t-base), background-color var(--t-base), border-color var(--t-base), opacity var(--t-base), transform var(--t-base), box-shadow var(--t-base);
    box-shadow: 0 0 0 1px rgba(59,130,246,0.3), var(--shadow-md);
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: white;
    box-shadow: 0 0 0 1px rgba(59,130,246,0.4), var(--shadow-lg), var(--glow-primary);
}

@media (hover: hover) {
    .btn-primary:hover {
        transform: translateY(-2px);
    }
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 11px 22px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: color var(--t-base), background-color var(--t-base), border-color var(--t-base), opacity var(--t-base), transform var(--t-base), box-shadow var(--t-base);
}

.btn-ghost:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

/* Hero stats grid — evenly distributes stats across rows.
   On desktop: 3 columns × 2 rows.  On mobile: stacks to 2 columns. */
.hero-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.hero-stat {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: var(--space-md) var(--space-lg);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    text-align: center;
    transition: background-color var(--t-fast);
}

@media (hover: hover) {
    .hero-stat:hover {
        background: var(--bg-hover);
    }
}

/* Remove right border on last column of each row (3-col grid) */
.hero-stat:nth-child(3n) {
    border-right: none;
}

/* Remove bottom border on last row (assumes 6 stats / 3-col grid) */
.hero-stat:nth-last-child(-n+3) {
    border-bottom: none;
}

.hero-stat-value {
    font-size: 1.375rem;
    font-weight: 900;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1;
}

.hero-stat-value.accent-green  { color: var(--success); }
.hero-stat-value.accent-blue   { color: var(--primary-light); }
.hero-stat-value.accent-purple { color: var(--secondary-light); }

.hero-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* ============================================================
   MOBILE TOPBAR (hidden on desktop)
   ============================================================ */

.topbar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 500;
    height: var(--header-h);
    background: var(--bg-topbar);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    align-items: center;

    /* Honor iPhone notch/status-bar safe area on left/right */
    padding: 0 max(var(--space-md), env(safe-area-inset-right))
               0 max(var(--space-md), env(safe-area-inset-left));
    gap: var(--space-sm);
}

.topbar::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
    opacity: 0.6;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex: 1;
}

.topbar-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 800;
    color: white;
    flex-shrink: 0;
}

.topbar-name {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Mobile tab strip */
.mobile-tabs {
    display: none;
    overflow-x: auto;
    scrollbar-width: none;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);

    /* Safe-area insets prevent tab labels from clipping behind the notch/island in landscape */
    padding: 0 max(var(--space-md), env(safe-area-inset-right))
               0 max(var(--space-md), env(safe-area-inset-left));
    gap: 2px;
    position: sticky;

    /* Sits immediately below the topbar */
    top: var(--header-h);
    z-index: 400;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Only show the right-edge fade when there are off-screen tabs to the right */
.mobile-tabs.has-overflow-right {
    -webkit-mask-image: linear-gradient(to right, black 80%, transparent 100%);
    mask-image: linear-gradient(to right, black 80%, transparent 100%);
}

.mobile-tabs::-webkit-scrollbar { display: none; }

.mobile-tab {
    display: flex;
    align-items: center;
    gap: 5px;

    /* Min 44px tall for iOS touch targets */
    padding: 0 var(--space-sm);
    min-height: 44px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: color var(--t-fast), background-color var(--t-fast), border-color var(--t-fast);
    flex-shrink: 0;
    position: relative;

    /* touch-action: manipulation inherited from global button rule */
}

.mobile-tab:hover {
    color: var(--text-secondary);
    background: var(--bg-subtle);
}

.mobile-tab:active {
    background: var(--primary-glow);
}

.mobile-tab.active {
    color: var(--primary-light);
    border-bottom-color: var(--primary);
    background: var(--primary-glow);
}

/* ============================================================
   PAGE CONTENT
   ============================================================ */

.page-content {
    flex: 1;
    padding: var(--space-2xl);
    max-width: calc(var(--content-max) + var(--space-2xl) * 2);
    width: 100%;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeUp 0.35s cubic-bezier(0.4,0,0.2,1);
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   SECTION HEADERS
   ============================================================ */

.section-header {
    margin-bottom: var(--space-2xl);
}

.section-title {
    font-size: clamp(1.5rem, 2.5vw, 2rem);
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: 6px;
    position: relative;
    padding-bottom: var(--space-md);
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 48px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: var(--radius-full);
}

.section-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.65;
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: border-color var(--t-base), box-shadow var(--t-base), transform var(--t-base);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    opacity: 0;
    transition: opacity var(--t-base);
}

.card:hover,
.card:focus-within:has(:focus-visible) {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg);
}

@media (hover: hover) {
    .card:hover {
        transform: translateY(-2px);
    }
}

.card:hover::before,
.card:focus-within:has(:focus-visible)::before {
    opacity: 1;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.card-icon {
    font-size: 1.5rem;
}

/* ============================================================
   HIGHLIGHT BOX
   ============================================================ */

.highlight-box {
    background: linear-gradient(135deg, rgba(16,185,129,0.1), rgba(5,150,105,0.05));
    border: 1px solid rgba(16,185,129,0.25);
    color: var(--text-primary);
    padding: var(--space-2xl);
    border-radius: var(--radius-xl);
    margin: var(--space-xl) 0;
    position: relative;
    overflow: hidden;
}

.highlight-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--success), #059669);
    border-radius: 2px 0 0 2px;
}

.highlight-content {
    position: relative;
}

.highlight-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.highlight-text {
    font-size: 0.9375rem;
    line-height: 1.9;
    color: var(--text-secondary);
}

.highlight-text strong {
    color: var(--text-primary);
    font-weight: 700;
}

.highlight-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

.highlight-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--success-glow);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
    transition: border-color var(--t-base), background-color var(--t-base);
}

.highlight-card:hover {
    border-color: var(--success);
    background: rgba(255, 255, 255, 0.05);
}

.highlight-card-title {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.highlight-card-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ============================================================
   FEATURE CARDS (grid)
   ============================================================ */

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-lg);
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-md);
}

.architecture-diagram {
    margin: 0 0 var(--space-lg);
    overflow-x: auto;
}

.architecture-diagram svg {
    display: block;
    width: 100%;
    height: auto;
    max-width: 820px;
    margin: 0 auto;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    transition: color var(--t-base), background-color var(--t-base), border-color var(--t-base), opacity var(--t-base), transform var(--t-base), box-shadow var(--t-base);
    position: relative;
    overflow: hidden;
}

.feature-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--t-base);
}

.feature-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
    box-shadow: var(--shadow-md);
}

@media (hover: hover) {
    .feature-card:hover {
        transform: translateY(-2px);
    }
}

.feature-card:hover::after {
    transform: scaleX(1);
}

.feature-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.feature-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.65;
}

/* ============================================================
   TIMELINE (Experience)
   ============================================================ */

.timeline {
    position: relative;
    padding-left: var(--space-2xl);
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 8px;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, var(--primary) 0%, rgba(59,130,246,0.1) 100%);
}

.timeline-item {
    position: relative;
    margin-bottom: var(--space-xl);
    padding: var(--space-lg);
    padding-left: var(--space-xl);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color var(--t-base), box-shadow var(--t-base);
}

@media (hover: hover) {
    .timeline-item:hover {
        border-color: var(--border-hover);
        box-shadow: var(--shadow-md);
    }
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -25px;
    top: 5px;
    width: 14px;
    height: 14px;
    background: var(--bg-base);
    border: 2px solid var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(59,130,246,0.1);
    transition: box-shadow var(--t-base);
}

.timeline-item:hover::before {
    box-shadow: 0 0 0 6px rgba(59,130,246,0.15), var(--glow-primary);
}

.timeline-item:first-child::before {
    background: var(--primary);
}

.timeline-company {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    margin-bottom: 2px;
}

.timeline-role {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--primary-light);
    margin-bottom: 4px;
}

.timeline-period {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.timeline-current-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    background: rgba(16,185,129,0.1);
    border: 1px solid rgba(16,185,129,0.25);
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--success);
    letter-spacing: 0.03em;
}

.timeline-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.75;
}

/* ============================================================
   SKILLS GRID
   ============================================================ */


.skill-list {
    list-style: none;
}

.skill-item {
    padding: 7px 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: color var(--t-fast);
}

.skill-item:last-child {
    border-bottom: none;
}

.skill-item::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    flex-shrink: 0;
    opacity: 0.7;
}

.skill-item:hover {
    color: var(--text-primary);
}

/* ============================================================
   TABLES
   ============================================================ */

.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    scrollbar-width: thin;
    scrollbar-color: var(--bg-elevated) transparent;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    font-size: 0.9rem;
}

thead {
    background: var(--bg-elevated);
}

th {
    padding: var(--space-md) var(--space-lg);
    text-align: left;
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
}

td {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

tr:hover td {
    background: var(--bg-hover);
    color: var(--text-primary);
}

tr:last-child td {
    border-bottom: none;
}

/* ============================================================
   METRIC BARS
   ============================================================ */

.metric-bar {
    margin: var(--space-md) 0;
}

.metric-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.metric-value {
    color: var(--primary-light);
    font-weight: 700;
    font-size: 0.9375rem;
}

.bar-container {
    height: 6px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-full);
    transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   CASE STUDIES
   ============================================================ */

.case-study {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    margin-bottom: var(--space-2xl);
    transition: border-color var(--t-base), box-shadow var(--t-base);
}

.case-study:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-xl);
}

.case-header {
    padding: var(--space-xl);
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-md);
    cursor: pointer;
}

.case-header:hover {
    background: var(--bg-surface);
}

.case-header:active {
    background: var(--primary-glow);
}

.case-header:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.case-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    align-self: center;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    transition: transform var(--t-base), color var(--t-base);
}

.case-header:hover .case-toggle {
    color: var(--text-secondary);
}

.case-study[aria-expanded="true"] .case-toggle {
    transform: rotate(180deg);
}

.case-title {
    font-size: 1.375rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    margin-bottom: var(--space-xs);
}

.case-date {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 500;
}

.case-repo-link {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 600;
    transition: color var(--t-fast);
}

.case-repo-link:hover {
    color: var(--primary);
}

.case-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: var(--space-md);
}

.case-tag {
    padding: 4px 10px;
    background: var(--primary-glow);
    color: var(--primary-light);
    border: 1px solid rgba(59,130,246,0.2);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.case-body {
    padding: var(--space-xl);
    overflow: hidden;
    transition: max-height var(--t-slow), padding var(--t-slow), opacity var(--t-base);
}

.case-study[aria-expanded="false"] .case-body {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

.case-study[aria-expanded="true"] .case-body {
    max-height: 4000px;
    opacity: 1;
}

.case-study[aria-expanded="false"] .case-header {
    border-bottom-color: transparent;
}

.case-section {
    margin-bottom: var(--space-lg);
}

.case-section-title {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.case-description {
    font-size: 0.9375rem;
    line-height: 1.75;
    color: var(--text-secondary);
}

.case-description--mb {
    margin-bottom: var(--space-md);
}

.publication-block {
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border);
}

.publication-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.publication-title {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.before-after {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--space-lg);
    margin: var(--space-lg) 0;
}

.before-card {
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    background: var(--before-bg);
    border: 1px solid var(--before-border);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.after-card {
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    background: var(--after-bg);
    border: 1px solid var(--after-border);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.before-label, .after-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: var(--space-md);
    display: inline-flex;
    padding: 3px 10px;
    border-radius: var(--radius-full);
}

.before-label {
    background: var(--before-bg);
    color: var(--before-label-color);
    border: 1px solid var(--before-border);
}

.after-label {
    background: var(--after-bg);
    color: var(--after-label-color);
    border: 1px solid var(--after-border);
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    gap: var(--space-md);
}

.metric-row:last-child {
    border-bottom: none;
}

.metric-name {
    font-weight: 500;
    color: var(--text-secondary);
    flex: 1;
}

.metric-row .metric-value {
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
}

.savings-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 10px 20px;
    background: rgba(16,185,129,0.1);
    border: 1px solid rgba(16,185,129,0.3);
    color: var(--success);
    border-radius: var(--radius-lg);
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    font-weight: 900;
    margin: var(--space-lg) 0;
    letter-spacing: -0.01em;
    word-break: break-word;
}

.diagram-placeholder {
    background: var(--bg-elevated);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: var(--space-lg) 0;
}

.tech-stack-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: var(--space-md);
}

.tech-badge {
    padding: 4px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: color var(--t-fast), background-color var(--t-fast), border-color var(--t-fast), opacity var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}

.tech-badge:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.impact-metrics {
    background: var(--bg-elevated);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    border-left: 3px solid var(--success);
    margin-bottom: var(--space-md);
}

.impact-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.impact-list {
    list-style: none;
}

.impact-item {
    padding: 3px 0 3px 1.25rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    position: relative;
}

.impact-item::before {
    content: '→';
    color: var(--success);
    font-weight: 700;
    position: absolute;
    left: 0;
    top: 0.15em;
}

/* ============================================================
   QUICK LINKS
   ============================================================ */

.quick-links {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.quick-links-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.quick-links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-xs);
}

.quick-link {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 9px var(--space-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: color var(--t-fast), background-color var(--t-fast), border-color var(--t-fast), opacity var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
    width: 100%;
    text-align: left;
}

.quick-link:hover {
    background: var(--primary-glow);
    color: var(--primary-light);
    border-color: rgba(59,130,246,0.25);
}

.quick-link:active {
    background: rgba(59,130,246,0.2);
    border-color: rgba(59,130,246,0.4);
}

.quick-link-icon {
    font-size: 0.875rem;
    flex-shrink: 0;
}

/* ============================================================
   TAB BADGE (sidebar)
   ============================================================ */


/* ============================================================
   FOOTER
   ============================================================ */

footer {
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    padding: var(--space-3xl) var(--space-2xl);
    color: var(--text-primary);
}

.footer-inner {
    max-width: var(--content-max);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-lg);
}

.footer-heading {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.footer-sub {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.7;
    max-width: 560px;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.footer-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 9px 18px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: color var(--t-base), background-color var(--t-base), border-color var(--t-base), opacity var(--t-base), transform var(--t-base), box-shadow var(--t-base);
}

.footer-link:hover {
    background: var(--primary-glow);
    border-color: rgba(59,130,246,0.3);
    color: var(--primary-light);
}

.footer-link:active {
    background: rgba(59,130,246,0.2);
}

.footer-copy {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: var(--space-md);
    padding-top: var(--space-xl);
    border-top: 1px solid var(--border);
    width: 100%;
}

/* ============================================================
   ANIMATIONS & UTILITIES
   ============================================================ */


.section-anchor {
    scroll-margin-top: 80px;
}

@media (width <= 768px) {
    .section-anchor {
        scroll-margin-top: calc(var(--header-h) + var(--mobile-tabs-h) + 8px);
    }
}

/* ============================================================
   UTILITY CLASSES (extracted from inline styles)
   Placed late in source order so they override component defaults
   without needing higher selector specificity.
   ============================================================ */

.skill-item.skill-row {
    justify-content: space-between;
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--border);
}

.skill-item.skill-row--last {
    border-bottom: none;
}

.skill-desc {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.subcat-title {
    font-size: 0.875rem;
    font-weight: 700;
    margin-bottom: var(--space-md);
    color: var(--primary-light);
}

.list-plain {
    list-style: none;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.list-plain > li {
    padding: 5px 0;
}

.dot-expert {
    color: var(--success);
    font-weight: 700;
}

.dot-advanced {
    color: var(--primary-light);
    font-weight: 700;
}

.dot-proficient {
    color: var(--secondary-light);
    font-weight: 700;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.legend-container {
    display: flex;
    gap: var(--space-xl);
    flex-wrap: wrap;
    font-size: 0.875rem;
}

.feature-description--lh-wide {
    line-height: 1.9;
}

.diagram-flow-text {
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

.diagram-flow-body {
    font-size: 0.875rem;
    line-height: 1.7;
}

.finops-total-block {
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border);
}

.finops-total {
    font-size: 1.125rem;
    font-weight: 800;
    color: var(--text-primary);
}

.finops-total-sub {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.diagram-table {
    margin-top: var(--space-md);
}

.legend-label {
    color: var(--text-secondary);
}

/* ============================================================
   RESPONSIVE — TABLET (≤1024px)
   ============================================================ */

@media (width <= 1024px) {
    :root {
        --sidebar-w: 200px;
    }
}

/* ============================================================
   RESPONSIVE — MOBILE (≤768px)
   Sidebar becomes hidden; topbar + mobile-tabs appear
   ============================================================ */

@media (width <= 768px) {
    .sidebar {
        display: none;
    }

    .topbar {
        display: flex;
    }

    .mobile-tabs {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        max-width: 100%;

        /* No extra padding needed — sticky topbar and tabs handle their own offset */
    }

    .hero {
        padding: var(--space-2xl) var(--space-lg);
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 0.9375rem;
    }

    /* Switch to 2-col grid on tablet/mobile — 3 rows of 2 stats */
    .hero-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Adjust border removal for 2-col layout */
    .hero-stat:nth-child(3n) {
        border-right: 1px solid var(--border);
    }

    .hero-stat:nth-child(2n) {
        border-right: none;
    }

    .hero-stat:nth-last-child(-n+3) {
        border-bottom: 1px solid var(--border);
    }

    .hero-stat:nth-last-child(-n+2) {
        border-bottom: none;
    }

    .page-content {
        padding: var(--space-lg);

        /* Ensure content doesn't bleed under the iOS home bar */
        padding-bottom: max(var(--space-lg), env(safe-area-inset-bottom));
    }

    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }

    .before-after {
        grid-template-columns: 1fr;
    }

    .hero-cta {
        flex-direction: column;
        align-items: stretch;
    }

    /* Full-width CTA buttons on mobile for easy tapping */
    .hero-cta .btn-primary,
    .hero-cta .btn-ghost {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }

    .footer-links {
        flex-direction: column;
        align-items: flex-start;
    }

    footer {
        padding: var(--space-2xl) var(--space-lg);

        /* Safe area for iPhone home bar */
        padding-bottom: max(var(--space-2xl), env(safe-area-inset-bottom));
    }

    .case-header {
        flex-direction: column;
    }

    /* Cards: reduce internal padding on mobile to avoid cramping */
    .card {
        padding: var(--space-lg);
    }

    /* Tables on mobile: smaller cell padding */
    th, td {
        padding: var(--space-sm) var(--space-md);
    }

    /* Highlight box: tighter padding on mobile */
    .highlight-box {
        padding: var(--space-lg);
    }

    .highlight-grid {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }

    /* Timeline: tighter left spacing on mobile */
    .timeline {
        padding-left: var(--space-xl);
    }

    .timeline::before {
        /* 6px = half of 12px dot, centering the line under the dot */
        left: 6px;
    }

    .timeline-item::before {
        /* Adjusted from desktop -25px to match the reduced timeline padding */
        left: -22px;
        width: 12px;
        height: 12px;
    }

    .timeline-company {
        font-size: 1.125rem;
    }
}

/* ============================================================
   RESPONSIVE — SMALL MOBILE (≤480px)
   ============================================================ */

@media (width <= 480px) {
    .hero {
        padding: var(--space-xl) var(--space-md);
    }

    .hero h1 {
        font-size: 1.75rem;
    }

    .hero-stat {
        padding: var(--space-md) var(--space-lg);
    }

    .hero-stat-value {
        font-size: 1.375rem;
    }

    .scroll-to-top {
        bottom: max(20px, env(safe-area-inset-bottom));
        right: 16px;
    }

    .theme-toggle {
        bottom: max(20px, env(safe-area-inset-bottom));
        right: 68px;
    }

    .quick-links-grid {
        grid-template-columns: 1fr;
    }

    .page-content {
        padding: var(--space-md);
        padding-bottom: max(var(--space-md), env(safe-area-inset-bottom));
    }

    /* Ensure card padding doesn't feel too tight on small screens */
    .card {
        padding: var(--space-md);
    }

    /* Case study headers: less padding on small screens */
    .case-header {
        padding: var(--space-lg);
    }

    .case-title {
        font-size: 1.125rem;
    }

    /* Tables: tighter padding for small viewports (scoped to tab content) */
    .tab-content th,
    .tab-content td {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.875rem;
    }

    /* Footer links: ensure 44px touch target */
    .footer-link {
        padding: var(--space-sm) var(--space-lg);
        min-height: 44px; /* WCAG 2.5.5 touch target */
    }

    /* Impact metrics: reduce padding */
    .impact-metrics {
        padding: var(--space-sm) var(--space-md);
    }

    /* Allow horizontal scroll rather than squashing diagram node labels */
    .architecture-diagram svg {
        min-width: 500px;
    }
}

/* ============================================================
   RESPONSIVE — ULTRA-SMALL MOBILE (≤320px)
   ============================================================ */

@media (width <= 320px) {
    .hero h1 {
        font-size: 1.5rem;
    }

    .hero-subtitle {
        font-size: 0.875rem;
    }

    .hero-stat-value {
        font-size: 1.25rem;
    }
}

/* ============================================================
   SCROLL REVEAL
   ============================================================ */

.reveal {
    opacity: 0;
    transform: translateY(16px);
}

.reveal.revealed {
    animation: revealUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    animation-delay: var(--reveal-delay, 0ms);
}

@keyframes revealUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */

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

/* ============================================================
   HIGH CONTRAST
   ============================================================ */

@media (prefers-contrast: more) {
    :root {
        --border:       rgba(255,255,255,0.2);
        --text-muted:   #94a3b8;
        --shadow-sm:    none;
        --shadow-md:    none;
        --shadow-lg:    none;
        --shadow-xl:    none;
    }

    [data-theme="light"] {
        --border:       rgba(0,0,0,0.25);
        --text-muted:   #334155;
    }
}

/* ============================================================
   PRINT
   ============================================================ */

@media print {
    .sidebar, .topbar, .mobile-tabs, .scroll-to-top, .theme-toggle, .reading-progress {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
    }

    .tab-content {
        display: block !important;
    }

    body {
        background: white;
        color: black;
    }
}
