/* ==========================================================================
   KEVIN STRUNA | PORTFOLIO STYLESHEET
   ========================================================================== */

/* --- 1. GLOBAL VARIABLES & BASE --- */
:root {
    --ios-blue: #007AFF;
    --bg-color: #f5f5f7;
    --text-color: #5c5c5c;
    --nav-bg: rgba(255, 255, 255, 0.75);
    --card-bg: rgba(255, 255, 255, 0.7);
    --card-border: rgba(255, 255, 255, 0.6);
    --shadow-light: rgba(0, 0, 0, 0.05);
    --shadow-medium: rgba(0, 0, 0, 0.1);
    --text-muted: #6e6e73;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- 2. GLOBAL ANIMATIONS --- */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(30px); scale: 0.98; }
    to { opacity: 1; transform: translateY(0); scale: 1; }
}

@keyframes scroll {
    0% { transform: translateX(0); }
    /* (card-width + gap) × card-count — update both here and the duplicate count in HTML if carousel dimensions change */
    100% { transform: translateX(calc(-280px * 7 - 30px * 7)); }
}

@keyframes pulse-green {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 12px rgba(52, 199, 89, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(52, 199, 89, 0); }
}

main > section, .hero-card, .bento-grid, .glass-card {
    animation: fadeUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* --- 3. TYPOGRAPHY & UTILITIES --- */



h1 { 
    font-size: 3.5rem; 
    font-weight: 700; 
    letter-spacing: -0.025em; 
    margin-bottom: 0.5rem;
    line-height: 1.1;
}

h2 { 
    font-size: 2.2rem; 
    font-weight: 600; 
    letter-spacing: -0.02em;
    margin-top: 3rem; 
    margin-bottom: 1.5rem;
}

h3 {
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.tagline {
    font-size: 1.35rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 0.5rem; 
    letter-spacing: -0.01em;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.section-header {
    margin-top: 80px;
    margin-bottom: 30px;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    padding-bottom: 15px;
}

/* --- 4. LAYOUT: NAV, MAIN, FOOTER --- */
nav {
    background: var(--nav-bg);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
    width: fit-content;
    max-width: calc(100% - 32px);
    margin: 20px auto 10px;
    padding: 0.75rem 1.5rem;
    border-radius: 100px;
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    position: sticky;
    top: 20px;
    z-index: 1000;
    text-align: center;
    overflow-x: auto;
    scrollbar-width: none;
}
nav::-webkit-scrollbar { display: none; }

nav a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    font-size: 0.9rem;
    margin: 0 12px;
    transition: color 0.2s ease, opacity 0.2s ease;
    opacity: 0.8;
}

nav a:hover, nav a.active {
    color: var(--ios-blue);
    opacity: 1;
}

main {
    flex: 1;
    max-width: 1000px; 
    margin: 0 auto;
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
}

footer {
    background-color: var(--bg-color);
    border-top: 1px solid rgba(0,0,0,0.1);
    padding: 60px 20px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

footer a { color: var(--text-muted); text-decoration: none; margin: 0 12px; transition: color 0.2s;}
footer a:hover { color: var(--ios-blue); text-decoration: none; }

.sep { opacity: 0.3; margin: 0 5px; }

.page-hero {
    text-align: center;
    padding: 40px 0 60px;
}

.hero-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 48px 40px;
    max-width: 480px;
    margin: 20px auto 0;
    background: var(--card-bg);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border-radius: 24px;
    border: 1px solid var(--card-border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 12px 24px -4px rgba(0, 0, 0, 0.06);
}

.hero-photo {
    width: 160px;
    height: 160px;
    background-color: #f0f0f5;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    margin-bottom: 12px;
}

.hero-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-socials {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 16px;
}

.cta-section {
    text-align: center;
    padding: 60px 0 20px;
}

.card-icon-wrap {
    width: 50px;
    height: 50px;
    background: rgba(120, 120, 128, 0.12);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

/* --- 5. UI COMPONENTS --- */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: var(--ios-blue);
    color: white;
    padding: 12px 26px;
    border-radius: 99px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    margin-top: 15px;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    box-shadow: 0 4px 12px rgba(0,122,255, 0.25);
}

.btn:hover { 
    background-color: #0066d6; 
    transform: scale(1.04); 
    box-shadow: 0 8px 20px rgba(0,122,255, 0.35);
}

.btn:active { transform: scale(0.96); }
.btn svg { width: 18px; height: 18px; fill: currentColor; }

.btn-light {
    background-color: white;
    color: black;
    font-weight: 600;
    border: none;
    box-shadow: 0 5px 15px rgba(255,255,255,0.2);
}

.btn-light:hover { background-color: #e5e5e5; transform: scale(1.04); }
.btn-light svg { fill: black; }

.social-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.social-link:hover { color: var(--ios-blue); }

/* Glass Cards */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border-radius: 24px;
    border: 1px solid var(--card-border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 12px 24px -4px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.4s ease;
}

.glass-card:hover {
    transform: translateY(-8px) scale(1.01);
    box-shadow: 0 20px 40px rgba(0,0,0,0.12);
}

.card-content { padding: 35px; }

/* Assets & Badges */
.app-icon {
    width: 85px;
    height: 85px;
    border-radius: 20px;
    margin-bottom: 20px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.glass-card:hover .app-icon { transform: scale(1.08) rotate(-3deg); }

.tech-badge {
    display: inline-block;
    background: #e5e5ea;
    color: #6e6e73;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 100px;
    margin-right: 6px;
    margin-top: 6px;
}

/* --- 6. FEATURED SECTIONS --- */

/* Hero Feature Card */
.hero-card {
    background-color: #1c1c1e; 
    color: #f5f5f7;
    border-radius: 30px;
    padding: 50px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.4);
    margin-bottom: 60px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
}

.hero-card::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.05), transparent 70%);
    pointer-events: none;
}

.hero-header { display: flex; align-items: center; gap: 30px; margin-bottom: 30px; flex-wrap: wrap; }
.hero-icon-large { width: 110px; height: 110px; border-radius: 24px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.hero-title h3 { font-size: 2.8rem; margin: 0 0 5px 0; color: white; letter-spacing: -0.02em; }
.hero-subtitle { font-size: 1rem; color: #98989d; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.hero-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin: 35px 0; }
.hero-card .tech-badge { background: rgba(255, 255, 255, 0.2); color: #fff; border: 1px solid rgba(255, 255, 255, 0.1); }

.feature-item {
    background: rgba(255,255,255,0.08);
    padding: 20px;
    border-radius: 18px;
    border: 1px solid rgba(255,255,255,0.05);
    transition: background 0.2s;
}

.feature-item:hover { background: rgba(255,255,255,0.12); }
.feature-item strong { color: #5ac8fa; display: block; margin-bottom: 8px; font-size: 1rem; }
.feature-item p { color: #d1d1d6; font-size: 0.95rem; margin: 0; line-height: 1.6; }

/* Bento Grid */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
    margin-top: 20px;
}

.grid-span-2 { grid-column: span 2; }

.product-card {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.product-card .card-content { display: flex; flex-direction: column; height: 100%; }
.product-card p { flex-grow: 1; }

/* App Carousel */
.carousel-container {
    overflow: hidden;
    padding: 40px 0;
    white-space: nowrap;
    position: relative;
    mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
}

.carousel-track { display: inline-flex; gap: 30px; animation: scroll 50s linear infinite; }
.carousel-track:hover { animation-play-state: paused; }

.carousel-card {
    width: 280px;
    background: var(--card-bg);
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.06);
    border: 1px solid var(--card-border);
    white-space: normal;
    flex-shrink: 0;
    text-align: left;
    transition: transform 0.3s ease;
}

.carousel-card:hover { transform: translateY(-8px); }

/* AQ Monitor Dashboard */
.bento-metrics {
    display: grid;
    grid-template-columns: 1fr; /* Mobile starts stacked */
    gap: 20px;
    margin-top: 20px;
}

.metric-card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 25px 15px;
    text-align: center;
    border: 1px solid var(--card-border);
    box-shadow: 0 4px 15px var(--shadow-light);
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.metric-card:hover { transform: scale(1.03); }

.metric-label { font-size: 0.85rem; color: var(--text-muted); margin: 0 0 10px 0; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.metric-value { font-size: 2.2rem; margin: 0; font-variant-numeric: tabular-nums; }
.metric-unit { font-size: 0.75rem; color: var(--text-muted); margin: 5px 0 0 0; }

.status-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.status-dot.online { background-color: #34c759; animation: pulse-green 2s infinite cubic-bezier(0.66, 0, 0, 1); }
.status-dot.offline { background-color: #ff3b30; box-shadow: 0 0 8px rgba(255, 59, 48, 0.4); }

.info-pane {
    max-width: 650px;
    margin: 20px auto 0;
    padding: 20px;
    text-align: left;
    background: var(--card-bg); 
    border-radius: 16px;
    border: 1px solid var(--card-border);
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.metric-icon {
    margin-bottom: 12px;
    opacity: 0.8;
    transition: stroke 0.3s ease;
}

/* --- 7. BLOG --- */

.back-link {
    color: var(--ios-blue);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.hero-banner {
    width: 100%;
    height: 350px;
    object-fit: cover;
    border-radius: 24px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.author-block {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(128,128,128,0.2);
}

.author-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #f0f0f5;
    object-fit: cover;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.author-meta {
    display: flex;
    flex-direction: column;
}

.author-name {
    font-weight: 700;
    color: var(--text-color);
    font-size: 1.05rem;
}

.publish-date {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.article-body {
    font-size: 1.15rem;
    line-height: 1.8;
    color: var(--text-color);
}

.article-body p {
    margin-bottom: 1.8rem;
}

.article-link {
    color: var(--ios-blue);
    text-decoration: none;
    border-bottom: 1px solid currentColor;
    transition: opacity 0.2s ease;
}
.article-link:hover { opacity: 0.7; }

.article-chart {
    width: 100%;
    height: auto;
    border-radius: 16px;
    margin: 40px 0;
    background: white;
    padding: 20px;
    box-sizing: border-box;
    box-shadow: 0 4px 15px var(--shadow-light);
    border: 1px solid var(--card-border);
}

/* --- 8. MEDIA QUERIES --- */

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.6rem; margin-top: 2rem; }

    /* Nav: smaller links on mobile, no wrapping */
    nav { padding: 0.6rem 0.75rem; }
    nav a { margin: 0 6px; font-size: 0.8rem; white-space: nowrap; }

    /* Section & card spacing */
    main > section { margin-top: 48px !important; }
    .section-header { margin-top: 40px; }
    .card-content { padding: 20px; }

    /* Page title headers */
    .page-hero { padding: 20px 0 24px !important; }

    /* Homepage hero */
    .hero-section { padding: 36px 24px !important; }
    .hero-photo { width: 120px !important; height: 120px !important; margin-bottom: 10px !important; }

    /* About CTA footer */
    .cta-section { padding: 36px 0 12px !important; }

    /* Projects hero card */
    .hero-card { padding: 28px; margin-bottom: 32px; }
    .hero-title h3 { font-size: 2rem; }
    .hero-icon-large { width: 80px; height: 80px; border-radius: 18px; }
    .hero-features { margin: 20px 0; gap: 12px; }

    /* Carousel */
    .carousel-container { padding: 20px 0; }

    /* Bento grid */
    .bento-grid { grid-template-columns: 1fr; }
    .grid-span-2 { grid-column: span 1; }

    /* Blog */
    .hero-banner { height: 200px; }

    /* Footer */
    footer { padding: 36px 20px; }
}

@media (min-width: 768px) {
    .bento-metrics {
        /* The magic 6-column grid */
        grid-template-columns: repeat(6, 1fr);
    }
    
    .metric-card {
        /* Top row items take up 2 slots each (2 + 2 + 2 = 6) */
        grid-column: span 2;
    }

    .metric-wide {
        /* Bottom row items take up 3 slots each (3 + 3 = 6) */
        grid-column: span 3;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .carousel-track { animation-play-state: paused; }
    main > section, .hero-card, .bento-grid, .glass-card { animation: none; }
}

/* Dark mode — applied via data-theme="dark", set by toggle or matched to OS preference in theme.js */
html[data-theme="dark"] {
    --bg-color: #000000;
    --text-color: #f5f5f7;
    --nav-bg: rgba(28, 28, 30, 0.7);
    --card-bg: rgba(28, 28, 30, 0.6);
    --card-border: rgba(255, 255, 255, 0.12);
    --shadow-light: rgba(0, 0, 0, 0.4);
    --text-muted: #aeaeb2;
}
html[data-theme="dark"] body { background-color: #000; }
html[data-theme="dark"] nav { background: rgba(40, 40, 40, 0.7); border: 1px solid rgba(255, 255, 255, 0.15); }
html[data-theme="dark"] .glass-card,
html[data-theme="dark"] .carousel-card { box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
html[data-theme="dark"] .tech-badge { background: #2c2c2e; color: #e5e5e5; }
html[data-theme="dark"] .section-header,
html[data-theme="dark"] footer { border-color: rgba(255,255,255,0.15); }
html[data-theme="dark"] .btn-light { background: #1c1c1e; color: white; border: 1px solid rgba(255,255,255,0.2); }
html[data-theme="dark"] .btn-light svg { fill: white; }
html[data-theme="dark"] input,
html[data-theme="dark"] textarea { background-color: #1c1c1e !important; border-color: #3a3a3c !important; color: white !important; }
html[data-theme="dark"] label { color: #d1d1d6 !important; }
html[data-theme="dark"] .glass-card .card-content > div { border-color: rgba(255, 255, 255, 0.1) !important; }

/* Manual light mode (force light even on dark systems) */
html[data-theme="light"] {
    --bg-color: #f5f5f7;
    --text-color: #5c5c5c;
    --nav-bg: rgba(255, 255, 255, 0.75);
    --card-bg: rgba(255, 255, 255, 0.7);
    --card-border: rgba(255, 255, 255, 0.6);
    --shadow-light: rgba(0, 0, 0, 0.05);
    --shadow-medium: rgba(0, 0, 0, 0.1);
    --text-muted: #6e6e73;
}
html[data-theme="light"] body { background-color: #f5f5f7; }
html[data-theme="light"] nav { background: rgba(255, 255, 255, 0.75); border: 1px solid rgba(0,0,0,0.08); }
html[data-theme="light"] .glass-card,
html[data-theme="light"] .carousel-card { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 12px 24px -4px rgba(0, 0, 0, 0.06); }
html[data-theme="light"] .tech-badge { background: #e5e5ea; color: #6e6e73; }
html[data-theme="light"] .section-header,
html[data-theme="light"] footer { border-color: rgba(0,0,0,0.1); }
html[data-theme="light"] .btn-light { background: white; color: black; border: none; }
html[data-theme="light"] .btn-light svg { fill: black; }
html[data-theme="light"] input,
html[data-theme="light"] textarea { background-color: white !important; border-color: rgba(0,0,0,0.2) !important; color: #5c5c5c !important; }
html[data-theme="light"] label { color: #5c5c5c !important; }
html[data-theme="light"] .glass-card .card-content > div { border-color: rgba(0,0,0,0.08) !important; }

/* Theme toggle button in nav */
.theme-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    margin: 0 4px;
    display: inline-flex;
    align-items: center;
    color: var(--text-color);
    opacity: 0.8;
    transition: color 0.2s ease, opacity 0.2s ease;
    vertical-align: middle;
    line-height: 1;
}

.theme-toggle-btn:hover { color: var(--ios-blue); opacity: 1; }

#back-to-top {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--card-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--card-border);
    box-shadow: 0 4px 16px var(--shadow-medium);
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.3s ease, transform 0.3s ease, color 0.2s ease, box-shadow 0.2s ease;
    pointer-events: none;
    z-index: 999;
}

#back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#back-to-top:hover {
    color: var(--ios-blue);
    box-shadow: 0 8px 24px var(--shadow-medium);
}