/* 1. CONFIGURATION & VARIABLES */
:root {
    --max-width: 1400px;
    --glass-bg: rgba(10, 16, 32, 0.68);
    --glass-border: rgba(255, 255, 255, 0.14);
    --blur: 18px;
    --accent: #22d9ff;
    --text: #f8fafc;
    --text-dim: #c2cee0;
    --inner-margin: 25px;
    --vertical-align: flex-start; /* Toggle: 'center' or 'flex-start' */
}

/* 2. RESET & BASE */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    height: 100vh;
    overflow: hidden;
    font-family: 'Inter', -apple-system, sans-serif;
    color: var(--text);
    background: #0f172a;
    display: flex;
    flex-direction: column;
}

.bg-image-container {
    position: absolute;
    inset: 0; /* Shorthand for top/left/right/bottom: 0 */
    background-image: linear-gradient(rgba(15, 23, 42, 0.8), rgba(15, 23, 42, 0.8)), url('../images/background.webp');
    background-size: cover;
    background-position: center;
    z-index: -1;
}

/* 3. HEADER & NAVIGATION */
header {
    height: 100px;
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 0 40px;
    flex-shrink: 0;
}

.header-inner {
    width: 100%;
    max-width: var(--max-width);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

nav { display: flex; gap: 10px; }

.nav-pill {
    text-decoration: none;
    color: var(--text);
    font-size: 0.8rem;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-pill:hover { border-color: var(--accent); color: var(--accent); }
.contact-btn { background: var(--accent); color: #0f172a; border: none; cursor: pointer; font-family: inherit; }
.contact-btn:hover { color: #0f172a; opacity: 0.85; }

/* 3b. CONTACT DROPDOWN */
header { position: relative; }

.contact-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 40px;
    width: min(380px, calc(100vw - 40px));
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    padding: 20px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

.contact-panel.is-open { opacity: 1; visibility: visible; transform: translateY(0); }

.contact-form { display: flex; flex-direction: column; gap: 12px; }
.contact-form h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 2px; color: var(--accent); }
.contact-hint { font-size: 0.75rem; color: var(--text-dim); line-height: 1.5; }

.contact-channel { border: 1px solid var(--glass-border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.contact-channel legend { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); padding: 0 6px; }
.contact-channel label { font-size: 0.8rem; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.contact-channel input { accent-color: var(--accent); }

.contact-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.75rem; color: var(--text-dim); }
.contact-field input, .contact-field textarea {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 8px 10px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
    resize: vertical;
}
.contact-field input:focus, .contact-field textarea:focus { outline: none; border-color: var(--accent); }

.contact-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.contact-actions { display: flex; align-items: center; gap: 12px; }
.contact-status { font-size: 0.75rem; color: var(--text-dim); }
.contact-status.is-error { color: #f87171; }
.contact-status.is-success { color: #4ade80; }

/* 4. LAYOUT SYSTEM */
.main-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: var(--vertical-align);
    padding: 0 40px 30px 40px;
    min-height: 0;
    overflow: hidden; /* Desktop: container doesn't scroll, panels might */
}

main {
    width: 100%;
    max-width: var(--max-width);
    height: 100%;
    max-height: 820px;
    display: grid;
    grid-template-columns: 1fr 2.4fr;
    gap: 20px;
    min-height: 0;
}

/* Individual page layout (one large panel) */
.subpage-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: var(--max-width);
    max-height: calc(100vh - 190px); /* Subtract header, footer, and padding */
    margin: 0 auto;
    height: auto; /* Default to content height */
}

.content-wrapper { display: grid; grid-template-rows: 1.1fr 0.9fr; gap: 20px; min-height: 0; }
.bottom-split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; min-height: 0; }

/* 5. COMPONENTS: GLASS PANELS */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.panel-header {
    padding: var(--inner-margin) var(--inner-margin) 10px var(--inner-margin);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-shrink: 0;
}

.panel-header h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 2px; color: var(--accent); }
.all-link { color: var(--accent); font-size: 0.75rem; text-decoration: none; }
.all-link:hover { text-decoration: underline; }

/* Links inside rendered content (project pages, news, cards) — otherwise they
   fall back to the browser's default blue/purple. Nav pills keep their own style. */
.panel-content a:not(.nav-pill) { color: var(--accent); }
.panel-content a:not(.nav-pill):hover { text-decoration: underline; }
.panel-content { padding: 0 var(--inner-margin) var(--inner-margin) var(--inner-margin); flex: 1; min-height: 0; display: flex; flex-direction: column; }

.scrollable-content {
    overflow-y: auto;
    flex: 1;
    padding-right: 10px; /* Space for scrollbar */
}

/* Custom Scrollbar */
.scrollable-content::-webkit-scrollbar { width: 6px; }
.scrollable-content::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.02); border-radius: 10px; }
.scrollable-content::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 10px; }
.scrollable-content::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* 6. COMPONENTS: CARDS */
.grid-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-cards-small { display: grid; grid-template-columns: 1fr; gap: 10px; }

.vertical-list { display: flex; flex-direction: column; gap: 20px; }
.vertical-list .card-inner { display: flex; flex-direction: row; gap: 20px; }
.vertical-list .card-img, .vertical-list .card-img-placeholder { width: 250px; aspect-ratio: 16/9; background-size: cover; background-position: center; flex-shrink: 0; }
.vertical-list .card-body { flex: 1; padding: 15px; }

.card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    overflow: hidden;
    transition: transform 0.3s ease, background 0.3s ease;
}

.card:hover { transform: translateY(-4px); background: rgba(255, 255, 255, 0.07); }
.card-img-placeholder { width: 100%; aspect-ratio: 16/7; background: rgba(255,255,255,0.05); }
.card-body { padding: 15px; }
.card-body h3 { font-size: 0.95rem; margin-bottom: 5px; }
.card-body p { font-size: 0.8rem; color: var(--text-dim); }

/* 7. TYPOGRAPHY & UTILITIES */
.bio-text { font-size: 0.95rem; line-height: 1.7; margin-top: 25px; }
.profile-photo { 
    width: 140px; 
    height: 140px; 
    border-radius: 50%; 
    object-fit: cover; 
    margin: 30px auto 20px auto; 
    display: block; 
    border: 3px solid var(--accent);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.2);
}
.social-links { display: flex; gap: 18px; justify-content: center; margin-bottom: 10px; padding-bottom: 20px; border-bottom: 1px solid var(--glass-border); }
.icon-link { transition: transform 0.2s ease; }
.icon-link:hover { transform: scale(1.1); }
.icon-svg { width: 22px; height: 22px; filter: invert(1); opacity: 0.7; transition: opacity 0.2s; }
.icon-link:hover .icon-svg { opacity: 1; }
.clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

footer {
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.7rem;
    color: var(--text-dim);
    background: rgba(0, 0, 0, 0.3);
}

/* 8. RESPONSIVE: LAPTOP (Medium) */
@media (max-width: 1250px) {
    .grid-cards { grid-template-columns: repeat(2, 1fr); }
    /* Home Page specific: hide 3rd card for symmetry */
    .grid-cards .project-card:nth-child(3) { display: none; }
}

/* 9. RESPONSIVE: MOBILE (Small) */
@media (max-width: 900px) {
    body { height: 100vh; overflow: hidden; }
    .bg-image-container { position: fixed; }
    
    header { height: auto; padding: 20px; flex-shrink: 0; }
    .header-inner { flex-direction: column; text-align: center; gap: 10px; }
    .contact-panel { right: 20px; left: 20px; width: auto; }
    
    .main-container { padding: 0 20px 20px 20px; overflow-y: auto; align-items: flex-start; }
    
    main { display: flex; flex-direction: column; max-height: none; height: auto; width: 100%; gap: 20px; }
    
    /* Subpage panels: natural height, but scroll internal if too tall for screen */
    .subpage-panel { max-height: calc(100vh - 160px); height: auto; }
    
    .content-wrapper, .bottom-split { display: flex; flex-direction: column; width: 100%; gap: 20px; }

    /* Fix the vanishing bio panel by ensuring it doesn't squash */
    aside.glass-panel { flex: none; height: auto; min-height: 200px; }

    .grid-cards { grid-template-columns: 1fr; }
    .grid-cards .project-card:nth-child(3) { display: block; }

    .glass-panel { height: auto; min-height: 0; }
    .panel-content { overflow: hidden; }
    .scrollable-content { overflow-y: auto; }
    
    /* Correct vertical list for mobile */
    .vertical-list .card-inner { flex-direction: column; gap: 0; }
    .vertical-list .card-img, .vertical-list .card-img-placeholder { width: 100%; aspect-ratio: 16/9; }
    
    .bio-text, .clamp-1, .clamp-2 { -webkit-line-clamp: unset; display: block; }
}

/* 10. FAIL-SAFE: SHORT SCREEN BREAKPOINT */
@media (max-height: 700px) {
    .subpage-panel { max-height: calc(100vh - 120px); }
}
