/* 1. Theme, document and accessibility */
:root {
  color-scheme: dark;
  --ink: #13181e;
  --paper: #e6e1d8;
  --accent: #be8c36;
  --quiet: #ada79d;
  --border: #615137;
  --nav-width: min(230px, calc(100vw - 32px));
  --nav-duration: .3s;
  font: 16px/1.5 Arial, sans-serif;
  color: var(--paper);
  background: var(--ink);
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #9e7838 var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
[hidden] { display: none !important; }
[id] { scroll-margin-top: 24px; }
h1, h2, h3, h4, p { margin-top: 0; }
.sr-only, .edge-toggle-text {
  position: absolute; width: 1px; height: 1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.skip-link { position: fixed; top: 8px; left: 16px; padding: 12px 20px; background: var(--ink); z-index: 100; transform: translateY(-150%); }
.skip-link:focus { transform: none; }
#site { overflow-x: clip; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: var(--ink); }
::-webkit-scrollbar-thumb { background: #9e7838; border: 3px solid var(--ink); border-radius: 10px; min-height: 48px; }
::-webkit-scrollbar-thumb:hover { background: #d1a455; }
::-webkit-scrollbar-thumb:active { background: #e0b66b; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
@supports selector(::-webkit-scrollbar) { html { scrollbar-width: auto; scrollbar-color: auto; } }
@media (forced-colors: active) { html { scrollbar-color: auto; } }

/* 2. Identity and biography */
.hero { padding: 55px 5% 0; }
.identity { display: flex; align-items: center; justify-content: space-between; gap: clamp(24px, 5vw, 96px); margin-bottom: 38px; }
.identity-copy { min-width: 0; }
h1 { font-size: clamp(46px, 10.7vw, 164px); font-weight: 400; letter-spacing: -.085em; line-height: 1.05; margin-bottom: 0; }
.alternate-names { margin: 12px 0 0; color: #c6aa72; font-size: clamp(14px, 1.4vw, 18px); letter-spacing: .04em; }
.avatar { width: clamp(70px, 10.7vw, 164px); height: clamp(70px, 10.7vw, 164px); object-fit: contain; flex: none; }
.profile-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); gap: clamp(40px, 7vw, 120px); align-items: start; margin-bottom: 50px; }
.profile-copy, .profile-links { min-width: 0; }
.intro { font-size: 18px; max-width: 560px; color: var(--quiet); margin: 0; overflow-wrap: anywhere; }
.about { padding-top: 40px; }
.about h2, .profile-links h2 { font-family: Georgia, serif; font-style: italic; font-weight: 400; font-size: 40px; line-height: 1; color: var(--accent); margin-bottom: 20px; }
.about p { max-width: 600px; color: var(--quiet); margin-bottom: 0; overflow-wrap: anywhere; }
.about p + p { margin-top: 16px; }
.fold { height: 130px; position: relative; background: var(--accent); clip-path: polygon(0 20%, 100% 0, 100% 80%, 0 100%); margin: 0 -6%; display: flex; align-items: center; overflow: hidden; }
.fold::after { content: ''; position: absolute; inset: 0; background: linear-gradient(115deg, #66502d00 40%, #4a351b88 50%, #dec38e00 59%); pointer-events: none; }
.fold span { font-family: Georgia, serif; font-style: italic; color: #292317; font-size: 82px; white-space: nowrap; letter-spacing: -5px; transform: rotate(-1.5deg); padding-left: 6%; }

/* Friends: compact dropdown alongside the biography heading */
.about-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; }
.about-heading-row h2 { margin: 0; }
.friends-dropdown { position: relative; flex: 0 0 auto; z-index: 25; }
.friends-trigger { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; padding: 7px 0 7px 3px; border-bottom: 1px solid #927442; color: #e2b464; cursor: pointer; font-size: 17px; line-height: 1.35; list-style: none; white-space: nowrap; transition: color .2s, border-color .2s; }
.friends-trigger::-webkit-details-marker { display: none; }
.friends-trigger::marker { content: ''; }
.friends-trigger:hover, .friends-dropdown[open] .friends-trigger { color: var(--paper); border-color: var(--accent); }
.friends-chevron { flex: none; transition: transform .2s ease; }
.friends-dropdown[open] .friends-chevron { transform: rotate(180deg); }
.friends-popover { position: absolute; top: calc(100% + 12px); right: 0; width: min(340px, calc(100vw - 40px)); padding: 22px; border: 1px solid var(--border); border-radius: 4px 18px 4px 4px; background: linear-gradient(145deg, #29271f 0%, #1b2025 60%); box-shadow: 0 18px 50px #00000080; }
.friends-popover::before { content: ''; position: absolute; top: -1px; left: 22px; width: 46px; height: 3px; background: var(--accent); }
.friends-popover-title { margin: 0 0 18px; color: var(--accent); font: italic 400 25px/1.15 Georgia, serif; }
.friends-menu-list { list-style: none; margin: 0; padding: 0; }
.friend-link { display: flex; align-items: center; gap: 15px; min-height: 72px; padding: 10px 14px; border: 1px solid #635135; border-radius: 4px; color: var(--paper); background: #13181eb3; transition: background .18s, border-color .18s; }
.friend-link:hover { background: #be8c361a; border-color: var(--accent); color: var(--paper); }
.friend-initial { display: flex; align-items: center; justify-content: center; flex: none; width: 49px; height: 49px; border: 1px solid #67543a; border-radius: 4px; color: #e2b464; background: #be8c360d; font: normal 28px/1 Georgia, serif; text-align: center; }
.friend-name { font-size: 19px; min-width: 0; overflow-wrap: anywhere; }
.friend-open { margin-left: auto; color: #b58b48; font-size: 18px; transition: transform .2s; }
.friend-link:hover .friend-open { transform: translate(2px,-2px); }
/* Reserved profile page for the first friend; biography is not invented. */
.friend-profile { min-height: 100vh; padding: clamp(28px, 6vw, 70px) 5%; max-width: 1050px; margin: 0 auto; }
.friend-profile-back { display: inline-flex; min-height: 44px; align-items: center; border-bottom: 1px solid #927442; color: #e2b464; }
.friend-profile-header { display: flex; align-items: center; gap: 24px; margin-top: clamp(68px, 10vw, 128px); }
.friend-profile-header .friend-initial { width: 78px; height: 78px; font-size: 45px; }
.friend-profile h1 { font-size: clamp(48px, 9vw, 110px); }
.friend-profile-note { margin-top: 32px; color: var(--quiet); }
@media (max-width: 520px) {
  .about-heading-row { gap: 10px; }
  .about-heading-row h2 { font-size: clamp(30px, 8.5vw, 36px); }
  .friends-trigger { font-size: 15px; gap: 7px; min-height: 44px; }
  .friends-popover { padding: 18px; }
  .friends-popover-title { font-size: 23px; }
  .friend-profile-header { gap: 15px; }
  .friend-profile-header .friend-initial { width: 55px; height: 55px; font-size: 32px; }
}

/* 3. Public profiles */
.profile-links { position: relative; padding: 28px; background: linear-gradient(145deg, #29271f, #1b2025 65%); border: 1px solid var(--border); border-radius: 4px 24px 4px 4px; box-shadow: 0 16px 40px #00000018; }
.profile-links::before { content: ''; position: absolute; top: -1px; left: 28px; width: 58px; height: 3px; background: var(--accent); }
.profile-links h2 { margin-bottom: 24px; }
.profile-link-list { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.profile-link { appearance: none; width: 100%; min-width: 0; min-height: 62px; display: flex; align-items: center; gap: 12px; padding: 16px 14px; border: 1px solid #635135; border-radius: 4px; background: #13181eb3; color: var(--paper); text-align: left; transition: background .18s, border-color .18s, transform .18s; }
.profile-link img { flex: none; width: 22px; height: 22px; filter: invert(65%) sepia(39%) saturate(707%) hue-rotate(359deg) brightness(86%) contrast(89%); }
.profile-link > span { font-size: 17px; min-width: 0; overflow-wrap: anywhere; }
.profile-link:disabled { opacity: 1; }
.profile-link:not(:disabled):hover { background: #be8c361a; border-color: var(--accent); color: var(--paper); transform: translateY(-2px); }
.youtube-soon { border-style: dashed; background: transparent; color: var(--quiet); }
.youtube-soon > span { display: flex; flex-direction: column; gap: 3px; }
.youtube-soon small { font-size: 12px; line-height: 1.2; letter-spacing: .03em; color: var(--accent); }
.contact-launch { padding-top: 24px; margin-top: 24px; border-top: 1px solid var(--border); }
.contact-launch .contact-send { background: transparent; color: var(--accent); }
.contact-launch .contact-send:hover { background: #be8c3617; }
.noscript-contact { color: var(--quiet); font-size: 14px; overflow-wrap: anywhere; }

/* 4. Portfolio and status labels */
.work { padding: 36px 5% 60px; }
.project-category { padding-top: 20px; margin-bottom: 50px; min-width: 0; }
.project-category:last-child { margin-bottom: 0; }
.category-title { font-family: Georgia, serif; font-style: italic; font-size: clamp(34px, 3.8vw, 48px); font-weight: 400; line-height: 1.15; color: var(--accent); letter-spacing: -1px; margin-bottom: 28px; }
.portfolio-project { min-width: 0; transition: transform .28s ease, border-color .28s ease, box-shadow .28s ease; }
.project-heading { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.project-title { font-size: clamp(25px, 2.6vw, 34px); line-height: 1.15; font-weight: 400; letter-spacing: -1px; margin: 0; color: #f0ebe2; overflow-wrap: anywhere; }
.portfolio-project p { color: #d3cec4; max-width: 650px; margin: 0 0 22px; overflow-wrap: anywhere; }
.portfolio-project p:last-child { margin-bottom: 0; }
.project-status { display: inline-flex; align-items: center; gap: 8px; padding: 6px 11px; border-radius: 3px; font-size: 13px; line-height: 1.3; white-space: nowrap; }
.project-status::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
.status-active { color: #d8b774; background: #be8c361a; border: 1px solid #be8c3655; }
.status-development { color: #d9d4c9; background: #13181ed9; border: 1px solid #ddd4c755; }
.status-abandoned { color: #aaa59c; background: #aaa59c08; border: 1px dashed #aaa59c55; }
.project-action { display: inline-flex; align-items: center; gap: 24px; min-height: 44px; color: #e2b464; border-bottom: 1px solid #927442; padding: 8px 0; }
.project-action:hover { color: var(--paper); }
.project-action span { display: inline-block; transition: transform .22s ease; }
.illustrated-project, .samosbor-project { min-height: 300px; margin-top: 16px; padding: clamp(28px, 4vw, 60px); border: 1px solid var(--border); border-radius: 24px; overflow: hidden; }
.illustrated-project { position: relative; isolation: isolate; margin-bottom: 24px; background: #181d22; }
.illustrated-project::before, .illustrated-project::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; }
.illustrated-project::before { z-index: -2; background-repeat: no-repeat; background-position: 85% center; background-size: auto 85%; }
.illustrated-project::after { z-index: -1; background: linear-gradient(90deg, #0a0e12f5 0%, #0a0e12db 42%, #0a0e129e 100%); }
.server-project::before { background-image: url('images/server-sun.png'); }
.android-project::before { background-image: url('icons/android.svg'); filter: invert(71%) sepia(27%) saturate(670%) hue-rotate(43deg) brightness(90%); }
.samosbor-project { display: flex; align-items: center; min-height: 380px; background-color: var(--ink); background-image: linear-gradient(90deg, #0a0e12f0 0%, #0a0e12d9 45%, #0a0e128c 100%), url('images/samosbor.webp'); background-size: 100% 100%, 190% auto; background-position: center, left center; background-repeat: no-repeat; }
.project-description { min-width: 0; width: 100%; max-width: 650px; }
.samosbor-project p { max-width: 560px; }

/* 5. Contact dialog */
.contact-dialog-open { overflow: hidden; }
.contact-dialog { position: fixed; inset: 0; margin: auto; width: min(560px, calc(100% - 32px)); max-height: calc(100dvh - 40px); padding: 32px; border: 1px solid var(--border); border-radius: 16px; background: #1b2025; color: var(--paper); box-shadow: 0 24px 80px #00000070; overflow-y: auto; }
.contact-dialog:not([open]) { display: none; }
.contact-dialog::backdrop { background: #080b10bf; backdrop-filter: blur(5px); }
.contact-dialog h2 { font: 400 28px/1.2 Georgia, serif; color: var(--accent); margin: 0 0 20px; padding-right: 32px; }
.contact-close { position: absolute; top: 12px; right: 12px; width: 44px; height: 44px; background: transparent; border: 0; color: var(--quiet); font: 30px/1 Arial, sans-serif; }
.contact-close:hover { color: var(--accent); }
.contact-dialog form { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.contact-dialog label { font-size: 14px; }
.contact-dialog input, .contact-dialog textarea { font-size: 16px; width: 100%; min-width: 0; border: 1px solid #635135; border-radius: 4px; background: #13181eb3; color: var(--paper); padding: 12px; }
.contact-dialog textarea { resize: vertical; min-height: 120px; max-height: 500px; }
.contact-dialog label:not(:first-child) { margin-top: 8px; }
.contact-trap { display: none; }
.contact-dialog input[type=file] { font-size: 13px; padding: 8px; overflow: hidden; }
.contact-dialog input::file-selector-button { font: inherit; background: #30291f; color: var(--paper); border: 1px solid #635135; border-radius: 3px; padding: 8px; margin-right: 8px; cursor: pointer; }
.attachment-help, .contact-feedback { font-size: 13px; color: var(--quiet); line-height: 1.5; margin: 0; overflow-wrap: anywhere; }
#attachment-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
#attachment-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; min-width: 0; }
#attachment-list span { overflow-wrap: anywhere; min-width: 0; }
#attachment-list button { background: transparent; color: var(--accent); border: 0; padding: 10px 0; font: inherit; flex: none; }
.contact-send { width: 100%; font: inherit; font-size: 16px; border: 1px solid #b58b48; border-radius: 4px; background: var(--accent); color: var(--ink); padding: 13px 18px; }
.contact-dialog .contact-send { margin-top: 8px; }
.contact-send:disabled { opacity: .5; }
.contact-send:not(:disabled):hover { background: #d1a455; }
.contact-dialog .contact-error { color: #e7b8a5; }
.optional-label { color: var(--quiet); font-size: 13px; }
#contact-progress { width: 100%; height: 8px; accent-color: var(--accent); }

/* 6. Hidden edge navigation: panel and tab share geometry and timing */
.edge-navigation { position: fixed; left: 0; top: 0; bottom: 0; width: 16px; z-index: 50; pointer-events: none; }
.edge-sensor { position: absolute; inset: 0; pointer-events: auto; }
.edge-toggle { position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 9px; height: 56px; border: 0; border-radius: 0 5px 5px 0; background: #be8c3666; color: var(--paper); pointer-events: auto; padding: 0; transition: background .2s, left var(--nav-duration) ease; }
.edge-toggle-icon { display: none; }
.edge-toggle:hover, .edge-toggle:focus-visible { background: var(--accent); }
.edge-menu { position: absolute; left: 0; top: 50%; transform: translate(-100%, -50%); width: var(--nav-width); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 24px 20px; background: #1b2025; border: 1px solid var(--border); border-left: 0; border-radius: 0 18px 18px 0; box-shadow: 12px 12px 36px #00000040; opacity: 0; visibility: hidden; pointer-events: none; transition: transform var(--nav-duration) ease, opacity .25s ease, visibility var(--nav-duration); }
.edge-navigation.is-open { width: var(--nav-width); }
.edge-navigation.is-open .edge-menu { transform: translate(0, -50%); opacity: 1; visibility: visible; pointer-events: auto; }
.edge-navigation.is-open .edge-toggle { left: var(--nav-width); }
.edge-menu-title { margin: 0 0 15px; color: var(--accent); font: italic 28px/1.2 Georgia, serif; }
.edge-menu a { display: flex; align-items: center; min-height: 44px; padding: 10px 12px; border-left: 2px solid transparent; color: var(--quiet); transition: color .2s, background .2s; }
.edge-menu a:hover { color: var(--paper); background: #be8c360c; }
.edge-menu a[aria-current] { border-left-color: var(--accent); color: var(--paper); background: #be8c3612; }
.edge-menu .edge-top { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

.edge-menu .edge-language-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; gap: 8px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.edge-menu .edge-language-picker a.language-flag-link { display: flex; justify-content: center; align-items: center; min-height: 50px; padding: 0; border: 1px solid #635135; border-left: 1px solid #635135; border-radius: 4px; background: #13181eb3; color: var(--paper); font-size: 24px; line-height: 1; transition: background .2s, border-color .2s, transform .18s; }
.edge-menu .edge-language-picker a.language-flag-link:hover,
.edge-menu .edge-language-picker a.language-flag-link:focus-visible { color: var(--paper); background: #be8c361a; border-color: var(--accent); transform: translateY(-1px); }
.edge-menu .edge-language-picker a.language-flag-link[aria-current="page"] { color: var(--paper); background: #be8c3618; border-color: var(--accent); box-shadow: inset 0 0 0 1px #be8c3633; }
@media (max-width: 520px) {
  .edge-menu .edge-language-picker { gap: 6px; }
  .edge-menu .edge-language-picker a.language-flag-link { min-height: 46px; font-size: 22px; }
}

/* 7. Responsive layouts */
@media (min-width: 761px) and (max-width: 1100px) { .profile-link-list { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .profile-layout { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .identity { gap: 18px; }
  h1 { font-size: clamp(32px, 10vw, 76px); }
  .avatar { width: clamp(48px, 10vw, 76px); height: clamp(48px, 10vw, 76px); }
  .about { padding-top: 30px; }
  .profile-links h2 { font-size: 36px; }
  .project-category { margin-bottom: 32px; }
  .illustrated-project, .samosbor-project { min-height: 300px; border-radius: 18px; }
  .illustrated-project::before { background-position: right center; background-size: auto 75%; }
  .illustrated-project::after { background: linear-gradient(90deg, #0a0e12f0, #0a0e12c7); }
  .samosbor-project { min-height: 320px; background-image: linear-gradient(90deg, #0a0e12f0, #0a0e12c2), url('images/samosbor.webp'); background-size: 100% 100%, max(230%, 720px) auto; }
}
@media (max-width: 520px) {
  .hero { padding-top: 42px; }
  .intro { font-size: 16px; }
  .fold { height: 100px; }
  .fold span { font-size: 64px; }
  .work { padding-bottom: 40px; }
  .contact-dialog { padding: 24px 20px; max-height: calc(100dvh - 24px); }
}
@media (max-width: 400px) {
  .profile-links { padding: 24px 20px; }
  .profile-link { padding: 14px 10px; gap: 9px; }
  .profile-link > span { font-size: 16px; }
}
@media (max-width: 360px) { .profile-link-list { grid-template-columns: 1fr; } }
@media (hover: none), (pointer: coarse) {
  .edge-navigation { top: auto; bottom: 20px; width: 48px; height: 48px; }
  .edge-sensor { display: none; }
  .edge-toggle { top: 0; transform: none; width: 44px; height: 44px; background: #1b2025; border: 1px solid var(--border); border-left: 0; border-radius: 0 8px 8px 0; }
  .edge-toggle-icon { display: inline; font-size: 22px; }
  .edge-menu { top: auto; bottom: 56px; transform: translateX(-100%); max-height: calc(100dvh - 120px); }
  .edge-navigation.is-open .edge-menu { transform: translateX(0); }
  .edge-navigation.is-open .edge-toggle { left: 0; }
}

/* 8. Motion preferences */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .portfolio-project:hover { transform: translateY(-3px); border-color: #be8c3699; box-shadow: 0 12px 28px #00000016; }
  .project-action:hover span { transform: translate(3px, -3px); }
}
@media (prefers-reduced-motion: no-preference) {
  .identity { animation: identity-arrive .75s ease both; }
  .contact-dialog[open] { animation: contact-appear .22s ease-out; }
  @keyframes identity-arrive { from { opacity: .6; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
  @keyframes contact-appear { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* 9. Language picker: a discreet independent control in the upper-right corner.
   It does not change the original avatar alignment or the hero row height. */
.hero { position: relative; }
.language-switcher {
  position: absolute;
  top: 12px;
  right: 5%;
  z-index: 90;
  color: var(--quiet);
}
.language-switcher > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  min-height: 38px;
  gap: 9px;
  padding: 7px 11px;
  cursor: pointer;
  list-style: none;
  border: 1px solid #66553d;
  border-radius: 5px;
  background: #1b2025;
  color: var(--paper);
  font-size: 14px;
  letter-spacing: .05em;
  transition: border-color .18s, background .18s;
}
.language-switcher > summary::-webkit-details-marker { display: none; }
.language-switcher > summary::marker { content: ''; }
.language-switcher > summary:hover,
.language-switcher[open] > summary { border-color: var(--accent); background: #24261f; }
.language-caret { color: var(--accent); font-size: 19px; line-height: 1; }
.language-options {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 174px;
  padding: 6px;
  border: 1px solid #66553d;
  border-radius: 7px;
  background: #1b2025;
  box-shadow: 0 14px 42px #000a;
}
.language-options a {
  display: flex;
  min-height: 38px;
  align-items: center;
  padding: 8px 11px;
  color: var(--quiet);
  border-radius: 4px;
  font-size: 14px;
}
.language-options a:hover,
.language-options a:focus-visible { color: var(--paper); background: #be8c361a; }
.language-options a[aria-current="page"] { color: #e2b464; background: #be8c3612; }
@media (max-width: 520px) {
  .language-switcher { top: 6px; }
  .language-switcher > summary {
    min-width: 60px;
    min-height: 30px;
    gap: 5px;
    padding: 4px 8px;
    font-size: 12px;
  }
}

/* Four compact language flags stay in one horizontal row in the edge menu. */
.edge-menu .edge-language-picker {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 8px;
  width: 100%;
}
.edge-menu .edge-language-picker > .language-flag-link {
  width: 100%;
  min-width: 0;
  margin: 0;
}
