/**
 * Main Stylesheet for kemalinecik.com
 *
 * A refined, minimalist personal site — editorial serif typography on a
 * quiet, layered canvas. Designed mobile-first with fluid type and spacing
 * so it stays elegant from 320px phones to ultra-wide displays.
 *
 * Table of Contents:
 *  1. Design Tokens
 *  2. Dark Mode Theme
 *  3. Reset & Base
 *  4. Background & Ambient Layers
 *  5. Typography
 *  6. Layout
 *  7. Language Switcher
 *  8. Profile Section
 *  9. Bio Section
 * 10. Social Links
 * 11. Footer & Controls
 * 12. Utilities
 * 13. Accessibility
 * 14. Entrance Animation
 * 15. Responsive
 * 16. Print
 */

/* =============================================================================
   1. Design Tokens
   ============================================================================= */

:root {
    color-scheme: light;

    /* Core palette — warm ink on paper */
    --color-primary: #1b1b1f;       /* headings / ink */
    --color-accent: #56565e;        /* secondary text */
    --color-text: #51515b;          /* body copy */
    --color-background: #ecebe8;     /* page base */
    --color-surface: #ffffff;       /* cards */
    --color-surface-2: #f1f0ec;     /* insets, segmented control */
    --color-border: rgba(20, 20, 30, 0.09);
    --color-border-strong: rgba(20, 20, 30, 0.16);
    --color-muted: #7c7c84;         /* footer meta */
    --color-subtle: #8c8c93;        /* captions */

    /* Single restrained accent — a muted clay that echoes the portrait */
    --color-warm: #a35f44;
    --color-warm-soft: rgba(163, 95, 68, 0.12);

    /* Ambient glows behind the content */
    --glow-top: rgba(255, 255, 255, 0.85);
    --glow-warm: rgba(163, 95, 68, 0.06);
    --glow-cool: rgba(70, 84, 120, 0.05);
    --highlight-inset: rgba(255, 255, 255, 0.65);

    /* Typography */
    --font-serif: 'Lora', Georgia, 'Times New Roman', serif;
    --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --line-height-base: 1.75;

    /* Spacing scale */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 2.5rem;
    --space-3xl: 3rem;

    /* Layout */
    --container-max-width: 680px;
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 22px;
    --radius-pill: 999px;

    /* Motion */
    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    --transition-fast: 0.18s var(--ease);
    --transition-base: 0.28s var(--ease);
    --transition-slow: 0.5s var(--ease);

    /* Elevation — soft, layered shadows */
    --shadow-sm: 0 1px 2px rgba(17, 17, 26, 0.05);
    --shadow-md:
        0 1px 2px rgba(17, 17, 26, 0.04),
        0 6px 16px -8px rgba(17, 17, 26, 0.10),
        0 16px 40px -16px rgba(17, 17, 26, 0.12);
    --shadow-lg:
        0 2px 4px rgba(17, 17, 26, 0.05),
        0 12px 28px -10px rgba(17, 17, 26, 0.14),
        0 30px 60px -20px rgba(17, 17, 26, 0.18);
    --shadow-img:
        0 18px 44px -18px rgba(17, 17, 26, 0.34),
        0 6px 14px -8px rgba(17, 17, 26, 0.18);

    /* Z-index scale */
    --z-overlay: 1000;
}

/* =============================================================================
   2. Dark Mode Theme
   ============================================================================= */

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --color-primary: #f1efec;
        --color-accent: #a6a6ac;
        --color-text: #aeaeb4;
        --color-background: #151617;
        --color-surface: #1e1f21;
        --color-surface-2: #26282a;
        --color-border: rgba(255, 255, 255, 0.10);
        --color-border-strong: rgba(255, 255, 255, 0.18);
        --color-muted: #84858a;
        --color-subtle: #9a9aa0;

        --color-warm: #d18b6f;
        --color-warm-soft: rgba(209, 139, 111, 0.16);

        --glow-top: rgba(120, 130, 150, 0.10);
        --glow-warm: rgba(209, 139, 111, 0.07);
        --glow-cool: rgba(90, 110, 160, 0.08);
        --highlight-inset: rgba(255, 255, 255, 0.05);

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-md:
            0 1px 2px rgba(0, 0, 0, 0.4),
            0 10px 30px -12px rgba(0, 0, 0, 0.6);
        --shadow-lg:
            0 2px 6px rgba(0, 0, 0, 0.5),
            0 24px 50px -18px rgba(0, 0, 0, 0.7);
        --shadow-img:
            0 22px 50px -20px rgba(0, 0, 0, 0.75),
            0 6px 16px -8px rgba(0, 0, 0, 0.55);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --color-primary: #f1efec;
    --color-accent: #a6a6ac;
    --color-text: #aeaeb4;
    --color-background: #151617;
    --color-surface: #1e1f21;
    --color-surface-2: #26282a;
    --color-border: rgba(255, 255, 255, 0.10);
    --color-border-strong: rgba(255, 255, 255, 0.18);
    --color-muted: #84858a;
    --color-subtle: #9a9aa0;

    --color-warm: #d18b6f;
    --color-warm-soft: rgba(209, 139, 111, 0.16);

    --glow-top: rgba(120, 130, 150, 0.10);
    --glow-warm: rgba(209, 139, 111, 0.07);
    --glow-cool: rgba(90, 110, 160, 0.08);
    --highlight-inset: rgba(255, 255, 255, 0.05);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md:
        0 1px 2px rgba(0, 0, 0, 0.4),
        0 10px 30px -12px rgba(0, 0, 0, 0.6);
    --shadow-lg:
        0 2px 6px rgba(0, 0, 0, 0.5),
        0 24px 50px -18px rgba(0, 0, 0, 0.7);
    --shadow-img:
        0 22px 50px -20px rgba(0, 0, 0, 0.75),
        0 6px 16px -8px rgba(0, 0, 0, 0.55);
}

/* =============================================================================
   3. Reset & Base
   ============================================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font-serif);
    font-size: clamp(1rem, 0.97rem + 0.18vw, 1.075rem);
    line-height: var(--line-height-base);
    color: var(--color-text);
    background-color: var(--color-background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'kern' 1, 'liga' 1;
    -webkit-tap-highlight-color: transparent;
    transition: background-color var(--transition-slow);
}

button {
    font-family: inherit;
    color: inherit;
}

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

a {
    color: var(--color-primary);
}

::selection {
    background: var(--color-warm-soft);
    color: var(--color-primary);
}

/* =============================================================================
   4. Background & Ambient Layers
   ============================================================================= */

/* Soft, slow gradients that give the flat page a sense of depth */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(60rem 48rem at 50% -18%, var(--glow-top), transparent 62%),
        radial-gradient(34rem 34rem at 86% 6%, var(--glow-warm), transparent 60%),
        radial-gradient(44rem 44rem at 6% 98%, var(--glow-cool), transparent 60%);
}

/* =============================================================================
   5. Typography
   ============================================================================= */

h1 {
    font-size: clamp(1.85rem, 1.3rem + 2.7vw, 2.6rem);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.02em;
    color: var(--color-primary);
    margin: clamp(1.1rem, 3vw, 1.6rem) 0 0.35rem;
}

p {
    margin: 0 0 var(--space-lg);
}

p:last-child {
    margin-bottom: 0;
}

em {
    font-style: italic;
}

strong {
    font-weight: 700;
}

/* =============================================================================
   6. Layout
   ============================================================================= */

.container {
    display: flex;
    flex-direction: column;
    gap: clamp(1.4rem, 3.5vw, 2.6rem);
    max-width: var(--container-max-width);
    margin-inline: auto;
    padding: clamp(2.25rem, 6vw, 5rem) clamp(1.15rem, 5vw, 2.5rem);
}

/* Shared surface treatment for the cards */
.profile-section,
.bio-section,
.chat-section {
    position: relative;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md), inset 0 1px 0 var(--highlight-inset);
    transition: background-color var(--transition-slow),
                border-color var(--transition-slow),
                box-shadow var(--transition-base);
}

/* =============================================================================
   7. Language Switcher + theme toggle (one centered line at the top)
   ============================================================================= */

/* The language bar and the theme toggle sit together on one line, the whole
   unit centered, with a small gap between them. */
.top-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: fit-content;
    margin: 0 auto clamp(2.25rem, 6vw, 3.25rem);
}

.lang-switcher {
    display: flex;
    width: fit-content;
    gap: 2px;
    padding: 4px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
}

/* Theme toggle next to the language bar — a matching pill, icon-only (sun/moon
   swapped by the global .theme-icon rules per data-theme). */
.top-controls .theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.45rem;
    height: 2.45rem;
    color: var(--color-muted);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: color var(--transition-fast),
                background-color var(--transition-fast),
                border-color var(--transition-fast);
}

.top-controls .theme-toggle:hover {
    color: var(--color-primary);
    border-color: var(--color-border-strong);
}

.top-controls .theme-toggle .theme-icon svg {
    width: 18px;
    height: 18px;
    display: inline-block;
    vertical-align: middle;
}

.lang-btn {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1;
    padding: 0.5rem 0.85rem;
    color: var(--color-muted);
    background: transparent;
    border: 0;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: color var(--transition-fast),
                background-color var(--transition-fast),
                box-shadow var(--transition-fast);
}

.lang-btn:hover {
    color: var(--color-primary);
}

.lang-btn.active {
    color: var(--color-primary);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
}

/* =============================================================================
   8. Profile Section
   ============================================================================= */

.profile-section {
    text-align: center;
    padding: clamp(1.1rem, 3vw, 1.5rem) clamp(1.25rem, 5vw, 2.75rem) clamp(2.25rem, 5vw, 3rem);
}

/* Subtle ambient wash inside the hero card */
.profile-section::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: radial-gradient(38rem 20rem at 50% -25%, var(--color-warm-soft), transparent 70%);
    opacity: 0.7;
}

.profile-section > * {
    position: relative;
    z-index: 1;
}

/* Portrait with framed ring + soft drop shadow */
.profile-img-frame {
    display: block;
    width: fit-content;
    position: relative;
    margin: 0 auto;
    border-radius: 50%;
}

.profile-img {
    width: clamp(132px, 38vw, 184px);
    height: clamp(132px, 38vw, 184px);
    border-radius: 50%;
    object-fit: cover;
    background: var(--color-surface-2);
    box-shadow:
        0 0 0 1px var(--color-border-strong),
        0 0 0 6px var(--color-surface),
        var(--shadow-img);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.profile-img-frame:hover .profile-img {
    transform: translateY(-3px) scale(1.015);
    box-shadow:
        0 0 0 1px var(--color-border-strong),
        0 0 0 6px var(--color-surface),
        var(--shadow-lg);
}

.position {
    font-size: clamp(0.88rem, 0.82rem + 0.32vw, 1rem);
    font-style: italic;
    color: var(--color-accent);
    margin: 0 auto;
    max-width: 30ch;
}

/* CV download — the primary call to action */
.cv-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: clamp(1.25rem, 3vw, 1.6rem);
    padding: 0.6rem 1.3rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: var(--color-surface);
    background: var(--color-primary);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-pill);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-base),
                background-color var(--transition-base),
                color var(--transition-base),
                box-shadow var(--transition-base);
}

.cv-button:hover {
    color: var(--color-primary);
    background: transparent;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.cv-button:active {
    transform: translateY(0);
}

.cv-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* =============================================================================
   9. Bio Section
   ============================================================================= */

.bio-section {
    padding: clamp(1.75rem, 5vw, 2.75rem) clamp(1.5rem, 5vw, 3rem);
}

.bio {
    font-size: clamp(0.9rem, 0.87rem + 0.16vw, 0.95rem);
    text-align: justify;
    hyphens: auto;
}

.bio p {
    margin-bottom: 1.4em;
}

/* In-text links (e.g. advisor) — quiet until hovered */
.no-blue-link {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.no-blue-link:hover {
    color: var(--color-warm);
}

/* =============================================================================
   9.5. Chat Bar — AI Assistant
   -----------------------------------------------------------------------------
   A slim bar that shares the cards' surface treatment. Collapsed it is a quiet
   invitation to ask a question; focused or typed-into it unfolds — with a soft
   vertical animation — into a full, sleek conversation surface.
   ============================================================================= */

.chat-section {
    /* Component-scoped accents (inherit the site's single warm clay) */
    --chat-online: #4f9d77;
    /* The card's own radius lets corner children clip cleanly */
}

/* ---- Composer: the visible bar when collapsed, pinned to the bottom open ---- */
.chat__composer {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.62rem 0.7rem 0.62rem 0.95rem;
    position: relative;
    z-index: 1;
}

/* Left brand mark — Kemal's own "Kİ" monogram (the site favicon), a quiet cue
   that this assistant is his custom build, not a third-party widget. */
.chat__spark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.7rem;
    height: 1.7rem;
}

/* The favicon is a light "Kİ" tile; circle-crop it and, on dark theme, reverse
   its colours so it reads as a light monogram on a dark surface. */
.chat__brand {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

[data-theme="dark"] .chat__brand {
    filter: invert(1);
}

/* A slow, gentle breath on the composer mark so it reads as "alive" (opacity
   only — no rotation, which would tilt the letters). */
@media (prefers-reduced-motion: no-preference) {
    .chat-section[data-status="online"] .chat__composer .chat__brand {
        animation: chatBrandPulse 4.2s var(--ease) infinite;
    }
}

@keyframes chatBrandPulse {
    0%, 100% { opacity: 0.7; }
    50%      { opacity: 1; }
}

.chat__input {
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--font-sans);
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--color-primary);
    background: transparent;
    border: 0;
    padding: 0.32rem 0;
    outline: none;
}

.chat__input::placeholder {
    color: var(--color-muted);
    opacity: 1;
}

.chat__input:disabled {
    cursor: not-allowed;
}

/* iOS Safari auto-zooms a focused input whose font-size is < 16px.
   Bump to 16px on touch devices so tapping the bar never zooms the page. */
@media (hover: none) {
    .chat__input {
        font-size: 16px;
    }
}

/* Send — a small circular control that brightens once there's something to say */
.chat__send {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    color: var(--color-surface);
    background: var(--color-primary);
    border: 0;
    border-radius: var(--radius-pill);
    cursor: pointer;
    opacity: 0.32;
    transform: scale(0.9);
    transition: opacity var(--transition-base),
                transform var(--transition-base),
                background-color var(--transition-base);
}

.chat__send svg {
    width: 15px;
    height: 15px;
}

.chat-section.chat--has-text .chat__send {
    opacity: 1;
    transform: scale(1);
}

@media (hover: hover) {
    .chat-section.chat--has-text .chat__send:hover {
        background: var(--color-warm);
        transform: scale(1.05);
    }
}

.chat__send:disabled {
    cursor: default;
    opacity: 0.32;
    transform: scale(0.9);
    background: var(--color-primary);
}

/* Collapsed bar invites a click without lifting like the buttons do */
@media (hover: hover) {
    .chat-section[data-state="collapsed"]:hover {
        border-color: var(--color-border-strong);
        box-shadow: var(--shadow-lg), inset 0 1px 0 var(--highlight-inset);
    }
}

.chat-section:focus-within {
    border-color: var(--color-border-strong);
}

/* ---- The expandable conversation panel (header + log) ---- */
.chat__panel {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows var(--transition-base);
}

.chat-section[data-state="expanded"] .chat__panel {
    grid-template-rows: 1fr;
}

.chat__panel-inner {
    overflow: hidden;
    min-height: 0;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.chat-section[data-state="expanded"] .chat__panel-inner {
    opacity: 1;
    transition-delay: 0.06s;
}

/* ---- Header ---- */
.chat__header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.85rem 0.7rem 0.8rem 0.95rem;
    border-bottom: 1px solid var(--color-border);
}

.chat__avatar {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: var(--radius-pill);
}

.chat__status-dot {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: var(--color-muted);
    border: 2px solid var(--color-surface);
    transition: background-color var(--transition-base);
}

.chat-section[data-status="online"] .chat__status-dot { background: var(--chat-online); }
.chat-section[data-status="warmup"] .chat__status-dot { background: var(--color-warm); }

.chat__heading {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.chat__title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.05rem 0.35rem;
    min-width: 0;
}

.chat__title {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--color-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 0 1 auto;
}

/* A small, muted, italic "(work in progress)" tag beside the title. On a narrow
   header it wraps to its own line (kept whole) instead of crowding the title. */
.chat__tag {
    font-family: var(--font-sans);
    font-size: 0.68rem;
    font-style: italic;
    font-weight: 400;
    letter-spacing: 0.01em;
    color: var(--color-muted);
    white-space: nowrap;
    flex: 0 0 auto;
}

.chat__status-text {
    font-family: var(--font-sans);
    font-size: 0.73rem;
    line-height: 1.5;
    color: var(--color-muted);
}

.chat__close {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    color: var(--color-muted);
    background: transparent;
    border: 0;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: color var(--transition-fast), background-color var(--transition-fast);
}

.chat__close:hover {
    color: var(--color-primary);
    background: var(--color-surface-2);
}

.chat__close svg {
    width: 16px;
    height: 16px;
}

/* ---- Settings: discreet gear (mirrors .chat__close) + popover ---- */
.chat__settings {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    color: var(--color-muted);
    background: transparent;
    border: 0;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: color var(--transition-fast), background-color var(--transition-fast);
}

.chat__settings svg { width: 16px; height: 16px; }

.chat__settings:hover,
.chat-section[data-settings="open"] .chat__settings {
    color: var(--color-primary);
    background: var(--color-surface-2);
}

/* While a popover is open, lift the whole chat card above its sibling cards
   (profile/bio/etc. set no z-index), so the menu floats over all page content
   instead of being painted under the later cards. */
.chat-section[data-settings="open"],
.chat-section[data-langmenu="open"] {
    z-index: 40;
}

/* Popover: same frosted card as the conversation panel, anchored under the gear */
.chat__settings-panel {
    position: absolute;
    top: 3.55rem;
    right: 0.6rem;
    z-index: 6;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    width: min(18rem, calc(100% - 1rem));
    padding: 0.9rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg), inset 0 1px 0 var(--highlight-inset);
    transform-origin: top right;
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    pointer-events: none;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.chat-section[data-settings="open"] .chat__settings-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.chat__settings-group {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.chat__settings-label {
    font-family: var(--font-sans);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-subtle);
}

/* Segmented control — same visual language as the page's .lang-switcher */
.chat__seg {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
}

.chat__seg-btn {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: var(--font-sans);
    font-size: 0.74rem;
    font-weight: 500;
    line-height: 1.12;
    padding: 0.4rem 0.4rem;
    color: var(--color-muted);
    background: transparent;
    border: 0;
    border-radius: var(--radius-md);
    cursor: pointer;
    /* Let long labels (e.g. German "Öffentlich", "Ausführlich") wrap/hyphenate
       instead of overflowing the fixed 3-up control. */
    white-space: normal;
    overflow-wrap: break-word;
    hyphens: auto;
    transition: color var(--transition-fast),
                background-color var(--transition-fast),
                box-shadow var(--transition-fast);
}

.chat__seg-btn:hover { color: var(--color-primary); }

.chat__seg-btn.active {
    color: var(--color-primary);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
}

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

/* New-chat — a header icon button (mirrors .chat__settings / .chat__close),
   sitting left of the gear. Resets the session, persona and mode + clears the
   saved conversation. Disabled until the first message gives it something to do. */
.chat__new {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    color: var(--color-muted);
    background: transparent;
    border: 0;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: color var(--transition-fast),
                background-color var(--transition-fast),
                opacity var(--transition-fast);
}

.chat__new svg { width: 16px; height: 16px; }

.chat__new:hover:not(:disabled) {
    color: var(--color-primary);
    background: var(--color-surface-2);
}

.chat__new:disabled {
    opacity: 0.32;
    cursor: default;
}

/* ---- Log / messages ---- */
.chat__log {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-height: clamp(220px, 42vh, 380px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.95rem 0.95rem 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border-strong) transparent;
}

.chat__log::-webkit-scrollbar {
    width: 8px;
}

.chat__log::-webkit-scrollbar-thumb {
    background: var(--color-border-strong);
    border-radius: var(--radius-pill);
    border: 2px solid transparent;
    background-clip: padding-box;
}

.chat__msg {
    max-width: 85%;
    padding: 0.5rem 0.8rem;
    font-size: 0.92rem;
    line-height: 1.6;
    border-radius: var(--radius-md);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    animation: chatMsgIn 0.34s var(--ease) both;
}

@keyframes chatMsgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat__msg--bot {
    align-self: flex-start;
    color: var(--color-text);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-bottom-left-radius: var(--radius-sm);
}

.chat__msg--user {
    align-self: flex-end;
    color: var(--color-surface);
    background: var(--color-primary);
    border-bottom-right-radius: var(--radius-sm);
}

.chat__msg--system {
    align-self: center;
    max-width: 90%;
    text-align: center;
    color: var(--color-muted);
    background: transparent;
    font-size: 0.82rem;
    font-style: italic;
}

/* Rich content inside bot replies (safe, whitelisted markdown) */
.chat__msg a {
    color: var(--color-warm);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
    overflow-wrap: anywhere;
    transition: color var(--transition-fast);
}

.chat__msg a:hover {
    color: var(--color-primary);
}

.chat__msg code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.88em;
    padding: 0.05em 0.35em;
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

/* Typing indicator (rendered inside a bot bubble while awaiting a reply) */
.chat__typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.1rem 0;
}

.chat__typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-muted);
    animation: chatDot 1.2s var(--ease) infinite;
}

.chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.chat__typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatDot {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30%           { opacity: 1;   transform: translateY(-3px); }
}

/* ---- Offline treatment — quiet, never an error ---- */
.chat-section[data-status="offline"] .chat__composer {
    opacity: 0.72;   /* dims the brand mark + input together */
}

/* =============================================================================
   10. Social Links
   ============================================================================= */

/* Even, balanced grid so the buttons never leave a lonely last row:
   2 columns on phones, 3 columns (two tidy rows) on larger screens. */
.social-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
    max-width: 400px;
    margin-inline: auto;
}

@media (min-width: 480px) {
    .social-links {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        max-width: none;
    }
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1.05rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-primary);
    text-decoration: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-base),
                background-color var(--transition-base),
                color var(--transition-base),
                border-color var(--transition-base),
                box-shadow var(--transition-base);
}

.social-link:hover {
    color: var(--color-surface);
    background: var(--color-primary);
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.social-link:active {
    transform: translateY(0);
}

.social-icon {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
}

/* =============================================================================
   11. Footer & Controls
   ============================================================================= */

footer {
    text-align: center;
    color: var(--color-muted);
    font-size: 0.875rem;
    padding-top: clamp(1.75rem, 4vw, 2.5rem);
    border-top: 1px solid var(--color-border);
}

footer p {
    margin-bottom: 0.85rem;
}

.address {
    font-size: 0.84rem;
    line-height: 1.7;
    color: var(--color-subtle);
}

.contact-link {
    color: var(--color-accent);
    text-decoration: none;
    border-bottom: 1px solid var(--color-border-strong);
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.contact-link:hover {
    color: var(--color-warm);
    border-color: var(--color-warm);
}

/* =============================================================================
   12. Utilities
   ============================================================================= */

/* Theme toggle label visibility (driven by data-theme / system preference) */
.theme-icon {
    display: none;
}

:root:not([data-theme="dark"]) .theme-icon--light {
    display: inline;
}

[data-theme="dark"] .theme-icon--dark {
    display: inline;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-icon--light {
        display: none;
    }
    :root:not([data-theme="light"]) .theme-icon--dark {
        display: inline;
    }
}

/* Screen-reader-only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* =============================================================================
   13. Accessibility
   ============================================================================= */

/* Visible keyboard focus on every interactive element */
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--color-warm);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
}

/* Skip link */
.skip-link {
    position: absolute;
    top: -120%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-primary);
    color: var(--color-surface);
    padding: var(--space-md) var(--space-xl);
    text-decoration: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    z-index: var(--z-overlay);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: top var(--transition-base);
}

.skip-link:focus {
    top: 0;
}

/* Reduced motion — drop transforms and animations */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .profile-img-frame:hover .profile-img,
    .social-link:hover,
    .cv-button:hover {
        transform: none;
    }
}

/* High contrast */
@media (prefers-contrast: more) {
    :root {
        --color-border: var(--color-primary);
        --color-border-strong: var(--color-primary);
        --shadow-md: none;
        --shadow-lg: none;
    }

    .profile-section,
    .bio-section {
        border-width: 2px;
    }
}

/* =============================================================================
   14. Entrance Animation
   ============================================================================= */

@media (prefers-reduced-motion: no-preference) {
    .container > .profile-section,
    .container > .chat-section,
    .container > .bio-section,
    .container > .social-links,
    .container > footer {
        opacity: 0;
        animation: rise 0.7s var(--ease) forwards;
    }

    .container > .profile-section { animation-delay: 0.05s; }
    .container > .chat-section    { animation-delay: 0.13s; }
    .container > .bio-section     { animation-delay: 0.21s; }
    .container > .social-links    { animation-delay: 0.29s; }
    .container > footer           { animation-delay: 0.37s; }

    @keyframes rise {
        from {
            opacity: 0;
            transform: translateY(14px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* =============================================================================
   15. Responsive
   ============================================================================= */

/* Phones — relax justification so lines don't gap awkwardly */
@media (max-width: 560px) {
    .bio {
        text-align: left;
        hyphens: none;
    }

    .social-link {
        font-size: 0.875rem;
        padding: 0.5rem 0.9rem;
    }
}

/* Very small screens — keep the language control from crowding */
@media (max-width: 360px) {
    .lang-btn {
        padding: 0.5rem 0.65rem;
        font-size: 0.74rem;
    }
}

/* Fine pointers (mouse) get the lift effects; coarse (touch) skip them */
@media (hover: none) {
    .social-link:hover,
    .cv-button:hover,
    .profile-img-frame:hover .profile-img {
        transform: none;
    }
}

/* =============================================================================
   16. Print
   ============================================================================= */

@media print {
    :root {
        --color-background: #ffffff;
        --color-surface: #ffffff;
        --color-text: #000000;
        --color-primary: #000000;
        --color-border: #cccccc;
        --color-border-strong: #999999;
    }

    body {
        background: #fff;
        color: #000;
        font-size: 12pt;
    }

    body::before,
    .skip-link,
    .top-controls,
    .chat-section {
        display: none !important;
    }

    .container {
        margin: 0;
        padding: 0;
        max-width: 100%;
        gap: 1rem;
    }

    .profile-section,
    .bio-section {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }

    .profile-img {
        box-shadow: none;
        border: 1px solid #ccc;
        width: 150px;
        height: 150px;
    }

    .social-links {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
    }

    .social-link {
        border: none;
        box-shadow: none;
        padding: 0.2rem 0;
    }

    .social-link::after {
        content: " (" attr(href) ")";
        font-size: 10pt;
        color: #666;
    }

    a {
        color: #000;
        text-decoration: underline;
    }

    h1, h2, h3 {
        page-break-after: avoid;
    }

    .bio p {
        orphans: 3;
        widows: 3;
    }
}
