/* CSS Reset: http://meyerweb.com/eric/tools/css/reset */

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
  display: block;
}
body {
  line-height: 1;
}
ol, ul {
  list-style: none;
}
blockquote, q {
  quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
  content: '';
  content: none;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}

:root {
  color-scheme: light;

  --text-primary: #1f2937;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;

  --border: #e5e7eb;
  --background: #ffffff;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
}
/**************************************************/

#body {
  font-family: 'Asap', sans-serif;
  font-size: 1em;
  line-height: 1.65;
  color: var(--text-primary);
}

#main {
  width: min(90%, 65rem);
  margin: 0 auto;
  position: relative;
  min-height: 100vh;
  box-sizing: border-box;
}



i {
  font-style: italic;
}

b {
  font-weight: 700;
}

h1 {
  font-size: 2.4em;
  line-height: 3em;
  font-weight: 500;
}

/**************************************************/
/* Profile image and description. */

#intro {
  padding-top: 4em;
  display: flex;
  align-items: flex-start;
  gap: 2em;
}

#intro-text {
  flex: 1;
  min-width: 0;
}

#intro-image {
  flex: 0 0 12em;
  width: 12em;
  height: 12em;
  margin: 1em 0 0;
  overflow: hidden;
  border-radius: 12px;
}

#intro-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/**************************************************/
/* Section buttons. */

#menu {
  display: flex;
}

.menu-item {
  float: left;
  margin-right: 2em;
}

h2 {
  font-size: 1.6em;
  line-height: 2.4em;
  margin-top: 0.5em;
  color: var(--text-secondary);
}

.selected h2 {
  color: var(--text-primary);
}

.button {
  display: inline-block;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 1.1em;
  font-weight: 500;
  line-height: 2em;
  margin-right: 1.5em;
  padding: 0;
  transition: color 0.2s ease;
}



.button.is-checked {
  font-weight: 600;
}

.button:hover,
.button.is-checked {
  color: var(--accent);
}

.button.is-checked {
  font-weight: 600;
}

.button-group:after {
  content: '';
  display: block;
  clear: both;
}

/**************************************************/
/* Isotope grid list of items. */

.grid {
  padding-bottom: 6em;
}

/* clear fix */
.grid:after {
  content: '';
  display: block;
  clear: both;
}

.description {
  margin-bottom: 1em;
}

.list-item {
  width: 100%;
  line-height: 1em;
  margin-top: 1em;
  box-sizing: border-box;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  gap: 24px;
}

.list-item .thumbnail { flex: 0 0 180px; }
.list-item .thumbnail img { width: 180px; height: auto; display: block; }
.list-item .project-description {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.list-item p.date {
  display: inline-block;
  width: 3em;
  color: var(--text-secondary);
}

/**************************************************/
/* Gallery of 3 preview videos. */

/* Horizontally scrollable image gallery */
.gallery {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 2px 12px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.gallery img {
  flex: 0 0 260px;
  width: 260px;
  height: 170px;
  max-width: 85%;
  object-fit: cover;
  border-radius: 8px;
  scroll-snap-align: start;
  display: block;
}

/**************************************************/
/* Contact tab. */

.contact-list {
  list-style: none;
  padding: 0;
  margin: 1em 0 0 0;
}

.contact-list li {
  line-height: 1.8em;
  margin-bottom: 0.4em;
}

.contact-list li b {
  display: inline-block;
  width: 6em;
  color: var(--text-primary);
}

h2,
.publication p,
.list-item p.date {
  color: var(--text-secondary);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* optional: hide scrollbar but keep swipe */
.gallery::-webkit-scrollbar { height: 6px; }
.gallery::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.previews {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  grid-auto-rows: minmax(100px, auto);
  height: 12.5em;
}

.previews video {
  border-radius: 5px;
}

.previews a:hover {
  border: none;
}

.preview1 {
  grid-column: 1;
  width: 100%;
}
.preview2 {
  grid-column: 2;
  width: 100%;
}
.preview3 {
  grid-column: 3;
  width: 100%;
}

/**************************************************/
/* Buttons for showing more or less highlights. */

.toggle-button {
  margin-top: 2em;
}

.toggle-button a {
  color: var(--text-muted);
}

.toggle-button a:hover {
  color: var(--accent);
}

/**************************************************/
/* Publication details (thumbnail media, title, and description). */

.thumbnail {
/*  width: 21%;*/
  width: 18%;
  float: left;
  margin-right: 2%;
}

.thumbnail:hover {
  border-bottom: none;
}

.thumbnail img {
  margin-top: 0.4em;
  border-radius: 6px;
  width: 100%;
  height: auto;
  display: block;
}

.thumbnail video {
  margin-top: 0.4em;
  border-radius: 5px;
  width: 100%;
  height: 100%;
}

h3 {
  font-size: 1em;
  line-height: 1.5em;
}

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

h3 a:hover {
  color: var(--accent);
}

.publication {
  margin-bottom: 0.5em;
}

.publication p {
  font-size: 1em;
  line-height: 1.5em;
  color: var(--text-secondary);
}

.project-description {
  min-width: 0;
}

/**************************************************/
/* Contact form (FormBeam). */

.contact-form {
  max-width: 30em;
  margin-top: 1.5em;
}

.contact-form p {
  margin-bottom: 0.8em;
}

.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form textarea {
  width: 100%;
  padding: 0.6em 0.8em;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 1em;
  line-height: 1.4;
  box-sizing: border-box;
  color: var(--text-primary);
  background: var(--background);
}

.contact-form textarea {
  resize: vertical;
  min-height: 6em;
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.contact-form button {
  padding: 0.6em 1.5em;
  border: none;
  border-radius: 6px;
  background: rgb(20, 110, 190);
  color: #fff;
  font-size: 1em;
  font-family: inherit;
  cursor: pointer;
}

.contact-form button:hover {
  background: #0f4e86;
}

/**************************************************/
/* Language toggle */

.lang-switch {
  margin-top: 1em;
}

.lang-btn {
  color: var(--text-muted);
  cursor: pointer;
}

.lang-btn.is-active {
  color: var(--text-primary);
  font-weight: 700;
}

/* Arabic page direction */
html[dir="rtl"] #intro-text,
html[dir="rtl"] .project-description,
html[dir="rtl"] .contact-list,
html[dir="rtl"] .contact-form,
html[dir="rtl"] .contact-form-intro {
  text-align: right;
}



/* Center the theme toggle button itself */
#intro-text .theme-switch button {
  margin: 0 auto;
}

html[dir="rtl"] #intro {
  direction: rtl;
}

html[dir="rtl"] #intro-text {
  float: none;
}

html[dir="rtl"] #intro-image {
  float: none;
  margin: 1em 0 0;
}

html[dir="rtl"] .contact-list li b {
  display: inline-block;
}

/* Tabs follow Arabic flow */

html[dir="rtl"] #filters {
  direction: rtl;
  text-align: right;
}

html[dir="rtl"] .button {
  float: right;
  margin-right: 0;
  margin-left: 1em;
}

/* Keep biography text aligned according to language */
#intro-text > p:first-of-type {
  text-align: left;
}

html[dir="rtl"] #intro-text > p:first-of-type {
  text-align: right;
}




.list-item.highlight,
.list-item.publication {
  padding: 1.3em;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--background);
  transition: border-color 0.2s ease,
              box-shadow 0.2s ease,
              transform 0.2s ease;
  min-width: 0;
  max-width: 100%;
}

/* .list-item.highlight:hover,
.list-item.publication:hover {
border-color: var(--text-muted);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
  transform: translateY(-2px);
} */


.project-description > p a {
  font-size: 0.95em;
}

.project-description > p {
  color: var(--text-muted);
}

.project-description > p a {
  color: var(--accent);
}

.project-description iframe {
  border-radius: 8px;
  margin-top: 0.8em;
  max-width: 100%;
  border: 1px solid var(--border);
  display: block;
}

.list-item.Movie .project-description p {
  font-size: 0.9em;
  color: var(--text-secondary);
}

.list-item.Movie .movie-title {
  font-weight: 600;
}

.list-item.Movie .thumbnail img {
  width: 180px;
  height: 260px;
  object-fit: cover;
}

.contact-form-intro {
  color: var(--text-secondary);
  font-style: italic;
  margin: 1.2em 0 0.6em;
}

.contact-form input:invalid:not(:placeholder-shown),
.contact-form textarea:invalid:not(:placeholder-shown) {
  border-color: #dc2626;
}

.contact-form button {
  margin-top: 0.4em;
}

.lang-btn { transition: color 0.15s ease; }
.lang-btn.is-active { border-bottom: 2px solid currentColor; }

.contact-form-heading {
  margin-top: 2em;
}



/**************************************************/
/* Subtle footer at the bottom of the page. */

#bio-toggle {
  color: var(--accent);
  cursor: pointer;
  margin-left: 4px;
}

#intro-text p + p {
  margin-top: 1.5em;
}

#intro-text p:not(.lang-switch) {
  text-align: left;
}

html[dir="rtl"] #intro-text p:not(.lang-switch) {
  text-align: right;
}

#footer {
  color: var(--text-muted);
  position: static;
  margin-top: 3em;
  padding: 1em 0;
  line-height: 1.8;
  border-top: 1px solid var(--border);
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.contact-form button {
  padding: 0.6em 1.5em;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 1em;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease;
}

.contact-form button:hover {
  background: var(--accent-hover);
}

/* Keyboard accessibility */
a:focus-visible,
button:focus-visible,
.lang-btn:focus-visible,
#bio-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Better text rendering */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

@media (max-width: 768px) {
  .list-item.highlight,
  .list-item.publication {
    padding: 1em;
    flex-direction: column;
    gap: 12px;
  }

  .list-item .thumbnail {
    flex: none;
    width: 100%;
    max-width: 220px;
    margin-right: 0;
  }

  .list-item .thumbnail img {
    width: 100%;
    height: auto;
  }

  .list-item {
    min-width: 0;
  }

  .gallery {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
  }

  .gallery img {
    flex: 0 0 220px;
    width: 220px;
    max-width: 85%;
    height: 145px;
  }

  h1 {
    font-size: 2em;
    line-height: 1.5em;
  }
}

@media (max-width: 768px) {
  #intro {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding-top: 2em;
  }

  #intro-image {
    order: -1;
    flex: none;
    width: 140px;
    height: 140px;
    margin: 0 auto;
  }

  #intro-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  #intro-text {
    width: 100%;
    flex: none;
    min-width: 0;
    text-align: left;
  }

  html[dir="rtl"] #intro-text {
    text-align: right;
  }


  /* Center navigation tabs */
  #filters {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 18px;
    text-align: center;
  }

  #filters .button {
    margin: 0;
    float: none;
  }
}


/* ===== DARK MODE ===== */

html[data-theme="dark"] {
  color-scheme: dark;

  --text-primary: #e5e7eb;
  --text-secondary: #a1aab8;
  --text-muted: #929dad;

  --accent: #8ab4f8;
  --accent-hover: #aecbfa;

  --border: #343d4a;
  --background: #151a22;
  --surface: #1e2631;
  --surface-hover: #273241;
}

/* Page background */
html[data-theme="dark"],
html[data-theme="dark"] body,
html[data-theme="dark"] #body,
html[data-theme="dark"] #main {
  background-color: var(--background);
  color: var(--text-primary);
}

/* Headings */
html[data-theme="dark"] h1,
html[data-theme="dark"] h3,
html[data-theme="dark"] h3 a,
html[data-theme="dark"] .selected h2 {
  color: var(--text-primary);
}

html[data-theme="dark"] h2,
html[data-theme="dark"] .publication p,
html[data-theme="dark"] .list-item p.date,
html[data-theme="dark"] .list-item.Movie .project-description p {
  color: var(--text-secondary);
}

/* Links */
html[data-theme="dark"] a,
html[data-theme="dark"] .project-description > p a {
  color: var(--accent);
}

html[data-theme="dark"] a:hover,
html[data-theme="dark"] h3 a:hover {
  color: var(--accent-hover);
}

/* Navigation tabs */
html[data-theme="dark"] .button {
  color: var(--text-secondary);
  background: transparent;
}

html[data-theme="dark"] .button:hover,
html[data-theme="dark"] .button.is-checked {
  color: var(--accent);
}

/* Cards */
html[data-theme="dark"] .list-item.highlight,
html[data-theme="dark"] .list-item.publication {
  background-color: var(--surface);
  border-color: var(--border);
}

html[data-theme="dark"] .list-item.highlight:hover,
html[data-theme="dark"] .list-item.publication:hover {
  border-color: #526176;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

/* Descriptions */
html[data-theme="dark"] .project-description > p {
  color: var(--text-secondary);
}

/* Contact information */
html[data-theme="dark"] .contact-list li,
html[data-theme="dark"] .contact-list li b,
html[data-theme="dark"] .contact-form-intro {
  color: var(--text-secondary);
}

/* Contact form */
html[data-theme="dark"] .contact-form input[type="text"],
html[data-theme="dark"] .contact-form input[type="email"],
html[data-theme="dark"] .contact-form textarea {
  background-color: var(--surface);
  color: var(--text-primary);
  border-color: var(--border);
}

html[data-theme="dark"] .contact-form input::placeholder,
html[data-theme="dark"] .contact-form textarea::placeholder {
  color: var(--text-muted);
}

html[data-theme="dark"] .contact-form input:focus,
html[data-theme="dark"] .contact-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(138, 180, 248, 0.15);
}

html[data-theme="dark"] .contact-form button {
  background-color: var(--accent);
  color: #ffffff;
}

html[data-theme="dark"] .contact-form button:hover {
  background-color: var(--accent-hover);
}

/* Language switch */
html[data-theme="dark"] .lang-btn {
  color: var(--text-muted);
}

html[data-theme="dark"] .lang-btn.is-active {
  color: var(--text-primary);
}

/* Bio toggle */
html[data-theme="dark"] #bio-toggle {
  color: var(--accent);
}

/* Gallery scrollbar */
html[data-theme="dark"] .gallery::-webkit-scrollbar-thumb {
  background: #455164;
}

/* Footer */
html[data-theme="dark"] #footer {
  color: var(--text-muted);
  border-top-color: var(--border);
}

/* Embedded videos */
html[data-theme="dark"] .project-description iframe {
  border-color: var(--border);
}

/* Invalid form fields */
html[data-theme="dark"] .contact-form input:invalid:not(:placeholder-shown),
html[data-theme="dark"] .contact-form textarea:invalid:not(:placeholder-shown) {
  border-color: #f87171;
}

/* Text selection */
html[data-theme="dark"] ::selection {
  background: #365b91;
  color: #ffffff;
}

/* Reverse visitor counter image in dark mode */
html[data-theme="dark"] .list-item img[src*="hitscounter.dev"] {
  filter: invert(1);
}

/* Theme toggle button */

.theme-switch {
  margin-top: 0.7em;
}

#theme-toggle {
  display: inline-block;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--text-secondary);
  border-radius: 3px;
  background: #000000;
  cursor: pointer;
  vertical-align: middle;
  transition: background-color 0.2s ease;
}

html[data-theme="dark"] #theme-toggle {
  background: #ffffff;
  border-color: #a1aab8;
}

#theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Center language switch, theme toggle, and social links on mobile only */
@media (max-width: 768px) {
  #intro-text .lang-switch,
  #intro-text .theme-switch,
  #intro-text > p:last-child {
    text-align: center !important;
  }
}