/* ============================================================
   JOHAN GILCHRIST — Personal Website Stylesheet
   ============================================================
   CSS works in "rules" — each rule picks an element (called a
   "selector") and sets properties on it. For example:
       body { background-color: #1c1c2e; }
   picks the whole page body and sets its background color.
   ============================================================ */

/* --- 1. GLOBAL DEFAULTS ---
   These apply to every single element on every page.
   The * selector means "everything". Box-sizing: border-box
   makes sizing more predictable (padding doesn't add extra width). */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* --- 2. ROOT VARIABLES ---
   CSS variables (--variable-name) let you define colors/sizes
   once and reuse them everywhere. Change one line here →
   updates the whole site. */
:root {
    --bg-dark:       #12121e;   /* main page background */
    --bg-card:       #1e1e32;   /* cards, nav background */
    --bg-section:    #181828;   /* alternating sections */
    --accent:        #5b9bd5;   /* links, highlights (blue) */
    --accent-hover:  #7db8e8;   /* accent on hover */
    --text-primary:  #e8e8f0;   /* main body text */
    --text-secondary:#a0a0b8;   /* subtitles, captions */
    --text-muted:    #6b6b88;   /* very subtle text */
    --border:        #2e2e4a;   /* subtle dividing lines */
    --shadow:        rgba(0, 0, 0, 0.4);

    --font-body:     'Inter', system-ui, -apple-system, sans-serif;
    --font-heading:  'Merriweather', Georgia, serif;

    --max-width:     1100px;    /* max content width */
    --nav-height:    64px;
}

/* --- 3. BASE ELEMENTS --- */
html {
    scroll-behavior: smooth; /* smooth scrolling when clicking anchor links */
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.75;
    /* Note: NO text-align: justify — we use the default (left)
       for better readability. Justified text creates uneven
       word spacing ("rivers of white space"). */
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 { font-size: 2.6rem; }
h2 { font-size: 1.9rem; margin-bottom: 1rem; }
h3 { font-size: 1.3rem; margin-bottom: 0.5rem; }

p {
    margin-bottom: 1.2rem;
    color: var(--text-primary);
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s; /* smooth color change on hover */
}
a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

img {
    max-width: 100%;    /* images never overflow their container */
    height: auto;
    display: block;
    border-radius: 6px;
}

figcaption {
    font-size: 0.9rem;
}

/* --- 4. LAYOUT UTILITIES ---
   .container limits content width and centers it. */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 2rem;
}

.section {
    padding: 5rem 0;
}

.section-alt {
    background-color: var(--bg-section);
}

/* --- 5. NAVIGATION ---
   position: sticky keeps the nav visible as you scroll.
   z-index: 100 keeps it above other content. */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    height: var(--nav-height);
    display: flex;
    align-items: center;
}

.nav__inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 2rem;
    width: 100%;
    display: flex;
    justify-content: space-between; /* logo left, links right */
    align-items: center;
}

.nav__logo {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.nav__logo:hover { color: var(--accent); text-decoration: none; }

.nav__links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav__links a {
    color: var(--text-secondary);
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 500;
    padding-bottom: 2px;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    text-decoration: none;
}

.nav__links a:hover,
.nav__links a.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
    text-decoration: none;
}

/* Hamburger menu button (hidden on desktop) */
.nav__toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}
.nav__toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    margin: 5px 0;
    transition: transform 0.3s, opacity 0.3s;
}

/* --- 6. HERO SECTION (home page top) --- */
.hero {
    min-height: calc(100vh - var(--nav-height));
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #12121e 0%, #1a1a35 50%, #12121e 100%);
    position: relative;
    overflow: hidden;
}

/* Subtle decorative background circle */
.hero::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(91,155,213,0.06) 0%, transparent 70%);
    right: -100px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.hero__inner {
    display: grid;
    grid-template-columns: 1fr 1fr; /* two equal columns */
    gap: 4rem;
    align-items: center;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 4rem 2rem;
}

.hero__text .label {
    display: inline-block;
    font-size: 0.8rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 1rem;
    font-weight: 600;
}

.hero__text h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    line-height: 1.15;
}

.hero__text .subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.hero__text .bio {
    margin-top: 1.5rem;
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

.hero__cta {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.hero__image {
    position: relative;
}

.hero__image img {
    width: 100%;
    max-width: 420px;
    border-radius: 12px;
    box-shadow: 0 20px 60px var(--shadow);
    margin: 0 auto;
}

/* --- 7. BUTTONS --- */
.btn {
    display: inline-block;
    padding: 0.7rem 1.6rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--accent);
    color: #fff;
    border: 2px solid var(--accent);
}
.btn-primary:hover {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(91,155,213,0.3);
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--border);
}
.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
    transform: translateY(-1px);
}

/* --- 8. CARDS (used for nav cards on home, research items, etc.) --- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.8rem;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    text-decoration: none;
    display: block;
    color: var(--text-primary);
}
.card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    box-shadow: 0 8px 30px var(--shadow);
    text-decoration: none;
    color: var(--text-primary);
}

.card__icon {
    font-size: 2rem;
    margin-bottom: 0.8rem;
}

.card__title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    font-family: var(--font-heading);
}

.card__desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

/* --- 9. SECTION HEADINGS --- */
.section-header {
    text-align: center;
    margin-bottom: 3rem;
}

.section-header h2 {
    margin-bottom: 0.5rem;
}

.section-header p {
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

.section-label {
    display: block;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* --- 10. HIGHLIGHT BOX (e.g. research publication) --- */
.highlight-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: 2rem;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2rem;
    align-items: center;
    margin-bottom: 2rem;
}

.highlight-box__img {
    width: 120px;
    border-radius: 6px;
}

/* --- 11. PUBLICATIONS LIST --- */
.pub-list {
    list-style: none;
    padding: 0;
}

.pub-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}

.pub-item:hover {
    border-color: var(--accent);
}

.pub-item__title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
    line-height: 1.4;
}

.pub-item__authors {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.pub-item__journal {
    font-size: 0.875rem;
    color: var(--accent);
    font-style: italic;
    margin-bottom: 0.5rem;
}

.pub-item__links {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.pub-badge {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-decoration: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: all 0.2s;
}

.pub-badge:hover {
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}

.pub-badge.doi { border-color: var(--accent); color: var(--accent); }

/* --- 12. PROFILE LINKS (Google Scholar, ORCID, etc.) --- */
.profile-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.profile-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
}

.profile-link:hover {
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}

/* --- 13. PHOTO GRID (adventures page) --- */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.2rem;
}

.photo-grid__item img {
    width: 100%;
    height: 280px;
    object-fit: cover; /* crops image to fill space without stretching */
    border-radius: 8px;
}

.photo-grid__caption {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    line-height: 1.5;
}

/* --- 14. QUOTE BLOCK --- */
blockquote {
    border-left: 4px solid var(--accent);
    padding: 1rem 1.5rem;
    margin: 2rem 0;
    background: var(--bg-card);
    border-radius: 0 8px 8px 0;
}

blockquote p {
    font-size: 1.1rem;
    font-style: italic;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

blockquote cite {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-style: normal;
}

/* --- 15. TWO-COLUMN TEXT+IMAGE LAYOUT --- */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: start;
    margin-bottom: 3rem;
}

.content-grid.reverse {
    direction: rtl; /* flips column order for alternating layout */
}

.content-grid.reverse > * {
    direction: ltr; /* restore normal text direction inside */
}

/* --- 16. CONTACT SECTION --- */
.contact-info {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 2rem;
    max-width: 500px;
}

.contact-info p {
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.contact-info strong {
    color: var(--text-primary);
}

/* --- 17. FOOTER --- */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--accent); text-decoration: none; }

/* --- 18. RESPONSIVE (MOBILE) ---
   @media rules apply styles ONLY when the screen is smaller
   than the specified width. This makes the site look good
   on phones too. */
@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.5rem; }

    .hero__inner {
        grid-template-columns: 1fr; /* stack vertically on mobile */
        gap: 2rem;
        text-align: center;
    }

    .hero__image { order: -1; } /* photo above text on mobile */

    .hero__text h1 { font-size: 2.2rem; }

    .hero__cta { justify-content: center; }

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

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

    .highlight-box {
        grid-template-columns: 1fr;
    }

    /* Mobile nav */
    .nav__links {
        display: none;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        right: 0;
        background: var(--bg-card);
        flex-direction: column;
        gap: 0;
        border-bottom: 1px solid var(--border);
    }

    .nav__links.open {
        display: flex;
    }

    .nav__links li a {
        display: block;
        padding: 1rem 2rem;
        border-bottom: 1px solid var(--border);
    }

    .nav__toggle { display: block; }
}
