/* ============================================================
   Ayoub El Majjodi — portfolio
   Editorial · warm paper · serif-set · light + dark
   ============================================================ */

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

:root {
  color-scheme: light;

  --font-serif: 'Newsreader', Georgia, 'Times New Roman', Times, serif;
  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --bg:          #fcfbf7;
  --bg-subtle:   #f4f2ea;
  --text:        #35332c;
  --text-strong: #1f1d17;
  --text-muted:  #5c5a50;
  --text-faint:  #6c695f;
  --rule:        rgba(31, 29, 23, 0.11);
  --rule-soft:   rgba(31, 29, 23, 0.06);
  --accent:      #8f5a12;   /* antique gold — research / archival brass */
  --accent-ink:  #fcfbf7;

  --radius:     12px;
  --radius-sm:  10px;
  --maxw:      43rem;   /* text measure */
  --maxw-page: 62rem;   /* full grid: label rail + content */
  --rail:      12rem;   /* left-hand category rail */
  --rail-gap:  clamp(1.75rem, 5vw, 3rem);
  --pad-x:   clamp(1.35rem, 6vw, 2.5rem);
  --ease:    cubic-bezier(0.22, 1, 0.36, 1);
}

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

  --bg:          #12110f;
  --bg-subtle:   #1c1b17;
  --text:        #e4e2d9;
  --text-strong: #f6f4ec;
  --text-muted:  #a6a399;
  --text-faint:  #8b8980;
  --rule:        rgba(246, 244, 236, 0.13);
  --rule-soft:   rgba(246, 244, 236, 0.06);
  --accent:      #d9b25f;   /* antique gold lifted to warm sand for dark */
  --accent-ink:  #12110f;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
}

body {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  line-height: 1.68;
  color: var(--text);
  background: var(--bg);
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

::selection { background: color-mix(in srgb, var(--accent) 20%, transparent); }

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

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

/* skip link + sr-only */
.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  background: var(--text-strong);
  color: var(--bg);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  transform: translateY(-160%);
  transition: transform 0.2s var(--ease);
}
.skip-link:focus-visible { transform: translateY(0); }
#main:focus { outline: none; }

.u-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* theme cross-fade, only while toggling */
:root.theme-anim,
:root.theme-anim *,
:root.theme-anim *::before,
:root.theme-anim *::after {
  transition: background-color 0.4s var(--ease), border-color 0.4s var(--ease),
              color 0.4s var(--ease), fill 0.4s var(--ease) !important;
}

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

/* ---------- icons ---------- */
.icon {
  width: 1em; height: 1em;
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
}
.arrow { display: inline-block; transition: transform 0.2s var(--ease); }
a:hover .arrow { transform: translate(2px, -2px); }

/* ---------- shell ---------- */
.wrap {
  width: 100%;
  max-width: var(--maxw-page);
  margin-inline: auto;
  padding-inline: var(--pad-x);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color 0.3s var(--ease);
  border-bottom: 1px solid transparent;
}
.site-header.scrolled { border-bottom-color: var(--rule-soft); }
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 3.75rem;
}

.brand {
  font-family: var(--font-serif);
  font-size: 1.12rem;
  font-weight: 500;
  color: var(--text-strong);
  white-space: nowrap;
  transition: color 0.2s var(--ease);
}
.brand:hover { color: var(--accent); }

.nav {
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 3vw, 1.6rem);
  font-family: var(--font-sans);
}
.nav a {
  font-size: 0.9rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding-block: 0.5rem;
  transition: color 0.2s var(--ease);
}
.nav a:hover,
.nav a[aria-current="page"] { color: var(--text-strong); }

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.4rem; height: 2.4rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.theme-toggle:hover { color: var(--text-strong); background: var(--bg-subtle); }
.theme-toggle .icon { width: 1rem; height: 1rem; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- main ---------- */
main { padding-block: clamp(2.5rem, 7vw, 4.25rem) clamp(4rem, 10vw, 7rem); }

/* ---------- hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, var(--maxw)) auto;
  align-items: start;
  gap: clamp(1.5rem, 5vw, 3.25rem);
}
.hero-main { grid-column: 1; min-width: 0; max-width: var(--maxw); }
.hero-figure { grid-column: 2; padding-top: 0.3rem; }
.avatar {
  width: clamp(7.5rem, 16vw, 10.5rem);
  height: clamp(7.5rem, 16vw, 10.5rem);
  border-radius: 50%;
  object-fit: cover;
}

.hero-eyebrow {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.08rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}
.hero-eyebrow .dot { display: none; }

.hero-name {
  font-family: var(--font-serif);
  font-size: clamp(2.75rem, 7vw, 4.15rem);
  font-weight: 500;
  letter-spacing: -0.022em;
  line-height: 1.0;
  color: var(--text-strong);
  text-wrap: balance;
}

.hero-meta {
  margin-top: 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  font-family: var(--font-sans);
  font-size: 0.94rem;
}
.hero-meta > div {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
}
.hero-meta > div::before {
  content: "◆";
  flex-shrink: 0;
  font-size: 0.5rem;
  line-height: 1;
  color: var(--accent);
  transform: translateY(-0.15em);
}
.hero-meta dt {
  flex-shrink: 0;
  width: 3rem;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.hero-meta dd { color: var(--text-muted); }

.hero-lead {
  font-size: 1.2rem;
  line-height: 1.62;
  color: var(--text);
  margin-top: 1.55rem;
}
.hero-lead + .hero-lead { margin-top: 0.85rem; }

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin-top: 2rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease),
              border-color 0.2s var(--ease);
}
.btn .icon { width: 0.95rem; height: 0.95rem; color: var(--brand, currentColor); opacity: 0.92; }
.btn:hover {
  color: var(--text-strong);
  border-color: var(--text-faint);
  background: var(--bg-subtle);
}

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 500;
}
.btn-primary .icon { color: var(--accent-ink); opacity: 1; }
.btn-primary:hover {
  border-color: color-mix(in srgb, var(--accent) 86%, #000);
  background: color-mix(in srgb, var(--accent) 86%, #000);
  color: var(--accent-ink);
}

.btn[data-brand="email"]    { --brand: #c2412a; }
.btn[data-brand="linkedin"] { --brand: #0A66C2; }
.btn[data-brand="github"]   { --brand: #1b1817; }
.btn[data-brand="scholar"]  { --brand: #4285F4; }
.btn[data-brand="cv"]       { --brand: #b4791b; }
:root[data-theme="dark"] .btn[data-brand="github"] { --brand: #e6edf3; }

/* ---------- sections (category rail left · content right) ---------- */
.section {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  column-gap: var(--rail-gap);
  margin-top: clamp(3rem, 7vw, 4.75rem);
}
.section-body {
  grid-column: 2;
  min-width: 0;
  max-width: var(--maxw);
}
.section-label {
  grid-column: 1;
  align-self: start;
  position: sticky;
  top: 5rem;
  display: flex;
  flex-direction: column;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--accent);
}
.section-label::after {
  content: "";
  width: 1px;
  height: 3rem;
  margin-top: 0.8rem;
  background: linear-gradient(var(--rule), transparent);
}

.prose > p { color: var(--text); }
.prose > p + p { margin-top: 1.1rem; }
.prose > p:first-of-type { font-size: 1.24rem; line-height: 1.55; color: var(--text-strong); }
.prose a,
.row-project a,
a.row-val {
  color: var(--text-strong);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.2s var(--ease), text-decoration-color 0.2s var(--ease);
}
.prose a:hover,
.row-project a:hover,
a.row-val:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* ---------- expertise (set as prose, not chips) ---------- */
.skills { display: flex; flex-direction: column; gap: 1.05rem; }
.skill-cat {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  letter-spacing: 0.01em;
  color: var(--text-faint);
  margin-bottom: 0.28rem;
}
.chips { display: block; line-height: 1.55; }
.chip { display: inline; color: var(--text-muted); }
.chip:not(:last-child)::after {
  content: " · ";
  color: var(--text-faint);
}

/* ---------- rows (experience / education / credentials / service) ---------- */
.rows { display: flex; flex-direction: column; }
.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.1rem 1.5rem;
  padding: 1.15rem 0;
}
.row + .row { border-top: 1px solid var(--rule-soft); }
.row:first-child { padding-top: 0; }
.row:last-child { padding-bottom: 0; }

.row-title {
  grid-column: 1;
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--text-strong);
  text-wrap: balance;
}
.row-org {
  grid-column: 1;
  font-size: 0.98rem;
  font-style: italic;
  color: var(--text-muted);
  margin-top: 0.1rem;
}
.row-date {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
  padding-top: 0.4rem;
}
.row-desc {
  grid-column: 1;
  color: var(--text-muted);
  font-size: 1.02rem;
  line-height: 1.6;
  margin-top: 0.5rem;
}

.row-project {
  grid-column: 1;
  margin-top: 1rem;
  padding: 1rem 1.15rem;
  background: var(--bg-subtle);
  border-radius: var(--radius);
}
.row-project-tag {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  color: var(--accent);
  margin-bottom: 0.35rem;
}
.row-project p {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-muted);
}
.row-project strong { color: var(--text-strong); font-weight: 600; }

.row-simple {
  grid-template-columns: 5rem 1fr;
  align-items: baseline;
  padding: 0.5rem 0;
}
.row-simple + .row-simple { border-top: 0; }
.row-simple .row-title {
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 400;
  color: var(--text-faint);
}
.row-val { color: var(--text-strong); }

/* ---------- publications ---------- */
.pub-list { display: flex; flex-direction: column; gap: 0.7rem; }
.pub {
  padding: 1.15rem 1.25rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  transition: border-color 0.2s var(--ease);
}
.pub:hover { border-color: var(--text-faint); }

.pub-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.pub-title {
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--text-strong);
  text-wrap: balance;
  transition: color 0.2s var(--ease);
}
a.pub-title:hover { color: var(--accent); }
.pub-year {
  flex-shrink: 0;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.pub-authors {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}
.pub-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.65rem;
  font-family: var(--font-sans);
}
.pub-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
}

.pub-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.8rem;
  margin-top: 0.7rem;
  font-family: var(--font-sans);
  font-size: 0.84rem;
}
.pub-type {
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
}
.pub-venue { color: var(--text-faint); font-style: italic; }
.pub-links { display: flex; gap: 1rem; margin-left: auto; }
.pub-links a { color: var(--text-muted); transition: color 0.2s var(--ease); }
.pub-links a:hover { color: var(--accent); }

.section-foot { margin-top: 1.5rem; font-family: var(--font-sans); }
.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: color 0.2s var(--ease);
}
.link-arrow:hover { color: var(--text-strong); }

/* ---------- elsewhere (bordered cards) ---------- */
.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
  gap: 0.55rem;
  font-family: var(--font-sans);
  font-size: 0.92rem;
}
.link-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.68rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease),
              background-color 0.2s var(--ease);
}
.link-card:hover {
  color: var(--text-strong);
  border-color: var(--text-faint);
  background: var(--bg-subtle);
}
.link-card .icon { width: 1rem; height: 1rem; color: var(--brand, currentColor); opacity: 0.85; }
.link-card:hover .icon { opacity: 1; }
.link-card .ext {
  margin-left: auto;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.link-card:hover .ext { opacity: 1; }

.link-card[data-brand="linkedin"]     { --brand: #0A66C2; }
.link-card[data-brand="github"]       { --brand: #1b1817; }
.link-card[data-brand="scholar"]      { --brand: #4285F4; }
.link-card[data-brand="researchgate"] { --brand: #00A0AA; }
.link-card[data-brand="x"]            { --brand: #101010; }
.link-card[data-brand="medium"]       { --brand: #111111; }
.link-card[data-brand="stack"]        { --brand: #E1701A; }
.link-card[data-brand="strava"]       { --brand: #FC4C02; }
.link-card[data-brand="flickr"]       { --brand: #E60081; }
:root[data-theme="dark"] .link-card[data-brand="github"] { --brand: #e6edf3; }
:root[data-theme="dark"] .link-card[data-brand="x"]      { --brand: #e7e9ea; }
:root[data-theme="dark"] .link-card[data-brand="medium"] { --brand: #e7e9ea; }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--rule-soft);
  padding-block: 2.5rem;
  margin-top: clamp(4rem, 10vw, 7rem);
}
.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}
.site-footer p, .to-top {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-faint);
}
.to-top {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: color 0.2s var(--ease);
}
.to-top:hover { color: var(--text-strong); }

/* ---------- reveal ---------- */
[data-reveal] {
  opacity: 0;
  transition: opacity 0.5s var(--ease);
}
[data-reveal].in-view { opacity: 1; }
@media (prefers-reduced-motion: reduce) { [data-reveal] { opacity: 1; } }
@media (scripting: none) { [data-reveal] { opacity: 1; } }

/* ---------- responsive ---------- */
@media (max-width: 52rem) {
  .hero {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  .hero-figure { grid-column: 1; grid-row: 1; padding-top: 0; }
  .hero-main { grid-column: 1; grid-row: 2; }
  .avatar { width: 5.5rem; height: 5.5rem; }

  .section { grid-template-columns: 1fr; row-gap: 0.7rem; }
  .section-body { grid-column: 1; }
  .section-label {
    grid-column: 1;
    grid-row: 1;
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 0.7rem;
  }
  .section-label::after {
    width: 2rem;
    height: 1px;
    margin-top: 0;
    background: linear-gradient(90deg, var(--rule), transparent);
  }
}

@media (max-width: 40rem) {
  body { font-size: 1.08rem; }
  .hero-name { font-size: clamp(2.3rem, 11vw, 2.9rem); }
  .row { grid-template-columns: 1fr; }
  .row-date {
    grid-column: 1;
    grid-row: auto;
    text-align: left;
    padding-top: 0.25rem;
  }
  .row-simple { grid-template-columns: 1fr; gap: 0.1rem; }
  .pub-head { flex-wrap: wrap; }
  .pub-links { margin-left: 0; width: 100%; margin-top: 0.5rem; }
  .nav { gap: 0.9rem; }
  .nav a { font-size: 0.85rem; }
}

@media (max-width: 30rem) {
  .brand-sur { display: none; }
}
