/* ==========================================================================
   nabilswelim.com — modern redesign (Site-2026.12)
   Cinematic dark theme: gold accents, full-bleed hero, scroll-reveal cards.
   ========================================================================== */

/* ---------- tokens: dark (default) ---------- */
:root {
  --bg: #0d0b08;
  --bg-2: #14100b;
  --panel: #1a1510;
  --panel-2: #211a12;
  --line: #33291c;
  --gold: #d8b36a;
  --gold-2: #b98f45;
  --gold-hover: #f0d096;
  --sand: #e9dcc3;
  --ink: #f2ead9;
  --ink-dim: #a99e8a;
  --nav-grad: linear-gradient(rgba(13, 11, 8, .85), rgba(13, 11, 8, 0));
  --nav-solid: rgba(13, 11, 8, .96);
  --nav-open: #0d0b08;
  --hero-veil: radial-gradient(ellipse at center, transparent 40%, rgba(13, 11, 8, .7) 100%),
               linear-gradient(rgba(13, 11, 8, .45), rgba(13, 11, 8, .25) 45%, var(--bg) 98%);
  --hero-shadow: 0 4px 30px rgba(0, 0, 0, .6);
  --hero-kicker: #d8b36a;
  --hero-title: #f2ead9;
  --hero-sub: #cfc4ad;
  --footer-bg: #0a0806;
  --serif: "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

/* ---------- tokens: light (papyrus / ivory) ---------- */
:root[data-theme="light"] {
  --bg: #f6f0e3;
  --bg-2: #efe7d4;
  --panel: #fbf6ea;
  --panel-2: #fffdf4;
  --line: #d9caa7;
  --gold: #a9802f;
  --gold-2: #8a6724;
  --gold-hover: #7a5c1e;
  --sand: #33270f;
  --ink: #241c10;
  --ink-dim: #6f5f45;
  --nav-grad: linear-gradient(rgba(246, 240, 227, .92), rgba(246, 240, 227, 0));
  --nav-solid: rgba(246, 240, 227, .97);
  --nav-open: #f6f0e3;
  --hero-veil: radial-gradient(ellipse at center, transparent 40%, rgba(246, 240, 227, .5) 100%),
               linear-gradient(rgba(246, 240, 227, .4), rgba(246, 240, 227, .2) 45%, var(--bg) 98%);
  --hero-shadow: 0 2px 24px rgba(60, 45, 20, .35);
  --hero-kicker: #8a6724;
  --hero-title: #33270f;
  --hero-sub: #6f5f45;
  --footer-bg: #eadfc6;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: clip; /* guard against accidental horizontal scroll on small screens */
  transition: background-color .3s, color .3s;
}

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

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

h1, h2, h3 { font-family: var(--serif); font-weight: normal; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

/* ---------- top nav ---------- */
.topnav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--nav-grad);
  transition: background .3s;
}

/* solid bar once scrolled (class added by js/site.js) */
.topnav.solid {
  background: var(--nav-solid);
  border-bottom: 1px solid var(--line);
  padding: 10px 28px;
}

.brand {
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: 2px;
  color: var(--sand);
  white-space: nowrap; /* keep the two-line lockup intact when the menu wraps */
}

.brand small { display: block; font-size: 9.5px; letter-spacing: 3.5px; color: var(--gold); }

.topnav ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px 14px;
  margin: 0 0 0 auto; /* keep the menu hugging the right, next to the theme toggle */
  padding: 0;
  list-style: none;
  font-size: 11.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.topnav a { color: var(--ink-dim); padding: 4px 0; border-bottom: 1px solid transparent; }
.topnav a:hover { color: var(--sand); }
.topnav a.current { color: var(--gold); border-bottom-color: var(--gold); }

/* hamburger button — hidden on desktop */
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--gold);
  margin: 4px 0;
  transition: transform .3s, opacity .3s;
}

/* open state: the three bars become an X */
.topnav.open .nav-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.topnav.open .nav-toggle span:nth-child(2) { opacity: 0; }
.topnav.open .nav-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* light/dark switch */
.theme-toggle {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  margin-left: 16px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--gold);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background .25s, color .25s, border-color .25s;
}

.theme-toggle:hover { background: var(--gold); color: #241b0e; border-color: var(--gold); }

/* ---------- hero ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-align: center;
}

/* compact hero for inner pages */
.hero.short { min-height: 58vh; }

.hero .slides { position: absolute; inset: 0; }

.hero .slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  filter: blur(2px) saturate(.9);
  transition: opacity 2.2s ease;
}

.hero .slide.on { opacity: .55; }

/* cinematic vignette over the photos */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--hero-veil);
}

.hero-inner { position: relative; z-index: 2; padding: 120px 24px 80px; }

/* hero colours follow the theme: the veil tint changes the photo tone per theme */
.hero-kicker {
  font-size: 12px;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: var(--hero-kicker);
  margin: 0 0 18px;
}

.hero-title {
  font-size: clamp(40px, 7vw, 84px);
  line-height: 1.05;
  margin: 0 0 18px;
  color: var(--hero-title);
  text-shadow: var(--hero-shadow);
}

.hero-title em { font-style: normal; color: var(--hero-kicker); }

.hero-sub {
  max-width: 640px;
  margin: 0 auto 34px;
  color: var(--hero-sub);
  font-size: 17px;
}

.hero .scroll-cue {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 2;
  color: var(--hero-kicker);
  font-size: 22px;
  animation: cue 2s infinite;
}

@keyframes cue {
  0%, 100% { transform: translate(-50%, 0); }
  50%      { transform: translate(-50%, 10px); }
}

/* ---------- home portrait ---------- */
.portrait-row {
  display: flex;
  align-items: center;
  gap: 44px;
  margin-bottom: 34px;
}

.portrait {
  flex: 0 0 clamp(260px, 34vw, 420px); /* large and clear, scales with viewport */
  margin: 0;
  padding: 12px;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--gold-2);
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .55);
}

.portrait img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  filter: sepia(.25) contrast(1.04); /* warm vintage treatment suits the source photo */
}

.portrait figcaption {
  text-align: center;
  padding-top: 10px;
  font-size: 12.5px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
}

.portrait-text { flex: 1; min-width: 0; }

.portrait-text .lead { margin-bottom: 18px; }

/* ---------- sections ---------- */
.section { padding: 72px 0; }
.section.alt { background: var(--bg-2); }

.section-head { margin-bottom: 36px; }

.section-head .rule {
  width: 64px;
  height: 2px;
  background: var(--gold);
  margin: 14px 0 0;
}

.section-title {
  font-size: clamp(26px, 3.4vw, 40px);
  margin: 0;
  color: var(--sand);
}

.section-title .ar { color: var(--gold); font-size: .7em; display: block; margin-top: 6px; }

.lead { color: var(--ink-dim); max-width: 760px; }

/* ---------- paper cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.card {
  position: relative;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px 22px 18px;
  transition: transform .35s, border-color .35s, box-shadow .35s;
  /* scroll-reveal start state (js/site.js adds .in) */
  opacity: 0;
  transform: translateY(24px);
}

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

.card:hover {
  transform: translateY(-5px);
  border-color: var(--gold-2);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
}

.card .cat-tag {
  display: inline-block;
  font-size: 10.5px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid var(--gold-2);
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 12px;
}

.card h3 { margin: 0 0 4px; font-size: 19px; color: var(--sand); line-height: 1.3; }

.card .title-ar {
  font-family: var(--serif);
  color: var(--gold);
  margin: 0 0 12px;
  font-size: 16px;
}

.card p { margin: 0 0 12px; color: var(--ink-dim); font-size: 14.5px; }

.card .ref {
  font-size: 13px;
  color: var(--ink-dim);
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: auto;
}

.card .ref b { color: var(--sand); font-weight: 600; }

/* download button: full-width bar pinned to the card bottom */
.card .dl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 14px;
  border: 1px solid var(--gold-2);
  border-radius: 8px;
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  transition: background .25s, color .25s, border-color .25s;
}

.card .dl-btn svg { flex: 0 0 auto; }

.card .dl-btn:hover {
  background: var(--gold);
  border-color: var(--gold);
  color: #241b0e;
}

/* cards are flex columns so .ref sits on the bottom */
.card { display: flex; flex-direction: column; }

/* ---------- search / filter bar (library page) ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 34px;
}

.toolbar input[type="search"] {
  flex: 1 1 260px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 15px;
  padding: 11px 20px;
  outline: none;
}

.toolbar input[type="search"]:focus { border-color: var(--gold); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 12.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all .25s;
}

.chip:hover { border-color: var(--gold-2); color: var(--sand); }
.chip.on { background: var(--gold); border-color: var(--gold); color: #241b0e; font-weight: 600; }

.empty-note { color: var(--ink-dim); font-style: italic; display: none; padding: 30px 0; }

/* ---------- credentials / article text ---------- */
.article { max-width: 800px; }

.article p { color: var(--ink-dim); }

.article strong, .article b { color: var(--sand); font-weight: 600; }

.article h3 {
  color: var(--gold);
  font-size: 22px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 38px 0 10px;
}

.article ul { color: var(--ink-dim); padding-left: 22px; }
.article li { margin-bottom: 8px; }

.figure-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin: 26px 0; }

.figure-grid img {
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: transform .3s, border-color .3s;
}

.figure-grid img:hover { transform: scale(1.03); border-color: var(--gold-2); }

/* ---------- image gallery ---------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.gallery figure {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
  cursor: zoom-in;
  transition: border-color .3s, transform .3s, box-shadow .3s;
}

.gallery figure:hover {
  border-color: var(--gold-2);
  transform: translateY(-4px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .5);
}

/* fixed-height thumbs, object-fit keeps crops tidy */
.gallery .thumb {
  height: 150px;
  width: 100%;
  object-fit: cover;
  display: block;
}

.gallery figcaption {
  padding: 9px 12px;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 6, 4, .93);
  padding: 40px 70px; /* room for arrow buttons */
}

.lightbox.on { display: flex; }

.lightbox img {
  max-width: 100%;
  max-height: 82vh;
  border: 1px solid var(--gold-2);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .7);
}

.lightbox .lb-caption {
  position: absolute;
  bottom: 26px;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--sand);
  font-size: 14px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.lightbox .lb-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--gold-2);
  background: rgba(26, 21, 16, .8);
  color: var(--gold);
  font-size: 20px;
  cursor: pointer;
  transition: background .25s;
}

.lightbox .lb-btn:hover { background: var(--gold); color: #241b0e; }
.lightbox .lb-prev { left: 14px; }
.lightbox .lb-next { right: 14px; }
.lightbox .lb-close {
  top: 18px;
  right: 18px;
  transform: none;
}

/* ---------- footer ---------- */
footer {
  border-top: 1px solid var(--line);
  background: var(--footer-bg);
  padding: 44px 0 60px;
  text-align: center;
}

footer .foot-nav { color: var(--ink-dim); font-size: 13.5px; letter-spacing: 1px; }

footer .foot-nav a { color: var(--ink-dim); }
footer .foot-nav a:hover { color: var(--gold); }

footer .copy { color: #6d6350; font-size: 12px; margin-top: 18px; }

/* ---------- responsive ---------- */

/* tablets: tighten the horizontal nav */
@media (max-width: 1080px) {
  .topnav { padding: 10px 16px; }
  .topnav ul { gap: 2px 10px; font-size: 10.5px; }
}

/* phones and small tablets: hamburger menu */
@media (max-width: 860px) {
  .topnav { padding: 10px 16px; }

  .nav-toggle { display: block; order: 3; }
  .theme-toggle { order: 2; margin-left: auto; }

  /* brand left, burger right; menu drops below */
  .topnav { flex-wrap: wrap; }

  .topnav ul {
    display: none;
    order: 4;
    flex-basis: 100%;
    flex-direction: column;
    gap: 0;
    margin-top: 10px;
    border-top: 1px solid var(--line);
    padding: 8px 0 4px;
  }

  .topnav.open { background: var(--nav-open); }

  .topnav.open ul { display: flex; }

  .topnav ul li a {
    display: block;
    padding: 11px 4px;
    font-size: 14px;
    border-bottom: 1px solid rgba(51, 41, 28, .5);
  }

  .topnav a.current { border-bottom-color: var(--gold); }

  .hero .slide { filter: blur(3px); }
  .hero-inner { padding: 110px 18px 70px; }
  .hero-kicker { letter-spacing: 4px; }
  .hero-sub { font-size: 15.5px; }

  .section { padding: 48px 0; }
  .wrap { padding: 0 18px; }

  .grid { grid-template-columns: 1fr; }
  .figure-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }

  /* portrait stacks above the bio text on phones */
  .portrait-row { flex-direction: column; gap: 26px; }
  .portrait { flex-basis: auto; width: min(78vw, 340px); }

  /* toolbar: search box on its own row, chips wrap below */
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar input[type="search"] { flex-basis: auto; }
  .chips { justify-content: flex-start; }
  .chip { padding: 7px 13px; font-size: 11.5px; }

  .card { padding: 18px 16px 14px; }
  .card h3 { font-size: 17.5px; }

  /* gallery + lightbox on phones */
  .gallery { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .gallery .thumb { height: 110px; }
  .lightbox { padding: 30px 8px; }
  .lightbox .lb-btn { width: 40px; height: 40px; }
  .lightbox .lb-prev { left: 6px; }
  .lightbox .lb-next { right: 6px; }

  footer { padding: 34px 0 46px; }
  footer .foot-nav { line-height: 2; }
}
