@font-face { font-family:'Libre Baskerville'; src:url('/Fonts/LibreBaskerville-VariableFont_wght.woff2') format('woff2'); font-weight:400; font-style:normal; font-display:swap; }
@font-face { font-family:'Libre Baskerville'; src:url('/Fonts/LibreBaskerville-VariableFont_wght.woff2') format('woff2'); font-weight:700; font-style:normal; font-display:swap; }
@font-face { font-family:'Libre Baskerville'; src:url('/Fonts/LibreBaskerville-Italic-VariableFont_wght.woff2') format('woff2'); font-weight:400; font-style:italic; font-display:swap; }
@font-face { font-family:'Libre Baskerville'; src:url('/Fonts/LibreBaskerville-Italic-VariableFont_wght.woff2') format('woff2'); font-weight:700; font-style:italic; font-display:swap; }

:root { --bg:#f9f9f9; --text:#1a1a1a; --muted:#666; --accent:#1f3a5f; --line:rgba(0,0,0,0.08); --sw:320px; --um:50px; --tr:0.3s cubic-bezier(0.4,0,0.2,1); }

*,html,body { box-sizing:border-box; margin:0; padding:0; }
* { -webkit-font-smoothing:antialiased; }
html { scrollbar-gutter:stable; scroll-behavior:smooth; }
body,html { font-family:"Libre Baskerville",Georgia,serif; background:var(--bg); color:var(--text); height:100%; }

.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); border:0; }
.skip-nav { position:absolute; top:-100%; left:1rem; background:var(--bg); color:var(--accent); font-size:0.85rem; padding:8px 16px; border:1px solid var(--accent); text-decoration:none; z-index:9999; transition:top 0.1s; }
.skip-nav:focus { top:1rem; }

section { display:none; opacity:0; outline:none; min-height:100%; padding-top:105px; }
section:focus { outline:none; }
body[data-active-tab="about"] #about, body[data-active-tab="publications"] #publications,
body[data-active-tab="affiliations"] #affiliations, body[data-active-tab="talks"] #talks,
body[data-active-tab="contact"] #contact { display:flex; flex-direction:column; opacity:1; animation:fadeIn 0.4s ease forwards 0.05s; }

nav { position:fixed; top:0; width:100%; height:100px; z-index:4000; display:flex; align-items:flex-end; justify-content:center; transform:translateZ(0); }
.nav-inner { display:grid; grid-template-columns:var(--sw) 1fr; gap:60px; width:100%; max-width:1600px; margin:0 auto; padding:0 var(--um) 15px; }
.nav-links { display:flex; align-items:center; margin-left:-1rem; }
.nav-row-break { display:none; }
.nav-links a { text-decoration:none; color:var(--text); font-weight:400; font-size:1rem; text-transform:uppercase; opacity:0.65; transition:var(--tr); letter-spacing:1.2px; outline:none; padding:10px 1rem; display:inline-block; }
.nav-links a:not(:last-child) { border-right:1px solid var(--line); }
.nav-links a:hover, .nav-links a[aria-current="page"] { opacity:1; transform:scale(1.05); }
.nav-links a[aria-current="page"] { font-weight:700; color:var(--accent); }

.mask { position:fixed; width:calc(min(1600px,100%) - var(--sw) - var(--um) - 60px); right:max(var(--um),calc((100% - 1600px) / 2 + var(--um))); z-index:3500; pointer-events:none; }
.mask-top    { top:0;    height:110px; background:linear-gradient(to bottom,var(--bg) 85%,rgba(249,249,249,0)); }
.mask-bottom { bottom:0; height:var(--um); background:linear-gradient(to top,var(--bg) 70%,rgba(249,249,249,0)); }

.main-layout { display:grid; grid-template-columns:var(--sw) 1fr; gap:60px; padding:0 var(--um); height:100vh; height:100dvh; overflow:hidden; max-width:1600px; margin:0 auto; }
.sidebar { height:100vh; height:100dvh; padding-top:var(--um); display:flex; flex-direction:column; position:sticky; top:0; z-index:3000; }
main { overflow-y:auto; padding:0 0 var(--um); height:100%; scrollbar-width:none; contain:content; -webkit-overflow-scrolling:touch; }
main::-webkit-scrollbar { display:none; }

.layout-split { display:grid; grid-template-columns:2fr 1fr; gap:var(--um); align-items:start; }

.profile-photo-container { width:100%; aspect-ratio:3/4; background:#f2f2f2; display:flex; align-items:center; justify-content:center; margin-bottom:2rem; border-radius:4px; border:1px solid var(--line); position:relative; overflow:hidden; min-height:380px; }
.profile-image { width:100%; height:100%; object-fit:cover; display:block; z-index:2; position:relative; opacity:0; transition:opacity 0.4s ease; }
.profile-image.loaded { opacity:1; }
.profile-placeholder { position:absolute; z-index:1; display:flex; align-items:center; justify-content:center; width:100%; height:100%; }
.profile-placeholder::after { content:"LYUBOMIR SAKALIYSKI"; color:#aaa; font-size:0.75rem; text-transform:uppercase; letter-spacing:2px; text-align:center; padding:20px; }

.sidebar h1 { font-size:1.15rem; font-weight:700; color:var(--accent); line-height:1.2; white-space:nowrap; }
.sidebar .job-title { color:var(--muted); font-size:0.95rem; line-height:1.5; margin:16px 0 20px; }
.sidebar .job-title span { display:block; white-space:nowrap; }

.social-links { display:flex; gap:15px; margin-bottom:25px; align-items:center; flex-wrap:wrap; }
.social-links a { display:block; transition:var(--tr); text-decoration:none; outline:none; }
.social-links a:hover { transform:scale(1.2); }
.icon-sm { width:22px; height:22px; filter:grayscale(1) brightness(0.7); opacity:0.8; display:block; pointer-events:none; transition:filter 0.3s ease,opacity 0.3s ease; }
.social-links a:hover .icon-sm { filter:none; opacity:1; }

.sidebar-footer { margin-top:auto; padding-bottom:var(--um); }
.sidebar-copyright { color:#999; font-size:0.75rem; }
.main-content-copyright { display:none; padding-top:var(--um); }
.privacy-wrap { position:relative; display:inline-block; margin-bottom:8px; }
.privacy-trigger { font-size:0.75rem; color:#999; cursor:pointer; display:inline-block; background:none; border:none; padding:0; font-family:inherit; line-height:inherit; }
.privacy-trigger:hover { color:#666; }
.privacy-popup { position:absolute; bottom:calc(100% + 8px); left:0; background:var(--bg); border:1px solid var(--line); padding:12px 16px; font-size:0.75rem; color:var(--muted); line-height:1.6; width:var(--sw); opacity:0; pointer-events:none; transition:opacity 0.2s ease; z-index:9999; box-shadow:0 2px 12px rgba(0,0,0,0.06); text-align:justify; }
.privacy-wrap:hover .privacy-popup, .privacy-wrap.open .privacy-popup { opacity:1; pointer-events:auto; }

.section-header { margin-bottom:1.5rem; border-bottom:1px solid var(--line); padding-bottom:10px; min-height:38px; position:sticky; top:90px; background:var(--bg); z-index:2; }
#about p { text-align:justify; }
p { line-height:1.7; color:var(--muted); margin-bottom:1.5rem; }
ul { list-style:none; padding:0; margin-bottom:1rem; }
li { margin-bottom:1.5rem; line-height:1.6; color:var(--muted); }
li:last-child { margin-bottom:0; }
li strong { color:var(--text); display:block; margin-bottom:4px; }
h3 { margin-bottom:1rem; color:var(--accent); }
ul + h3, p + h3 { margin-top:1.5rem; }

.pub-item { display:flex; align-items:center; gap:20px; position:relative; }
.pub-item:last-child { margin-bottom:0; }
.pub-item:has(.pdf-link-icon) .pub-content { padding-left:61px; }
.pub-content { flex:1; line-height:1.4; }
.pub-content em { display:block; }
.pdf-link-icon { transition:var(--tr); text-decoration:none; position:absolute; inset:0; display:flex; align-items:center; }
.icon-pdf { width:41px; height:41px; display:block; filter:grayscale(1) brightness(0.7); opacity:0.8; transition:filter 0.3s ease,opacity 0.3s ease,transform 0.3s ease; }
.pdf-link-icon:hover .icon-pdf { filter:none; opacity:1; transform:scale(1.1); }
.icon-no-pdf { width:41px; height:41px; display:block; filter:grayscale(1) brightness(0.7); opacity:0.8; flex-shrink:0; pointer-events:none; }

.contact-form { flex-grow:1; display:flex; flex-direction:column; gap:1rem; }
.form-group { display:flex; flex-direction:column; gap:0.4rem; position:relative; }
.form-row { display:grid; grid-template-columns:1fr 1fr; gap:1.5rem; }
.form-group-message { flex-grow:1; display:flex; flex-direction:column; }
.form-group-message textarea { flex-grow:1; min-height:80px; resize:none; margin-bottom:1rem; }
input,textarea { padding:12px; border:1px solid var(--line); background:white; font:inherit; font-size:1rem; border-radius:2px; width:100%; outline:none; color:var(--muted); transition:0.3s; }
.error { border-color:rgba(255,0,0,0.6)!important; box-shadow:0 0 8px rgba(255,0,0,0.15)!important; }

.btn-container { display:flex; gap:15px; align-items:center; min-height:30px; }
.btn-style { background:none; border:none; padding:10px 0.75rem; display:flex; align-items:center; font-family:inherit; font-weight:400; cursor:pointer; color:var(--text); text-transform:uppercase; font-size:1rem; letter-spacing:1.2px; opacity:0.65; transition:var(--tr); margin-left:-0.75rem; }
.btn-style:hover { opacity:1; transform:scale(1.05); }
.btn-style:disabled { opacity:0.3; cursor:not-allowed; transform:none; }
.send-error { font-size:0.85rem; color:rgba(180,0,0,0.75); letter-spacing:0.5px; display:none; }

#contact-success { display:none; flex-direction:column; align-items:center; justify-content:center; min-height:650px; text-align:center; opacity:0; }
.success-msg { font-size:1rem; color:var(--text); margin-bottom:30px; letter-spacing:1.2px; text-transform:uppercase; opacity:0.65; }
.success-msg-line { width:80px; height:1px; background:var(--line); margin-bottom:30px; }
.btn-reset { background:none; border:none; cursor:pointer; color:var(--muted); transition:0.4s cubic-bezier(0.4,0,0.2,1); display:flex; align-items:center; justify-content:center; padding:0 20px; }
.btn-reset:hover { color:var(--text); transform:scale(1.2); }
.btn-reset:hover svg { animation:rotateLoop 2s linear infinite; }
.hp-field { position:absolute; left:-5000px; visibility:hidden; }

@keyframes rotateLoop { to { transform:rotate(360deg); } }
@keyframes fadeIn { from { opacity:0; transform:translateY(5px); } to { opacity:1; transform:translateY(0); } }

@media (min-width:1001px) {
    body[data-active-tab="about"] main,
    body[data-active-tab="contact"] main { overflow:hidden; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration:0.01ms !important; animation-iteration-count:1 !important; transition-duration:0.01ms !important; }
    html { scroll-behavior:auto; }
}

/* ── Narrow desktop / iPad landscape ────────────────────────────────────────
   Scaling --sw and --um shrinks the sidebar column and outer margins so the
   full desktop layout fits at ~1 024 px without any structural changes:
   the nav stays single-line, sections keep their padding, the sidebar footer
   stays visible, and the photo simply scales with the narrower column. ───── */
@media (min-width:1001px) and (max-width:1150px) {
    :root { --sw:240px; --um:30px; font-size:15px; }
    .nav-links { margin-left:-0.75rem; }
    .nav-links a { font-size:0.9rem; padding:10px 0.75rem; letter-spacing:1px; }
    .sidebar h1 { font-size:1rem; }
    .sidebar .job-title { font-size:0.85rem; }
    .sidebar .job-title span { white-space:normal; }
    /* Align photo top with nav-links top (~49 px from viewport top) */
    .sidebar { padding-top:50px; }
    /* Restore 3:4 portrait crop, anchor from top so face is preserved */
    .profile-photo-container { min-height:0; max-height:320px; }
    .profile-image { object-position:top; }
    /* Reduce gap between social icons and footer; clamp prevents the
       margin from growing large on taller viewports while collapsing
       gracefully on short-chrome viewports */
    .sidebar-footer { margin-top:clamp(0px, calc(100dvh - 624px), 3rem); }
    /* Tighten the space between the nav buttons and first content line */
    section { padding-top:95px; }
    .section-header { top:83px; }
    body[data-active-tab="about"] main,
    body[data-active-tab="contact"] main { overflow-y:auto; }
}

@media (max-width:1000px) {
    html { scrollbar-gutter:auto; }
    html,body { height:auto; overflow:visible; }
    .main-layout { display:flex; flex-direction:column; height:auto; padding:0 20px; gap:0; overflow:visible; }
    .mask { display:none; }
    nav { position:sticky; top:0; background:white; align-items:center; padding:10px 0; border-bottom:1px solid var(--line); height:auto; min-height:80px; }
    .nav-inner > div[aria-hidden="true"] { display:none; }
    .nav-inner { display:flex; justify-content:center; width:100%; padding:0; }
    .nav-links { gap:0; margin-left:0; flex-wrap:wrap; justify-content:center; width:100%; }
    .nav-links a { font-size:0.9rem; padding:8px 0.6rem; letter-spacing:0.8px; }
    .nav-links a:not(:last-child) { border-right:none; }
    .nav-row-break { display:block; width:100%; flex-basis:100%; height:0; }
    main { overflow:visible; height:auto; padding-bottom:0; }
    section { padding-top:20px; min-height:0; height:auto; }
    .layout-split { display:block; }
    .split-right { margin-top:2rem; }
    .form-row { grid-template-columns:1fr; gap:1rem; }
    .form-group-message { flex-grow:1; }
    .form-group-message textarea { flex-grow:1; min-height:60px; resize:none; margin-bottom:1rem; }
    #contact { height:calc(100dvh - 80px); }
    #contact-success { min-height:60vh; }
    .sidebar { height:auto; padding-top:20px; position:relative; z-index:10; }
    .sidebar-copyright { display:none; }
    .main-content-copyright { display:block; padding:20px 0 30px; color:#999; font-size:0.75rem; border-top:1px solid var(--line); margin-top:20px; }
    .main-content-copyright .privacy-wrap { display:block; margin-bottom:8px; }
    .main-content-copyright .privacy-popup { width:100%; }
    .icon-pdf,.icon-no-pdf { width:34px; height:34px; }
    .pub-item:has(.pdf-link-icon) .pub-content { padding-left:54px; }
    .sidebar-footer { display:none; }
    body:not([data-active-tab="about"]) .sidebar { display:none; }
    .section-header { position:static; background:transparent; border-bottom:none; padding-bottom:0; min-height:0; margin-bottom:0.75rem; }
}

/* ── iPad portrait / large-phone landscape ───────────────────────────────── */
/* Hides the forced flex-break so the nav sits on one line when space allows. */
/* flex-wrap:wrap (inherited from mobile) means it still wraps naturally on   */
/* anything narrower than the content — no hard break, no clipping.           */
@media (min-width:660px) and (max-width:1000px) {
    .nav-row-break { display:none; }
    .nav-links a:not(:last-child) { border-right:1px solid var(--line); }
}
