/* MathNet site — modern, minimal, parent-trustable */

/* -------- Design tokens -------- */
:root {
    /* Brand */
    --brand-50:  #eef2ff;
    --brand-100: #e0e7ff;
    --brand-200: #c7d2fe;
    --brand-500: #6366f1;
    --brand-600: #4f46e5;
    --brand-700: #4338ca;
    --brand-900: #312e81;

    --accent-500: #f59e0b;   /* points / rewards */
    --accent-600: #d97706;
    --success-500: #10b981;
    --success-600: #059669;

    /* Neutrals */
    --bg:        #ffffff;
    --bg-soft:   #fafafb;
    --bg-muted:  #f4f4f6;
    --border:    #e5e7eb;
    --text:      #0f172a;
    --text-soft: #475569;
    --text-mute: #94a3b8;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 12px -2px rgb(15 23 42 / 0.08), 0 2px 4px -2px rgb(15 23 42 / 0.04);
    --shadow-lg: 0 20px 40px -12px rgb(15 23 42 / 0.15), 0 8px 16px -8px rgb(15 23 42 / 0.08);

    --radius-sm: 8px;
    --radius:    14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --container: 1200px;
    --container-narrow: 760px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:        #0b0e1a;
        --bg-soft:   #11142198;
        --bg-muted:  #1a1d2e;
        --border:    #232844;
        --text:      #e2e8f0;
        --text-soft: #94a3b8;
        --text-mute: #64748b;
        --brand-50:  #1e1b4b;
        --brand-100: #2e2a6e;
    }
}

/* -------- Reset / base -------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-feature-settings: 'cv11', 'ss01';
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img, svg { max-width: 100%; display: block; }

a { color: var(--brand-600); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--brand-700); }

h1, h2, h3, h4 {
    color: var(--text);
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin: 0 0 .6em;
}
h1 { font-size: clamp(2.4rem, 5vw, 3.8rem); font-weight: 800; letter-spacing: -0.03em; }
h2 { font-size: clamp(1.7rem, 3vw, 2.4rem); font-weight: 700; }
h3 { font-size: 1.25rem; font-weight: 700; }
h4 { font-size: 1rem; font-weight: 600; }

p { margin: 0 0 1em; color: var(--text-soft); }
small { color: var(--text-mute); }

ul { padding-left: 1.2em; }
li { margin-bottom: .3em; }

code, pre {
    font-family: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace;
    font-size: .9em;
}
code {
    background: var(--bg-muted);
    padding: .15em .45em;
    border-radius: 5px;
    color: var(--brand-700);
}
pre {
    background: var(--bg-muted);
    padding: 1.25em 1.5em;
    border-radius: var(--radius);
    overflow-x: auto;
    border: 1px solid var(--border);
    line-height: 1.55;
}
pre code { background: none; padding: 0; color: inherit; }

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 3rem 0;
}

/* -------- Layout -------- */
.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 1.5rem;
}
.container-narrow { max-width: var(--container-narrow); margin: 0 auto; padding: 0 1.5rem; }

main { min-height: 60vh; }

/* -------- Header / nav -------- */
.site-header {
    position: sticky;
    top: 0;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

.site-header .nav-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    gap: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: .55rem;
    font-weight: 700;
    color: var(--text);
    font-size: 1.1rem;
    letter-spacing: -0.01em;
}
.logo:hover { color: var(--text); }
.logo-icon { width: 32px; height: 32px; border-radius: 7px; object-fit: cover; box-shadow: 0 1px 3px rgb(0 0 0 / 0.1); }

.nav-menu {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 2rem;
    margin: 0;
    padding: 0;
}
.nav-menu a {
    color: var(--text-soft);
    font-weight: 500;
    font-size: .95rem;
    transition: color .15s ease;
}
.nav-menu a:hover { color: var(--text); }

.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: .5rem;
    flex-direction: column;
    gap: 5px;
}
.mobile-menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    transition: transform .2s ease, opacity .2s ease;
}

@media (max-width: 768px) {
    .nav-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        gap: 0;
        background: var(--bg);
        border-bottom: 1px solid var(--border);
        padding: 1rem 1.5rem 1.5rem;
        max-height: 0;
        overflow: hidden;
        transition: max-height .25s ease, padding .25s ease;
    }
    .nav-menu.active { max-height: 400px; padding: 1rem 1.5rem 1.5rem; }
    .nav-menu li { width: 100%; padding: .5rem 0; border-bottom: 1px solid var(--border); }
    .nav-menu li:last-child { border-bottom: none; padding-top: 1rem; }
    .mobile-menu-toggle { display: flex; }
}

/* -------- Buttons -------- */
.btn-primary, .btn-secondary, .btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .7rem 1.4rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: .95rem;
    transition: transform .12s ease, box-shadow .15s ease, background .15s ease;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary {
    background: var(--brand-600);
    color: white;
    box-shadow: 0 1px 2px rgb(79 70 229 / 0.3), 0 4px 12px -2px rgb(79 70 229 / 0.25);
}
.btn-primary:hover { background: var(--brand-700); color: white; transform: translateY(-1px); box-shadow: 0 2px 4px rgb(79 70 229 / 0.35), 0 8px 20px -2px rgb(79 70 229 / 0.3); }
.btn-secondary {
    background: var(--bg-muted);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-soft); color: var(--text); }
.btn-ghost { color: var(--text-soft); background: transparent; }
.btn-ghost:hover { color: var(--text); }

/* -------- Hero -------- */
.hero {
    position: relative;
    padding: clamp(2rem, 5vw, 4rem) 0 clamp(2rem, 4vw, 3.5rem);
    overflow: hidden;
}
.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(60% 40% at 20% 0%, color-mix(in srgb, var(--brand-500) 18%, transparent), transparent),
        radial-gradient(50% 35% at 95% 20%, color-mix(in srgb, var(--accent-500) 14%, transparent), transparent);
    z-index: -1;
}
.hero-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: 4rem;
}
.hero-eyebrow {
    display: inline-block;
    background: var(--brand-50);
    color: var(--brand-700);
    padding: .35rem .9rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-bottom: 1.25rem;
}
.hero h1 { margin-bottom: 1.5rem; }
.hero h1 .gradient {
    background: linear-gradient(120deg, var(--brand-600), var(--accent-500));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.hero-sub {
    font-size: 1.15rem;
    margin-bottom: 2rem;
    max-width: 540px;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.hero-meta { margin-top: 1.5rem; color: var(--text-mute); font-size: .85rem; }

.hero-visual {
    position: relative;
    aspect-ratio: 4 / 5;
    background: linear-gradient(160deg, var(--brand-100), color-mix(in srgb, var(--accent-500) 12%, var(--bg-soft)));
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
/* -------- Hero carousel -------- */
.hero-carousel {
    position: relative;
    width: 100%;
    overflow: hidden;
}
.carousel-track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.carousel-track::-webkit-scrollbar { display: none; }
.slide {
    flex: 0 0 100%;
    min-width: 0;
    margin: 0;
    padding: 0 1rem;
    scroll-snap-align: center;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.slide img {
    width: auto;
    max-width: 100%;
    max-height: 540px;
    border-radius: var(--radius-lg);
    box-shadow: 0 30px 60px -15px rgb(15 23 42 / 0.35);
}
.slide figcaption {
    margin-top: 1rem;
    color: var(--text-soft);
    font-size: .95rem;
    max-width: 360px;
}
.slide figcaption strong { color: var(--text); }
.carousel-dots {
    display: flex;
    justify-content: center;
    gap: .65rem;
    margin-top: 1.5rem;
}
.carousel-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: none;
    background: var(--border);
    cursor: pointer;
    padding: 0;
    transition: background .15s ease, transform .15s ease, width .15s ease;
}
.carousel-dot:hover { background: var(--text-mute); }
.carousel-dot.active { background: var(--brand-600); width: 28px; border-radius: 6px; }
@media (max-width: 600px) {
    .slide img { max-height: 480px; }
}
.hero-visual img {
    max-width: 78%;
    max-height: 88%;
    border-radius: var(--radius);
    box-shadow: 0 30px 60px -15px rgb(15 23 42 / 0.35);
}
.hero-visual img.hero-fallback {
    max-width: 55%;
    max-height: 55%;
    border-radius: 28px;
    box-shadow: 0 30px 60px -15px rgb(15 23 42 / 0.35);
}

@media (max-width: 900px) {
    .hero-grid { grid-template-columns: 1fr; gap: 3rem; }
    .hero-visual { max-width: 380px; margin: 0 auto; }
}

/* -------- Sections -------- */
.section { padding: clamp(3rem, 7vw, 6rem) 0; }
.section-tight { padding: clamp(2rem, 5vw, 4rem) 0; }
.section-muted { background: var(--bg-soft); }

/* -------- "Why this exists" trigger + dialog -------- */
.why-trigger {
    background: none;
    border: none;
    padding: .25rem 0;
    margin: 0 0 2rem;
    color: var(--brand-700);
    font: inherit;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}
.why-trigger:hover { color: var(--brand-600); text-decoration: underline; }
.why-trigger .why-tri {
    display: inline-block;
    transition: transform 0.15s ease;
    font-size: .85rem;
}
.why-trigger:hover .why-tri { transform: translateX(2px); }

.why-dialog {
    max-width: 640px;
    width: calc(100vw - 2rem);
    border: 1px solid var(--border);
    border-left: 4px solid var(--brand-500);
    border-radius: 12px;
    padding: clamp(1.5rem, 3vw, 2.25rem) clamp(1.5rem, 3vw, 2.5rem);
    background: var(--bg);
    color: var(--text);
    box-shadow: var(--shadow-lg, 0 20px 50px rgba(0,0,0,.25));
    /* margin auto + dialog default centering */
}
.why-dialog::backdrop {
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(2px);
}
.why-dialog h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: clamp(1.4rem, 2.5vw, 1.75rem);
}
.why-dialog p {
    color: var(--text);
    line-height: 1.65;
    margin-bottom: 1rem;
}
.why-dialog p:last-of-type { margin-bottom: 0; }
.why-dialog .note-signature {
    margin-top: 1.5rem !important;
    font-style: italic;
    color: var(--text-muted);
    font-size: .95rem;
}
.why-close-form {
    position: absolute;
    top: .5rem;
    right: .75rem;
    margin: 0;
}
.why-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: .25rem .5rem;
    border-radius: 4px;
}
.why-close:hover { color: var(--text); background: var(--bg-soft); }

.section-header {
    text-align: center;
    max-width: 700px;
    margin: 0 auto 3rem;
}
.section-header .eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: .8rem;
    font-weight: 700;
    color: var(--brand-600);
    margin-bottom: .8rem;
}
.section-header h2 { margin-bottom: .8rem; }
.section-header p { font-size: 1.1rem; }

/* -------- Card grids -------- */
.grid-3 { display: grid; gap: 1.5rem; grid-template-columns: repeat(3, 1fr); }
.grid-2 { display: grid; gap: 1.5rem; grid-template-columns: repeat(2, 1fr); }
.grid-4 { display: grid; gap: 1.25rem; grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 580px) {
    .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--brand-200); }
.card h3 { margin-bottom: .5rem; }
.card p { margin-bottom: 0; font-size: .95rem; }
.card .icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--brand-50);
    color: var(--brand-600);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 1rem;
}
.card.accent .icon { background: color-mix(in srgb, var(--accent-500) 15%, transparent); color: var(--accent-600); }
.card.success .icon { background: color-mix(in srgb, var(--success-500) 15%, transparent); color: var(--success-600); }

.card-link { display: block; color: inherit; text-decoration: none; }
.card-link h3 { color: var(--text); }
.card-link:hover h3 { color: var(--brand-700); }

/* -------- Screenshot gallery (horizontal scroller) -------- */
.shots-scroller {
    display: flex;
    gap: 1.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-padding: 1.5rem;
    -webkit-overflow-scrolling: touch;
    padding: .5rem 1.5rem 2rem;
    margin: 0 -1.5rem;
    /* hide horizontal scrollbar visually but keep functionality */
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.shots-scroller::-webkit-scrollbar { height: 8px; }
.shots-scroller::-webkit-scrollbar-track { background: transparent; }
.shots-scroller::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.shot {
    flex: 0 0 320px;
    background: linear-gradient(160deg, var(--brand-100), color-mix(in srgb, var(--accent-500) 12%, var(--bg-soft)));
    border-radius: var(--radius-lg);
    padding: 2rem 0 0;
    text-align: center;
    overflow: hidden;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}
.shot-frame {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0 1.25rem;
}
.shot img {
    width: 100%;
    height: auto;
    max-height: 580px;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 20px 40px -10px rgb(15 23 42 / 0.25);
}
.shot-caption {
    background: var(--bg);
    margin-top: 1.25rem;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
}
.shot-caption h3 { margin-bottom: .2rem; font-size: 1.05rem; }
.shot-caption p { font-size: .9rem; margin: 0; }

@media (max-width: 600px) {
    .shot { flex: 0 0 280px; }
}

/* -------- Rewards flow diagram -------- */
.flow {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin: 2rem 0;
}
.flow-step {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    position: relative;
}
.flow-step .step-num {
    display: inline-flex;
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    background: var(--brand-600);
    color: white;
    border-radius: 50%;
    font-weight: 700;
    font-size: .85rem;
    margin-bottom: .6rem;
}
.flow-step h4 { margin-bottom: .25rem; }
.flow-step p { font-size: .85rem; margin: 0; }
@media (max-width: 800px) { .flow { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .flow { grid-template-columns: 1fr; } }

/* -------- Stat strip -------- */
.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
    text-align: center;
    padding: 2rem 0;
}
.stats .stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.stats .stat-label { color: var(--text-soft); font-size: .9rem; margin-top: .25rem; }
@media (max-width: 700px) { .stats { grid-template-columns: 1fr 1fr; gap: 1.5rem; } }

/* -------- CTA band -------- */
.cta-band {
    background: linear-gradient(120deg, var(--brand-700), var(--brand-500));
    color: white;
    border-radius: var(--radius-xl);
    padding: clamp(2.5rem, 6vw, 4rem);
    text-align: center;
}
.cta-band h2 { color: white; }
.cta-band p { color: rgb(255 255 255 / 0.85); font-size: 1.1rem; max-width: 560px; margin: 0 auto 1.5rem; }
.cta-band .btn-primary { background: white; color: var(--brand-700); box-shadow: none; }
.cta-band .btn-primary:hover { background: rgb(255 255 255 / 0.92); color: var(--brand-700); }

/* -------- Article (content pages) -------- */
.article { padding: clamp(3rem, 6vw, 5rem) 0; }
.article-header {
    max-width: var(--container-narrow);
    margin: 0 auto 2.5rem;
    padding: 0 1.5rem;
    text-align: center;
}
.article-header .eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: .8rem;
    font-weight: 700;
    color: var(--brand-600);
    margin-bottom: .8rem;
}
.article-body {
    max-width: var(--container-narrow);
    margin: 0 auto;
    padding: 0 1.5rem;
}
.article-body h2 { margin-top: 2.5rem; }
.article-body h3 { margin-top: 1.8rem; }
.article-body p, .article-body li { font-size: 1.05rem; }
.article-body img { border-radius: var(--radius); margin: 1.5rem 0; }
.article-body blockquote {
    border-left: 3px solid var(--brand-500);
    padding: .5rem 1.25rem;
    margin: 1.5rem 0;
    background: var(--bg-soft);
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-soft);
}
.article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: .95rem;
}
.article-body th, .article-body td {
    text-align: left;
    padding: .65rem .8rem;
    border-bottom: 1px solid var(--border);
}
.article-body th { font-weight: 600; color: var(--text); background: var(--bg-soft); }

/* -------- Footer -------- */
.site-footer {
    background: var(--bg-soft);
    border-top: 1px solid var(--border);
    padding: 4rem 0 2rem;
    margin-top: 5rem;
}
.footer-content {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 3rem;
    margin-bottom: 3rem;
}
.footer-section h3 { font-size: 1.05rem; margin-bottom: .5rem; }
.footer-section h4 {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: .75rem;
    color: var(--text-mute);
    margin-bottom: 1rem;
}
.footer-section p { color: var(--text-soft); font-size: .9rem; }
.footer-section ul { list-style: none; padding: 0; margin: 0; }
.footer-section li { margin-bottom: .5rem; font-size: .9rem; }
.footer-section a { color: var(--text-soft); }
.footer-section a:hover { color: var(--brand-700); }
.footer-bottom {
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
    text-align: center;
    color: var(--text-mute);
    font-size: .85rem;
}
@media (max-width: 800px) { .footer-content { grid-template-columns: 1fr 1fr; gap: 2rem; } }
@media (max-width: 500px) { .footer-content { grid-template-columns: 1fr; } }

/* -------- Utility -------- */
.text-center { text-align: center; }
.muted { color: var(--text-soft); }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 1rem; }
.mt-4 { margin-top: 2rem; }
.mt-6 { margin-top: 3rem; }
