/* Modern CSS Reset and Variables */
:root {
    --color-background: #ffffff;
    --color-text: #1a1a1a;
    --color-text-secondary: #4a4a4a;
    --color-border: #e5e5e5;
    --color-accent: #0066cc;
    --color-card-shadow: rgba(0, 0, 0, 0.1);
    --color-white: #ffffff;
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
                 Roboto, 'Helvetica Neue', Arial, sans-serif,
                 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
    --spacing-base: 1rem;
    --max-width: 960px;
    --breakpoint-desktop: 1024px;
    --breakpoint-tablet: 768px;
    --breakpoint-mobile: 480px;
}

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

html {
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    font-synthesis: none;
}

body {
    font-family: var(--font-sans);
    color: var(--color-text);
    background-color: var(--color-background);
    min-height: 100vh;
    font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1;
    font-kerning: normal;
    text-size-adjust: 100%;
    line-height: 1.5;
}

/* Base list reset and styles */
ul, ol {
    padding-left: 1.5rem;
    margin: 1.5rem 0;
}

/* Custom bullets for unordered lists */
ul {
    list-style: none;
}

ul li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.75em; /* Centers with first line of text */
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background-color: var(--color-accent);
    border-radius: 50%;
}

/* Nested lists */
ul ul {
    margin: 0.75rem 0;
}

ul ul li::before {
    width: 5px;
    height: 5px;
    border: 1px solid var(--color-accent);
    background-color: transparent;
}

/* Third level */
ul ul ul li::before {
    width: 4px;
    height: 4px;
    background-color: var(--color-accent);
    opacity: 0.5;
}

/* Ordered lists */
ol {
    list-style: none;
    counter-reset: custom-counter;
}

ol li {
    position: relative;
    padding-left: 2rem;
    margin-bottom: 0.75rem;
    line-height: 1.6;
    counter-increment: custom-counter;
}

ol li::before {
    content: counter(custom-counter);
    position: absolute;
    left: 0;
    top: 0.25em;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-accent);
}

/* Nested ordered lists */
ol ol {
    margin: 0.75rem 0;
    counter-reset: custom-counter-nested;
}

ol ol li {
    counter-increment: custom-counter-nested;
}

ol ol li::before {
    content: counter(custom-counter) "." counter(custom-counter-nested);
    font-size: 0.8125rem;
}

/* Mixed nesting */
ul ol, ol ul {
    margin: 0.75rem 0;
}

/* Special cases */
.bio ul,
.posts ul {
    margin-bottom: 2rem;
}

/* Mobile optimization */
@media (max-width: 768px) {
    ul, ol {
        padding-left: 1rem;
    }

    ul li,
    ol li {
        padding-left: 1.25rem;
        margin-bottom: 0.5rem;
    }

    ol li::before {
        top: 0.2em;
    }
}

/* High-contrast mode */
@media (prefers-contrast: more) {
    ul li::before {
        width: 8px;
        height: 8px;
        border: 2px solid currentColor;
    }
    
    ol li::before {
        font-weight: 700;
    }
}

/* Print styles */
@media print {
    ul li::before {
        border: 1px solid currentColor;
        background: none;
    }
    
    ol li::before {
        color: currentColor;
    }
}

/* Container */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem;
}

/* Profile Header */
.profile-header {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 2rem 0;
    margin-bottom: 2rem;
}

.profile-image {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--color-white);
    box-shadow: 0 2px 8px var(--color-card-shadow);
    flex-shrink: 0;
}

.profile-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-info h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.headline {
    font-size: 1.25rem;
    color: var(--color-text-secondary);
    font-weight: 400;
    line-height: 1.4;
}

/* Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    margin-top: 2rem;
}

/* Main Content */
.main-content {
    background: var(--color-white);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 4px var(--color-card-shadow);
}

/* Bio Section */
.bio {
    margin-bottom: 3rem;
}

.bio h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--color-text);
}

.bio h3 {
    font-size: 1.25rem;
    margin: 2rem 0 1rem;
    color: var(--color-text);
}

.bio p {
    margin-bottom: 1.5rem;
    line-height: 1.7;
}

/* Posts Section */
.posts h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

.posts-grid {
    display: grid;
    gap: 1.5rem;
}

.post-preview {
    padding: 1.5rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    transition: transform 0.2s ease;
}

.post-preview:hover {
    transform: translateY(-2px);
}

.post-preview h3 {
    margin-bottom: 0.5rem;
}

.post-preview h3 a {
    color: var(--color-text);
    text-decoration: none;
}

.post-preview h3 a:hover {
    color: var(--color-accent);
}

.post-preview time {
    display: block;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.post-preview p {
    margin-bottom: 1rem;
    color: var(--color-text-secondary);
}

.post-preview .read-more {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 500;
}

/* Sidebar */
.sidebar {
    background: var(--color-white);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 4px var(--color-card-shadow);
}

.links-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--color-text);
}

.links-grid {
    display: grid;
    gap: 1rem;
}

.social-link {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--color-white);
    border-radius: 8px;
    text-decoration: none;
    color: var(--color-text);
    font-weight: 500;
    box-shadow: 0 2px 4px var(--color-card-shadow);
    border: 1px solid var(--color-border);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.social-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: transparent;
    transition: all 0.2s ease;
}

.social-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--color-card-shadow);
    border-color: transparent;
}

.social-link:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px var(--color-card-shadow);
}

/* Platform-specific colors */
.social-link[href*="twitter"]::before { background: #1DA1F2; }
.social-link[href*="linkedin"]::before { background: #0077B5; }
.social-link[href*="gates"]::before { background: #FF5722; }
.social-link[href*="youtube"]::before { background: #FF0000; }

/* Focus styles for accessibility */
.social-link:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}


/* Base mobile styles (tablets and below) */
@media (max-width: 1024px) {
    .container {
        padding: 1rem;
        width: 100%;
    }
    
    .content-grid {
        gap: 1.5rem;
    }
}

/* Mobile styles */
@media (max-width: 768px) {
    /* Header adjustments */
    .profile-header {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 1.5rem;
        padding: 1rem 0;
        margin-bottom: 1.5rem;
        width: 100%;
    }

    .profile-image {
        width: 140px;
        height: 140px;
        margin: 0 auto;
    }

    .profile-info {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .profile-info h1 {
        font-size: 1.75rem;
        margin-bottom: 0.75rem;
        width: 100%;
    }

    .headline {
        font-size: 1.1rem;
        max-width: 500px;
        margin: 0 auto;
        width: 100%;
    }

    /* Main content layout */
    .content-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1.5rem;
        width: 100%;
    }

    .main-content,
    .sidebar {
        width: 100%;
        padding: 1.25rem;
        margin: 0;
    }

    /* Post grid adjustments */
    .posts-grid {
        display: grid;
        gap: 1.25rem;
        width: 100%;
    }

    .post-preview {
        width: 100%;
        padding: 1.25rem;
        margin: 0;
    }

    /* Sidebar adjustments */
    .links-grid {
        display: grid;
        gap: 1rem;
        width: 100%;
    }

    .social-link {
        padding: 1rem;
        min-height: 3.5rem; /* Better touch target */
        justify-content: flex-start;
    }
    
    .social-link:hover {
        transform: none; /* Remove hover effect on touch devices */
    }

    .social-link {
        width: 100%;
        min-height: 3.5rem;
        padding: 1rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Small phone refinements */
@media (max-width: 480px) {
    .container {
        padding: 0.75rem;
    }

    .profile-header {
        padding: 0.75rem 0;
        gap: 1rem;
    }

    .profile-image {
        width: 120px;
        height: 120px;
    }

    .profile-info h1 {
        font-size: 1.5rem;
    }

    .headline {
        font-size: 1rem;
        padding: 0;
    }

    .main-content,
    .sidebar {
        padding: 1rem;
    }

    .post-preview {
        padding: 1rem;
    }

    /* Adjust typography for readability */
    .bio p {
        font-size: 1rem;
        line-height: 1.6;
    }

    .bio h2,
    .posts h2,
    .links-section h2 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }

    .post-preview h3 {
        font-size: 1.1rem;
    }
}

/* Safe Area Insets */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    }
}