/* ============================================================
   Muhammed Ustaomeroglu - personal site
   Palette & type adapted from the RET project page
   (warm paper, Türk mavisi accent, serif body, single scroll)
   ============================================================ */

:root {
    --bg: #fbfaf7;
    --bg-alt: #f3f1ea;
    --ink: #1d1c1a;
    --ink-soft: #4a4843;
    --ink-faint: #7c786f;
    --rule: #e4e0d6;
    --accent: #109fb4;          /* turquoise (Türk mavisi, leaning teal) */
    --accent-hover: #0c8499;
    --accent-soft: #d2eef1;
    --maxw: 760px;
    --maxw-wide: 1080px;
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Charter", Georgia, Cambria, serif;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

body {
    font-family: var(--serif);
    font-size: 19px;
    line-height: 1.7;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover { text-decoration: underline; }

em { font-style: italic; }
strong { font-weight: 600; }

.wrap {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 24px;
}

/* ---------- Navigation (kept top-right) ---------- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(251, 250, 247, 0.85);
    backdrop-filter: blur(12px) saturate(1.1);
    border-bottom: 1px solid var(--rule);
    transition: background 0.3s ease;
}

.nav-container {
    max-width: var(--maxw-wide);
    margin: 0 auto;
    padding: 13px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.nav-logo {
    font-family: var(--serif);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ink);
    text-decoration: none;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.nav-logo:hover {
    color: var(--accent);
    text-decoration: none;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 6px;
}

.nav-link {
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 500;
    color: var(--ink-faint);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 999px;
    transition: color 0.15s ease, background 0.15s ease;
}

.nav-link:hover {
    background: var(--accent-soft);
    color: var(--accent);
    text-decoration: none;
}

.nav-link.active {
    background: var(--accent);
    color: #fff;
}

.nav-link.active:hover {
    background: var(--accent);
    color: #fff;
}

/* Mobile menu toggle */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    gap: 4px;
    transition: var(--transition);
}

.mobile-menu-toggle:hover {
    background: var(--bg-alt);
}

.mobile-menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
}

/* ---------- Hero / Home ---------- */
.hero {
    padding: 124px 0 80px;
    background: linear-gradient(180deg, #fffdf8 0%, var(--bg) 100%);
    border-bottom: 1px solid var(--rule);
    scroll-margin-top: 72px;
}

.hero .wrap {
    max-width: var(--maxw-wide);
}

.hero-grid {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 20px 56px;
    align-items: center;
}

.hero-content {
    min-width: 0;
}

.hero-name {
    grid-column: 1 / -1;
    font-size: clamp(34px, 5.4vw, 58px);
    line-height: 1.05;
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--ink);
}

.hero-description {
    font-size: 18px;
    line-height: 1.7;
    color: var(--ink-soft);
    margin: 24px 0 0;
    max-width: 660px;
}

.hero-description a { font-weight: 500; }
.hero-description strong { color: var(--ink); }

.hero-actions {
    display: flex;
    gap: 12px;
    margin-top: 32px;
    flex-wrap: wrap;
}

/* Buttons (RET pill style) */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--sans);
    font-size: 15px;
    font-weight: 600;
    padding: 11px 22px;
    border-radius: 999px;
    border: 1px solid var(--ink);
    color: var(--ink);
    background: transparent;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}

.btn-secondary {
    background: transparent;
    border-color: var(--ink);
    color: var(--ink);
}

.btn-secondary:hover {
    background: var(--ink);
    color: var(--bg);
}

/* Profile photo */
.hero-image {
    display: flex;
    justify-content: center;
    align-items: center;
}

.profile-container {
    position: relative;
    width: 420px;
    height: 340px;
    max-width: 100%;
}

.profile-photo {
    width: 100%;
    height: 100%;
    border-radius: 16px;
    object-fit: cover;
    border: 1px solid var(--rule);
    box-shadow: 0 18px 44px rgba(16, 159, 180, 0.16);
    transition: var(--transition);
}

.profile-photo:hover {
    transform: translateY(-3px);
}

.profile-bg {
    position: absolute;
    top: -16px;
    right: -16px;
    width: calc(100% + 32px);
    height: calc(100% + 32px);
    background: linear-gradient(135deg, var(--accent-soft), var(--accent));
    border-radius: 24px;
    z-index: -1;
    opacity: 0.18;
}

.loading {
    width: 100%;
    height: 100%;
    border-radius: 16px;
    background: linear-gradient(45deg, var(--bg-alt), var(--accent-soft));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-family: var(--sans);
    font-weight: 600;
    font-size: 1rem;
}

/* ---------- Sections ---------- */
main section {
    padding: 72px 0;
    border-bottom: 1px solid var(--rule);
    scroll-margin-top: 72px;
}

main section:last-of-type {
    border-bottom: none;
}

h2 {
    font-size: clamp(28px, 4.2vw, 38px);
    line-height: 1.12;
    margin: 0 0 28px;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--ink);
}

/* ---------- Research ---------- */
.research-theme {
    margin: 0 0 8px;
}

.research-theme + .research-theme {
    margin-top: 44px;
    padding-top: 44px;
    border-top: 1px solid var(--rule);
}

.theme-title {
    font-family: var(--serif);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--ink);
    margin: 0 0 14px;
    line-height: 1.3;
}

.research-theme p {
    font-size: 18px;
    line-height: 1.7;
    color: var(--ink-soft);
    margin: 0 0 16px;
}

.research-theme strong { color: var(--ink); }
.research-theme em { color: var(--ink); font-style: italic; }

/* ---------- Contact ---------- */
.contact-note {
    font-size: 17px;
    line-height: 1.7;
    color: var(--ink-soft);
    margin: 0 0 28px;
    max-width: 640px;
}

.contact-icons {
    display: flex;
    flex-direction: row;
    gap: 12px;
    flex-wrap: wrap;
}

.contact-icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 1px solid var(--rule);
    background: #fff;
    color: var(--ink-soft);
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.contact-icon-link:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    text-decoration: none;
    transform: translateY(-2px);
}

/* ---------- Footer ---------- */
.footer {
    text-align: center;
    padding: 44px 24px 60px;
    background: var(--bg-alt);
    border-top: 1px solid var(--rule);
}

.footer p {
    margin: 0;
    font-family: var(--sans);
    font-size: 14px;
    color: var(--ink-faint);
}

/* ---------- Scroll reveal ---------- */
.reveal {
    opacity: 0;
    transform: translateY(22px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.in {
    opacity: 1;
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    .reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
    .hero-grid {
        grid-template-columns: 1fr;
        gap: 36px;
        text-align: center;
    }

    .hero-content { order: 2; }
    .hero-image { order: 1; }

    .hero-description {
        margin-left: auto;
        margin-right: auto;
    }

    .hero-actions { justify-content: center; }

    .profile-container {
        width: 400px;
        height: 323px;
    }
}

@media (max-width: 760px) {
    .nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg);
        flex-direction: column;
        padding: 16px 20px;
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
        border-bottom: 1px solid var(--rule);
        border-radius: 0 0 16px 16px;
        gap: 4px;
    }

    .nav-menu.active {
        display: flex;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .nav-logo {
        font-size: 0.98rem;
    }

    .hero {
        padding: 104px 0 64px;
    }

    .hero-description {
        font-size: 17px;
    }

    main section {
        padding: 56px 0;
    }

}

@media (max-width: 480px) {
    body { font-size: 18px; }

    .profile-container {
        width: 260px;
        height: 210px;
    }

    .btn {
        padding: 11px 20px;
        font-size: 14px;
    }
}

/* ---------- AI assistant widget ---------- */
.ai-launcher {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1100;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 999px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(16, 159, 180, 0.32);
    transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.ai-launcher:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 14px 34px rgba(16, 159, 180, 0.4);
}

.ai-panel {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    width: min(380px, calc(100vw - 32px));
    height: min(560px, calc(100vh - 90px));
    background: var(--bg);
    border: 1px solid var(--rule);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(29, 28, 26, 0.18);
    overflow: hidden;
    opacity: 0;
    transform: translateY(14px) scale(0.98);
    transform-origin: bottom right;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.ai-panel.ai-open {
    opacity: 1;
    transform: none;
}

/* display:flex above would defeat the hidden attribute without this */
.ai-panel[hidden],
.ai-chips[hidden],
.ai-launcher[hidden] {
    display: none;
}

.ai-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 12px;
    background: linear-gradient(180deg, #fffdf8 0%, var(--bg) 100%);
    border-bottom: 1px solid var(--rule);
}

.ai-title {
    font-family: var(--serif);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ink);
    margin: 0;
    line-height: 1.3;
}

.ai-sub {
    font-family: var(--sans);
    font-size: 11.5px;
    color: var(--ink-faint);
    margin: 3px 0 0;
}

.ai-close {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border: 1px solid var(--rule);
    border-radius: 50%;
    background: #fff;
    color: var(--ink-soft);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.ai-close:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.ai-log {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-msg {
    max-width: 86%;
    padding: 9px 13px;
    border-radius: 12px;
    font-family: var(--serif);
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink);
    overflow-wrap: break-word;
}

.ai-msg-model {
    align-self: flex-start;
    background: #fff;
    border: 1px solid var(--rule);
    border-bottom-left-radius: 4px;
}

.ai-msg-user {
    align-self: flex-end;
    background: var(--accent-soft);
    border-bottom-right-radius: 4px;
}

.ai-msg a {
    color: var(--accent);
    font-weight: 500;
}

.ai-typing span {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin: 0 2px;
    border-radius: 50%;
    background: var(--accent);
    animation: ai-pulse 1.1s infinite ease-in-out;
}

.ai-typing span:nth-child(2) { animation-delay: 0.18s; }
.ai-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes ai-pulse {
    0%, 100% { opacity: 0.25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

.ai-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 14px 10px;
}

.ai-chip {
    font-family: var(--sans);
    font-size: 12.5px;
    font-weight: 500;
    padding: 6px 13px;
    border-radius: 999px;
    border: 1px solid var(--rule);
    background: #fff;
    color: var(--ink-soft);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.ai-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.ai-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--rule);
    background: var(--bg-alt);
}

.ai-input {
    flex: 1;
    font-family: var(--sans);
    font-size: 14px;
    color: var(--ink);
    padding: 10px 14px;
    border: 1px solid var(--rule);
    border-radius: 999px;
    background: #fff;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ai-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.ai-send {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.12s ease;
}

.ai-send:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

@media (max-width: 480px) {
    .ai-launcher {
        right: 14px;
        bottom: 14px;
    }

    .ai-panel {
        right: 12px;
        bottom: 12px;
        width: calc(100vw - 24px);
        height: min(540px, calc(100vh - 64px));
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-panel {
        transition: none;
    }

    .ai-typing span {
        animation: none;
        opacity: 0.6;
    }
}
