/* Optional dark theme: soft greys that keep the page's quiet tone. Light stays the default. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: #2c2c2b;
  --surface-light: #353534;
  --raised: #404040;
  --ink: #f3f3f0;
  --ink-fade: #9d9a94;
  --ink-soft: #c2bfb9;
  --btn: #f3f3f0;
  --btn-ink: #2c2c2b;
  --line: #4a4844;
}

[data-theme="dark"] .page::after { filter: invert(1); opacity: .035; }
[data-theme="dark"] .ink { fill: #e4e4e1; }

/* Raised pieces that were white */
[data-theme="dark"] .tag,
[data-theme="dark"] .pill,
[data-theme="dark"] .btn-light,
[data-theme="dark"] .project-card,
[data-theme="dark"] .sheet-close,
[data-theme="dark"] .xp-logo { background: var(--raised); color: var(--ink); }
[data-theme="dark"] { --brush: #4d4c49; }
[data-theme="dark"] .services .divider-tag { background: var(--raised); }
[data-theme="dark"] .btn-light,
[data-theme="dark"] .pill { box-shadow: none; }

/* The main button flips to light */
[data-theme="dark"] .btn-dark,
[data-theme="dark"] .sheet-visit { background: var(--btn); color: var(--btn-ink); box-shadow: none; }

/* White edges from the light theme become soft or disappear */
[data-theme="dark"] .hero,
[data-theme="dark"] .services,
[data-theme="dark"] .cta { box-shadow: none; }
/* The name stays light so it never merges with the circle behind it */

/* Text and icons with fixed dark colours */
[data-theme="dark"] .bar { color: #d8d8d4; }
[data-theme="dark"] .logo { color: #dcdcd8; opacity: .85; filter: none; }
[data-theme="dark"] .service-icon svg,
[data-theme="dark"] .cta-circle svg { stroke: #dcdcd8; }
[data-theme="dark"] .cta-circle { background: var(--raised); }
[data-theme="dark"] .xp-year { color: #92928e; }
[data-theme="dark"] .is-current .xp-year { color: transparent; }
[data-theme="dark"] .xp-row.is-current:not(:last-child)::before { background: #7f7f7b; }
[data-theme="dark"] .xp-logo { border-color: var(--line); }

/* Logos keep their light seals, slightly dimmed; only the University of Palestine wordmark swaps colour */
[data-theme="dark"] .logo img { filter: grayscale(1) brightness(.88); }
[data-theme="dark"] .logo-on-light { display: none; }
[data-theme="dark"] .logo-on-dark { display: block; }
[data-theme="dark"] .xp-row .xp-logo img[src*="iug"] { filter: grayscale(1) brightness(.88); }

/* Screens stay readable without glowing */
[data-theme="dark"] .project-media img { filter: grayscale(1) brightness(.86); }
[data-theme="dark"] .project-card:focus-visible img { filter: brightness(.92); }
[data-theme="dark"] .viewer-open { filter: brightness(.86); }
[data-theme="dark"] .viewer-dot::before { background: var(--line); }
[data-theme="dark"] .viewer-dot[aria-current="true"]::before { background: var(--ink); }
[data-theme="dark"] .project-card { box-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25); }
[data-theme="dark"] .sheet::backdrop { background: rgba(0, 0, 0, .55); }
[data-theme="dark"] .sheet-close { box-shadow: none; }

@media (hover: hover) and (pointer: fine) {
  [data-theme="dark"] .btn-dark:hover,
  [data-theme="dark"] .sheet-visit:hover { background: #ffffff; box-shadow: none; }
  [data-theme="dark"] .btn-light:hover,
  [data-theme="dark"] .pill:hover { background: #4a4a49; box-shadow: none; }
  [data-theme="dark"] .bar-icon:hover,
  [data-theme="dark"] .bar-theme:hover { background: rgba(255, 255, 255, .07); }
  [data-theme="dark"] .logo:hover { opacity: 1; filter: none; }
  [data-theme="dark"] .logo:hover img,
  [data-theme="dark"] .xp-row:hover .xp-logo img[src*="iug"] { filter: none; }
  [data-theme="dark"] .project-card:hover { box-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 26px rgba(0, 0, 0, .32); }
  [data-theme="dark"] .project-card:hover .project-media img { filter: brightness(.92); }
}

@media (hover: none) {
  [data-theme="dark"] .project-media img { filter: grayscale(1) brightness(.86); }
}

/* From 900px the card's face and its text drawer carry the surface, not the card */
@media (min-width: 900px) {
  [data-theme="dark"] .project-card,
  [data-theme="dark"] .project-card:hover { background: none; box-shadow: none; }
  [data-theme="dark"] .project-face,
  [data-theme="dark"] .project-summary { background: var(--raised); }
  [data-theme="dark"] .project-face { box-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25); }
  [data-theme="dark"] .project-summary { box-shadow: 0 14px 28px rgba(0, 0, 0, .3); }
  [data-theme="dark"] .project-card:hover .project-face { box-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 16px 36px rgba(0, 0, 0, .34); }
}

[data-theme="dark"] ::selection { background: #bbbbb7; color: #2c2c2b; }
@media (hover: hover) and (pointer: fine) {
  [data-theme="dark"]::-webkit-scrollbar-thumb, [data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(243, 243, 240, .3); background-clip: padding-box; }
  [data-theme="dark"]::-webkit-scrollbar-thumb:hover, [data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(243, 243, 240, .6); background-clip: padding-box; }
  @supports not selector(::-webkit-scrollbar) {
    html[data-theme="dark"] { scrollbar-color: rgba(243, 243, 240, .3) transparent; }
  }
}
