/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: #0f0f1a;
    color: #e0e0e0;
    line-height: 1.7;
    overflow-x: hidden;
}

main {
    min-width: 0;
    max-width: 100%;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(168, 85, 247, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(59, 130, 246, 0.06) 0%, transparent 50%);
    z-index: -1;
    animation: bgPulse 15s ease-in-out infinite alternate;
}

@keyframes bgPulse {
    from { opacity: 0.7; }
    to { opacity: 1; }
}

/* ===== NAVIGATION ===== */
nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(15, 15, 26, 0.92);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(99, 102, 241, 0.2);
    z-index: 1000;
    overflow: hidden;
}

.nav-inner {
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0 1.5rem;
    overflow-x: auto;
    min-width: 0;
    scrollbar-width: none;
}

.nav-inner::-webkit-scrollbar { display: none; }

.nav-logo {
    font-size: 1.3rem;
    font-weight: 800;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
    padding: 0.9rem 1rem 0.9rem 0;
    border-right: 1px solid rgba(99, 102, 241, 0.2);
    margin-right: 0.5rem;
}

nav a {
    color: #94a3b8;
    text-decoration: none;
    padding: 0.9rem 0.8rem;
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

nav a:hover,
nav a.active {
    color: #c4b5fd;
    border-bottom-color: #a855f7;
}

/* ===== HERO ===== */
.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 6rem 2rem 4rem;
    position: relative;
}

.hero-badge,
.section-label {
    display: inline-block;
    padding: 0.4rem 1.2rem;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 50px;
    font-size: 0.85rem;
    color: #a5b4fc;
    margin-bottom: 1.5rem;
    letter-spacing: 0.5px;
}

.hero h1 {
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 900;
    background: linear-gradient(135deg, #fff 0%, #c4b5fd 50%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.1;
    margin-bottom: 1.2rem;
}

.hero p {
    font-size: 1.2rem;
    color: #94a3b8;
    max-width: 720px;
    margin-bottom: 2.5rem;
}

.hero-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    max-width: 1040px;
    width: 100%;
    margin-top: 1rem;
}

.hero-card {
    background: rgba(30, 30, 50, 0.6);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: left;
    transition: all 0.3s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.hero-card:hover {
    border-color: rgba(168, 85, 247, 0.5);
    transform: translateY(-4px);
    box-shadow: 0 10px 40px rgba(99, 102, 241, 0.15);
}

.hero-card .icon {
    font-size: 2rem;
    margin-bottom: 0.8rem;
}

.hero-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #e2e8f0;
    margin-bottom: 0.3rem;
}

.hero-card p {
    font-size: 0.82rem;
    color: #64748b;
    margin: 0;
}

/* ===== MAIN CONTAINER / SECTIONS ===== */
.container {
    max-width: 1040px;
    margin: 0 auto;
    padding: 0 2rem;
    min-width: 0;
}

section {
    padding: 5rem 0;
    border-top: 1px solid rgba(99, 102, 241, 0.08);
    scroll-margin-top: 4rem;
    min-width: 0;
}

#course {
    padding-top: 0;
}

#course > .generated-section:first-child {
    border-top: 1px solid rgba(99, 102, 241, 0.08);
}

.section-label {
    padding: 0.3rem 0.9rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
}

section h2 {
    font-size: 2.2rem;
    font-weight: 800;
    color: #f1f5f9;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.section-subtitle {
    font-size: 1.05rem;
    color: #64748b;
    margin-bottom: 3rem;
    max-width: 760px;
}

/* ===== CARDS / BOXES ===== */
.card {
    background: rgba(30, 30, 50, 0.5);
    border: 1px solid rgba(99, 102, 241, 0.12);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    transition: border-color 0.3s;
    min-width: 0;
}

.card:hover { border-color: rgba(168, 85, 247, 0.3); }

.card h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: #e2e8f0;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    overflow-wrap: anywhere;
}

.card h4 {
    font-size: 1.05rem;
    font-weight: 600;
    color: #c4b5fd;
    margin: 1.5rem 0 0.6rem;
}

.card p,
.card li {
    color: #b0b8c8;
    font-size: 0.95rem;
    overflow-wrap: anywhere;
}

.card p + p { margin-top: 0.8rem; }

.card ul,
.card ol {
    padding-left: 1.3rem;
    margin: 0.5rem 0;
}

.card li { margin-bottom: 0.35rem; }

.loading-card {
    margin-top: 0;
}

/* ===== STORY FLOW ===== */
.story-flow {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.story-flow div {
    background: rgba(20, 20, 40, 0.7);
    border: 1px dashed rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    padding: 1.1rem;
}

.story-flow strong {
    display: block;
    color: #c4b5fd;
    margin-bottom: 0.35rem;
}

.story-flow span {
    display: block;
    color: #94a3b8;
    font-size: 0.9rem;
}

/* ===== TIP / WARNING / SUCCESS BOXES ===== */
.tip-box,
.warn-box,
.success-box,
.trick-box {
    border-radius: 12px;
    padding: 1.2rem 1.5rem;
    margin: 1.2rem 0;
    font-size: 0.92rem;
}

.tip-box {
    background: rgba(59, 130, 246, 0.08);
    border-left: 4px solid #3b82f6;
    color: #93c5fd;
}

.warn-box {
    background: rgba(245, 158, 11, 0.08);
    border-left: 4px solid #f59e0b;
    color: #fcd34d;
}

.success-box {
    background: rgba(34, 197, 94, 0.08);
    border-left: 4px solid #22c55e;
    color: #86efac;
}

.trick-box {
    background: rgba(168, 85, 247, 0.08);
    border-left: 4px solid #a855f7;
    color: #d8b4fe;
}

.tip-box strong,
.warn-box strong,
.success-box strong,
.trick-box strong {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
}

.tip-box p,
.warn-box p,
.success-box p,
.trick-box p,
.tip-box li,
.warn-box li,
.success-box li,
.trick-box li {
    color: inherit;
}

/* ===== CODE / TABLES ===== */
code {
    background: rgba(15, 15, 30, 0.8);
    border: 1px solid rgba(99, 102, 241, 0.18);
    border-radius: 6px;
    color: #c4b5fd;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 0.88em;
    padding: 0.08rem 0.35rem;
}

pre {
    background: rgba(20, 20, 40, 0.7);
    border: 1px dashed rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1rem 0;
    overflow-x: auto;
    line-height: 1.5;
    max-width: 100%;
}

pre code {
    padding: 0;
    background: transparent;
    border: 0;
    color: #c4b5fd;
    white-space: pre;
}

.table-wrap {
    overflow-x: auto;
    margin: 1.2rem 0;
    border-radius: 12px;
    border: 1px solid rgba(99, 102, 241, 0.15);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

thead { background: rgba(99, 102, 241, 0.12); }

th {
    padding: 0.8rem 1rem;
    text-align: left;
    font-weight: 700;
    color: #c4b5fd;
    white-space: nowrap;
}

td {
    padding: 0.7rem 1rem;
    border-top: 1px solid rgba(99, 102, 241, 0.08);
    color: #b0b8c8;
    vertical-align: top;
}

tr:hover td { background: rgba(99, 102, 241, 0.04); }

/* ===== GRID LAYOUTS ===== */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.2rem;
}

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

/* ===== STEPS ===== */
.steps {
    counter-reset: step;
    list-style: none;
    padding: 0;
}

.steps li {
    counter-increment: step;
    position: relative;
    padding: 1rem 0 1rem 3.5rem;
    border-left: 2px solid rgba(99, 102, 241, 0.2);
    margin-left: 1rem;
}

.steps li::before {
    content: counter(step);
    position: absolute;
    left: -14px;
    top: 1rem;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.steps li:last-child { border-left-color: transparent; }
.steps li strong { color: #e2e8f0; font-size: 1rem; }

/* ===== TAGS / HIGHLIGHTS ===== */
.tag {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    margin: 0.15rem;
}

.tag-blue { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.tag-purple { background: rgba(168, 85, 247, 0.15); color: #d8b4fe; }
.tag-green { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.tag-orange { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.hl { color: #a5b4fc; font-weight: 600; }
.hl-green { color: #86efac; font-weight: 600; }
.hl-orange { color: #fcd34d; font-weight: 600; }
.hl-pink { color: #f0abfc; font-weight: 600; }

/* ===== BACK TO TOP / FOOTER ===== */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
    z-index: 999;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
}

.back-to-top:hover { transform: scale(1.1); }

footer {
    text-align: center;
    padding: 3rem 2rem;
    color: #475569;
    font-size: 0.82rem;
    border-top: 1px solid rgba(99, 102, 241, 0.08);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .hero { min-height: auto; padding: 5rem 1rem 3rem; }
    .hero h1 { font-size: 2.2rem; }
    .hero p { font-size: 1rem; }
    .hero-cards { grid-template-columns: 1fr; }
    nav a { font-size: 0.72rem; padding: 0.8rem 0.5rem; }
    .container { padding: 0 1rem; }
    .card { padding: 1.3rem; border-radius: 14px; }
    section { padding: 3.5rem 0; }
    section h2 { font-size: 1.75rem; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .steps li { padding-left: 2.3rem; margin-left: 0.8rem; }
}

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