/* =============================================================
   Rafiputra — Portfolio Stylesheet
   ============================================================= */

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

/* ---------- 1a. Theme Variables ---------- */
/* :root  => Default theme (LIGHT)
   .dark-mode => Dark theme overrides (toggled via JS) */
:root {
    color-scheme: light;

    /* Surfaces */
    --bg: #ffffff;
    --bg-alt: #f5f6fa;
    --surface: #ffffff;
    --nav-bg: rgba(255, 255, 255, 0.55);
    --nav-bg-scrolled: rgba(255, 255, 255, 0.78);
    --glass-sheen: rgba(255, 255, 255, 0.45);
    --glass-shadow: rgba(15, 17, 21, 0.08);
    --menu-bg: rgba(255, 255, 255, 0.72);

    /* Borders & lines */
    --border: #e6e8ef;
    --grid-line: rgba(15, 17, 21, 0.05);

    /* Text */
    --text: #0f1115;
    --text-muted: #5b6473;

    /* Accent */
    --accent: #4f6dff;
    --accent-2: #7c3aed;
    --accent-soft: rgba(79, 109, 255, 0.10);

    /* Hero glows */
    --hero-glow-1: rgba(79, 109, 255, 0.18);
    --hero-glow-2: rgba(124, 58, 237, 0.14);

    /* Decorative */
    --accent-ring: rgba(79, 109, 255, 0.18);
    --thumb-bg: linear-gradient(135deg, rgba(79, 109, 255, 0.18), rgba(124, 58, 237, 0.18));

    /* Status */
    --success: #16a34a;

    /* Shadows */
    --shadow-sm: 0 4px 14px rgba(15, 17, 21, 0.06);
    --shadow-md: 0 14px 36px rgba(15, 17, 21, 0.10);

    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;

    /* Layout */
    --container: 1140px;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 22px;
    --transition: 0.3s ease;
}

.dark-mode {
    color-scheme: dark;

    /* Surfaces */
    --bg: #0f1115;
    --bg-alt: #151821;
    --surface: #1c2030;
    --nav-bg: rgba(15, 17, 21, 0.45);
    --nav-bg-scrolled: rgba(15, 17, 21, 0.78);
    --glass-sheen: rgba(255, 255, 255, 0.06);
    --glass-shadow: rgba(0, 0, 0, 0.45);
    --menu-bg: rgba(28, 32, 48, 0.72);

    /* Borders & lines */
    --border: #262b3a;
    --grid-line: rgba(255, 255, 255, 0.06);

    /* Text */
    --text: #e6e8ee;
    --text-muted: #9aa3b2;

    /* Accent */
    --accent: #6c8cff;
    --accent-2: #8b5cf6;
    --accent-soft: rgba(108, 140, 255, 0.14);

    /* Hero glows */
    --hero-glow-1: rgba(108, 140, 255, 0.18);
    --hero-glow-2: rgba(139, 92, 246, 0.15);

    /* Decorative */
    --accent-ring: rgba(108, 140, 255, 0.20);
    --thumb-bg: linear-gradient(135deg, rgba(108, 140, 255, 0.25), rgba(139, 92, 246, 0.25));

    /* Status */
    --success: #22c55e;

    /* Shadows */
    --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.35);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--transition), color var(--transition);
}

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

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition);
}

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

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: transparent;
    color: inherit;
}

ul {
    list-style: none;
}

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

/* ---------- 2. Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.6rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    transition: transform var(--transition), background-color var(--transition),
        color var(--transition), box-shadow var(--transition);
    will-change: transform;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    color: #fff;
}

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

.btn-ghost:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-2px);
}

.btn-link {
    padding: 0;
    color: var(--accent);
    background: transparent;
    font-weight: 600;
}

.btn-link:hover {
    color: var(--accent-2);
    transform: translateX(3px);
}

/* ---------- 3. Navbar ---------- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 1rem 0;
    background-color: var(--nav-bg);
    backdrop-filter: blur(18px) saturate(180%);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.04) inset;
    transition: background-color var(--transition), border-color var(--transition),
        padding var(--transition), box-shadow var(--transition);
}

/* Subtle "wet glass" sheen along the top edge */
.navbar::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg, var(--glass-sheen), transparent 40%);
    opacity: 0.9;
}

.navbar.scrolled {
    padding: 0.65rem 0;
    background-color: var(--nav-bg-scrolled);
    box-shadow: 0 8px 30px var(--glass-shadow),
        0 1px 0 0 rgba(255, 255, 255, 0.05) inset;
}

/* Fallback when backdrop-filter is unsupported (e.g. older Firefox) */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .navbar {
        background-color: var(--nav-bg-scrolled);
    }
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 1;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.3px;
}

.logo-symbol {
    font-family: var(--font-mono);
    color: var(--accent);
    background: var(--accent-soft);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.85rem;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
    position: relative;
    padding: 4px 0;
}

.nav-links a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -4px;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width var(--transition);
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text);
}

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

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    padding: 6px;
}

.menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform var(--transition), opacity var(--transition);
}

.menu-toggle.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.menu-toggle.open span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ---------- 4a. Theme toggle button ---------- */
.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 1.25rem;
    transition: transform var(--transition), border-color var(--transition),
        color var(--transition), background-color var(--transition);
    position: relative;
    overflow: hidden;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: rotate(15deg);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    transition: transform 0.4s ease, opacity 0.3s ease;
}

/* Show sun in dark mode, moon in light mode */
.theme-toggle .icon-sun {
    display: none;
}

.theme-toggle .icon-moon {
    display: block;
}

.dark-mode .theme-toggle .icon-sun {
    display: block;
}

.dark-mode .theme-toggle .icon-moon {
    display: none;
}

/* ---------- 4. Hero ---------- */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 8rem 0 4rem;
    background: radial-gradient(circle at 20% 20%, var(--hero-glow-1), transparent 50%),
        radial-gradient(circle at 80% 70%, var(--hero-glow-2), transparent 55%),
        var(--bg);
    overflow: hidden;
}

.hero-container {
    text-align: center;
    max-width: 820px;
}

.hero-greet {
    font-family: var(--font-mono);
    color: var(--accent);
    font-size: 1rem;
    margin-bottom: 1rem;
    animation: fadeInUp 0.8s ease both;
}

.hero-name {
    font-size: clamp(2.4rem, 6vw, 4.2rem);
    line-height: 1.1;
    font-weight: 800;
    margin-bottom: 0.75rem;
    animation: fadeInUp 0.8s ease 0.1s both;
}

.accent {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero-role {
    font-size: clamp(1.1rem, 2.2vw, 1.5rem);
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 1.4rem;
    animation: fadeInUp 0.8s ease 0.2s both;
}

.hero-desc {
    color: var(--text-muted);
    font-size: 1.05rem;
    max-width: 620px;
    margin: 0 auto 2.2rem;
    animation: fadeInUp 0.8s ease 0.3s both;
}

.hero-cta {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    animation: fadeInUp 0.8s ease 0.4s both;
}

.scroll-indicator {
    position: absolute;
    bottom: 2.2rem;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 38px;
    border: 2px solid var(--text-muted);
    border-radius: 14px;
    display: flex;
    justify-content: center;
}

.scroll-indicator span {
    width: 4px;
    height: 8px;
    background: var(--accent);
    border-radius: 2px;
    margin-top: 6px;
    animation: scrollDot 1.6s ease-in-out infinite;
}

/* ---------- 5. Sections (Generic) ---------- */
.section {
    padding: 6rem 0;
}

.section-alt {
    background-color: var(--bg-alt);
}

.section-header {
    text-align: center;
    margin-bottom: 3.5rem;
}

.section-label {
    display: inline-block;
    font-family: var(--font-mono);
    color: var(--accent);
    font-size: 0.85rem;
    letter-spacing: 1px;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
}

.section-title {
    font-size: clamp(1.8rem, 3.5vw, 2.6rem);
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.section-sub {
    color: var(--text-muted);
    max-width: 560px;
    margin: 0 auto;
}

/* Reveal-on-scroll utility */
.reveal {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

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

/* ---------- 6. Journey / Timeline ---------- */
.timeline {
    position: relative;
    max-width: 760px;
    margin: 0 auto;
    padding-left: 2rem;
    border-left: 2px solid var(--border);
}

.timeline-item {
    position: relative;
    margin-bottom: 2.4rem;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -2.6rem;
    top: 0.6rem;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-ring);
}

.timeline-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.4rem 1.6rem;
    transition: transform var(--transition), border-color var(--transition);
}

.timeline-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
}

.timeline-time {
    display: inline-block;
    font-family: var(--font-mono);
    color: var(--accent);
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.timeline-card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.timeline-card p {
    color: var(--text-muted);
}

/* ---------- 7. Skills ---------- */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}

.skill-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 2rem 1.6rem;
    transition: transform var(--transition), border-color var(--transition),
        box-shadow var(--transition);
}

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

.skill-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    background: var(--accent-soft);
    margin-bottom: 1rem;
}

.skill-card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.skill-card p {
    color: var(--text-muted);
    margin-bottom: 1.1rem;
    font-size: 0.95rem;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-list li {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    background: var(--accent-soft);
    color: var(--accent);
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: border-color var(--transition);
}

.tag-list li:hover {
    border-color: var(--accent);
}

.tag-list-sm li {
    font-size: 0.72rem;
    padding: 3px 8px;
}

/* ---------- 8. Projects ---------- */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.6rem;
}

.project-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition), border-color var(--transition),
        box-shadow var(--transition);
}

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

.project-thumb {
    aspect-ratio: 16 / 10;
    background: var(--thumb-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.project-thumb::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: linear-gradient(transparent 95%, var(--grid-line) 95%),
        linear-gradient(90deg, transparent 95%, var(--grid-line) 95%);
    background-size: 22px 22px;
    opacity: 0.6;
}

.project-emoji {
    font-size: 3.4rem;
    z-index: 1;
}

.project-body {
    padding: 1.4rem 1.5rem 1.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    flex: 1;
}

.project-title {
    font-size: 1.2rem;
}

.project-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    flex: 1;
}

/* ---------- 9. Contact ---------- */
.contact-container {
    max-width: 980px;
}

.contact-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 2.5rem;
    align-items: start;
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.form-group input,
.form-group textarea {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.8rem 1rem;
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.contact-form .btn {
    align-self: flex-start;
}

.contact-side h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.contact-side p {
    color: var(--text-muted);
    margin-bottom: 1.2rem;
}

.social-list {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.social-list a {
    display: inline-flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: transform var(--transition), border-color var(--transition),
        color var(--transition);
    font-weight: 500;
}

.social-list a:hover {
    transform: translateX(4px);
    border-color: var(--accent);
    color: var(--accent);
}

.social-icon {
    display: inline-flex;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    border-radius: 8px;
    color: var(--accent);
}

/* ---------- 10. Footer ---------- */
.footer {
    background: var(--bg-alt);
    border-top: 1px solid var(--border);
    padding: 1.8rem 0;
}

.footer-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.back-to-top {
    font-family: var(--font-mono);
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: color var(--transition), border-color var(--transition),
        transform var(--transition);
}

.back-to-top:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: translateY(-2px);
}

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

@keyframes scrollDot {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateY(10px);
        opacity: 0;
    }
}

/* ---------- 12. Responsive ---------- */
@media (max-width: 860px) {
    .contact-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .menu-toggle {
        display: flex;
    }

    .nav-links {
        position: fixed;
        top: 64px;
        right: 1rem;
        left: 1rem;
        flex-direction: column;
        background: var(--menu-bg);
        backdrop-filter: blur(18px) saturate(180%);
        -webkit-backdrop-filter: blur(18px) saturate(180%);
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        padding: 1.2rem;
        gap: 0.8rem;
        opacity: 0;
        transform: translateY(-10px);
        pointer-events: none;
        transition: opacity var(--transition), transform var(--transition);
        box-shadow: 0 18px 40px var(--glass-shadow);
    }

    .nav-links.open {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }

    .nav-links a {
        display: block;
        padding: 6px 4px;
    }

    .section {
        padding: 4.5rem 0;
    }

    .timeline {
        padding-left: 1.6rem;
    }

    .timeline-dot {
        left: -2.2rem;
    }
}

@media (max-width: 480px) {
    .hero-cta {
        flex-direction: column;
        align-items: stretch;
    }

    .btn {
        width: 100%;
    }

    .footer-container {
        justify-content: center;
        text-align: center;
    }
}

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