/* ===========================================
   WILLIAM PAGE - PREMIUM DESIGN SYSTEM
   Refined, Professional, Memorable
   =========================================== */

@import url('https://fonts.googleapis.com/css2?family=Crimson+Text:ital@0;1&family=DM+Sans:wght@400;500;700&display=swap');

:root {
    /* Color Palette - Warm Sophistication */
    --color-bg: #fafaf7;
    --color-bg-alt: #f3f0ed;
    --color-bg-card: #ffffff;

    --color-primary: #d4a574;      /* Warm gold/tan */
    --color-primary-dark: #a88a5f;
    --color-primary-light: #e8d4b8;

    --color-accent: #2c3e50;       /* Deep navy/charcoal */
    --color-accent-light: #475569;

    --color-text: #1a1a18;
    --color-text-muted: #646460;
    --color-text-light: #8b8985;
    --color-border: #e8e5e0;

    /* Typography - Sophisticated Pairing */
    --font-display: 'Crimson Text', Georgia, serif;
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 2rem;
    --space-lg: 4rem;
    --space-xl: 8rem;
    --space-2xl: 12rem;

    /* Layout */
    --container-max: 1200px;
    --nav-height: 80px;

    /* Effects */
    --radius: 4px;
    --radius-lg: 8px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.1);
    --transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===========================================
   RESET & BASE
   =========================================== */

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--nav-height) + 20px);
}

body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.65;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition);
    position: relative;
}

a:hover {
    color: var(--color-primary-dark);
}

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

/* ===========================================
   LAYOUT & GRID
   =========================================== */

.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-md);
}

section {
    padding: var(--space-2xl) 0;
    position: relative;
}

section:nth-child(even) {
    background: var(--color-bg-alt);
}

.section-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 4rem);
    font-weight: 700;
    line-height: 1.2;
    color: var(--color-accent);
    margin-bottom: var(--space-md);
    letter-spacing: -0.02em;
}

.section-subtitle {
    font-size: 1.1rem;
    color: var(--color-text-muted);
    margin-bottom: var(--space-lg);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.section-header {
    margin-bottom: var(--space-xl);
    text-align: center;
}

/* ===========================================
   NAVIGATION
   =========================================== */

.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: rgba(250, 250, 247, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 1000;
    border-bottom: 1px solid var(--color-border);
    transition: all var(--transition);
}

.nav.scrolled {
    background: rgba(250, 250, 247, 0.98);
    box-shadow: var(--shadow-sm);
}

.nav-content {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-md);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--color-accent);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color var(--transition);
}

.nav-logo .logo-name {
    color: var(--color-accent);
}

.nav-logo .logo-accent {
    color: var(--color-primary);
    font-weight: 400;
}

.nav-logo:hover {
    color: var(--color-primary);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    list-style: none;
}

.nav-links a {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text-muted);
    transition: color var(--transition);
    letter-spacing: 0.01em;
}

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

.nav-cta {
    background: var(--color-primary);
    color: white !important;
    padding: var(--space-xs) 1.2rem;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 0.9rem;
    transition: all var(--transition);
}

.nav-cta:hover {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-xs);
}

.nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--color-text);
    transition: all var(--transition);
}

/* ===========================================
   HERO SECTION
   =========================================== */

.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding-top: var(--nav-height);
    background: linear-gradient(135deg, var(--color-bg) 0%, var(--color-bg-alt) 100%);
    padding-bottom: var(--space-2xl);
}

.hero {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: var(--space-xl);
    padding: var(--nav-height) var(--space-md) var(--space-2xl);
}

.hero-content {
    max-width: 600px;
}

.hero-badge {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--color-primary);
    margin-bottom: var(--space-md);
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-primary-light);
    border-radius: var(--radius-lg);
    animation: fadeInUp 0.8s ease 0.2s both;
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(3rem, 8vw, 5.5rem);
    font-weight: 700;
    line-height: 1.1;
    color: var(--color-accent);
    margin-bottom: var(--space-md);
    letter-spacing: -0.03em;
    animation: fadeInUp 0.8s ease 0.3s both;
}

.hero-subtitle {
    font-size: 1.2rem;
    line-height: 1.7;
    color: var(--color-text-muted);
    margin-bottom: var(--space-lg);
    max-width: 550px;
    animation: fadeInUp 0.8s ease 0.4s both;
}

.hero-cta {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
    animation: fadeInUp 0.8s ease 0.5s both;
}

.hero-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeInUp 0.8s ease 0.6s both;
}

.hero-stat-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: var(--space-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    width: 100%;
    max-width: 350px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--color-border);
}

.stat-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.stat-label {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-primary);
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-accent);
}

/* ===========================================
   BUTTONS
   =========================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-lg);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    letter-spacing: 0.01em;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    transition: left var(--transition);
    z-index: -1;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: transparent;
    color: var(--color-accent);
    border: 2px solid var(--color-accent);
}

.btn-secondary:hover {
    background: var(--color-accent);
    color: white;
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

/* ===========================================
   ABOUT SECTION
   =========================================== */

.about-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.about-content {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: var(--space-xl);
    align-items: start;
}

.about-text {
    max-width: 700px;
}

.about-lead {
    font-size: 1.25rem;
    line-height: 1.7;
    color: var(--color-text);
    font-weight: 500;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-lg);
    border-bottom: 2px solid var(--color-primary-light);
}

.about-section {
    margin-bottom: var(--space-lg);
}

.about-section h3 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--color-accent);
    margin-bottom: var(--space-sm);
    font-weight: 700;
}

.about-section p {
    color: var(--color-text-muted);
    line-height: 1.8;
}

.about-highlights {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.highlight-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    text-align: center;
    transition: all var(--transition);
    cursor: pointer;
}

.highlight-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-4px);
}

.highlight-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-sm);
}

.highlight-card h4 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--color-accent);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.highlight-card p {
    font-size: 0.95rem;
    color: var(--color-text-muted);
    margin: 0;
}

/* ===========================================
   SERVICES SECTION
   =========================================== */

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--space-lg);
}

/* Smart responsive behavior based on card count */
/* 4 cards: 2x2 grid */
.services-grid:has(> :nth-child(4):last-child) {
    grid-template-columns: repeat(2, 1fr);
}

/* 5 cards: 3 columns with last 2 cards centered in bottom row */
.services-grid:has(> :nth-child(5):last-child) {
    grid-template-columns: repeat(3, 1fr);
}

.services-grid:has(> :nth-child(5):last-child) > :nth-child(4) {
    grid-column: 1 / 2;
}

.services-grid:has(> :nth-child(5):last-child) > :nth-child(5) {
    grid-column: 2 / 3;
}

/* 6 cards: 3x2 grid */
.services-grid:has(> :nth-child(6):last-child) {
    grid-template-columns: repeat(3, 1fr);
}

.service-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.service-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--color-primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition);
}

.service-card:hover::before {
    transform: scaleX(1);
}

.service-card:hover {
    border-color: var(--color-primary-light);
    box-shadow: var(--shadow-lg);
    transform: translateY(-6px);
}

.service-number {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 700;
    color: var(--color-primary-light);
    margin-bottom: var(--space-sm);
    line-height: 1;
}

.service-card h3 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--color-accent);
    margin-bottom: var(--space-sm);
    font-weight: 700;
}

.service-card p {
    color: var(--color-text-muted);
    margin-bottom: var(--space-md);
    flex-grow: 1;
    line-height: 1.8;
}

.service-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.service-tags span {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
    background: var(--color-primary-light);
    color: var(--color-accent);
    border-radius: 20px;
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.01em;
}

/* ===========================================
   PORTFOLIO SECTION
   =========================================== */

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: var(--space-lg);
}

.portfolio-card {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    overflow: hidden;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
}

.portfolio-card:hover {
    border-color: var(--color-primary);
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}

.portfolio-image {
    aspect-ratio: 16 / 10;
    background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-bg-alt) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.portfolio-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition);
}

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

.portfolio-image-placeholder {
    color: var(--color-primary);
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
}

.portfolio-content {
    padding: var(--space-lg);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.portfolio-card h3 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    color: var(--color-accent);
    margin-bottom: var(--space-sm);
    font-weight: 700;
}

.portfolio-card p {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    margin-bottom: var(--space-md);
    line-height: 1.8;
    flex-grow: 1;
}

.portfolio-tech {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: var(--space-md);
}

.portfolio-tech span {
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-primary-light);
    color: var(--color-primary);
    border-radius: 20px;
    font-weight: 600;
}

.portfolio-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--color-primary);
    transition: all var(--transition);
}

.portfolio-link::after {
    content: '→';
    transition: transform var(--transition);
}

.portfolio-link:hover::after {
    transform: translateX(4px);
}

.portfolio-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--space-2xl);
    color: var(--color-text-muted);
}

/* ===========================================
   CONTACT SECTION
   =========================================== */

.contact-wrapper {
    max-width: 900px;
    margin: 0 auto;
}

.contact-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.contact-intro {
    font-size: 1.15rem;
    color: var(--color-text-muted);
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.8;
}

.contact-content {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-md);
}

.contact-info {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-lg);
}

/* Adjust to 2 columns when social links are not available */
.contact-info:has(#contact-social-item[style*="display: none"]) {
    grid-template-columns: 1fr 1fr;
}

.contact-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.contact-label {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-primary);
}

.contact-value {
    font-size: 1rem;
    color: var(--color-accent);
    font-weight: 600;
    transition: color var(--transition);
}

.contact-value:hover {
    color: var(--color-primary);
}

.contact-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.contact-link {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0;
    color: var(--color-accent);
    font-weight: 500;
    transition: all var(--transition);
}

.contact-link:hover {
    color: var(--color-primary);
    transform: translateX(4px);
}

/* ===========================================
   FOOTER
   =========================================== */

.footer {
    padding: var(--space-lg) 0;
    border-top: 1px solid var(--color-border);
    text-align: center;
    background: var(--color-bg-alt);
}

.footer-content p {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    margin: 0.5rem 0;
}

.footer-accent {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-primary);
    letter-spacing: 0.05em;
}

/* ===========================================
   ANIMATIONS
   =========================================== */

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

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

.fade-in {
    animation: fadeInUp 0.7s ease forwards;
}

.scroll-reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ===========================================
   RESPONSIVE
   =========================================== */

@media (max-width: 1024px) {
    .hero {
        grid-template-columns: 1fr;
        padding: var(--nav-height) var(--space-md) var(--space-xl);
    }

    .hero-visual {
        order: -1;
        margin-bottom: var(--space-lg);
    }

    .about-content {
        grid-template-columns: 1fr;
    }

    .about-highlights {
        grid-template-columns: 1fr 1fr;
    }

    .contact-info {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    :root {
        --space-xl: 5rem;
        --space-2xl: 6rem;
        --nav-height: 70px;
    }

    body {
        font-size: 15px;
    }

    .section-title {
        font-size: clamp(2rem, 5vw, 3rem);
    }

    .nav-links {
        position: fixed;
        top: var(--nav-height);
        left: 0;
        right: 0;
        background: var(--color-bg);
        flex-direction: column;
        padding: var(--space-md);
        gap: var(--space-sm);
        border-bottom: 1px solid var(--color-border);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition);
    }

    .nav-links.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    .nav-toggle {
        display: flex;
    }

    .nav-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .nav-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .nav-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }

    .hero-cta {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .about-highlights {
        grid-template-columns: 1fr;
    }

    .services-grid {
        grid-template-columns: 1fr;
    }

    /* Reset smart grid on mobile */
    .services-grid:has(> :nth-child(4):last-child),
    .services-grid:has(> :nth-child(5):last-child),
    .services-grid:has(> :nth-child(6):last-child) {
        grid-template-columns: 1fr;
    }

    .services-grid:has(> :nth-child(5):last-child) > :nth-child(4),
    .services-grid:has(> :nth-child(5):last-child) > :nth-child(5) {
        grid-column: auto;
    }

    .portfolio-grid {
        grid-template-columns: 1fr;
    }

    .hero-stat-card {
        max-width: 100%;
    }

    .contact-info {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .contact-links {
        align-items: center;
    }
}

@media (max-width: 480px) {
    :root {
        --space-md: 1.5rem;
        --space-lg: 2.5rem;
        --space-xl: 3.5rem;
        --nav-height: 65px;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .service-number {
        font-size: 2.5rem;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    section {
        padding: var(--space-xl) 0;
    }
}

/* ===========================================
   ACCESSIBILITY & REDUCED MOTION
   =========================================== */

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===========================================
   PRINT STYLES
   =========================================== */

@media print {
    .nav,
    .hero-cta,
    .contact {
        display: none;
    }

    body {
        color: black;
        background: white;
    }

    a {
        text-decoration: underline;
    }
}
