/* malarbi.ca: the work as a transit network.
   Three route colours (LLM systems, Cloud–edge, Residential energy) on white map ground,
   ink sign panels for actions, Cabin (Johnston lineage) throughout. */

:root {
  --ground: #ffffff;
  --ink: #16181d;
  --ink-2: #4a4f59;
  --ink-3: #5f6470;
  --rule: #d9dce2;
  --on-line: #ffffff;
  --llm: #d4351c;
  --edge: #0a58b8;
  --energy: #00804a;
  --select: #ffd9cf;
  --font: "Cabin", system-ui, -apple-system, "Segoe UI", sans-serif;
  --arabic: "Noto Kufi Arabic", "Geeza Pro", "Segoe UI", sans-serif;
  --gutter: 32px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0f1115;
    --ink: #eceef2;
    --ink-2: #b8bdc6;
    --ink-3: #9ba1ac;
    --rule: #2b2f37;
    --on-line: #0f1115;
    --llm: #ff6b4f;
    --edge: #5ea3ff;
    --energy: #3ccb87;
    --select: #5b2116;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
  scrollbar-color: var(--ink-3) var(--ground);
  -webkit-text-size-adjust: 100%;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--select); color: var(--ink); }

h1, h2, h3, h4 { text-wrap: balance; }
p { text-wrap: pretty; }

a { color: inherit; text-decoration-thickness: 1.5px; text-underline-offset: 0.2em; }
a:hover { text-decoration-color: var(--llm); }
:focus-visible { outline: 3px solid var(--edge); outline-offset: 3px; }

bdi[lang="ar"] { font-family: var(--arabic); font-weight: 500; }

.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.skip {
  position: absolute; left: 16px; top: -100px; z-index: 20;
  background: var(--ink); color: var(--ground); padding: 10px 16px; font-weight: 600; text-decoration: none;
}
.skip:focus { top: 10px; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 var(--gutter); }

/* ---- navigation: a station name board ------------------------------------------- */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: var(--ground);
  border-bottom: 1px solid var(--rule);
}
.nav .wrap { display: flex; align-items: center; gap: 28px; height: 60px; }
.brand { font-weight: 700; font-size: 1.0625rem; text-decoration: none; white-space: nowrap; }
.nav ul {
  display: flex; gap: 24px; margin: 0 0 0 auto; padding: 0; list-style: none;
  overflow-x: auto; scrollbar-width: none;
}
.nav ul::-webkit-scrollbar { display: none; }
.nav ul a {
  display: block; padding: 17px 0 14px; white-space: nowrap;
  color: var(--ink-2); font-weight: 500; font-size: 0.95rem; text-decoration: none;
  border-bottom: 3px solid transparent;
}
.nav ul a:hover { color: var(--ink); }
.nav ul a[aria-current] { color: var(--ink); border-bottom-color: var(--llm); }

/* ---- sign panels (actions) ----------------------------------------------------------- */
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.sign {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: 0;
  background: var(--ink); color: var(--ground); border: 2px solid var(--ink);
  font-weight: 500; font-size: 1rem; text-decoration: none;
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.sign b { font-weight: 700; }
.sign:hover { background: var(--llm); border-color: var(--llm); color: var(--on-line); }
.sign-quiet { background: transparent; color: var(--ink); }
.sign-quiet:hover { background: var(--ink); border-color: var(--ink); color: var(--ground); }
.sign-big { font-size: clamp(1.15rem, 2.6vw, 1.6rem); font-weight: 600; padding: 16px 24px; overflow-wrap: anywhere; }

/* ---- first viewport ----------------------------------------------------------------- */
.hero { padding: 64px 0 72px; }
.hero-grid {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 56px; align-items: center;
}
/* the name always sits on one line: sized from its measured width (about 6.8x the font size) to fit its column */
.hero h1 {
  font-size: clamp(2.75rem, calc(5.91vw - 7.1px), 4rem); font-weight: 700;
  line-height: 1; letter-spacing: -0.025em; margin: 0; white-space: nowrap;
}
.role { font-size: clamp(1.25rem, 1vw + 1rem, 1.6rem); font-weight: 600; line-height: 1.3; margin: 18px 0 0; }
.cred { color: var(--ink-3); font-size: 1rem; margin: 10px 0 0; }
.intro { color: var(--ink-2); max-width: 62ch; margin: 24px 0 0; }

/* ---- the network map ----------------------------------------------------------------- */
.network { margin: 0; }
.map { display: block; width: 100%; height: auto; overflow: visible; }
.map-tall { display: none; }
.map text {
  fill: var(--ink); font-size: 15px; font-weight: 600; font-stretch: 87.5%;
  text-anchor: middle;
}
.map text.start { text-anchor: start; }
.map text.end { text-anchor: end; }
.map .xchg text { font-weight: 700; font-size: 16px; }
.map-tall text { font-size: 14px; }
.map-tall .xchg text { font-size: 15px; }
.map a { cursor: pointer; }
.map a:hover text, .map a:focus-visible text { text-decoration: underline; text-decoration-thickness: 1.5px; }
.map a:focus-visible { outline: none; }
.map a:focus-visible text { fill: var(--edge); }
.r-llm { --c: var(--llm); }
.r-edge { --c: var(--edge); }
.r-energy { --c: var(--energy); }
.map .route { fill: none; stroke: var(--c); stroke-width: 8; stroke-linejoin: round; }
.map .bar { stroke: var(--c); stroke-width: 8; }
.map .tick { stroke: var(--c); stroke-width: 6; }
.map .xchg circle { fill: var(--ground); stroke: var(--ink); stroke-width: 4; }
.map .r { transition: opacity 0.25s var(--ease); }

/* hovering or focusing a line (on the map or in the key) isolates it */
.network:has(.r-llm:hover, .r-llm :focus-visible, .legend [data-line="llm"]:is(:hover, :focus-visible)) .r:not(.r-llm),
.network:has(.r-edge:hover, .r-edge :focus-visible, .legend [data-line="edge"]:is(:hover, :focus-visible)) .r:not(.r-edge),
.network:has(.r-energy:hover, .r-energy :focus-visible, .legend [data-line="energy"]:is(:hover, :focus-visible)) .r:not(.r-energy) {
  opacity: 0.14;
}

@media (prefers-reduced-motion: no-preference) {
  .map .route { stroke-dasharray: 1; animation: draw 1.3s var(--ease) both; }
  .map .r-energy .route { animation-delay: 0.15s; }
  .map .r-llm .route { animation-delay: 0.45s; }
}
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }

.legend {
  display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: center;
  list-style: none; margin: 20px 0 0; padding: 0;
}
.legend a {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink-2); font-weight: 600; font-size: 0.95rem; text-decoration: none;
}
.legend a:hover { color: var(--ink); }
.legend .swatch { width: 28px; height: 8px; background: var(--c); }
.legend [data-line="llm"] { --c: var(--llm); }
.legend [data-line="edge"] { --c: var(--edge); }
.legend [data-line="energy"] { --c: var(--energy); }

/* ---- sections: heading in its own column, like a timetable board --------------------- */
.section { padding: 80px 0; border-top: 1px solid var(--rule); }
.section-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 9fr); gap: 32px; }
.section-head { align-self: start; position: sticky; top: 92px; }
.section-head h2 { font-size: 2rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.015em; margin: 0; }
.section-intro { color: var(--ink-3); margin: 10px 0 0; font-size: 1rem; }
.section-body { max-width: 650px; margin: 0; padding: 0; }

/* ---- line diagrams (Work) ------------------------------------------------------------- */
.line + .line { margin-top: 72px; }
.line-name { margin: 0 0 28px; font-size: 1rem; line-height: 1; }
.route-tag {
  display: inline-block; padding: 7px 12px 6px; border-radius: 0;
  background: var(--c); color: var(--on-line); font-weight: 700; font-size: 0.95rem;
}

.stations { list-style: none; margin: 0; padding: 0; --m: 14.5px; }
.station { position: relative; padding: 0 0 48px 56px; }
.station:last-child { padding-bottom: 0; }
/* the route itself: one continuous line from the first station to the last */
.station::after {
  content: ""; position: absolute; left: 16px; width: 8px;
  top: var(--m); bottom: calc(-1 * var(--m)); background: var(--c);
}
.station:last-child::after { display: none; }
/* station tick */
.station::before {
  content: ""; position: absolute; z-index: 1;
  left: 20px; top: calc(var(--m) - 3px); width: 18px; height: 6px; background: var(--c);
}
/* terminus bar */
.station:last-child::before { left: 7px; top: calc(var(--m) - 4px); width: 26px; height: 8px; }
/* a stop that belongs to another list (the Cloud–edge line runs on to LINGUA and to Sensing as a Service) */
.station.stop { padding-bottom: 36px; }
.station.stop a {
  display: inline-block; line-height: 29px;
  font-weight: 600; font-stretch: 87.5%; color: var(--ink-2); text-decoration: none;
}
.station.stop a:hover { color: var(--ink); text-decoration: underline; }
/* interchange ring */
.station.xchg::before {
  left: 8px; top: calc(var(--m) - 12px); width: 24px; height: 24px;
  background: var(--ground); border: 4px solid var(--ink); border-radius: 50%;
}

.station h4 { font-size: 1.375rem; line-height: 1.3; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.station .kicker { color: var(--ink-3); font-weight: 500; margin: 4px 0 12px; }
.station p { margin: 0 0 12px; color: var(--ink-2); }
.station .result { color: var(--ink); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 16px 0 0 !important; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 0;
  font-size: 0.8125rem; font-weight: 600; font-stretch: 87.5%; line-height: 1.5;
  border: 1.5px solid var(--ink); color: var(--ink);
}
.tag.done { background: var(--ink); color: var(--ground); }
.tag.next { border-style: dashed; }
.tag.plain { border-color: transparent; padding-left: 0; padding-right: 0; color: var(--ink-3); font-weight: 500; }

/* ---- timetables (Publications, Experience, Teaching, Education) ---------------------- */
.timetable { list-style: none; margin: 0; padding: 0; }
.timetable > li {
  display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 16px;
  padding: 18px 0; border-top: 1px solid var(--rule);
}
.timetable > li:first-child { border-top: 0; padding-top: 0; }
.timetable.dated > li { grid-template-columns: 9.5rem minmax(0, 1fr); gap: 24px; }

.routes { display: flex; flex-direction: column; gap: 4px; padding-top: 9px; }
.rt { display: block; width: 32px; height: 6px; background: var(--c); }
.rt-llm { --c: var(--llm); }
.rt-edge { --c: var(--edge); }
.rt-energy { --c: var(--energy); }

.pubs .title { display: block; font-weight: 600; color: var(--ink); margin-bottom: 2px; }
.pubs .authors, .pubs .venue { color: var(--ink-2); font-size: 0.95rem; }
.pubs .authors b { color: var(--ink); font-weight: 600; }
.pubs .tag { margin-left: 2px; vertical-align: 1px; }
.pubs a { font-size: 0.95rem; color: var(--edge); }

.when { font-weight: 600; font-stretch: 87.5%; color: var(--ink-2); padding-top: 1px; }
.timetable h3 { font-size: 1.125rem; font-weight: 700; line-height: 1.35; margin: 0; }
.where { color: var(--ink-2); }
.timetable p { color: var(--ink-2); margin: 6px 0 0; }

.notice { border-top: 3px solid var(--ink); border-bottom: 1px solid var(--rule); padding: 16px 0 18px; margin-bottom: 24px; }
.notice h3 { font-size: 1.125rem; font-weight: 700; margin: 0; }
.notice p { color: var(--ink-2); margin: 4px 0 0; }

/* ---- skills key ----------------------------------------------------------------------- */
.skills > div {
  display: grid; grid-template-columns: 12rem minmax(0, 1fr); gap: 24px;
  padding: 12px 0; border-top: 1px solid var(--rule);
}
.skills > div:first-child { border-top: 0; padding-top: 0; }
.skills dt { font-weight: 700; }
.skills dd { margin: 0; color: var(--ink-2); }

/* ---- contact: end of the line --------------------------------------------------------- */
.contact-lead { font-size: 1.25rem; line-height: 1.45; margin: 0; max-width: 34ch; }
.contact .actions { margin-top: 28px; align-items: center; }
/* the LLM line ends here: a route stub and its terminus bar, drawn into the email panel */
.terminus-mark {
  flex: none; width: 64px; height: 32px;
  background:
    linear-gradient(var(--llm), var(--llm)) 0 50% / 58px 8px no-repeat,
    linear-gradient(var(--llm), var(--llm)) 54px 50% / 8px 28px no-repeat;
}

footer { border-top: 1px solid var(--rule); padding: 28px 0 44px; color: var(--ink-3); font-size: 0.9rem; }

/* ---- 404 ------------------------------------------------------------------------------- */
.lost { padding: 96px 0 120px; }
.lost h1 { font-size: clamp(2.5rem, 4vw + 1rem, 4rem); line-height: 1; letter-spacing: -0.025em; margin: 0; }
.lost p { color: var(--ink-2); font-size: 1.125rem; margin: 16px 0 0; }

/* ---- responsive ------------------------------------------------------------------------ */
@media (max-width: 960px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 48px; }
  .section-grid { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .section-head { position: static; }
  .hero h1 { font-size: min(4.5rem, calc(14.18vw - 9.1px)); }
}

@media (max-width: 640px) {
  :root { --gutter: 16px; }
  .nav .wrap { gap: 18px; height: 52px; }
  .nav ul {
    margin-left: 0; gap: 20px; flex: 1;
    mask-image: linear-gradient(to right, #000 85%, transparent);
  }
  .nav ul a { padding: 14px 0 11px; }
  .hero { padding: 32px 0 56px; }
  .hero h1 { font-size: min(4.5rem, calc(14.18vw - 4.5px)); }
  .map-wide { display: none; }
  .map-tall { display: block; max-width: 380px; margin: 0 auto; }
  .legend { justify-content: flex-start; }
  .section { padding: 56px 0; }
  .section-head h2 { font-size: 1.75rem; }
  .station { padding-left: 48px; padding-bottom: 40px; }
  .timetable.dated > li { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .timetable > li { grid-template-columns: 40px minmax(0, 1fr); gap: 12px; }
  .skills > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .sign { width: 100%; justify-content: center; flex-wrap: wrap; }
  /* stacked layout: the stub turns vertical and runs down into the email panel */
  .terminus-mark {
    width: 28px; height: 36px; margin: 0 auto -12px;
    background:
      linear-gradient(var(--llm), var(--llm)) 50% 0 / 8px 32px no-repeat,
      linear-gradient(var(--llm), var(--llm)) 50% 100% / 28px 8px no-repeat;
  }
}

@media print {
  .nav, .skip, .network { display: none; }
  .section-head { position: static; }
  .sign { background: none; color: var(--ink); border: 0; padding: 0; }
  .contact .sign-quiet { display: none; }
}
