/* ============================================================
   Dr. Kaweh Kerami — Personal Academic Website
   Design direction: Apple-inspired editorial minimalism
   Extreme whitespace · Dramatic type scale · Purposeful motion
   ============================================================ */

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

/* ---- Design Tokens ---- */
:root {
    /* Surfaces */
    --bg:           #FAFAFA;
    --bg-elevated:  #FFFFFF;
    --bg-dark:      #111111;
    --bg-dark-el:   #1C1C1E;

    /* Text */
    --ink:          #1D1D1F;
    --ink-mid:      #6E6E73;
    --ink-light:    #737378;  /* Bumped from #86868B → 4.6:1 on white for WCAG AA */
    --ink-faint:    #AEAEB2;

    /* Accent */
    --accent:       #2563EB;
    --accent-hover: #1D4ED8;
    --accent-light: #DBEAFE;

    /* Semantic */
    --success:      #16A34A;
    --warning:      #D97706;
    --error:        #DC2626;

    /* Rules */
    --rule:         #E5E5E7;
    --rule-dark:    #2D2D2D;

    /* Dark mode text */
    --dark-text:    #F5F5F7;
    --dark-mid:     #A1A1A6;
    --dark-light:   #8E8E93;  /* Bumped from #636366 → 4.5:1 on #111 for WCAG AA */

    /* Typography */
    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body:    'Lora', Georgia, serif;
    --font-ui:      'Inter', system-ui, -apple-system, sans-serif;

    /* Layout */
    --max-w:        1080px;
    --section-pad:  6rem 2rem;

    /* Radius */
    --radius-sm:    4px;
    --radius-md:    8px;
    --radius-lg:    12px;
    --radius-xl:    16px;
    --radius-full:  50%;

    /* Motion */
    --ease:         cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-out:     cubic-bezier(0.22, 1, 0.36, 1);
    --ease-in:      cubic-bezier(0.55, 0, 1, 0.45);
    --spring:       cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---- Base ---- */
html {
    scroll-behavior: smooth;
    font-size: 17px;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
}

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

::selection {
    background: rgba(37, 99, 235, 0.15);
}

/* ---- Accessibility: Skip Link ---- */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    z-index: 999;
    padding: 0.75rem 1.25rem;
    background: var(--ink);
    color: #fff;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: top 0.2s var(--ease);
}
.skip-link:focus {
    top: 1rem;
}

/* ---- Accessibility: Focus-Visible ---- */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
/* Suppress default focus ring when not keyboard-navigating */
*:focus:not(:focus-visible) {
    outline: none;
}

/* ---- Scroll Reveal ---- */
.js-loaded .reveal {
    opacity: 0;
    transform: translateY(32px);
    transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out);
}
.js-loaded .reveal.visible {
    opacity: 1;
    transform: none;
}

/* ============================================================
   NAVIGATION
   ============================================================ */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(250, 250, 250, 0.82);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid transparent;
    transition: border-color 0.4s var(--ease), box-shadow 0.4s var(--ease);
}

.site-header.scrolled {
    border-color: var(--rule);
    box-shadow: 0 1px 20px rgba(0, 0, 0, 0.04);
}

.navigation {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    color: var(--ink);
    transition: opacity 0.3s;
}
.logo:hover { opacity: 0.5; }

.nav-links {
    list-style: none;
    display: flex;
    gap: 2.25rem;
}

.nav-links a {
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--ink-mid);
    position: relative;
    transition: color 0.3s;
    padding-bottom: 2px;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1.5px;
    background: var(--accent);
    transition: width 0.3s var(--ease-out);
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--ink);
}

.nav-links a:hover::after,
.nav-links a.active::after {
    width: 100%;
}

/* Mobile toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    width: 44px;       /* WCAG: min 44×44 touch target */
    height: 44px;
    position: relative;
    z-index: 201;
    align-items: center;
    justify-content: center;
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 1.5px;
    background: var(--ink);
    transition: transform 0.3s var(--ease-out), opacity 0.3s;
}

.nav-toggle span:first-child { transform: translateY(-4px); }
.nav-toggle span:last-child  { transform: translateY(4px); }

.nav-toggle.active span:first-child { transform: rotate(45deg) translateY(0); }
.nav-toggle.active span:last-child  { transform: rotate(-45deg) translateY(0); }

/* ============================================================
   HERO
   ============================================================ */
.hero {
    padding: 10rem 2rem 8rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hero-image-wrap {
    margin-bottom: 3rem;
}

.image-frame {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.04),
        0 8px 40px rgba(0, 0, 0, 0.08);
    transition: transform 0.6s var(--ease-out), box-shadow 0.6s var(--ease-out);
}

.image-frame:hover {
    transform: scale(1.03);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.04),
        0 16px 60px rgba(0, 0, 0, 0.12);
}

.hero-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
}

/* h1: Actual name — accessible heading */
.hero-name {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    color: var(--ink);
    margin-bottom: 1rem;
}

/* Tagline: large editorial statement (now a <p>, not <h1>) */
.hero-title {
    font-family: var(--font-display);
    font-size: 4.5rem; /* IE11 fallback */
    font-size: clamp(3.2rem, 8vw, 7rem);
    font-weight: 300;
    line-height: 1.0;
    letter-spacing: -0.03em;
    color: var(--ink);
    margin-bottom: 2rem;
}

.hero-title em {
    font-style: italic;
    color: var(--ink-mid);
}

.hero-lead {
    font-family: var(--font-body);
    font-size: 1.1rem;
    line-height: 1.7;
    color: var(--ink-mid);
    max-width: 520px;
    margin-bottom: 2.5rem;
    font-weight: 400;
}

.hero-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.hero-tag {
    font-family: var(--font-ui);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-light);
}

.hero-divider {
    width: 20px;
    height: 1px;
    background: var(--rule);
}

/* ============================================================
   SECTIONS — SHARED
   ============================================================ */
.section {
    padding: var(--section-pad);
}

.section-inner {
    max-width: var(--max-w);
    margin: 0 auto;
}

.section-header {
    margin-bottom: 4rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--rule);
}

.section-header h2 {
    font-family: var(--font-display);
    font-size: 2.8rem;
    font-weight: 300;
    letter-spacing: -0.02em;
    color: var(--ink);
}

/* ============================================================
   BIOGRAPHY
   ============================================================ */
.bio-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 6rem;
    margin-bottom: 5rem;
}

.bio-text p {
    font-size: 0.97rem;
    line-height: 1.9;
    color: var(--ink-mid);
    margin-bottom: 1.4rem;
}
.bio-text p:last-child { margin-bottom: 0; }

/* Credentials */
.credential-block h3 {
    font-family: var(--font-ui);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-light);
    margin-bottom: 1.75rem;
}

.credential-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.credential-list li {
    display: grid;
    grid-template-columns: 3rem 1fr;
    gap: 0.75rem;
    align-items: start;
}

.cred-year {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    color: var(--ink-light);
    padding-top: 0.2rem;
    font-weight: 400;
}

.cred-detail {
    font-family: var(--font-body);
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--ink);
}

.cred-detail em {
    display: block;
    color: var(--ink-light);
    font-style: italic;
    font-size: 0.82rem;
    margin-top: 0.15rem;
}

/* Experience grid */
.experience-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5rem;
    padding-top: 4rem;
    border-top: 1px solid var(--rule);
}

.exp-col h3 {
    font-family: var(--font-ui);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-light);
    margin-bottom: 1.75rem;
}

.exp-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.exp-role {
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--ink);
    margin-bottom: 0.1rem;
}

.exp-place {
    font-size: 0.88rem;
    color: var(--ink-mid);
    font-style: italic;
}

.exp-period {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    color: var(--ink-light);
    margin-top: 0.2rem;
    letter-spacing: 0.02em;
}

/* ============================================================
   RESEARCH — DARK SECTION
   ============================================================ */
.section--dark {
    background: var(--bg-dark);
    color: #f5f5f7;
    position: relative;
}

/* Gradient bridge from light to dark */
.section--dark::before {
    content: '';
    position: absolute;
    top: -80px;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(to bottom, var(--bg), var(--bg-dark));
    pointer-events: none;
}

.section--dark .section-header {
    border-bottom-color: var(--rule-dark);
}

.section--dark .section-header h2 {
    color: #f5f5f7;
}

.research-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 6rem;
    align-items: start;
}

.statement-lead {
    font-family: var(--font-display);
    font-size: 1.9rem;
    font-weight: 300;
    font-style: italic;
    line-height: 1.35;
    color: #f5f5f7;
    margin-bottom: 2rem;
    letter-spacing: -0.01em;
}

.research-statement p {
    font-size: 0.95rem;
    line-height: 1.9;
    color: #a1a1a6;
    margin-bottom: 1rem;
}

.theme-group {
    margin-bottom: 2.5rem;
}
.theme-group:last-child { margin-bottom: 0; }

.research-themes h3 {
    font-family: var(--font-ui);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--dark-light);
    margin-bottom: 1.25rem;
}

.theme-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.theme-list li {
    font-size: 0.88rem;
    color: #a1a1a6;
    padding-left: 1.25rem;
    position: relative;
    transition: color 0.3s;
}

.theme-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.55em;
    width: 6px;
    height: 1px;
    background: var(--accent);
    transition: width 0.3s var(--ease-out);
}

.theme-list li:hover {
    color: #f5f5f7;
}

.theme-list li:hover::before {
    width: 12px;
}

/* ============================================================
   PUBLICATIONS
   ============================================================ */
.pub-intro {
    font-size: 0.95rem;
    color: var(--ink-mid);
    margin-bottom: 3rem;
}

.inline-link {
    color: var(--accent);
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s;
}
.inline-link:hover {
    border-color: var(--accent);
}

.pub-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.pub-item {
    display: grid;
    grid-template-columns: 4rem 1fr;
    gap: 2rem;
    align-items: start;
    padding: 2rem 0;
    border-bottom: 1px solid var(--rule);
    transition: background 0.3s;
}

.pub-section-label {
    font-family: var(--font-ui);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-light);
    margin-top: 3rem;
    margin-bottom: 0;
}

.pub-section-label:first-of-type {
    margin-top: 0;
}

.pub-section-label + .pub-list .pub-item:first-child {
    border-top: 1px solid var(--rule);
}

.pub-year {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    color: var(--ink-light);
    padding-top: 0.3rem;
    font-weight: 400;
}

.pub-title {
    font-family: var(--font-body);
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--ink);
    line-height: 1.45;
    margin-bottom: 0.35rem;
}

.pub-venue {
    font-family: var(--font-ui);
    font-size: 0.82rem;
    color: var(--ink-light);
    letter-spacing: 0.01em;
}

.pub-note {
    margin-top: 2rem;
    font-family: var(--font-ui);
    font-size: 0.75rem;
    color: var(--ink-light);
    font-style: italic;
}

/* ============================================================
   CONTACT
   ============================================================ */
.contact-body {
    max-width: 640px;
}

.contact-lead {
    font-size: 1.05rem;
    color: var(--ink-mid);
    line-height: 1.8;
    margin-bottom: 3rem;
}

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

.contact-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.5rem 0;
    min-height: 56px;  /* WCAG: comfortable touch target */
    border-bottom: 1px solid var(--rule);
    transition: padding-left 0.3s var(--ease-out);
}

.contact-card:first-child {
    border-top: 1px solid var(--rule);
}

.contact-card:hover {
    padding-left: 0.5rem;
}

.contact-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--rule);
    color: var(--ink-mid);
    flex-shrink: 0;
    transition: background 0.3s, border-color 0.3s, color 0.3s;
}

.contact-card:hover .contact-icon {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.contact-detail {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.contact-label {
    font-family: var(--font-ui);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-light);
}

.contact-value {
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--ink);
}

.contact-arrow {
    font-size: 1.1rem;
    color: var(--ink-light);
    transition: transform 0.3s var(--ease-out), color 0.3s;
}

.contact-card:hover .contact-arrow {
    transform: translateX(4px);
    color: var(--accent);
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
    padding: 3rem 2rem;
    border-top: 1px solid var(--rule);
    background: var(--bg);
}

.footer-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    flex-wrap: wrap;
}

.footer-left {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.footer-name {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 400;
    color: var(--ink);
}

.footer-title {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    color: var(--ink-light);
    letter-spacing: 0.02em;
}

.footer-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.3rem;
}

.back-top {
    font-family: var(--font-ui);
    font-size: 0.78rem;
    color: var(--ink-mid);
    letter-spacing: 0.03em;
    transition: color 0.3s;
}
.back-top:hover { color: var(--accent); }

.footer-copy {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    color: var(--ink-light);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 860px) {
    :root {
        --section-pad: 6rem 2rem;
    }

    .hero {
        padding: 7rem 2rem 5rem;
    }

    .bio-grid {
        grid-template-columns: 1fr;
        gap: 3.5rem;
    }

    .research-grid {
        grid-template-columns: 1fr;
        gap: 3.5rem;
    }

    .experience-grid {
        grid-template-columns: 1fr;
        gap: 3.5rem;
    }

    .section--dark::before {
        height: 50px;
        top: -50px;
    }
}

@media (max-width: 640px) {
    :root {
        --section-pad: 4.5rem 1.5rem;
    }

    .hero {
        padding: 6rem 1.5rem 4rem;
    }

    .hero-name {
        font-size: 1.25rem;
    }

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

    .hero-lead {
        font-size: 1rem;
    }

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

    .section-header h2 {
        font-size: 2.2rem;
    }

    /* Nav: show toggle, hide links by default */
    .nav-toggle {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 0;
    }

    .nav-links {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(250, 250, 250, 0.97);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2.5rem;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s var(--ease);
        z-index: 200;
        padding: 4rem 2rem;
    }

    .nav-links.open {
        opacity: 1;
        pointer-events: all;
    }

    .nav-links a {
        font-size: 1rem;
        letter-spacing: 0.06em;
        padding: 0.75rem 1.5rem;  /* WCAG: 48px+ touch target height */
    }

    .navigation {
        padding: 0.85rem 1.5rem;
    }

    .pub-item {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .pub-year {
        padding-top: 0;
    }

    .footer-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .footer-right {
        align-items: flex-start;
    }

    .hero-meta {
        flex-direction: column;
        gap: 0.25rem;
    }

    .hero-divider {
        display: none;
    }
}
