/* ===== 1. CSS Reset ===== */

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

/* Remove default margin */
* {
    margin: 0;
    padding: 0;
}

/* Enable keyboard animations */
@media (prefers-reduced-motion: no-preference) {
    html {
        interpolate-size: allow-keywords;
    }
}

body {
    line-height: 1.5;   /* Add accessible line height */
    -webkit-font-smoothing: antialiased;    /* Improve text rendering */
}

/* Improve media defaults */
img, picture, video, canvas, svg {
    display: block;
    max-width: 100%;
}

/* Inherit fonts for form controls */
input, button, textarea, select {
    font: inherit;
    color: inherit;
    background: none;
}

/* Avoid text overlays */
p, h1, h2, h3, h4, h5, h6 {
    overflow-wrap: break-word;
}

/* Improve line wrapping */
p {
    text-wrap: pretty;
}

h1, h2, h3, h4, h5, h6 {
    text-wrap: balance;
}

/* Create root stacking context */
#root, #__next {
    isolation: isolate;
}

/* ===== 2. Variables (Custom Properties) ===== */

:root {
    /* Colour Variables */
    --clr-bg: #000000;
    --clr-text: #ffffff;
    --clr-accent: #8890FF;
    --clr-secondary-text: #CED0CE;
    --clr-card-bg: #1D1D1D;
    --clr-border: #2C2C2C;
    --clr-inactive: #767676;
    --clr-hover: #4B53C2;
    --clr-active: #7C83F0;
    --clr-shadow: rgba(136, 144, 255, 0.25);

    /* Typography Variables */
    --font-heading: 'Archivo', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Spacing and sizing variables */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 2rem;
    --spacing-lg: 4rem;
    --spacing-xl: 6rem;

    --max-width: 1200px;
    --border-radius: 0.5rem;
}

/* ===== 3. Global Styles ===== */

/* Set base font, background, and colour styles */
html, body {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    background-color: var(--clr-bg);
    color: var(--clr-text);
    scroll-behavior: smooth;
}

/* Enable sticky footer layout */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Allow main to fill remaining space */
main {
    flex: 1;  /* Grow and fill space between header & footer */

    /* Add top spacing to the main content to avoid overlap with the fixed header  */
    margin-top: 80px;
}

/* Typography: use heading font for all heading levels */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--clr-text);
}

/* Set line height for larger headings */
h1, h2, h3 { 
    line-height: 1.2;
}

/* Set line height for smaller headings */
h4, h5, h6 {
    line-height: 1.4;
}

/* Heading sizes */
h1 { font-size: 2.5rem; }  /* 40px */
h2 { font-size: 2.25rem; }   /* 36px */
h3 { font-size: 1.25rem; }    /* 20px */
h4 { font-size: 1.125rem; }  /* 18px */
h5 { font-size: 1.125rem; } /* 18px */
h6 { font-size: 1.125rem; } /* 18px */

/* Paragraph styling */
p {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--clr-secondary-text);
    margin-bottom: 1rem;
}

/* Inline text styles */
strong { font-weight: 600; }
em { font-style: italic; }

/* Link styling with hover and focus states */
a {
    text-decoration: none;
    color: var(--clr-text);
    transition: all 0.2s ease;
}

a:hover {
    color: var(--clr-hover);
    cursor: pointer;
}

a:focus {
    text-decoration: underline;
    outline: 2px solid var(--clr-accent);
    outline-offset: 4px;
}

/* Remove default list styles */
ul, ol, li {
    list-style-type: none;
}

/* Responsive image display */
img {
    max-width: 100%;
    display: block;
}

/* Reset button to inherit font and enable cursor pointer */
button {
    font: inherit;
    cursor: pointer;
}

/* Form field styling */
input, textarea, select {
    border: 1px solid var(--clr-card-bg);
    border-radius: 0.5rem;
    padding: 0.75rem;
    color: var(--clr-text);
    outline: none;
}

/* Add visible focus outline for accessibility */
input:focus, textarea:focus, select:focus {
    outline: 2px solid var(--clr-accent);
}

/* Container layout utility */
.container {
    max-width: 1200px;
    margin: 32px auto;
    padding: 0 1rem;
}

/* Utility classes */

.text-center {
    text-align: center;
}

/* Subtle text stye for section intros or supportive copy */
.muted-text {
    color: var(--clr-secondary-text);
}

/* Base styles for individual service cards:
   Use flex column layout, padding, background-color, and border border */
.custom-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-color: var(--clr-card-bg);
    border: 1px solid var(--clr-border);
    border-radius: var(--border-radius);
    padding: 24px;
}

.custom-card:hover {
    border: 1px solid var(--clr-hover);
}

.card-btn {
    border: none;
    background-color: none;
    color: var(--clr-accent);
}

.card-btn:hover, .card-btn:focus {
    color: var(--clr-hover);
}

/* Style card icons:
   Emphasise the size and accent colour */
.custom-card i {
    font-size: 2rem;
    color: var(--clr-accent);
    background-color: var(--clr-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    width: 64px;
    border-radius: 8px;
}

/* Visually hided content but keep it accessible to screen readers */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.focusable:active,
.focusable:focus {
    position: static;
    width: auto;
    height: auto;
    margin: 0.5rem;
    padding: 0.5rem 1rem;
    clip: auto;
    white-space: normal;
    background-color: var(--clr-accent);
    color: var(--clr-text);
    text-decoration: underline;
    z-index: 1000;
}

/* Margin for the section cta buttons */
.section-cta {
    margin-top: 24px;
}

/* ===== 4. Custom Button Styles ===== */

/* Primary CTA button */
.primary-cta {
    background-color: var(--clr-accent);
    border-radius: var(--border-radius);
    text-align: center;
    padding: 8px 16px;
}

/* Hover state for primary CTA button */
.primary-cta:hover {
    font-weight: 600;
    border: 1px solid var(--clr-hover);
    background-color: var(--clr-hover);
    color: var(--clr-text);
}

/* Secondary CTA button (outline style) */
.secondary-cta {
    background-color: transparent;
    border: 1px solid var(--clr-active);
    border-radius: var(--border-radius);
    color: var(--clr-active);
    text-align: center;
    padding: 8px 16px;
}

/* Hover state for secondary CTA button */
.secondary-cta:hover {
    font-weight: 600;
    border: 1px solid var(--clr-accent);
    background-color: var(--clr-accent);
    color: var(--clr-text);
}

.primary-cta:focus,
.secondary-cta:focus {
    outline: 2px solid var(--clr-accent);
    outline-offset: 4px;
    box-shadow: 0 0 0 4px var(--clr-shadow);
}

/* ===== 5. Header Styles ===== */

/* Layout structure for header */
header {
    display: flex;                      /* Align logo and nav horizontally */ 
    justify-content: space-between;     /* Push logo left and menu right */
    align-items: center;                /* verically centre items */
    padding: 16px;                      /* Inner spacing */
    /* Make header fixed so it stays visible at the top whilst scrolling */
    position: fixed;        /* Remove for document flow and pin to view */
    top: 0;                 /* Anchor to top of the viewport */
    left: 0;                /* Align to the left edge of the screen*/
    right: 0;               /* Stretch to right edge of the screen*/
    z-index: 1000;          /* Ensure it appears above all other elements */
    background-color: var(--clr-bg);    /* Stop content from showing through */
}

/* Logo styles */
.logo {
    font-size: 1.25rem;     
    font-weight: 700;
    line-height: 1.2;
}

/* Navigation menu (mobile) - hidden by default */
.nav-bar {
    display: none;
}

/* Style the hamburger button (mobile and tablet) */
.hamburger {
    border: none;       /* Remove default button border */
    background: none;   /* Remove default button background */
    font-size: 30px;    /* Increase icon size for better visibility */
}

/* Show nav bar when toggled open (mobile) */
.nav-bar.open {
    display: block;
    position: absolute;                     /* Position below the header*/
    top: 60px;
    left: 16px;
    right: 16px;
    background-color: var(--clr-card-bg);   /* Matches card background */
    padding: 16px;
    border-radius: var(--border-radius);
    z-index: 100;                           /* Ensure it overlays content */
}

/* Navigation link styles */
#main-nav a {
    display: block;         /* Make links fulll width on mobile */
    font-size: 1.125rem;
    font-weight: 500;
}

/* Navigation list item spacing */
#main-nav li {
    margin: 0.8rem 0;       /* Vertical spacing between items */
    padding: 0.5rem;
}

/* Active link indicator */
.active {
    color: var(--clr-active);       /* Use active colour for current page */
}

/* ===== 6. Footer Styles ===== */

/* Footer container layout */
footer {
    display: flex;
    flex-direction: column;     /* Stack content vertically on mobile */
    gap: 12px;                  /* Space between sections */
    padding: 16px;              /* Inner padding */
}

/* Icon spacing next to logo text */
footer .logo i {
    margin-right: 6px;
}

/* Stack newsletter form fields, and nav lists */
.newsletter-signup form,
footer nav {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Add border and spacing below subscribe button */
.newsletter-signup form .primary-cta {
    border: 1px solid var(--clr-active);    /* Match footer's accent */
    margin-bottom: 16px;
}

/* Set consistent height for email input field */
.newsletter-signup form input {
    height: 39px;
}

/* Display social icons in a row with spacing */
footer .social-links ul {
    display: flex;
    gap: 16px;
    margin: 16px 0;
}

/* Add spacing above legal links section */
.bottom-footer {
    margin-top: 20px;
}

/* ===== HERO STYLES ===== */

/* Hero styles */
#hero {
    /* Outer padding to prevent content touching the edges */
    padding: 16px 16px;
}

.hero-content-container {
    /* Enables background layering and prevents overflow clipping*/
    position: relative;
    overflow: hidden;
    padding: 24px 16px;
}

.hero-bg {
    /* Full cover background image placed behaind the content */
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url(../assets/images/coding-station.webp);
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    z-index: 1;
}

.hero-text {
    /* Brings text above the background */
    position: relative;
    z-index: 2;
    padding: 24px 0;
    /* Centre's the content   */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 24px;
    max-width: 600px;
    margin: 0 auto; /* Horizontally centre text container */
}

.hero-btns {
    /* Ensure button container spans the width of the text container */
    width: 100%;
}

.hero-btns ul {
    /* Stack buttons vertically with spacing */
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.hero-btns li {
    /* Ensure list items fill available width */
    display: block;
    width: 100%;
}

.hero-btns a {
    /* Force buttons to stretch across full width of the container */
    display: block;
    width: 100%;
}

/* ===== Home page Services Cards ===== */

/* Layout for the card container:
   Stacks vertically on mobile with 24px gap between */
.services-card-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Smooth tranistion for icon colour and background colour on hover */
.custom-card i {
    transition: color 0.2s ease, background-color 0.2s ease;
}

/* On card hover, update icon styling for interactive visual feedback */
.services-card-container .custom-card:hover i {
    background-color: var(--clr-accent);
    color: var(--clr-text);
}

/* ===== Featured Projects Styles ===== */

/* Grid layout for project cards */
.featured-project-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 32px;
}

/* Individual project cards styles */
.project-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-color: var(--clr-card-bg);
    border: 1px solid var(--clr-border);
    border-radius: var(--border-radius);
    transition: border-color 0.2s ease-in-out;
}

.project-card:hover, .project-card:focus, .card-border {
    border: 1px solid var(--clr-hover);
}

/* Card content */
.content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 24px;
}

/* Project image and hover FX */
.image-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(to bottom, #000000 0%, #1d1d1d 40%, #636ae8 100%);
    border-top-left-radius: var(--border-radius);
    border-top-right-radius: var(--border-radius);
    width: 100%;
    height: 200px;
    overflow: hidden;
}

.image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: scale-down;
    transform: scale(1);        /* Initial state */
    transition: transform 0.5s ease-in-out;
}

.project-card:hover img {
    transform: scale(1.3);      /* Zoom on hover */
}

/* Hover buttons on image */
.hover-btns-container {
    position: absolute;
    bottom: 16px;
    left: 16px;
    display: none;
}

.hover-btns-container {
    background: rgba(0, 0, 0, 0.6);
}

.primary-hover-btn, .secondary-hover-btn {
    color: var(--clr-text) !important;
    border: none;
    border-radius: var(--border-radius);
    text-align: center;
    padding: 8px 16px;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.primary-hover-btn {
    background-color: var(--clr-accent);
}

.secondary-hover-btn {
    background-color: var(--clr-bg);
    margin-left: 8px;
}

.primary-hover-btn:hover {
    background-color: var(--clr-hover);
    font-weight: 600;
}

.secondary-hover-btn:hover {
    background-color: var(--clr-border);
    font-weight: 600;
}

/* Link styling in card */
.project-card a {
    color: var(--clr-accent);
    transition: color 0.2s ease-in-out;
}

.project-card a:hover {
    color: var(--clr-hover);
}

/* ===== Tech Stack Styles ===== */

/* Tech stack icon styling */
.icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    margin-right: 48px;
}

/* Wrapper - acts as the viewport */
.scrolling-wrapper {
    overflow-x: hidden;
    width: 100%;
    margin-top: 2rem;
}

/* Scrolling wrapper icons list */
.scrolling-track {
    display: flex;
    width: max-content;
    min-width: 200%;
    animation: scroll-left 15s linear infinite;
    will-change: transform;
}

.scrolling-wrapper:hover .scrolling-track {
    animation-play-state: paused;
}

.icon-html5 {
    fill: #E34F26;
}

@keyframes scroll-left {
    0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    transform: translate3d(-50%, 0, 0);
  }
}

/* ===== Contact CTA Section */

/* Outer wrapper for the CTA section with background animation and centred content */
.contact-cta-wrapper {
    position: relative;
    width: 100%;
    height: 400px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* CTA text and buttons content */
.cta-content {
    position: relative;
    z-index: 1;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.pulsing-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.grid-bg {
    width: 100%;
    height: 100%;
    background-color: var(--clr-card-bg);
    border-radius: var(--border-radius);
}

.pulse {
    fill: var(--clr-accent);
    opacity: 0.6;
    animation: pulse 2.5s ease-in-out infinite;
}

.pulse:nth-of-type(2) { 
    animation-delay: 0.3s; 
}

.pulse:nth-of-type(3) { 
    animation-delay: 0.6s; 
}

.pulse:nth-of-type(4) { 
    animation-delay: 0.9s; 
}

.pulse:nth-of-type(5) { 
    animation-delay: 1.2s; 
}

.pulse:nth-of-type(6) { 
    animation-delay: 1.5s; 
}
.pulse:nth-of-type(7) { 
    animation-delay: 1.8s; 
}
.pulse:nth-of-type(8) { 
    animation-delay: 2.1s; 
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.5;
        r: 6;
    }

    50% {
        opacity: 1;
        r: 10;
    }
}

/* ===== Media Queries ===== */

/* Tablet view and up (min-width: 768px)*/
@media (min-width: 768px) {
    /* Centre align logo anf newsletter */
    .logo,
    .newsletter-signup {
        text-align: center;
    }

    /* Arrange input and button side by side */
    .newsletter-signup form {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: baseline;
    }

    /* Expand input to fill the space, max 332px */
    .newsletter-signup form input {
        flex-grow: 1;
        max-width: 332px;
    }

    /* Align bottom footer sections horizontally */
    .bottom-footer {
        display: flex;
        justify-content: space-between;
        gap: 2rem;
        flex-wrap: wrap;
    }

    /* Move social media buttons to the beginning and enlarge */
    .social-links {
        order: -1;
        font-size: 24px;
        margin-top: 0;
    }

    /* Override full-width buttons for larger screens */
    .hero-btns,
    .hero-btns li {
        width: auto;        /* Allow buttons to size based on content */
    }

    /* Arrange hero buttons side by side */
    .hero-btns ul {
        flex-direction: row;    /* Horizontal button layout */
    }

    /* Switch to horizontal layout, and allow wrapping for a 2x2 grid */
    .services-card-container {
        flex-direction: row;
        flex-wrap: wrap;
    }

    /* Each card takes up approximately half the width of the container, allowing 2 per row */
    .custom-card {
        flex: 1 1 48%;      /* Grow/shrink as needed, basis of 48% to account   for gap/margins */
    }
}

/* Desktop view and up (min-width: 960px) */
@media (min-width: 960px) {
    /* Increase padding around the header content */
    header {
        padding: 1rem 4rem;
    }
    
    /* Show nav bar inline */
    .nav-bar {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        gap: 20px;
    }

     /* Hide hamburger toggle */
    .hamburger {
        display: none;
    }

    /* Arrange service cards in a single row on desktop screens */
    .services-card-container {
        flex-wrap: nowrap;
    }

    /* Set card to occupy approxiately 1/4 of the row */
    .custom-card {
        flex: 1 1 22%;
    }
}

/* Show on hover for devices with pointer (desktop) */
@media (hover: hover) and (pointer: fine) {
  .project-card:hover .hover-btns-container {
    display: block;
  }
}

/* Show when .show-btns is toggled on (mobile) */
@media (hover: none) and (pointer: coarse) {
  .project-card .hover-btns-container.show-btns {
    display: block;
  }
}