/* =========================================================================
   Prof. Dr. Magdy Mohamed Hussein — biography site
   Layout uses CSS logical properties only (inline-start/end, block-start/end)
   so the whole page mirrors automatically between RTL (ar) and LTR (en).
   ========================================================================= */

:root {
  --navy-900: #0e1830;
  --navy-800: #14213d;
  --navy-700: #1f3158;
  --navy-100: #e8ecf4;
  --gold-500: #c9a24a;   /* decorative gold (rules, borders, dots) */
  --gold-300: #e2c886;   /* gold text on navy */
  --gold-700: #7d5f18;   /* gold text on light backgrounds (AA) */
  --paper: #faf8f3;
  --surface: #ffffff;
  --ink: #1d2333;
  --muted: #545b6e;
  --line: #e6e0d2;
  --line-strong: #d6cdb8;
  --focus: #b8862b;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 4px 14px rgba(20, 33, 61, .05);
  --header-h: 68px;
  --container: 1200px;
  --gutter: clamp(16px, 4vw, 32px);

  --font-body: "Cairo", "Segoe UI", Tahoma, sans-serif;
  --font-head: "Noto Naskh Arabic", "Cairo", serif;
  color-scheme: light;
}
html[lang="en"] {
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-head: "Playfair Display", Georgia, "Times New Roman", serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.75;
  text-rendering: optimizeLegibility;
}
html[lang="en"] body { line-height: 1.65; }

img { max-width: 100%; height: auto; display: block; }
a { color: var(--navy-700); text-underline-offset: .2em; }
a:hover { color: var(--gold-700); }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-head); color: var(--navy-800); line-height: 1.3; margin: 0; }
p { margin: 0; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; inset-inline-start: 1rem; inset-block-start: -100px; z-index: 100;
  background: var(--navy-800); color: #fff; padding: .6rem 1rem; border-radius: var(--radius-sm);
}
.skip-link:focus { inset-block-start: 1rem; color: #fff; }

.icon { display: block; flex: none; }
html[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  border: 0; border-radius: 50%; background: transparent; cursor: pointer;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; inset-block-start: 0; z-index: 50;
  background: var(--navy-800);
  color: #fff;
  border-block-end: 2px solid var(--gold-500);
}
.header-inner { display: flex; align-items: center; gap: 1rem; min-height: var(--header-h); }

.brand { display: flex; align-items: center; gap: .7rem; color: #fff; text-decoration: none; margin-inline-end: auto; min-width: 0; }
.brand:hover { color: var(--gold-300); }
.brand-mark {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 1.5px solid var(--gold-500); border-radius: 50%;
  font-family: "Playfair Display", Georgia, serif; font-weight: 700; font-size: .95rem; letter-spacing: .02em; color: var(--gold-300);
}
.brand-name { font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.primary-nav { display: none; align-items: center; gap: .25rem; }
.nav-link, .mega-toggle {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .5rem .85rem; border-radius: var(--radius-sm);
  color: #fff; text-decoration: none; background: transparent; border: 0; cursor: pointer;
  font-weight: 600; font-size: .95rem;
}
.nav-link:hover, .mega-toggle:hover, .mega-toggle[aria-expanded="true"] { background: rgba(255, 255, 255, .1); color: var(--gold-300); }
.mega-toggle[aria-expanded="true"] .icon { transform: rotate(180deg); }

/* Desktop mega-menu: every section in order, flowing down the columns */
.mega-menu {
  position: absolute; inset-inline: 0; inset-block-start: 100%;
  background: var(--surface); color: var(--ink);
  border-block-end: 3px solid var(--gold-500);
  box-shadow: 0 18px 40px rgba(14, 24, 48, .18);
  max-height: calc(100vh - var(--header-h) - 20px); overflow-y: auto;
  padding-block: 1.25rem 1.5rem;
}
.nav-list--mega { columns: 3 260px; column-gap: 2rem; column-rule: 1px solid var(--line); }
.nav-list--mega > li { break-inside: avoid; }

.lang-toggle { display: inline-flex; align-items: center; gap: .15rem; }
.lang-btn {
  min-width: 44px; min-height: 40px; padding: .2rem .55rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; cursor: pointer; font-weight: 600;
}
.lang-btn[lang="ar"] { font-family: "Cairo", sans-serif; }
.lang-btn[lang="en"] { font-family: "Inter", sans-serif; }
.site-header .lang-btn { color: #fff; }
.site-header .lang-btn:hover { color: var(--gold-300); }
.lang-btn[aria-pressed="true"] { border-color: var(--gold-500); color: var(--gold-300); cursor: default; }
.lang-sep { opacity: .5; }

.menu-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; background: transparent; border: 0; color: #fff; cursor: pointer; border-radius: var(--radius-sm); }
.menu-btn:hover { color: var(--gold-300); }
@media (min-width: 1024px) {
  .primary-nav { display: flex; }
  .menu-btn { display: none; }
}
@media (max-width: 419.98px) {
  .header-inner { gap: .4rem; }
  .site-header .lang-btn { min-width: 40px; padding-inline: .35rem; }
}

/* ---------- Shared nav list (mega menu, drawer, TOC) ---------- */
.nav-list, .nav-list ol { list-style: none; margin: 0; padding: 0; }
.nav-list a {
  display: flex; align-items: baseline; gap: .55rem;
  padding: .4rem .6rem; border-radius: var(--radius-sm);
  color: var(--ink); text-decoration: none; line-height: 1.45; font-size: .95rem;
}
.nav-list a:hover { background: var(--navy-100); color: var(--navy-800); }
.nav-num { flex: none; min-width: 2.1em; font-variant-numeric: tabular-nums; color: var(--gold-700); font-weight: 700; font-size: .85em; }
.nav-list ol { padding-inline-start: 1.4rem; border-inline-start: 2px solid var(--line); margin-inline-start: 1rem; }
.nav-list a[aria-current="true"] { background: var(--navy-800); color: #fff; }
.nav-list a[aria-current="true"] .nav-num { color: var(--gold-300); }

/* ---------- Mobile drawer (a modal <dialog>) ---------- */
.drawer {
  margin: 0; padding: 0; border: 0; max-width: none; max-height: none;
  width: min(88vw, 380px); height: 100%; height: 100dvh;
  inset-block: 0; inset-inline-start: auto; inset-inline-end: 0;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 0 40px rgba(14, 24, 48, .3);
}
.drawer::backdrop { background: rgba(14, 24, 48, .55); }
.drawer[open] { animation: drawer-in-ltr .25s ease-out; }
html[dir="rtl"] .drawer[open] { animation-name: drawer-in-rtl; }
@keyframes drawer-in-ltr { from { transform: translateX(100%); } }
@keyframes drawer-in-rtl { from { transform: translateX(-100%); } }
.drawer-panel { display: flex; flex-direction: column; height: 100%; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding-block: .75rem; padding-inline: 1.25rem .75rem;
  background: var(--navy-800); color: #fff; border-block-end: 2px solid var(--gold-500);
}
.drawer-title { color: #fff; font-size: 1.15rem; }
.drawer-close { color: #fff; }
.drawer nav { flex: 1; overflow-y: auto; padding: .75rem; }
.lang-toggle--drawer { justify-content: center; padding: .75rem; border-block-start: 1px solid var(--line); }
.lang-toggle--drawer .lang-btn[aria-pressed="true"], .lang-toggle--footer .lang-btn[aria-pressed="true"] { color: var(--gold-700); }
html[lang="en"] .lang-toggle--drawer .lang-btn[aria-pressed="true"] { color: var(--gold-700); }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(1200px 400px at 85% -10%, rgba(201, 162, 74, .18), transparent 60%),
    linear-gradient(160deg, var(--navy-800), var(--navy-900));
  color: #fff;
  border-block-end: 4px solid var(--gold-500);
}
.hero-inner {
  display: grid; gap: 2rem; align-items: center; justify-items: center; text-align: center;
  padding-block: clamp(2.5rem, 6vw, 4.5rem);
}
.hero-portrait { margin: 0; width: min(240px, 62vw); }
.hero-portrait img {
  width: 100%; aspect-ratio: 720 / 854; object-fit: cover;
  border-radius: 14px; border: 3px solid var(--gold-500);
  box-shadow: 0 0 0 8px rgba(201, 162, 74, .15), 0 20px 40px rgba(0, 0, 0, .35);
}
.hero-eyebrow { color: var(--gold-300); font-weight: 600; letter-spacing: .02em; font-size: .95rem; }
html[lang="en"] .hero-eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; }
.hero-name { color: #fff; font-size: clamp(2rem, 5.2vw, 3.2rem); margin-block: .35rem .25rem; }
.hero-name-alt { color: var(--gold-300); font-family: "Playfair Display", "Noto Naskh Arabic", serif; font-size: clamp(1.05rem, 2.4vw, 1.35rem); }
.hero-name-alt bdi:lang(ar) { font-family: "Noto Naskh Arabic", serif; }
.hero-position { margin-block-start: 1.1rem; font-size: clamp(1.05rem, 2.2vw, 1.25rem); font-weight: 600; }
.hero-tagline { margin-block-start: .5rem; color: #d5dbe8; max-width: 46ch; margin-inline: auto; }
.hero-contact { list-style: none; margin: 1.4rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; }
.hero-contact li {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .35rem .85rem; border: 1px solid rgba(226, 200, 134, .45); border-radius: 999px;
  font-size: .92rem; color: #eef1f7;
}
.hero-contact a { color: #fff; text-decoration: none; }
.hero-contact a:hover { color: var(--gold-300); text-decoration: underline; }
.hero-contact .icon { color: var(--gold-300); }

@media (min-width: 820px) {
  .hero-inner { grid-template-columns: auto 1fr; justify-items: start; text-align: start; gap: 3.5rem; }
  .hero-portrait { width: 280px; }
  .hero-tagline { margin-inline: 0; }
  .hero-contact { justify-content: flex-start; }
}

/* ---------- Layout: content + sticky table of contents ---------- */
.layout { display: grid; gap: 2.5rem; padding-block: 2.5rem 4rem; }
.toc { display: none; }
@media (min-width: 1100px) {
  .layout { grid-template-columns: 270px minmax(0, 1fr); gap: 3rem; }
  .toc { display: block; }
  .toc-inner {
    position: sticky; inset-block-start: calc(var(--header-h) + 1.25rem);
    max-height: calc(100vh - var(--header-h) - 2.5rem); overflow-y: auto;
    padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  }
  .toc-title { font-size: 1rem; color: var(--gold-700); margin-block-end: .5rem; padding-inline: .6rem; font-family: var(--font-body); font-weight: 700; }
  .nav-list--toc a { font-size: .88rem; padding-block: .3rem; }
}

/* ---------- Sections ---------- */
.content { min-width: 0; }
.cv-section { scroll-margin-top: calc(var(--header-h) + 16px); }
.cv-section + .cv-section { margin-block-start: 3rem; padding-block-start: 3rem; border-block-start: 1px solid var(--line); position: relative; }
.cv-section + .cv-section::before {
  content: ""; position: absolute; inset-block-start: -4px; inset-inline-start: 50%;
  width: 8px; height: 8px; background: var(--gold-500); transform: translateX(-50%) rotate(45deg);
}
html[dir="rtl"] .cv-section + .cv-section::before { transform: translateX(50%) rotate(45deg); }
.cv-subsection { scroll-margin-top: calc(var(--header-h) + 16px); margin-block-start: 2rem; }

.section-head { display: flex; align-items: flex-start; gap: .9rem; margin-block-end: 1.25rem; }
.section-num {
  flex: none; display: grid; place-items: center; min-width: 2.6rem; height: 2.6rem; padding-inline: .4rem;
  border-radius: 999px; background: var(--navy-800); color: var(--gold-300);
  font-family: "Inter", sans-serif; font-weight: 700; font-size: .95rem; font-variant-numeric: tabular-nums;
}
.section-title { font-size: clamp(1.35rem, 2.6vw, 1.75rem); padding-block-start: .1rem; }
.section-title::after { content: ""; display: block; width: 56px; height: 3px; background: var(--gold-500); margin-block-start: .6rem; border-radius: 2px; }
.cv-subsection .section-num { min-width: 2.4rem; height: 2.2rem; background: var(--surface); color: var(--navy-800); border: 1.5px solid var(--gold-500); font-size: .85rem; }
.cv-subsection .section-title { font-size: clamp(1.15rem, 2.2vw, 1.4rem); }
.cv-subsection .section-title::after { width: 36px; height: 2px; }

.coming-soon { padding: 1.25rem; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); text-align: center; background: var(--surface); }

/* Numbered item cards */
.cv-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.cv-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .85rem; align-items: start;
  padding: .9rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.cv-item[hidden] { display: none; }
.item-num {
  display: grid; place-items: center; min-width: 2rem; height: 2rem; padding-inline: .3rem;
  border-radius: var(--radius-sm); background: var(--navy-100); color: var(--navy-800);
  font-family: "Inter", sans-serif; font-weight: 600; font-size: .85rem; font-variant-numeric: tabular-nums;
}
.item-text { overflow-wrap: anywhere; }
.item-text strong { color: var(--navy-800); font-weight: 700; }
.item-meta { display: flex; flex-wrap: wrap; gap: .4rem; margin-block-start: .45rem; }
.badge {
  display: inline-flex; align-items: center; padding: .05rem .6rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; line-height: 1.7; border: 1px solid var(--line-strong); color: var(--muted); background: var(--paper);
  font-variant-numeric: tabular-nums;
}
.badge--phd { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.badge--ma { background: #f4ecd8; border-color: #e3d2a6; color: var(--gold-700); }

/* Single-item sections (current position, appointment) */
.cv-list--single .cv-item { grid-template-columns: minmax(0, 1fr); border-inline-start: 4px solid var(--gold-500); font-size: 1.05rem; }
.cv-list--single .item-num { display: none; }

/* Career timeline */
.cv-list--timeline { gap: 0; padding-inline-start: 1.1rem; border-inline-start: 2px solid var(--line-strong); }
.cv-list--timeline .cv-item { position: relative; margin-block-end: .75rem; grid-template-columns: minmax(0, 1fr); }
.cv-list--timeline .cv-item::before {
  content: ""; position: absolute; inset-inline-start: calc(-1.1rem - 8px); inset-block-start: 1.25rem;
  width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--gold-500);
}
.cv-list--timeline .item-num { display: none; }

/* Search / filter tools for long lists */
.list-tools {
  display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center;
  margin-block-end: 1rem; padding: .75rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.search-field { position: relative; flex: 1 1 260px; }
.search-field .icon { position: absolute; inset-inline-start: .75rem; inset-block-start: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-input {
  width: 100%; min-height: 44px; padding-block: .5rem; padding-inline: 2.4rem .8rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink);
  font: inherit; font-size: .95rem;
}
.search-input:focus { background: #fff; border-color: var(--navy-700); }
.search-input::-webkit-search-cancel-button { cursor: pointer; }
.chip-group { display: inline-flex; flex-wrap: wrap; gap: .35rem; border: 0; margin: 0; padding: 0; }
.chip {
  min-height: 36px; padding: .2rem .9rem; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--paper); cursor: pointer; font-size: .88rem; font-weight: 600; color: var(--ink);
}
.chip:hover { border-color: var(--navy-700); }
.chip[aria-pressed="true"] { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.result-count { font-size: .88rem; color: var(--muted); margin-inline-start: auto; font-variant-numeric: tabular-nums; }
.no-results { padding: 1rem; text-align: center; color: var(--muted); }

/* Refereeing groups (researcher → papers) */
.groups { display: grid; gap: 1rem; }
.group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.group[hidden] { display: none; }
.group-head { padding: .9rem 1.1rem; background: var(--navy-100); border-block-end: 1px solid var(--line); }
.group-label { display: block; font-size: .78rem; font-weight: 700; color: var(--gold-700); letter-spacing: .03em; }
.group-title { font-family: var(--font-body); font-size: 1.02rem; font-weight: 700; color: var(--navy-800); }
.group .cv-list { padding: .75rem; gap: .5rem; }
.group .cv-item { box-shadow: none; background: var(--paper); }

/* Video lectures */
.channel + .channel { margin-block-start: 2rem; }
.channel-title { font-family: var(--font-body); font-size: 1.05rem; font-weight: 700; color: var(--gold-700); margin-block-end: .8rem; }
.video-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.video-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.video-frame { position: relative; aspect-ratio: 16 / 9; background: var(--navy-900); }
.video-frame iframe, .video-play img { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; object-fit: cover; }
.video-play { position: absolute; inset: 0; width: 100%; padding: 0; border: 0; cursor: pointer; background: none; }
.video-play::after {
  content: ""; position: absolute; inset-block-start: 50%; inset-inline-start: 50%; width: 64px; height: 64px; margin: -32px;
  border-radius: 50%; background: rgba(14, 24, 48, .82) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 7l9 5-9 5z' fill='%23e2c886'/%3E%3C/svg%3E") center / 34px no-repeat;
  border: 2px solid var(--gold-500); transition: transform .2s ease;
}
.video-play:hover::after, .video-play:focus-visible::after { transform: scale(1.08); }
.video-body { padding: .9rem 1rem 1rem; display: flex; flex-direction: column; gap: .4rem; flex: 1; }
.video-title { font-family: var(--font-body); font-size: .98rem; font-weight: 700; color: var(--navy-800); line-height: 1.5; }
.video-meta { font-size: .85rem; color: var(--muted); }
.video-link { margin-block-start: auto; font-size: .88rem; font-weight: 600; }

/* Gallery */
.gallery-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(min(46%, 200px), 1fr)); }
.gallery-thumb {
  display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--navy-100); cursor: zoom-in; aspect-ratio: 4 / 3;
}
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.gallery-thumb:hover img { transform: scale(1.04); }

/* Lightbox */
.lightbox { width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(10, 16, 32, .94); color: #fff; }
.lightbox::backdrop { background: rgba(10, 16, 32, .6); }
.lightbox-inner { position: relative; width: 100%; height: 100%; display: grid; place-items: center; padding: 3.5rem 1rem 1rem; }
.lightbox-figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: .8rem; max-width: min(1200px, 100%); }
.lightbox-img { max-height: calc(100vh - 11rem); max-height: calc(100dvh - 11rem); width: auto; border-radius: var(--radius-sm); box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.lightbox-caption { display: flex; flex-direction: column; align-items: center; gap: .15rem; text-align: center; padding-inline: 3.5rem; }
.lightbox-caption-main { font-weight: 600; }
.lightbox-caption-alt { color: #c8cfdd; font-size: .9rem; }
.lightbox-counter { color: var(--gold-300); font-size: .85rem; font-variant-numeric: tabular-nums; }
.lightbox .icon-btn { color: #fff; background: rgba(255, 255, 255, .1); }
.lightbox .icon-btn:hover { background: rgba(255, 255, 255, .2); color: var(--gold-300); }
.lightbox-close { position: absolute; inset-block-start: .75rem; inset-inline-end: .75rem; }
.lightbox-nav { position: absolute; inset-block-start: 50%; transform: translateY(-50%); width: 52px; height: 52px; }
.lightbox-prev { inset-inline-start: .5rem; }
.lightbox-next { inset-inline-end: .5rem; }

/* ---------- Footer ---------- */
.site-footer { background: var(--navy-900); color: #d5dbe8; border-block-start: 3px solid var(--gold-500); }
.footer-inner { display: grid; gap: 1.5rem; padding-block: 2.25rem; }
.footer-name { font-family: var(--font-head); color: #fff; font-size: 1.25rem; font-weight: 700; }
.footer-affiliation { margin-block-start: .25rem; }
.footer-contact { list-style: none; margin: .75rem 0 0; padding: 0; display: grid; gap: .25rem; }
.footer-contact a { color: var(--gold-300); }
.footer-contact a:hover { color: #fff; }
.footer-side { display: grid; gap: .75rem; align-content: start; }
.site-footer .lang-btn { color: #d5dbe8; }
.site-footer .lang-btn:hover { color: #fff; }
.site-footer .lang-btn[aria-pressed="true"] { color: var(--gold-300); }
.footer-copy { font-size: .88rem; color: #aab3c6; }
@media (min-width: 760px) {
  .footer-inner { grid-template-columns: 1fr auto; align-items: end; }
  .footer-side { justify-items: end; }
}

/* ---------- Back to top ---------- */
.to-top {
  position: fixed; inset-block-end: 1.25rem; inset-inline-end: 1.25rem; z-index: 40;
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  background: var(--navy-800); color: var(--gold-300); border: 2px solid var(--gold-500); box-shadow: var(--shadow);
}
.to-top:hover { color: #fff; }
.to-top[hidden] { display: none; }

.noscript { padding: 1.5rem var(--gutter); text-align: center; color: var(--muted); }

/* ---------- Soft fade-in (only when JS + motion allowed) ---------- */
.can-animate .reveal { opacity: 0; transform: translateY(10px); transition: opacity .6s ease, transform .6s ease; }
.can-animate .reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .can-animate .reveal { opacity: 1; transform: none; transition: none; }
  .drawer[open] { animation: none; }
  .gallery-thumb img, .video-play::after { transition: none; }
}

/* ---------- Small screens ---------- */
@media (max-width: 559.98px) {
  .brand-name { font-size: 1rem; }
  .cv-item { padding: .8rem .85rem; gap: .65rem; }
  .lightbox-caption { padding-inline: .5rem; }
  .lightbox-nav { inset-block-start: auto; inset-block-end: .75rem; transform: none; }
  .lightbox-inner { padding-block-end: 4.5rem; }
}

/* ---------- Hosting badge ----------
   Netlify injects a "Powered by Netlify" iframe on free-plan sites; hidden at the owner's request. */
#nl-badge-frame, #nl-hud-frame { display: none !important; }

/* ---------- Print ---------- */
@media print {
  .site-header, .toc, .to-top, .list-tools, .site-footer .lang-toggle, .video-frame, .drawer, .lightbox { display: none !important; }
  .hero { background: none; color: #000; border: 0; }
  .hero-name, .hero-position, .hero-tagline, .hero-contact li, .hero-contact a { color: #000; }
  .cv-item, .group, .video-card { box-shadow: none; break-inside: avoid; }
  .can-animate .reveal { opacity: 1; transform: none; }
  .cv-item[hidden], .group[hidden] { display: grid !important; }
}
