/* ============================================
   TI-84 Calculator Online — Design System
   Premium dark theme with calculator aesthetics
   ============================================ */

/* ---- Google Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ---- CSS Custom Properties (Design Tokens) ---- */
:root {
    /* — Background Palette — */
    --bg-body:        #060A13;
    --bg-primary:     #0A0E17;
    --bg-surface:     #111827;
    --bg-elevated:    #1C2640;
    --bg-hover:       #243052;
    --bg-glass:       rgba(17, 24, 39, 0.75);

    /* — Accent Palette — */
    --accent:         #00D4AA;
    --accent-rgb:     0, 212, 170;
    --accent-hover:   #00F0C0;
    --accent-muted:   rgba(0, 212, 170, 0.15);
    --accent-subtle:  rgba(0, 212, 170, 0.08);

    /* — Secondary Accent — */
    --blue:           #3B82F6;
    --blue-rgb:       59, 130, 246;
    --blue-muted:     rgba(59, 130, 246, 0.15);

    /* — Feedback Colors — */
    --success:        #10B981;
    --warning:        #F59E0B;
    --danger:         #EF4444;
    --info:           #3B82F6;

    /* — Text Palette — */
    --text-primary:   #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted:     #64748B;
    --text-dim:       #475569;
    --text-inverse:   #0A0E17;

    /* — Border & Dividers — */
    --border:         rgba(148, 163, 184, 0.1);
    --border-hover:   rgba(148, 163, 184, 0.2);
    --border-accent:  rgba(0, 212, 170, 0.3);

    /* — Shadows — */
    --shadow-sm:      0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md:      0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg:      0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-xl:      0 16px 48px rgba(0, 0, 0, 0.6);
    --shadow-glow:    0 0 20px rgba(var(--accent-rgb), 0.2);
    --shadow-glow-lg: 0 0 40px rgba(var(--accent-rgb), 0.15);

    /* — Typography — */
    --font-sans:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:      'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

    --text-xs:   0.75rem;    /* 12px */
    --text-sm:   0.875rem;   /* 14px */
    --text-base: 1rem;       /* 16px */
    --text-lg:   1.125rem;   /* 18px */
    --text-xl:   1.25rem;    /* 20px */
    --text-2xl:  1.5rem;     /* 24px */
    --text-3xl:  1.875rem;   /* 30px */
    --text-4xl:  2.25rem;    /* 36px */
    --text-5xl:  3rem;       /* 48px */
    --text-6xl:  3.75rem;    /* 60px */

    --leading-tight:  1.25;
    --leading-normal: 1.6;
    --leading-relaxed: 1.8;

    /* — Spacing Scale — */
    --space-1:  0.25rem;
    --space-2:  0.5rem;
    --space-3:  0.75rem;
    --space-4:  1rem;
    --space-5:  1.25rem;
    --space-6:  1.5rem;
    --space-8:  2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;
    --space-24: 6rem;

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

    /* — Transitions — */
    --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast:   150ms;
    --duration-normal: 250ms;
    --duration-slow:   400ms;

    /* — Z-Index Scale — */
    --z-base:     1;
    --z-dropdown: 100;
    --z-sticky:   200;
    --z-modal:    300;
    --z-toast:    400;
    --z-tooltip:  500;

    /* — Layout — */
    --container-sm:  640px;
    --container-md:  768px;
    --container-lg:  1024px;
    --container-xl:  1200px;
    --container-2xl: 1400px;
    --sidebar-width: 320px;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: 80px;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background: var(--bg-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Subtle background pattern */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(var(--accent-rgb), 0.06), transparent),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(var(--blue-rgb), 0.04), transparent);
    pointer-events: none;
    z-index: 0;
}

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

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--duration-fast) var(--ease-out);
}

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

ul, ol {
    list-style: none;
}

button, input, textarea, select {
    font: inherit;
    color: inherit;
    border: none;
    outline: none;
    background: none;
}

button {
    cursor: pointer;
}

table {
    border-collapse: collapse;
    width: 100%;
}

/* ---- Typography System ---- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: var(--leading-tight);
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

h1 {
    font-size: var(--text-4xl);
    font-weight: 800;
    letter-spacing: -0.03em;
}

h2 {
    font-size: var(--text-2xl);
    margin-top: var(--space-12);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border);
}

h3 {
    font-size: var(--text-xl);
    margin-top: var(--space-8);
    margin-bottom: var(--space-3);
}

h4 {
    font-size: var(--text-lg);
    margin-top: var(--space-6);
    margin-bottom: var(--space-2);
}

p {
    margin-bottom: var(--space-4);
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
}

strong {
    color: var(--text-primary);
    font-weight: 600;
}

code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    padding: 0.15em 0.4em;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ---- Layout Utilities ---- */
.container {
    width: 100%;
    max-width: var(--container-xl);
    margin: 0 auto;
    padding: 0 var(--space-6);
    position: relative;
    z-index: var(--z-base);
}

.container--narrow {
    max-width: var(--container-md);
}

.container--wide {
    max-width: var(--container-2xl);
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

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

/* ---- Component: Card ---- */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    transition: all var(--duration-normal) var(--ease-out);
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card--glass {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.card--accent {
    border-color: var(--border-accent);
    background: linear-gradient(135deg, var(--accent-subtle), var(--bg-surface));
}

/* ---- Component: Button ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0.75rem 1.5rem;
    font-size: var(--text-sm);
    font-weight: 600;
    border-radius: var(--radius-lg);
    transition: all var(--duration-normal) var(--ease-out);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
    opacity: 0;
    transition: opacity var(--duration-fast);
}

.btn:hover::before {
    opacity: 1;
}

.btn--primary {
    background: linear-gradient(135deg, var(--accent), #00B894);
    color: var(--text-inverse);
    box-shadow: 0 4px 14px rgba(var(--accent-rgb), 0.3);
}

.btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--accent-rgb), 0.4);
    color: var(--text-inverse);
}

.btn--secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn--secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.btn--outline {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--border-accent);
}

.btn--outline:hover {
    background: var(--accent-muted);
}

.btn--lg {
    padding: 1rem 2rem;
    font-size: var(--text-base);
    border-radius: var(--radius-xl);
}

.btn--sm {
    padding: 0.5rem 1rem;
    font-size: var(--text-xs);
}

.btn--icon {
    padding: 0.65rem;
    border-radius: var(--radius-md);
}

/* ---- Component: Badge ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 0.25rem 0.75rem;
    font-size: var(--text-xs);
    font-weight: 600;
    border-radius: var(--radius-full);
    background: var(--accent-muted);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge--blue {
    background: var(--blue-muted);
    color: var(--blue);
}

.badge--warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

/* ---- Component: Tag ---- */
.tag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    font-size: var(--text-xs);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

/* ---- Component: Table ---- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin: var(--space-6) 0;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background: var(--bg-elevated);
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

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

.table tr:hover td {
    background: var(--accent-subtle);
}

.table .check { color: var(--success); }
.table .cross { color: var(--danger); }

/* ---- Component: FAQ Accordion ---- */
.faq-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-3);
    overflow: hidden;
    transition: border-color var(--duration-normal);
}

.faq-item:hover {
    border-color: var(--border-hover);
}

.faq-question {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    background: var(--bg-surface);
    cursor: pointer;
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    text-align: left;
    transition: background var(--duration-fast);
}

.faq-question:hover {
    background: var(--bg-elevated);
}

.faq-question::after {
    content: '+';
    font-size: var(--text-xl);
    font-weight: 300;
    color: var(--accent);
    transition: transform var(--duration-normal) var(--ease-spring);
    flex-shrink: 0;
    margin-left: var(--space-4);
}

.faq-item.active .faq-question::after {
    content: '−';
    transform: rotate(180deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--duration-slow) var(--ease-out),
                padding var(--duration-slow) var(--ease-out);
}

.faq-item.active .faq-answer {
    max-height: 500px;
    padding: 0 var(--space-5) var(--space-5);
}

.faq-answer p {
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
}

/* ---- Component: Breadcrumb ---- */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) 0;
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--text-secondary);
    transition: color var(--duration-fast);
}

.breadcrumb a:hover {
    color: var(--accent);
}

.breadcrumb .separator {
    color: var(--text-dim);
    font-size: var(--text-xs);
}

.breadcrumb .current {
    color: var(--text-primary);
    font-weight: 500;
}

/* ---- Component: CTA Banner ---- */
.cta-banner {
    background: linear-gradient(135deg, var(--accent-subtle), var(--blue-muted));
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-xl);
    padding: var(--space-8) var(--space-10);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.cta-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(var(--accent-rgb), 0.1), transparent 70%);
    pointer-events: none;
}

.cta-banner h3 {
    font-size: var(--text-2xl);
    margin-bottom: var(--space-3);
}

.cta-banner p {
    color: var(--text-secondary);
    margin-bottom: var(--space-6);
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

/* ---- Component: Tooltip ---- */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    padding: 0.35rem 0.7rem;
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-fast), transform var(--duration-fast);
    z-index: var(--z-tooltip);
}

[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-8px);
}

/* ---- Animations ---- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.6; }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.2); }
    50%      { box-shadow: 0 0 25px rgba(var(--accent-rgb), 0.4); }
}

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s var(--ease-out) both;
}

.animate-fade-in {
    animation: fadeIn 0.4s var(--ease-out) both;
}

.animate-slide-down {
    animation: slideDown 0.3s var(--ease-out) both;
}

/* Stagger children animation */
.stagger > * {
    animation: fadeInUp 0.5s var(--ease-out) both;
}
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.1s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.2s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.3s; }

/* ---- Scroll-reveal (JS triggers .is-visible) ---- */
.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}

.reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Ad Zone Placeholders ---- */
.ad-zone {
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-dim);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: var(--space-6) 0;
}

.ad-zone--header {
    min-height: 90px;
    max-width: 728px;
    margin: var(--space-4) auto;
}

.ad-zone--sidebar {
    min-height: 250px;
    width: 100%;
    position: sticky;
    top: 100px;
}

.ad-zone--inline {
    min-height: 100px;
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    h1 { font-size: var(--text-3xl); }
}

@media (max-width: 768px) {
    html { font-size: 15px; }

    .container { padding: 0 var(--space-4); }

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

    h1 { font-size: var(--text-2xl); }
    h2 { font-size: var(--text-xl); margin-top: var(--space-8); }
    h3 { font-size: var(--text-lg); }

    .hide-mobile { display: none !important; }
    .show-mobile { display: block !important; }
}

@media (max-width: 480px) {
    html { font-size: 14px; }
    h1 { font-size: var(--text-xl); }

    .btn--lg {
        padding: 0.85rem 1.5rem;
        font-size: var(--text-sm);
    }
}

/* ---- Selection ---- */
::selection {
    background: rgba(var(--accent-rgb), 0.3);
    color: var(--text-primary);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-hover);
}

/* ---- Print ---- */
@media print {
    body::before { display: none; }
    .ad-zone { display: none; }
    nav, .mobile-menu { display: none; }
    .btn { border: 1px solid #333; }
}
