/* ╔════════════════════════════════════════════════════════════╗
   ║  Tử Vi Đẩu Số — Shared Theme (Math-Viz Style)              ║
   ║  shared_theme.css — Clean, organized, readable             ║
   ╚════════════════════════════════════════════════════════════╝ */

/* ─────────────────────────────────────
   §0  Design Tokens (CSS Variables)
   ───────────────────────────────────── */
:root {
    /* Background palette (dark → light) */
    --bg-primary:    #0d1117;
    --bg-secondary:  #161b22;
    --bg-tertiary:   #21262d;
    --bg-card:       #1c2128;

    /* Text palette */
    --text-primary:  #e6edf3;
    --text-secondary:#c9d1d9;
    --text-muted:    #8b949e;

    /* Accent colors */
    --accent-gold:   #F9A825;
    --accent-blue:   #4FC3F7;
    --accent-green:  #66BB6A;
    --accent-red:    #EF5350;
    --accent-purple: #AB47BC;
    --accent-orange: #FF8A65;

    /* Borders & effects */
    --border-color:  #30363d;
    --border-subtle: rgba(255,255,255,.06);
    --radius:        8px;
    --radius-lg:     12px;
    --shadow:        0 2px 12px rgba(0,0,0,.4);
    --shadow-hover:  0 4px 20px rgba(0,0,0,.55);

    /* Typography */
    --font-body:     'Inter', 'Segoe UI', system-ui, sans-serif;
    --font-mono:     'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    /* Spacing scale */
    --sp-xs:  .25rem;
    --sp-sm:  .5rem;
    --sp-md:  .75rem;
    --sp-lg:  1.25rem;
    --sp-xl:  2rem;
}

/* ─────────────────────────────────────
   §0.1  Light Theme Override
   ───────────────────────────────────── */
[data-theme="light"] {
    /* Day Mode Colors */
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f3f5;
    --bg-nav: rgba(248, 249, 250, 0.9);
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --border-subtle: #e9ecef;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);

    /* Accent colors remain mostly same but slightly adjusted for contrast */
    --accent-gold:   #E65100;
    --accent-blue:   #0288D1;
    --accent-green:  #388E3C;
    --accent-red:    #D32F2F;
    --accent-purple: #7B1FA2;
    --accent-orange: #F4511E;
}

[data-theme="dark"] {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-nav: rgba(13, 17, 23, 0.9);
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --border-color: #30363d;
    --border-subtle: #21262d;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* ─────────────────────────────────────
   §1  Reset & Base
   ───────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: color .2s;
}
a:hover {
    color: var(--accent-gold);
    text-decoration: underline;
}

code {
    font-family: var(--font-mono);
    font-size: .85em;
    background: var(--bg-primary);
    padding: .1em .35em;
    border-radius: 4px;
}

/* ─────────────────────────────────────
   §2  Header
   ───────────────────────────────────── */
.site-header {
    text-align: center;
    padding: 2.5rem 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(180deg, rgba(249,168,37,.06), transparent 80%);
}

.site-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-gold);
    letter-spacing: .04em;
    margin-bottom: .35rem;
}

.site-header .subtitle {
    color: var(--text-muted);
    font-size: .95rem;
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ─────────────────────────────────────
   §3  Sticky Navigation Bar
   ───────────────────────────────────── */
.nav-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .5rem;
    padding: .65rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-nav);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-bar a {
    padding: .35rem .85rem;
    border-radius: var(--radius);
    font-size: .84rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all .2s ease;
}

.nav-bar a:hover {
    background: var(--bg-tertiary);
    color: var(--accent-gold);
    text-decoration: none;
}

.nav-bar a.active {
    background: var(--bg-tertiary);
    color: var(--accent-gold);
}

.nav-sep {
    color: var(--border-color);
    font-size: .75rem;
    align-self: center;
    padding: 0 .15rem;
    pointer-events: none;
    user-select: none;
}

/* Theme Toggle Icons */
[data-theme="dark"] .icon-light-mode { display: inline-block !important; }
[data-theme="dark"] .icon-dark-mode { display: none !important; }
[data-theme="light"] .icon-light-mode { display: none !important; }
[data-theme="light"] .icon-dark-mode { display: inline-block !important; }

#themeToggle {
    transition: transform 0.3s ease;
}

#themeToggle:hover {
    transform: rotate(15deg) scale(1.1);
    color: var(--accent-gold);
}

/* ─────────────────────────────────────
   §4  Main Container
   ───────────────────────────────────── */
main {
    max-width: 100%;
    margin: 0 auto;
    padding: var(--sp-xl) 2% 4rem;
}

/* ─────────────────────────────────────
   §5  Section Cards
   ───────────────────────────────────── */
.viz-section, .card {
    margin-bottom: 2.5rem;
    padding: 1.5rem 1.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.viz-section h2, .card h2, .card h3 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--accent-gold);
    margin-bottom: .4rem;
    padding-bottom: .55rem;
    border-bottom: 1px solid var(--border-color);
}

.viz-section h2 .sec-num {
    display: inline-block;
    color: var(--accent-blue);
    font-size: .88rem;
    margin-right: .45rem;
    vertical-align: baseline;
}

.viz-section .sec-desc, .card .sec-desc {
    color: var(--text-muted);
    font-size: .92rem;
    line-height: 1.65;
    margin-bottom: 1.1rem;
}

.sub-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--accent-blue);
    margin: 1.4rem 0 .7rem;
    padding-bottom: .35rem;
    border-bottom: 1px dashed var(--border-color);
}

/* ─────────────────────────────────────
   §6  Form Controls
   ───────────────────────────────────── */
.form-controls,
.phi-controls,
.mod-controls,
.tc-controls {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.form-controls label,
.phi-controls label,
.mod-controls label,
.tc-controls label {
    color: var(--text-muted);
    font-size: .88rem;
    font-weight: 500;
}

.form-select,
.form-input,
.phi-select,
.mod-input {
    padding: .35rem .7rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: .88rem;
    min-width: 88px;
    transition: border-color .2s;
}

.form-select:focus,
.form-input:focus,
.phi-select:focus,
.mod-input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.btn-primary,
.phi-btn {
    padding: .4rem 1.1rem;
    background: var(--accent-blue);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: .88rem;
    transition: background .2s, transform .1s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary:hover,
.phi-btn:hover {
    background: #29B6F6;
    color: var(--bg-primary);
    text-decoration: none;
}

.btn-primary:active,
.phi-btn:active {
    transform: scale(.97);
}

.btn-primary.active,
.phi-btn.active {
    background: var(--accent-gold);
}

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

/* Utility for inputs and tables to look decent on dark mode */
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: var(--sp-sm);
    border: 1px solid var(--border-color);
}
th {
    background: var(--bg-tertiary);
    color: var(--accent-blue);
}

/* ─────────────────────────────────────
   §17  Footer
   ───────────────────────────────────── */
.site-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: .82rem;
}

/* ─────────────────────────────────────
   §18  Responsive (≤ 768px)
   ───────────────────────────────────── */
@media (max-width: 768px) {
    .site-header h1 {
        font-size: 1.4rem;
    }

    .viz-section, .card {
        padding: 1rem;
    }

    .nav-bar {
        gap: .3rem;
    }

    .nav-bar a {
        font-size: .76rem;
        padding: .25rem .5rem;
    }
}
