/* Meriem Bousselmi — portfolio styles
   Palette taken from her CV: deep purple #5c347a, accent #884cb8, lavender #eee5f7, ink #2b2833 */
:root {
  --bg: #fcfaff;
  --surface: #ffffff;
  --panel: #f4eefb;
  --soft: #eee5f7;
  --ink: #2b2833;
  --muted: #655f74;
  --brand: #5c347a;
  --accent: #884cb8;
  --accent-ink: #ffffff;
  --line: #e4daf0;
  --lav: #d8c5eb;
  --blob1: #eee5f7;
  --blob2: #f6f0fc;
  --ok: #2f7d4f;
  --bad: #b3261e;
  --shadow: 0 1px 2px rgba(92, 52, 122, .06), 0 8px 24px rgba(92, 52, 122, .08);
  --radius: 16px;
  --grad: linear-gradient(100deg, #5c347a 0%, #884cb8 100%);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #140f1e;
  --surface: #1d1630;
  --panel: #251c3b;
  --soft: #2d2247;
  --ink: #f0eaf8;
  --muted: #b6abcb;
  --brand: #d8c5eb;
  --accent: #b185e0;
  --accent-ink: #1a1228;
  --line: #3a2d5c;
  --lav: #4a3a73;
  --blob1: #2a1f45;
  --blob2: #1d1632;
  --ok: #6fcf97;
  --bad: #ff8a80;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px rgba(0, 0, 0, .35);
  --grad: linear-gradient(100deg, #d8c5eb 0%, #a974dc 100%);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}
/* soft organic blobs, like the CV background */
body::before, body::after {
  content: "";
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
}
body::before { width: 780px; height: 780px; top: -300px; right: -240px; background: radial-gradient(circle at 40% 40%, var(--blob1), transparent 68%); }
body::after { width: 640px; height: 640px; bottom: -260px; left: -200px; background: radial-gradient(circle at 60% 60%, var(--blob2), transparent 68%); }
main { flex: 1; }
img, svg { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--brand); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--brand); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0; color: var(--brand); letter-spacing: -.01em; }
p { margin: 0 0 1em; }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 50; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); background: color-mix(in srgb, var(--bg) 82%, transparent); border-bottom: 1px solid var(--line); }
.bar { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--brand); font-weight: 700; }
.brand .mono { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--grad); color: #fff; font-size: 15px; letter-spacing: .02em; }
:root[data-theme="dark"] .brand .mono { color: #1a1228; }
.brand .nm { font-size: 17px; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { text-decoration: none; color: var(--muted); font-weight: 600; font-size: 15px; padding: 8px 14px; border-radius: 999px; transition: background .15s, color .15s; }
.nav a:hover { background: var(--soft); color: var(--brand); }
.nav a[aria-current="page"] { background: var(--soft); color: var(--brand); }
.tools { display: flex; align-items: center; gap: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--surface); }
.seg button { border: 0; background: transparent; color: var(--muted); font: 700 13px/1 inherit; padding: 7px 11px; border-radius: 999px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; }
:root[data-theme="dark"] .seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 50%; cursor: pointer; font-size: 17px; }
.icon-btn:hover { background: var(--soft); }
.menu-btn { display: none; }

/* ---------- Pages ---------- */
.page { display: none; padding: 40px 0 72px; }
.page.active { display: block; animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.section { margin-top: 56px; }
.section > h2, .group-title { font-size: 24px; margin-bottom: 18px; }
.group-title { font-size: 18px; margin: 36px 0 14px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: 13px; }
.page-head { max-width: 760px; margin-bottom: 26px; }
.page-head h2 { font-size: clamp(28px, 4vw, 40px); margin: 8px 0 10px; }
.page-head p { color: var(--muted); font-size: 17px; margin: 0; }
.eyebrow { display: inline-block; font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }

.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card h3 { font-size: 18px; margin-bottom: 12px; }

/* ---------- Hero ---------- */
.hero { display: grid; grid-template-columns: 1.35fr 1fr; gap: 36px; align-items: start; position: relative; }
.badge { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--brand); background: var(--soft); border: 1px solid var(--lav); padding: 6px 12px; border-radius: 999px; margin-bottom: 18px; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #3fb06b; box-shadow: 0 0 0 4px rgba(63, 176, 107, .2); }
.hero h1 { font-size: clamp(40px, 6.5vw, 68px); letter-spacing: -.03em; margin-bottom: 10px; color: var(--brand); }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.role { font-size: 18px; font-weight: 700; color: var(--accent); margin-bottom: 18px; line-height: 1.4; }
.lead { font-size: 18px; margin-bottom: 14px; }
.lead-muted { color: var(--muted); }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 700 15px/1 inherit; padding: 14px 22px; border-radius: 999px; border: 1.5px solid transparent; cursor: pointer; text-decoration: none; transition: transform .12s, box-shadow .12s, background .15s; }
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 6px 18px rgba(92, 52, 122, .28); }
.btn.primary:hover { transform: translateY(-1px); color: #fff; background: #6d3f90; }
:root[data-theme="dark"] .btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px rgba(0, 0, 0, .4); }
:root[data-theme="dark"] .btn.primary:hover { background: #c59cf0; color: var(--accent-ink); }
.btn.ghost { color: var(--brand); border-color: var(--lav); background: var(--surface); }
.btn.ghost:hover { background: var(--soft); color: var(--brand); }
.btn[disabled] { opacity: .6; cursor: progress; }

.facts { padding: 26px; }
.avatar-box { position: relative; width: 148px; height: 148px; margin: 0 auto 20px; }
.av-ring { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(from 200deg, #5c347a, #884cb8, #d8c5eb, #884cb8, #5c347a); }
.av-img { position: absolute; inset: 5px; width: calc(100% - 10px); height: calc(100% - 10px); border-radius: 50%; object-fit: cover; border: 4px solid var(--surface); background: var(--soft); }
.fact { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-top: 1px solid var(--line); }
.fact:first-of-type { border-top: 0; }
.fact .ico { width: 34px; height: 34px; border-radius: 10px; background: var(--soft); display: grid; place-items: center; flex: none; font-size: 16px; }
.fact b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.fact span { font-size: 15px; }

/* joke card */
.joke { margin-top: 18px; padding: 18px 20px; border-radius: var(--radius); background: var(--panel); border: 1px dashed var(--lav); }
.joke small { display: block; font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.joke p { margin: 0 0 12px; font-size: 15.5px; min-height: 3.4em; }
.joke button { font: 700 13px/1 inherit; color: var(--brand); background: var(--surface); border: 1px solid var(--lav); padding: 8px 14px; border-radius: 999px; cursor: pointer; }
.joke button:hover { background: var(--soft); }

/* decorative sparkline, like the CV's growth line */
.spark { position: absolute; right: -10px; bottom: -70px; width: 360px; opacity: .55; pointer-events: none; z-index: -1; }
.spark path { fill: none; stroke: var(--lav); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.spark circle { fill: var(--accent); stroke: var(--surface); stroke-width: 3; }

.feature .ico { width: 46px; height: 46px; border-radius: 14px; background: var(--soft); display: grid; place-items: center; font-size: 22px; margin-bottom: 14px; }
.feature h3 { font-size: 17px; margin-bottom: 8px; }
.feature p { margin: 0; color: var(--muted); font-size: 15px; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.list li { position: relative; padding-left: 22px; font-size: 15.5px; }
.list li::before { content: ""; position: absolute; left: 0; top: .6em; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.list li b { color: var(--brand); }

/* pipeline (from the CV) */
.pipeline { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin-top: 8px; align-items: stretch; }
.step { position: relative; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--lav); border-radius: 12px; padding: 14px 16px; margin-right: 34px; box-shadow: var(--shadow); }
.step:last-child { margin-right: 0; background: var(--brand); border-color: var(--brand); border-top-color: var(--brand); }
:root[data-theme="dark"] .step:last-child { background: var(--accent); border-color: var(--accent); }
.step:nth-child(2) { border-top-color: var(--accent); }
.step:not(:last-child)::after { content: "→"; position: absolute; right: -28px; top: 50%; transform: translateY(-50%); color: var(--accent); font-weight: 800; font-size: 20px; }
.step b { display: block; font-size: 15px; color: var(--brand); }
.step span { font-size: 13.5px; color: var(--muted); }
.step:last-child b, .step:last-child span { color: #fff; }
:root[data-theme="dark"] .step:last-child b, :root[data-theme="dark"] .step:last-child span { color: var(--accent-ink); }

/* ---------- Filters / pills ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.chip-btn { font: 600 14px/1 inherit; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; }
.chip-btn:hover { background: var(--soft); color: var(--brand); }
.chip-btn[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
:root[data-theme="dark"] .chip-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { font-size: 13.5px; font-weight: 600; padding: 6px 12px; border-radius: 999px; background: var(--soft); color: var(--brand); }

/* ---------- Skills ---------- */
[hidden] { display: none !important; }
.skill-card h3 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding-bottom: 12px; border-bottom: 2px solid var(--soft); margin-bottom: 8px; }
.skill-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 15.5px; }
.skill-row:last-child { border-bottom: 0; }
.stars { color: var(--accent); letter-spacing: 2px; white-space: nowrap; font-size: 15px; }
.stars .off { color: var(--lav); }
.note { color: var(--muted); font-size: 14px; margin: 14px 0 0; }

/* ---------- Stats ---------- */
.stat { text-align: left; padding: 20px 22px; }
.stat .num { display: block; font-size: clamp(32px, 4vw, 42px); font-weight: 800; letter-spacing: -.02em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .lbl { margin-top: 8px; color: var(--muted); font-size: 14.5px; line-height: 1.45; }
.dist { display: grid; gap: 12px; }
.dist-row { display: grid; grid-template-columns: 170px 1fr 44px; gap: 12px; align-items: center; font-size: 14.5px; }
.dist-row span:last-child { text-align: right; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.bar-track { height: 12px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--grad); transition: width 1s cubic-bezier(.2, .7, .2, 1); }
.quote { margin: 0 0 16px; padding: 4px 0 4px 16px; border-left: 4px solid var(--accent); font-size: 16px; }
.quote cite { display: block; margin-top: 6px; font-style: normal; font-size: 13.5px; color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 22px; border-left: 3px solid var(--lav); display: grid; gap: 18px; }
.timeline li { position: relative; display: grid; grid-template-columns: 150px 1fr; gap: 14px; }
.timeline li::before { content: ""; position: absolute; left: -31px; top: 6px; width: 15px; height: 15px; border-radius: 50%; background: var(--accent); border: 3px solid var(--bg); box-shadow: 0 0 0 2px var(--lav); }
.timeline b { color: var(--brand); }
.timeline span { color: var(--ink); }

/* ---------- Projects ---------- */
.project { display: flex; flex-direction: column; gap: 10px; }
.project .meta { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.project .meta span:last-child { color: var(--muted); white-space: nowrap; }
.project h3 { margin: 0; font-size: 19px; }
.project > p { margin: 0; color: var(--muted); }
.project .detail { display: none; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 4px; }
.project.open .detail { display: block; }
.detail h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); margin: 14px 0 6px; }
.detail h4:first-child { margin-top: 0; }
.detail p { margin: 0; font-size: 15px; }
.detail ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 15px; }
.detail .result { background: var(--panel); padding: 12px 14px; border-radius: 10px; border-left: 4px solid var(--accent); }
.more { align-self: flex-start; margin-top: auto; font: 700 14px/1 inherit; color: var(--brand); background: transparent; border: 0; padding: 8px 0; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.more::after { content: " ↓"; }
.project.open .more::after { content: " ↑"; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 22px 0; color: var(--muted); font-size: 14px; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 20px; }

/* ---------- Dialog ---------- */
dialog { width: min(560px, 100% - 24px); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px rgba(40, 20, 70, .35); overflow: auto; }
dialog::backdrop { background: rgba(30, 15, 50, .55); backdrop-filter: blur(3px); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.dlg-head h2 { font-size: 20px; }
.dlg-body { padding: 20px 22px 24px; }
.reveal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.reveal { position: relative; text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 12px; font: inherit; color: var(--ink); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
button.reveal { cursor: pointer; }
button.reveal:hover { background: var(--soft); }
.reveal small { font-size: 12px; font-weight: 700; color: var(--muted); }
.reveal .val { font-weight: 700; font-size: 13.5px; color: var(--brand); overflow-wrap: anywhere; }
.reveal .val a { color: inherit; }
.reveal .copy { margin-top: 4px; align-self: flex-start; font: 700 12px/1 inherit; padding: 6px 9px; border-radius: 999px; border: 1px solid var(--lav); background: var(--surface); color: var(--brand); cursor: pointer; }
.divider { display: flex; align-items: center; gap: 12px; margin: 22px 0 16px; font-size: 13px; font-weight: 700; color: var(--muted); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.req { color: var(--bad); margin-left: 3px; }
.field input[type="email"] { width: 100%; font: inherit; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); }
.field input:focus, .editor-box:focus-within { border-color: var(--accent); outline: 3px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.editor-box { border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); overflow: hidden; }
.toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border-bottom: 1px solid var(--line); background: var(--panel); }
.toolbar button { min-width: 34px; height: 32px; border: 0; background: transparent; color: var(--ink); border-radius: 8px; cursor: pointer; font-size: 14px; }
.toolbar button:hover { background: var(--soft); }
.editor { min-height: 130px; padding: 12px 14px; outline: 0; overflow-wrap: anywhere; }
.editor[data-empty="true"]::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.editor ul, .editor ol { margin: 4px 0; padding-left: 22px; }
.invalid input, .invalid .editor-box { border-color: var(--bad); }
.err { color: var(--bad); font-size: 13.5px; margin-top: 6px; min-height: 0; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.status { margin-top: 14px; font-size: 14.5px; }
.status.ok { color: var(--ok); font-weight: 700; }
.status.fail { color: var(--bad); }

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .hero { grid-template-columns: 1fr; }
  .g3, .g4 { grid-template-columns: repeat(2, 1fr); }
  .pipeline { grid-template-columns: 1fr 1fr; gap: 14px; }
  .step { margin-right: 0; }
  .step::after { display: none; }
  .menu-btn { display: inline-grid; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; background: var(--bg); border-bottom: 1px solid var(--line); padding: 10px 16px 16px; margin: 0; }
  .nav.open { display: flex; }
  .nav a { padding: 12px 14px; }
  .tools { margin-left: auto; }
}
@media (max-width: 640px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .page { padding-top: 28px; }
  .brand .nm { display: none; }
  .reveal-grid { grid-template-columns: 1fr; }
  .dist-row { grid-template-columns: 110px 1fr 36px; font-size: 13.5px; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
  .pipeline { grid-template-columns: 1fr; }
  .spark { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .site-header, .cta, .joke, dialog, .spark { display: none !important; }
  .page { display: block !important; }
  body::before, body::after { display: none; }
}

/* tagline + misc */
.tagline { font-size: clamp(18px, 2.4vw, 22px); font-weight: 600; font-style: italic; color: var(--ink); margin: 0 0 18px; }
.tagline::before { content: "SELECT "; font-style: normal; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .72em; font-weight: 700; color: var(--accent); background: var(--soft); padding: 2px 8px; border-radius: 6px; margin-right: 8px; vertical-align: 2px; }
.card + .card { margin-top: 0; }
.section.card { box-shadow: var(--shadow); }
