/* Modern CSS Reset and Base Styles */
:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --text-color: #1f2937;
    --light-text: #f3f4f6;
    --background-light: #ffffff;
    --background-dark: #111827;
    --transition-speed: 0.3s;
}

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

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

body {
    margin: 0;
    padding: 0;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-color);
    overflow-x: hidden;
}

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

/* Typography */
:root {
    --primary-bg: rgba(22, 27, 34, 0.975);
    --scrolled-bg: rgba(22, 27, 34, 0.9);
    --text-light: #fff;
    --text-dark: #000;
    --link-hover: #00bcd4;
    --home-bg: #f4f4f4;
}

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

.open-sans-strong {
    font-family: "Open Sans", sans-serif;
    font-weight: 700;
    font-style: normal;
}

.open-sans-regular {
    font-family: "Open Sans", sans-serif;
    font-weight: 400;
    font-style: normal;
}

/* Header and Navigation */
header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    color: var(--text-light);
    padding: 1rem 2rem;
    background: rgba(17, 24, 39, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: background 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.transparent-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--light-text);
    text-decoration: none;
    transition: color var(--transition-speed), transform var(--transition-speed);
}

.logo:hover {
    color: var(--primary-color);
    transform: translateY(-2px);
}

.transparent-navbar-links {
    display: flex;
    gap: 1rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.transparent-navbar-links a {
    color: var(--light-text);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-speed);
    padding: 0;
    background: none;
    border: none;
}

.transparent-navbar-links a:hover {
    color: var(--primary-color);
}

#home-start {
    height: 30vh;
    font-size: 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-light);
}

#home-info {
    height: 10vh;
    font-size: 20px;
    display: flex;
    flex-direction: column;
    justify-content: left;
    align-items: left;
    color: var(--text-dark);
}

section {
    padding: 100px 20px;
}

/* Header Scroll Effect */
header.scrolled {
    background: rgba(17, 24, 39, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.home-background-image {
    background-color: var(--home-bg);
    background-image: url('../assets/breck-pano.jpg');
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
    background-position: center; 
    width: 100%; /* Avoid 100vw to prevent horizontal scrollbars on mobile */
    height: auto; /* Height adjusts dynamically */
    min-height: 100vh; /* Ensures it covers at least the viewport height */
}

body {
    margin: 0;
    padding: 0;
}

.transparent-navbar-links li a {
    text-decoration: none;
    color: var(--light-text);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: all var(--transition-speed);
}

.transparent-navbar-links li a:hover {
    color: var(--primary-color);
    background: rgba(255, 255, 255, 0.1);
}

/* Hero Section */
.home-background-image {
    background-color: var(--background-dark);
    background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('../assets/breck-pano.jpg');
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
    background-position: center;
    min-height: 100vh;
    min-height: 100svh; /* iOS Safari viewport units */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

#home-start {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
}

#home-start h1 {
    font-size: clamp(2rem, 6vw, 4rem);
    margin-bottom: 2rem;
    color: var(--light-text);
    animation: fadeInUp 1s ease;
}

/* Typing Animation Styles */
.typing-container {
    font-size: 1.5rem;
    color: var(--light-text);
    opacity: 0.9;
    margin-bottom: 1.5rem;
    line-height: 1.6;
    display: inline-block; /* Keep inline flow so the cursor aligns with the last line */
    text-align: center;
    min-height: 1.6em; /* reserve at least one line of height */
    white-space: normal; /* allow wrapping */
    word-break: break-word;
    overflow-wrap: anywhere;
    max-width: min(90vw, 800px);
}

#typing-text {
    display: inline-block;
}

#welcome-typing-text {
    display: inline; /* ensure cursor sits inline with the text */
}

.cursor {
    display: inline-block;
    color: var(--light-text);
    font-weight: bold;
    animation: blink 1s infinite;
    margin-left: 2px;
    vertical-align: baseline; /* align with text baseline even when text wraps */
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

#home-start p {
    font-size: 1.5rem;
    color: var(--light-text);
    opacity: 0.9;
    animation: fadeInUp 1s ease 0.2s;
    animation-fill-mode: both;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

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

/* Footer */
footer {
    background: var(--primary-bg);
    color: var(--text-light);
    text-align: center;
    padding: 1rem;
    position: relative;
    z-index: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
    .transparent-navbar {
        flex-direction: column;
        gap: 1rem;
    }

    .transparent-navbar-links {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    #home-start h1 {
        font-size: clamp(1.75rem, 7vw, 2.5rem);
    }

    #home-start p {
        font-size: 1.2rem;
    }

    /* Make parallax backgrounds behave on mobile */
    .home-background-image {
        background-attachment: scroll;
    }
    #about::before {
        background-attachment: scroll;
    }

    /* Comfortable spacing */
    .container {
        padding: 3rem 1rem;
    }

    .typing-container {
        font-size: 1.2rem;
    }
}

/* Scroll Behavior */
html {
    scroll-behavior: smooth;
}

/* Account for fixed header when scrolling to anchors */
section {
    scroll-margin-top: 80px;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 4rem 2rem;
}

/* Section Styles */
section {
    padding: 4rem 0;
}

section h2 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: var(--text-color);
    text-align: center;
}

/* Ensure gradient text headings are centered */
section h2.gradient-text {
    display: block;
    text-align: center;
}

/* About Section */
#about {
    background-color: var(--background-light);
    position: relative;
    overflow: hidden;
    z-index: -1;
}

#about::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('../assets/cardiff-sunset.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    opacity: 0.9;
    z-index: -1;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
}

#about .container {
    position: relative;
    z-index: 2;
    margin: 2rem auto;
    max-width: 1000px;
}

#about h2 {
    color: #1a1a1a;
    margin-bottom: 2rem;
    padding-top: 1rem;
    font-size: 2.5rem;
}

#about p {
    font-size: 1.4rem;
    line-height: 1.8;
    color: #1a1a1a;
    margin: 0 auto;
    padding: 0 2rem 2rem;
    max-width: 800px;
    text-align: center;
}

/* Projects Section */
#projects {
    background-color: #0d1117;
    color: #c9d1d9;
}

/* GitHub Stats Section */
.github-stats-section {
    margin-top: 4rem;
    text-align: center;
}

.github-stats-section h3 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: #c9d1d9;
    font-weight: 600;
}

.github-stats-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    max-width: 500px;
}

.github-stats-image {
    max-width: 100%;
    height: auto;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: block;
}

.github-stats-image:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.4);
}

@media (max-width: 768px) {
    .github-stats-section {
        margin-top: 3rem;
    }
    
    .github-stats-section h3 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }
}

#projects h2,
#projects h3,
#projects p {
    color: #c9d1d9;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 0;
}

/* Gradient Text Animation (inspired by ReactBits GradientText) */
.gradient-text {
    display: inline-block;
    background: linear-gradient(90deg, 
        #667eea 0%, #764ba2 10%, #f093fb 20%, #f5576c 30%, #4facfe 40%,
        #667eea 50%, #764ba2 60%, #f093fb 70%, #f5576c 80%, #4facfe 90%,
        #667eea 100%
    );
    background-size: 300% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: #667eea; /* Fallback color */
    animation: gradient-shift 12s linear infinite;
    text-align: center;
    width: 100%;
}

/* Shiny Text Animation (inspired by ReactBits ShinyText) */
.shiny-text {
    position: relative;
    display: inline-block;
    background: linear-gradient(90deg, 
        #9b9fa6 0%,
        #4a5568 20%,
        #2d3748 50%,
        #4a5568 80%,
        #9b9fa6 100%
    );
    background-size: 300% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: #4a5568; /* Fallback color */
    animation: shiny-sweep 15s ease-out infinite;
}

/* Gradient direction variants */
.gradient-text.scroll-right {
    animation: gradient-shift-right 12s linear infinite;
}

.gradient-text.scroll-left {
    animation: gradient-shift-left 12s linear infinite;
}

/* Speed variants */
.gradient-text.speed-slow {
    animation-duration: 20s;
}

.gradient-text.speed-normal {
    animation-duration: 12s;
}

.gradient-text.speed-fast {
    animation-duration: 6s;
}

/* Default direction (left-to-right) for backward compatibility */
@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    100% { background-position: 150% 50%; }
}

/* Right-to-left scrolling */
@keyframes gradient-shift-right {
    0% { background-position: 150% 50%; }
    100% { background-position: 0% 50%; }
}

/* Left-to-right scrolling */
@keyframes gradient-shift-left {
    0% { background-position: 0% 50%; }
    100% { background-position: 150% 50%; }
}

@keyframes shiny-sweep {
    0% { background-position: 300% 0; }
    83% { background-position: -100% 0; }
    100% { background-position: -100% 0; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .gradient-text { animation: none; }
    .shiny-text { animation: none; }
}

.project-card {
    background-color: #161b22;
    border: 1px solid #30363d;
    text-decoration: none;
    color: #c9d1d9;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 200px;
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15);
    border-color: #58a6ff;
}

.project-image {
    padding: 1rem;
    background: transparent;
    border-bottom: 1px solid #30363d;
}

.repo-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.repo-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: #58a6ff;
    text-decoration: none;
    line-height: 1.3;
    word-break: break-word;
    flex: 1;
}

.repo-stats {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #8b949e;
    white-space: nowrap;
}

.stars {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.project-info {
    padding: 1rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.repo-description {
    margin: 0 0 1rem 0;
    color: #c9d1d9;
    font-size: 0.9rem;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.repo-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: #8b949e;
    gap: 1rem;
}

.language {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
}

.language-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.updated {
    font-size: 0.75rem;
    white-space: nowrap;
}

/* Loading and Error States */
.loading-projects,
.projects-error {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    color: #c9d1d9;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #30363d;
    border-top: 3px solid #58a6ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.projects-error a {
    color: #58a6ff;
    text-decoration: none;
}

.projects-error a:hover {
    text-decoration: underline;
}

/* Responsive Design for Projects */
@media (max-width: 480px) {
    .projects-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 1rem 0;
        max-width: 100%;
    }
    
    .project-card {
        max-width: 100%;
    }
    
    .repo-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .repo-stats {
        align-self: flex-end;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
        padding: 1.5rem 0;
    }
    
    .project-card {
        max-width: 100%;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .projects-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
        max-width: 900px;
    }
}

@media (min-width: 1025px) {
    .projects-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
        max-width: 1200px;
    }
}

/* Legacy styles for compatibility */
.project-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    transition: transform 0.3s ease;
}

.striker-icon {
    filter: brightness(0) invert(1);
}

.project-card:hover .project-image img {
    transform: scale(1.05);
}

.project-info h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
    color: #c9d1d9;
}

.project-info p {
    margin: 0;
    color: #c9d1d9;
    font-size: 1rem;
    line-height: 1.5;
}

/* Gallery Section */
#gallery {
    background-color: var(--background-light);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    padding: 2rem 0;
}

/* Animations */
.fade-in-element {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

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

/* Mobile Navigation */
.mobile-nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--light-text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

@media (max-width: 768px) {
    .mobile-nav-toggle {
        display: block;
    }

    .transparent-navbar-links {
        display: none;
        width: 100%;
        text-align: center;
    }

    .transparent-navbar-links.active {
        display: flex;
        flex-direction: column;
    }

    .mobile-nav-toggle.active {
        color: var(--primary-color);
    }
}

/* Subtitle */
.subtitle {
    font-size: 1.2rem !important;
    margin-top: 1rem;
    opacity: 0.8;
}

/* Scroll Progress Indicator */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary-color);
    transform-origin: 0 50%;
    transform: scaleX(0);
    transition: transform 0.2s ease;
    z-index: 1001;
}

/* Project Page Styles */
.project-content {
    padding-top: 80px;
    min-height: 100vh;
    background-color: var(--background-light);
}

.project-content h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: var(--text-color);
}

.project-header {
    display: flex;
    align-items: flex-start;
    gap: 2rem;
    margin-bottom: 3rem;
}

.project-image-container {
    width: 100%;
    max-width: 200px;
    margin: 0;
    background: transparent;
    flex-shrink: 0;
}

.project-hero-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.project-overview {
    flex: 1;
}

.project-overview h1 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 2.5rem;
}

.project-overview h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.project-overview p {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-color);
}

.project-details,
.project-features {
    margin-bottom: 0rem;
}

.project-details h2,
.project-features h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.project-details ul,
.project-features ul {
    list-style-type: none;
    padding: 0;
}

.project-details li,
.project-features li {
    margin-bottom: 0.25rem;
    padding-left: 1.5rem;
    position: relative;
    font-size: 1.1rem;
    line-height: 1.6;
}

.project-details li::before,
.project-features li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--primary-color);
}

.project-link {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 0.5rem;
    transition: background-color 0.3s ease;
}

.project-link:hover {
    background-color: var(--secondary-color);
}

@media (max-width: 768px) {
    .project-header {
        flex-direction: column;
    }

    .project-hero-image {
        width: 100%;
        height: auto;
    }
}

.project-goals {
    margin-bottom: 0rem;
}

.goals-content {
    max-width: 800px;
    margin: 0 auto;
}

.goals-content h2 {
    margin-bottom: 1rem;
    font-size: 2rem;
    line-height: 1.6;
}


.goals-content p {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    line-height: 1.6;
}

.goals-content ul {
    list-style-type: none;
    padding: 0;
}

.goals-content li {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    position: relative;
    font-size: 1.1rem;
    line-height: 1.6;
}

.goals-content li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--primary-color);
}

.project-details-container {
    display: flex;
    gap: 8rem;
    justify-content: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
}

.project-details,
.project-features {
    flex: 1;
    min-width: 350px;
    max-width: 500px;
}

.project-details h2,
.project-features h2 {
    text-align: center;
    margin-bottom: rem;
}

.project-details ul,
.project-features ul {
    list-style-type: none;
    padding: 0;
    margin: 0 auto;
    max-width: 400px;
}

.project-details li,
.project-features li {
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
    position: relative;
    font-size: 1.1rem;
    line-height: 1.6;
}

.project-details li::before,
.project-features li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--primary-color);
}

@media (max-width: 768px) {
    .project-details-container {
        flex-direction: column;
        gap: 2rem;
    }

    .project-details,
    .project-features {
        max-width: 100%;
    }
}

.title-container {
    display: flex;
    align-items: center;
    gap: 2rem;
    margin-bottom: 1rem;
}

.title-container h1 {
    margin: 0;
}

.github-link {
    display: inline-flex;
    align-items: center;
    color: var(--light-text);
    text-decoration: none;
    transition: transform var(--transition-speed), color var(--transition-speed);
    transform: scale(1.5);
    margin-top: 0.25rem;
}

.github-link:hover {
    transform: scale(1.7);
    color: #8b949e;
}

.github-icon {
    width: 24px;
    height: 24px;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.social-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.social-icon {
    color: var(--light-text);
    transition: color var(--transition-speed), transform var(--transition-speed);
}

.social-icon:hover {
    color: var(--primary-color);
    transform: translateY(-2px);
}

.social-icon svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* Project page specific styles */
.project-page {
    background: #0d1117;
    color: var(--text-light);
}

.project-page .project-content {
    background: #0d1117;
}

.project-page h1,
.project-page h2,
.project-page h3,
.project-page p,
.project-page li {
    color: var(--text-light);
}

.project-page .transparent-navbar {
    background: transparent;
    backdrop-filter: none;
}

.project-page .transparent-navbar a {
    color: var(--text-light);
}

.project-page .transparent-navbar a:hover {
    color: #58a6ff;
}

.project-page .social-icon {
    color: var(--text-light);
}

.project-page .social-icon:hover {
    color: #58a6ff;
}

.project-page .container {
    background: #0d1117;
}

.project-page footer {
    background: #0d1117;
    color: var(--text-light);
}