/* ===================================
   TStar Website — Style
   =================================== */

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

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #0d1220;
    --bg-card: #111827;
    --accent-blue: #1a3a5c;
    --accent-light: #2d5a8e;
    --accent-highlight: #4a9eff;
    --text-primary: #ffffff;
    --text-secondary: #c0c8d8;
    --text-muted: #6b7a90;
    --border-color: #1e2a3a;
    --font-main: 'Playfair', Georgia, 'Times New Roman', serif;
    --paragraph-increase: 2pt; 
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    text-align: justify;
    overflow-x: hidden;
}

a {
    color: var(--accent-highlight);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover { color: #7ec0ff; }

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

code {
    background: rgba(74, 158, 255, 0.12);
    padding: 2px 7px;
    border-radius: 4px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--accent-highlight);
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 24px;
}

/* === PROGRESS BAR === */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-highlight), #7ec0ff);
    z-index: 10000;
    transition: width 0.1s linear;
    pointer-events: none;
}

/* === HEADER === */
.site-header {
    position: fixed;
    top: 3px;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(10, 14, 23, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    transition: background 0.3s ease;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.header-logo img { width: 40px; height: 40px; }

.header-nav {
    display: flex;
    align-items: center;
    gap: 32px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-link {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    transition: color 0.3s ease;
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-highlight);
    transition: width 0.3s ease;
}

.nav-link:hover,
.nav-link.active { color: var(--text-primary); }

.nav-link:hover::after,
.nav-link.active::after { width: 100%; }

.btn-download {
    background: var(--accent-highlight);
    color: var(--bg-primary) !important;
    padding: 8px 20px;
    border-radius: 6px;
    font-weight: 600;
}

.btn-download::after { display: none; }
.btn-download:hover { background: #6bb3ff; color: var(--bg-primary) !important; }

/* Search Toggle */
.search-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-toggle:hover {
    border-color: var(--accent-highlight);
    color: var(--accent-highlight);
}

/* Hamburger */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    z-index: 1010;
}

.hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    transition: all 0.3s ease;
    border-radius: 2px;
}

.hamburger.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* === SEARCH OVERLAY === */
.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(10, 14, 23, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 120px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.search-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.search-container {
    width: 100%;
    max-width: 640px;
    padding: 0 24px;
}

.search-input-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 18px;
    transition: border-color 0.3s ease;
}

.search-input-wrap:focus-within {
    border-color: var(--accent-highlight);
}

.search-icon {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-input-wrap input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-family: var(--font-main);
    font-size: 1.1rem;
    color: var(--text-primary);
}

.search-input-wrap input::placeholder {
    color: var(--text-muted);
}

.search-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    transition: color 0.3s ease;
    display: flex;
}

.search-close:hover { color: var(--text-primary); }

.search-results {
    margin-top: 16px;
    max-height: 50vh;
    overflow-y: auto;
}

.search-result-item {
    display: block;
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: background 0.2s ease;
    color: var(--text-secondary);
    cursor: pointer;
}

.search-result-item:hover {
    background: rgba(74, 158, 255, 0.08);
    color: var(--text-primary);
}

.search-result-item .result-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 2px;
}

.search-result-item .result-section {
    font-size: 0.8rem;
    color: var(--accent-highlight);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.search-result-item .result-snippet {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.4;
}

.search-result-item mark {
    background: rgba(74, 158, 255, 0.25);
    color: var(--text-primary);
    border-radius: 2px;
    padding: 0 2px;
}

.search-no-results {
    text-align: center;
    padding: 32px 0;
    color: var(--text-muted);
    font-size: 1rem;
}

/* === HERO === */
.hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
}

.hero-bg {
    position: absolute;
    inset: 0;
    background-image: url('../images/nebula-bg.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.5;
    z-index: 0;
}

.hero-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
        rgba(10, 14, 23, 0.3) 0%,
        rgba(10, 14, 23, 0.6) 60%,
        rgba(10, 14, 23, 1) 100%
    );
}

.hero-content {
    position: relative;
    z-index: 1;
    padding: 80px 24px 40px;
}

.hero-logo {
    width: 120px;
    height: 120px;
    margin: 0 auto 24px;
    filter: drop-shadow(0 4px 20px rgba(74, 158, 255, 0.3));
}

.hero-title {
    font-size: clamp(3rem, 8vw, 6rem);
    font-weight: 900;
    letter-spacing: 6px;
    line-height: 1.1;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #ffffff 0%, #a0c8ff 50%, #4a9eff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: clamp(1.1rem, 3vw, 1.6rem);
    font-weight: 400;
    color: var(--text-secondary);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.hero-tagline {
    font-size: clamp(0.9rem, 2vw, 1.15rem);
    font-weight: 400;
    font-style: italic;
    color: var(--text-muted);
    margin-bottom: 36px;
}

.hero-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    display: inline-block;
    padding: 14px 36px;
    border-radius: 8px;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: var(--accent-highlight);
    color: var(--bg-primary);
}

.btn-primary:hover {
    background: #6bb3ff;
    color: var(--bg-primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(74, 158, 255, 0.3);
}

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

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent-highlight);
    color: var(--accent-highlight);
    transform: translateY(-2px);
}

.hero-scroll-indicator {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
}

.hero-scroll-indicator span {
    display: block;
    width: 2px;
    height: 40px;
    background: linear-gradient(to bottom, var(--accent-highlight), transparent);
    animation: scrollPulse 2s ease-in-out infinite;
}

@keyframes scrollPulse {
    0%, 100% { opacity: 1; transform: scaleY(1); }
    50% { opacity: 0.3; transform: scaleY(0.6); }
}

/* Page Hero */
.page-hero {
    position: relative;
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
}

.page-hero .hero-bg { opacity: 0.3; }
.page-hero .hero-content { padding: 120px 24px 60px; }

/* === MAIN CONTENT === */
.main-content { padding-bottom: 80px; }

.content-section {
    padding: 60px 0;
    border-bottom: 1px solid var(--border-color);
}

.content-section:last-child { border-bottom: none; }

.section-title {
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--accent-blue);
    display: block;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.subsection-title {
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    font-weight: 600;
    color: var(--accent-highlight);
    margin-top: 32px;
    margin-bottom: 12px;
    text-align: center;
}

/* Keep header and footer left-aligned */
.site-header, .header-inner, .header-nav, .footer-inner { text-align: left; }

/* Ensure hero headings are centered */
.hero-title, .hero-subtitle, .hero-tagline { text-align: center; }

.content-section p {
    font-size: calc(1rem + var(--paragraph-increase));
    color: var(--text-secondary);
    margin-bottom: 16px;
    max-width: 100%;
}

.content-section em { color: var(--text-muted); font-style: italic; }

/* Feature List */
.feature-list {
    list-style: none;
    padding: 0;
    margin: 0 0 24px 0;
}

.feature-list li {
    position: relative;
    padding: 8px 0 8px 24px;
    font-size: 0.98rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.feature-list li::before {
    content: '›';
    position: absolute;
    left: 0;
    color: var(--accent-highlight);
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.5;
}

.feature-list li strong { color: var(--text-primary); }

.feature-list.numbered {
    counter-reset: item;
    list-style: none;
}

.feature-list.numbered li { counter-increment: item; }
.feature-list.numbered li::before { content: counter(item) '.'; font-size: 1rem; font-weight: 600; }

/* CTA */
.cta-box { margin-top: 32px; text-align: center; }

/* TOC */
.toc-nav { margin-top: 16px; }

.toc-list {
    list-style: none;
    counter-reset: toc;
    padding: 0;
    columns: 2;
    column-gap: 40px;
}

.toc-list li {
    counter-increment: toc;
    padding: 6px 0;
    font-size: 1rem;
    break-inside: avoid;
}

.toc-list li a {
    color: var(--text-secondary);
    transition: color 0.3s ease, padding-left 0.3s ease;
}

.toc-list li a:hover {
    color: var(--accent-highlight);
    padding-left: 8px;
}

/* Prevent horizontal overflow on small screens (tutorials TOC, long words/links) */
.toc-list li a,
.toc-list li,
.feature-list li,
.content-section p,
.toc-list {
    overflow-wrap: anywhere;
    word-break: break-word;
}

@media (max-width: 768px) {
    /* Stack TOC into a single column on small screens to avoid forcing extra width */
    .toc-list { columns: 1; column-gap: 0; }

    /* Reduce container paddings on small screens to avoid incidental overflow */
    .container { padding: 0 16px; }
    .header-inner { padding: 0 16px; }
}

.toc-list li a::before {
    content: counter(toc) '. ';
    color: var(--accent-highlight);
    font-weight: 600;
}

/* Shortcuts */
.shortcuts-table { max-width: 500px; }

.shortcut-row {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.shortcut-key {
    display: inline-block;
    min-width: 160px;
    background: rgba(74, 158, 255, 0.1);
    color: #ffcc00;
    padding: 4px 12px;
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    margin-right: 16px;
}

.shortcut-desc { color: var(--text-secondary); font-size: 0.95rem; }

/* === BACK TO TOP === */
.back-to-top {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 900;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-highlight);
    color: var(--bg-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: all 0.4s ease;
    box-shadow: 0 4px 20px rgba(74, 158, 255, 0.3);
}

.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.back-to-top:hover {
    background: #6bb3ff;
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(74, 158, 255, 0.4);
}

/* === FOOTER === */
.site-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 40px 0;
}

.footer-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.footer-nav {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-nav a {
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: color 0.3s ease;
}

.footer-nav a:hover { color: var(--accent-highlight); }

.footer-copy { color: var(--text-muted); font-size: 0.85rem; }

/* === FADE-IN === */
.fade-line {
    opacity: 1;
    transform: translateY(0);
    transition: none;
}

.fade-line.visible {
    opacity: 1;
    transform: translateY(0);
}

/* === PRELOADER === */
.preloader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.6s ease, visibility 0.6s ease;
    visibility: visible;
}

.preloader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.preloader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.preloader-spinner {
    width: 60px;
    height: 60px;
    border: 3px solid var(--accent-blue);
    border-top-color: var(--accent-highlight);
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.preloader-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* === IMAGE COMPARISON === */
.comparison-section {
    padding: 80px 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.comparison-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 40px;
    font-size: 1.05rem;
}

.comparison-wrapper {
    max-width: 960px;
    margin: 0 auto;
}

.comparison-container {
    position: relative;
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

/* Original image remains in normal flow so it defines container height */
.comparison-original {
    position: relative;
    width: 100%;
    display: block;
}

.comparison-original img {
    display: block;
    width: 100%;
    height: auto;
}

/* Final image is absolutely positioned over the original and kept fixed; .reveal just clips it */
.comparison-final {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.comparison-final img.comparison-final-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    /* start clipped to 50% */
    clip-path: inset(0 50% 0 0);
}

.comparison-label {
    position: absolute;
    bottom: 16px;
    left: 16px;
    background: rgba(0, 0, 0, 0.6);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10;
}

.comparison-label[data-for="final"] {
    right: 16px;
    left: auto;
}

.comparison-slider {
    position: absolute;
    top: 0;
    left: 50%;
    width: 3px;
    height: 100%;
    background: #ffffff;
    cursor: col-resize;
    z-index: 5;
    transform: translateX(-50%);
}

/* small white circular handle */
.comparison-slider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    z-index: 6;
}

/* remove any arrow text */
.comparison-slider::after { content: ''; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .hamburger { display: flex; }

    .header-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        background: var(--bg-secondary);
        flex-direction: column;
        justify-content: center;
        gap: 32px;
        padding: 40px;
        transition: right 0.4s ease;
        border-left: 1px solid var(--border-color);
    }

    .header-nav.open { right: 0; }
    .nav-link { font-size: 1.1rem; }
    .nav-link::after { display: none; }
    .btn-download { text-align: center; width: 100%; }
    .hero-logo { width: 80px; height: 80px; }
    .content-section { padding: 40px 0; }
    .toc-list { columns: 1; }
    .shortcut-key { min-width: 120px; font-size: 0.8rem; }
    .hero-buttons { flex-direction: column; align-items: center; }
    .hero-buttons .btn { width: 220px; text-align: center; }
    .back-to-top { bottom: 20px; right: 20px; width: 42px; height: 42px; }
}

@media (max-width: 480px) {
    .header-inner { padding: 0 16px; }
    .container { padding: 0 16px; }
    .section-title { font-size: 1.4rem; }
    .subsection-title { font-size: 1.1rem; }
    .feature-list li { font-size: 0.92rem; }
}

/* Selection */
::selection { background: rgba(74, 158, 255, 0.3); color: var(--text-primary); }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--accent-blue); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-light); }