/* ahmad-hamid.com — the shared shell: fonts, colour tokens, Saudi motifs,
   header, pages, footer. Every page loads this one file. It is external on
   purpose: the Content-Security-Policy sent by server.py forbids inline
   styles and scripts. Layout uses logical properties (inline-start/end), so
   the same rules serve Arabic (rtl) and English (ltr); site.js flips
   <html dir>, lang and data-theme.

   Design (2026-10-23): espresso brown and lavender on warm sand, with a
   brass hairline. The motifs are drawn in CSS gradients and one inline SVG,
   no image files, so they follow the theme:
   - Al-Qatt Al-Asiri (Asir): nested triangles and sawtooth rows, under the
     name on the home page and along the top edge of every card;
   - Najdi merlons (Riyadh, Diriyah mud-brick parapets): the triangle row
     that crowns the footer, with the small triangular openings below it;
   - Sadu weave / Hijazi rawshan lattice: the faint diamond grid behind the
     dark title bands. */

/* ---- Fonts: local files, the CSP allows font-src 'self' only ---------- */

@font-face {
  font-family: "Reem Kufi";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/reem-kufi-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFC;
}

@font-face {
  font-family: "Reem Kufi";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/reem-kufi-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F;
}

@font-face {
  font-family: "Marcellus";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/marcellus-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F;
}

/* ---- Tokens ------------------------------------------------------------ */

:root {
  --bg: #f3ece2;
  --surface: #fbf8f3;
  --surface-2: #ece3d6;
  --text: #2b1c15;
  --muted: #6f5b4f;
  --border: #dccdbb;
  --accent: #6b4fa0;
  --accent-strong: #563d87;
  --accent-soft: rgba(107, 79, 160, 0.12);
  --accent-line: rgba(107, 79, 160, 0.4);
  --lavender: #a98fd6;
  --brown: #6b4532;
  --sand: #e9dcc8;
  --gold: #b8914f;
  --ok: #3d7a4a;
  --ok-soft: rgba(61, 122, 74, 0.14);
  --band-bg: #2b1c15;
  --band-bg-2: #3d2920;
  --band-text: #f3ebdf;
  --band-muted: #c9b7a7;
  --band-line: rgba(184, 145, 79, 0.5);
  --band-soft-line: rgba(243, 235, 223, 0.1);
  --band-accent: #c9b3ef;
  --band-accent-soft: rgba(201, 179, 239, 0.16);
  --band-openings: rgba(201, 179, 239, 0.32);
  --lattice: rgba(201, 179, 239, 0.2);
  --shadow-sm: 0 1px 2px rgba(43, 28, 21, 0.06);
  --shadow-md: 0 22px 44px -20px rgba(43, 28, 21, 0.4);
  --radius: 18px;
  --header-h: 68px;
  --font-body: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Noto Sans Arabic", sans-serif;
  --font-display: "Marcellus", "Reem Kufi", Georgia, "Times New Roman", serif;
  --display-weight: 400;
  color-scheme: light;
}

/* Headings: Marcellus for English, Reem Kufi for Arabic. The Work and
   Personal project lists are always English, whatever the shell language. */
:root[lang="ar"] {
  --font-display: "Reem Kufi", "Marcellus", "Sakkal Majalla", "Segoe UI", sans-serif;
  --display-weight: 700;
}

[lang="en"] {
  --font-display: "Marcellus", "Reem Kufi", Georgia, "Times New Roman", serif;
  --display-weight: 400;
}

/* Dark follows the system unless the visitor chose light; the explicit
   choice (data-theme) always wins. The two blocks must stay identical. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #140e0b;
    --surface: #211813;
    --surface-2: #2c211b;
    --text: #f1e7da;
    --muted: #b5a08f;
    --border: #3a2c24;
    --accent: #c3aaea;
    --accent-strong: #d6c3f3;
    --accent-soft: rgba(195, 170, 234, 0.14);
    --accent-line: rgba(195, 170, 234, 0.45);
    --lavender: #9a7fcf;
    --brown: #7a5540;
    --sand: #e3d2ba;
    --gold: #cfa968;
    --ok: #86c793;
    --ok-soft: rgba(134, 199, 147, 0.16);
    --band-bg: #1f1612;
    --band-bg-2: #2c1e18;
    --band-text: #f3ebdf;
    --band-muted: #b9a697;
    --band-line: rgba(207, 169, 104, 0.4);
    --band-soft-line: rgba(243, 235, 223, 0.08);
    --band-accent: #c9b3ef;
    --band-accent-soft: rgba(201, 179, 239, 0.16);
    --band-openings: rgba(201, 179, 239, 0.3);
    --lattice: rgba(201, 179, 239, 0.16);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 22px 44px -20px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #140e0b;
  --surface: #211813;
  --surface-2: #2c211b;
  --text: #f1e7da;
  --muted: #b5a08f;
  --border: #3a2c24;
  --accent: #c3aaea;
  --accent-strong: #d6c3f3;
  --accent-soft: rgba(195, 170, 234, 0.14);
  --accent-line: rgba(195, 170, 234, 0.45);
  --lavender: #9a7fcf;
  --brown: #7a5540;
  --sand: #e3d2ba;
  --gold: #cfa968;
  --ok: #86c793;
  --ok-soft: rgba(134, 199, 147, 0.16);
  --band-bg: #1f1612;
  --band-bg-2: #2c1e18;
  --band-text: #f3ebdf;
  --band-muted: #b9a697;
  --band-line: rgba(207, 169, 104, 0.4);
  --band-soft-line: rgba(243, 235, 223, 0.08);
  --band-accent: #c9b3ef;
  --band-accent-soft: rgba(201, 179, 239, 0.16);
  --band-openings: rgba(201, 179, 239, 0.3);
  --lattice: rgba(201, 179, 239, 0.16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 22px 44px -20px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

/* ---- Base -------------------------------------------------------------- */

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
img { display: block; max-width: 100%; }

h1,
h2 {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
}

/* Line icons in the header and on the section cards. */
.ico {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.container {
  width: 100%;
  max-width: 1080px;
  margin-inline: auto;
  padding-inline: 24px;
}

/* ---- Header ------------------------------------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--band-bg);
  color: var(--band-text);
  border-bottom: 1px solid var(--band-soft-line);
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--band-text);
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 1.2rem;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.brand img {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  box-shadow: 0 0 0 1px var(--band-line);
}

.brand:focus-visible {
  outline: 2px solid var(--band-accent);
  outline-offset: 3px;
  border-radius: 8px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-inline-start: 16px;
}

.nav a {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--band-muted);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav a:hover {
  color: var(--band-text);
  background: rgba(243, 235, 223, 0.07);
}

.nav a[aria-current="page"] {
  color: var(--band-accent);
  background: var(--band-accent-soft);
}

.nav a:focus-visible {
  outline: 2px solid var(--band-accent);
  outline-offset: 2px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-inline-start: auto;
}

.ctl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  min-width: 38px;
  padding: 0 12px;
  border: 1px solid rgba(243, 235, 223, 0.22);
  border-radius: 999px;
  background: rgba(243, 235, 223, 0.05);
  color: var(--band-text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.ctl:hover {
  border-color: var(--band-accent);
  background: var(--band-accent-soft);
}

.ctl:focus-visible {
  outline: 2px solid var(--band-accent);
  outline-offset: 2px;
}

.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }

/* ---- Title bands (the dark top of every page) ------------------------- */

main {
  flex: 1;
  padding-block: 0 72px;
}

.band {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, var(--band-bg) 0%, var(--band-bg-2) 100%);
  color: var(--band-text);
  border-bottom: 1px solid var(--band-line);
}

/* Sadu / rawshan lattice, fading out towards the text. */
.band::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-end: -60px;
  width: min(55vw, 620px);
  background-image:
    repeating-linear-gradient(45deg, var(--lattice) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(-45deg, var(--lattice) 0 1px, transparent 1px 28px);
  -webkit-mask-image: radial-gradient(ellipse 70% 90% at 65% 50%, #000 0%, transparent 100%);
  mask-image: radial-gradient(ellipse 70% 90% at 65% 50%, #000 0%, transparent 100%);
  pointer-events: none;
}

.band .container { position: relative; }

/* Home: the name in both languages; the interface language decides which
   one leads. */
.hero { padding-block: 56px 92px; }

.hero-name {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}

.name-en,
.name-ar { display: block; }

.name-en {
  order: 1;
  font-family: "Marcellus", Georgia, "Times New Roman", serif;
  font-weight: 400;
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  line-height: 1.1;
  letter-spacing: 0.01em;
}

.name-ar {
  order: 2;
  font-family: "Reem Kufi", "Sakkal Majalla", "Segoe UI", sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.5;
  color: var(--band-accent);
}

:root[lang="ar"] .name-ar {
  order: 1;
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  line-height: 1.35;
  color: inherit;
}

:root[lang="ar"] .name-en {
  order: 2;
  font-size: 0.95rem;
  line-height: 1.4;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--band-accent);
}

/* Each name keeps its own direction; both align with the page. */
:root[dir="rtl"] .name-en { text-align: right; }
:root[dir="ltr"] .name-ar { text-align: left; }

/* The Al-Qatt band under the name (inline SVG on the home page). */
.qatt {
  display: block;
  width: min(100%, 460px);
  height: 22px;
  margin-block: 26px 22px;
}

.p-gold { fill: var(--gold); }
.p-brown { fill: var(--brown); }
.p-lav { fill: var(--lavender); }
.p-sand { fill: var(--sand); }

.hero-tagline {
  max-width: 36rem;
  margin: 0;
  color: var(--band-muted);
  font-size: 1.2rem;
}

/* Work, Personal, 404: just the title, with a short Qatt underline. */
.page-band { padding-block: 44px 84px; }

.page-title {
  margin: 0;
  font-size: clamp(2rem, 4.5vw, 2.8rem);
  line-height: 1.25;
}

.page-title::after {
  content: "";
  display: block;
  width: 112px;
  height: 7px;
  margin-top: 16px;
  background: conic-gradient(from 135deg at 50% 0, var(--band-accent) 0 90deg, transparent 90deg) 0 0 / 14px 7px repeat-x;
}

/* ---- Cards (home sections and project cards) -------------------------- */

.sections,
.projects {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 22px;
  margin-top: -48px;
}

.sections {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

.projects {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  margin-bottom: 0;
  padding: 0;
  list-style: none;
}

.section-card,
.project {
  --card-pad: 28px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  overflow: hidden;
  padding: var(--card-pad);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: inherit;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.project { --card-pad: 24px; }

/* The Al-Qatt sawtooth along the top edge of every card. */
.section-card::before,
.project::before {
  content: "";
  flex: none;
  height: 8px;
  margin: calc(-1 * var(--card-pad)) calc(-1 * var(--card-pad)) 4px;
  background-color: var(--brown);
  background-image: conic-gradient(from 135deg at 50% 0, var(--lavender) 0 90deg, transparent 90deg);
  background-size: 16px 8px;
  background-repeat: repeat-x;
}

a.section-card:hover,
a.project:hover {
  border-color: var(--accent-line);
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}

a.section-card:focus-visible,
a.project:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.section-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border: 1px solid var(--accent-line);
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
}

.section-icon .ico {
  width: 26px;
  height: 26px;
  stroke-width: 1.6;
}

.section-card h2 {
  margin: 0;
  font-size: 1.65rem;
  line-height: 1.3;
}

.section-card p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.section-arrow {
  margin-top: auto;
  padding-top: 6px;
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 600;
}

/* ---- Project cards ----------------------------------------------------- */

.project-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Logo files carry their own background; the thin border keeps every
   logo's edge visible on both light and dark surfaces. */
.project-logo {
  flex: none;
  width: 56px;
  height: 56px;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.project-id {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.project-name {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 1.35rem;
  line-height: 1.2;
}

.project-full {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.3;
}

.status {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  margin-inline-start: auto;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status-live {
  color: var(--ok);
  background: var(--ok-soft);
}

.status-soon {
  color: var(--muted);
  background: var(--surface-2);
}

.project-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.project-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
}

.project-soon { opacity: 0.75; }

/* ---- Empty state, 404 -------------------------------------------------- */

.empty {
  padding: 48px 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.notfound {
  padding-block: 56px;
  text-align: center;
}

.notfound p {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 1.1rem;
}

.button {
  display: inline-flex;
  align-items: center;
  padding: 11px 22px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-md);
  transition: background 0.15s ease;
}

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

:root[data-theme="dark"] .button { color: var(--bg); }

/* ---- Footer: a Najdi parapet ------------------------------------------ */

.site-footer {
  margin-top: auto;
  color: var(--band-muted);
  font-size: 0.875rem;
}

/* Merlons: spaced triangles in the footer colour, standing on the bar. */
.merlons {
  height: 16px;
  background: conic-gradient(from 143.13deg at 50% 0, var(--band-bg) 0 73.74deg, transparent 73.74deg) 0 0 / 32px 16px repeat-x;
}

.footer-bar {
  padding-bottom: 22px;
  border-top: 1px solid var(--band-line);
  background: var(--band-bg);
}

/* The small triangular openings in the wall under each merlon. */
.footer-bar::before {
  content: "";
  display: block;
  height: 8px;
  margin: 10px 0 16px;
  background: conic-gradient(from 150deg at 50% 0, var(--band-openings) 0 60deg, transparent 60deg) 0 0 / 32px 8px repeat-x;
}

.footer-bar .container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

/* ---- Small screens ----------------------------------------------------- */

@media (max-width: 600px) {
  .container { padding-inline: 16px; }
  .brand-name { display: none; }
  .nav { margin-inline-start: 2px; }
  .nav a { padding: 8px 10px; font-size: 0.9rem; }
  .ctl { padding: 0 10px; }
  .ctl-text { display: none; }
  main { padding-bottom: 56px; }
  .hero { padding-block: 36px 76px; }
  .page-band { padding-block: 32px 70px; }
  .hero-tagline { font-size: 1.1rem; }
  .section-card { --card-pad: 22px; }
  .project { --card-pad: 20px; }
  .sections,
  .projects { gap: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  html { scroll-behavior: auto; }
}
