/* Dark is the default. The theme button (theme.js) sets data-theme="light". */
:root {
  color-scheme: dark;
  --bg: #141414;
  --text: #e8e8e6;
  --muted: #9a9a97;
  --line: #2a2a2a;
  --card: #1b1b1b;
  --hover: #222222;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #fdfdfc;
  --text: #1c1c1c;
  --muted: #6b6b6b;
  --line: #e6e6e3;
  --card: #ffffff;
  --hover: #f4f4f2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

/* Top menu on every page */
.site-nav {
  display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px 24px;
  padding-bottom: 14px; margin-bottom: 40px; border-bottom: 1px solid var(--line);
}
.site-name { font-weight: 600; text-decoration: none; }
.site-links { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 0.95rem; }
.site-links a { color: var(--muted); text-decoration: none; }
.site-links a:hover, .site-links a[aria-current="page"] { color: var(--text); }
.theme-toggle {
  all: unset; cursor: pointer; color: var(--muted);
  display: inline-flex; align-self: center; padding: 2px; border-radius: 4px;
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.theme-toggle svg { width: 18px; height: 18px; display: block; }

h1 { font-size: 1.7rem; margin: 0; font-weight: 600; }
h2 { font-size: 0.8rem; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin: 48px 0 16px; }
h3 { font-size: 1rem; margin: 0; font-weight: 600; }
p { margin: 0; }

.role { color: var(--muted); margin: 4px 0 16px; }
.bio { max-width: 640px; margin-bottom: 16px; }
.year { color: var(--muted); font-size: 0.85rem; }
h2 + .section-note { margin: -8px 0 16px; color: var(--muted); font-size: 0.9rem; }
.bio + .bio { margin-top: -4px; }
h3 a { text-decoration: none; }
h3 a:hover { text-decoration: underline; }

a { color: var(--text); text-underline-offset: 3px; text-decoration-color: var(--muted); }
a:hover { text-decoration-color: var(--text); }
.links { display: flex; gap: 20px; flex-wrap: wrap; }

/* Photo next to the intro text on the About page */
.intro { display: flex; gap: 36px; align-items: flex-start; }
.intro > div { flex: 1; min-width: 0; }
.portrait {
  width: 200px; height: 200px; flex-shrink: 0;
  object-fit: cover; border-radius: 12px; display: block;
}
.portrait-sm { width: 120px; height: 120px; margin-bottom: 16px; }
@media (max-width: 560px) {
  .intro { flex-direction: column; gap: 20px; }
  .portrait { width: 140px; height: 140px; }
}

/* Product and project cards (links to their pages) */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.card {
  all: unset;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  transition: background 0.15s, transform 0.15s;
}
.card:hover { background: var(--hover); transform: translateY(-2px); }
.card:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.card > p:last-child { color: var(--muted); font-size: 0.9rem; }
.cover { position: relative; margin-bottom: 8px; }
.cover img {
  width: 100%;
  height: auto; /* else the img height attribute wins over aspect-ratio */
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

/* Experience | Education + Skills */
.columns {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 0 48px;
}
@media (max-width: 760px) {
  .columns { grid-template-columns: 1fr; }
  main { padding-top: 16px; }
}
.entry { padding: 10px 0; border-top: 1px solid var(--line); }
.entry p:last-child:not(.year) { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }
.skills { color: var(--muted); margin-bottom: 8px; }

footer { margin-top: 48px; color: var(--muted); font-size: 0.85rem; }

/* Product and project pages */
.crumbs { font-size: 0.85rem; color: var(--muted); margin-bottom: 16px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.page { max-width: 820px; }
.page-head { margin-bottom: 20px; }
.page-head h1 { line-height: 1.3; }
.intro { font-size: 1.1rem; margin-top: 6px; }
.page h2 { font-size: 1.15rem; font-weight: 600; color: var(--text); text-transform: none; letter-spacing: 0; margin: 36px 0 8px; }
.page h3 { margin: 18px 0 4px; }
.page p + p { margin-top: 10px; }
/* Physical paddings first, so the logical one wins in both directions (also over Bootstrap's reset). */
.page ul, .page ol { margin: 8px 0 0; padding-left: 0; padding-right: 0; padding-inline-start: 1.25em; }
.page li + li { margin-top: 4px; }
.page .tags { margin-top: 36px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.button {
  display: inline-block; padding: 8px 16px; border-radius: 8px;
  background: var(--text); color: var(--bg); text-decoration: none; font-weight: 600; font-size: 0.95rem;
}
.button:hover { opacity: 0.88; }
.button.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }

/* Short facts table on product pages */
.facts { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 0.95rem; }
.facts th, .facts td { text-align: start; vertical-align: top; padding: 7px 0; border-top: 1px solid var(--line); }
.facts tr:last-child th, .facts tr:last-child td { border-bottom: 1px solid var(--line); }
.facts th { width: 34%; padding-inline-end: 16px; color: var(--muted); font-weight: 500; }
@media (max-width: 560px) { .facts th { width: 40%; } }

/* Picture gallery: a big picture with arrows, small pictures below (gallery.js) */
.gallery { margin: 0 0 8px; }
.gallery figure { margin: 0; }
.stage { position: relative; background: #000; border-radius: 8px; overflow: hidden; }
.stage img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: contain; }
.arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, 0.55); color: #fff;
  font-size: 26px; line-height: 1; cursor: pointer;
}
.prev { left: 10px; }
.next { right: 10px; }
.counter {
  position: absolute; left: 12px; bottom: 10px;
  color: #fff; background: rgba(0, 0, 0, 0.55);
  font-size: 0.75rem; padding: 2px 8px; border-radius: 999px;
  font-weight: 400; line-height: 1.6;
}
.caption { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }
.thumbs { display: flex; gap: 8px; padding-top: 8px; overflow-x: auto; }
.thumbs img {
  width: 88px; height: auto; aspect-ratio: 16 / 9; object-fit: cover;
  border-radius: 4px; cursor: pointer; opacity: 0.5;
  border: 2px solid transparent;
}
.thumbs img.active { opacity: 1; border-color: var(--text); }
.gallery.single .arrow, .gallery.single .counter, .gallery.single .thumbs { display: none; }

/* Bootstrap tabs (ID Vision page), in the site colours */
.tabs {
  margin: 8px 0 20px;
  padding: 0;
  --bs-nav-tabs-border-color: var(--line);
  --bs-nav-tabs-link-hover-border-color: var(--line) var(--line) var(--line);
  --bs-nav-tabs-link-active-color: var(--text);
  --bs-nav-tabs-link-active-bg: var(--bg);
  --bs-nav-tabs-link-active-border-color: var(--line) var(--line) var(--bg);
  --bs-nav-link-color: var(--muted);
  --bs-nav-link-hover-color: var(--text);
  --bs-nav-link-font-size: 0.95rem;
}
.tags { color: var(--muted); font-size: 0.85rem; }

/* Persian pages: IRANSans, the same font as the panels of the products. */
@font-face {
  font-family: "IranSansWeb";
  src: url("/fonts/iransansweb.woff2") format("woff2");
  font-display: swap;
}
html[lang="fa"] body {
  font-family: "IranSansWeb", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.9;
}
/* Letter spacing breaks the joined Persian letters. */
html[lang="fa"] h2 { letter-spacing: 0; font-size: 0.9rem; }
html[lang="fa"] .page h2 { font-size: 1.15rem; }

/* Phone: small cards, image on the left */
@media (max-width: 560px) {
  .grid { gap: 10px; }
  .card { display: grid; grid-template-columns: 112px 1fr; column-gap: 12px; row-gap: 0; padding: 8px; align-items: start; }
  .cover { grid-row: 1 / span 3; margin: 0; }
  .cover img { aspect-ratio: 4 / 3; }
  .card > p:last-child { font-size: 0.85rem; line-height: 1.4; }
}
