/* =========================================================
   Portfolio BTS SIO - option SISR
   Design moderne, aere et ludique - theme clair / sombre
   (suit la preference systeme + bascule manuelle memorisee)
   ========================================================= */

/* ---------- Jetons de theme ---------- */
:root {
  color-scheme: light dark;

  --bg: #f4f6fc;
  --bg-soft: #ecf0f9;
  --surface: #ffffff;
  --surface-2: #f6f8fd;
  --text: #1b2333;
  --heading: #0e1628;
  --muted: #5a6579;
  --border: #e4e9f3;
  --border-strong: #d2d9e8;

  --accent: #6366f1;          /* indigo */
  --accent-hover: #4f46e5;
  --accent-2: #06b6d4;        /* cyan */
  --accent-3: #ec4899;        /* rose - la touche ludique */
  --grad: linear-gradient(135deg, #6366f1 0%, #7c74f3 42%, #06b6d4 100%);
  --grad-soft: linear-gradient(135deg, rgba(99,102,241,.16), rgba(6,182,212,.12));
  --glow-1: rgba(99,102,241,.14);
  --glow-2: rgba(6,182,212,.10);

  --ok: #12925b;   --ok-bg: #e4f6ec;
  --warn: #a96a12; --warn-bg: #fbf1de;
  --bad: #cf3f3f;  --bad-bg: #fdebeb;

  /* Alias utilises dans certaines pages */
  --navy: var(--heading);
  --navy-2: #26304a;
  --teal: var(--accent);
  --teal-dark: var(--accent-hover);

  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 26px;
  --maxw: 1120px;
  --shadow: 0 1px 2px rgba(14,22,40,.05), 0 14px 34px -14px rgba(14,22,40,.18);
  --shadow-lg: 0 2px 8px rgba(14,22,40,.08), 0 30px 64px -22px rgba(79,70,229,.38);
  --ring: 0 0 0 3px rgba(99,102,241,.38);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(.22,.61,.36,1);
  --space: clamp(56px, 9vw, 96px);
}

/* Thème sombre automatique (sauf choix explicite "clair") */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0d15;
    --bg-soft: #10141f;
    --surface: #181f30;
    --surface-2: #1f2739;
    --text: #e2e8f4;
    --heading: #f4f7fd;
    --muted: #9aa6bd;
    --border: #2e3850;
    --border-strong: #3c4a68;
    --accent: #838cf8;
    --accent-hover: #a7adfb;
    --accent-2: #22d3ee;
    --accent-3: #f472b6;
    --grad: linear-gradient(135deg, #4f46e5 0%, #6a5ef0 42%, #0891b2 100%);
    --grad-soft: linear-gradient(135deg, rgba(131,140,248,.18), rgba(34,211,238,.12));
    --glow-1: rgba(99,102,241,.16);
    --glow-2: rgba(8,145,178,.14);
    --ok: #4ade80;   --ok-bg: rgba(34,197,94,.15);
    --warn: #fbbf24; --warn-bg: rgba(251,191,36,.15);
    --bad: #f87171;  --bad-bg: rgba(248,113,113,.15);
    --navy-2: #c7cedf;
    --shadow: 0 1px 2px rgba(0,0,0,.45), 0 18px 44px -18px rgba(0,0,0,.65);
    --shadow-lg: 0 2px 10px rgba(0,0,0,.5), 0 34px 74px -26px rgba(0,0,0,.72);
    --ring: 0 0 0 3px rgba(131,140,248,.45);
  }
}

/* Bascule manuelle "sombre" (prioritaire dans les deux sens) */
:root[data-theme="dark"] {
  --bg: #0a0d15;
  --bg-soft: #10141f;
  --surface: #181f30;
  --surface-2: #1f2739;
  --text: #e2e8f4;
  --heading: #f4f7fd;
  --muted: #9aa6bd;
  --border: #2e3850;
  --border-strong: #3c4a68;
  --accent: #838cf8;
  --accent-hover: #a7adfb;
  --accent-2: #22d3ee;
  --accent-3: #f472b6;
  --grad: linear-gradient(135deg, #4f46e5 0%, #6a5ef0 42%, #0891b2 100%);
  --grad-soft: linear-gradient(135deg, rgba(131,140,248,.18), rgba(34,211,238,.12));
  --glow-1: rgba(99,102,241,.16);
  --glow-2: rgba(8,145,178,.14);
  --ok: #4ade80;   --ok-bg: rgba(34,197,94,.15);
  --warn: #fbbf24; --warn-bg: rgba(251,191,36,.15);
  --bad: #f87171;  --bad-bg: rgba(248,113,113,.15);
  --navy-2: #c7cedf;
  --shadow: 0 1px 2px rgba(0,0,0,.45), 0 18px 44px -18px rgba(0,0,0,.65);
  --shadow-lg: 0 2px 10px rgba(0,0,0,.5), 0 34px 74px -26px rgba(0,0,0,.72);
  --ring: 0 0 0 3px rgba(131,140,248,.45);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 560px at 100% -8%, var(--glow-1), transparent 60%),
    radial-gradient(900px 480px at -10% 12%, var(--glow-2), transparent 55%);
  background-repeat: no-repeat;
  line-height: 1.68;
  font-size: 16.5px;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }

a { color: var(--accent-hover); text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
a:hover { color: var(--accent); }

h1, h2, h3, h4 { color: var(--heading); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 1rem + 3vw, 2.6rem); }
h2 { font-size: clamp(1.35rem, 1rem + 1.4vw, 1.75rem); margin-top: 1.7em; }
h3 { font-size: 1.16rem; margin-top: 1.5em; }
p { margin: 0 0 1em; }

.muted { color: var(--muted); }
.small { font-size: .9rem; }
.center { text-align: center; }
.gradient-text {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }

/* ---------- En-tete / navigation (verre depoli) ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
@supports (backdrop-filter: blur(8px)) {
  .site-header {
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    backdrop-filter: saturate(160%) blur(10px);
    -webkit-backdrop-filter: saturate(160%) blur(10px);
  }
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: 68px;
}
.brand { display: flex; flex-direction: column; text-decoration: none; line-height: 1.15; flex: 0 0 auto; }
.brand-name { font-weight: 800; letter-spacing: .02em; color: var(--heading); white-space: nowrap; }
.brand-sub {
  font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; font-weight: 700;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}

.header-tools { display: flex; align-items: center; gap: 8px; }

.site-nav { display: flex; flex-wrap: nowrap; gap: 2px; }
.site-nav a {
  color: var(--muted); text-decoration: none; white-space: nowrap;
  padding: 9px 12px; border-radius: 999px;
  font-size: .9rem; font-weight: 600;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.site-nav a:hover { background: var(--grad-soft); color: var(--heading); }
.site-nav a.is-active { background: var(--grad); color: #fff; box-shadow: 0 8px 20px -8px var(--accent); }

.theme-toggle, .nav-toggle {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--heading);
  font-size: 1.1rem; line-height: 1;
  border-radius: 12px; cursor: pointer;
  transition: transform .18s var(--ease), background .18s var(--ease), border-color .18s;
}
.theme-toggle:hover { transform: rotate(-18deg) scale(1.06); border-color: var(--accent); }
.nav-toggle { display: none; }

@media (max-width: 1180px) {
  .nav-toggle { display: inline-grid; }
  .header-inner { position: relative; }
  .site-nav {
    display: none; position: absolute; left: 0; right: 0; top: calc(100% + 1px);
    flex-direction: column; gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 10px; box-shadow: var(--shadow);
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 12px 14px; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background: var(--grad);
  color: #fff;
  padding: clamp(52px, 8vw, 88px) 0 clamp(60px, 9vw, 104px);
  border-bottom: 1px solid var(--border);
}
.hero::before, .hero::after {
  content: ""; position: absolute; border-radius: 50%;
  filter: blur(40px); opacity: .55; pointer-events: none;
}
.hero::before {
  width: 380px; height: 380px; top: -120px; right: -60px;
  background: radial-gradient(circle at 30% 30%, #ffffff, rgba(236,72,153,.5), transparent 70%);
}
.hero::after {
  width: 320px; height: 320px; bottom: -140px; left: -80px;
  background: radial-gradient(circle at 60% 40%, rgba(34,211,238,.8), transparent 70%);
}
@media (prefers-reduced-motion: no-preference) {
  .hero::before { animation: floaty 15s var(--ease) infinite; }
  .hero::after { animation: floaty 19s var(--ease) infinite reverse; }
}
.hero .container { position: relative; z-index: 1; }
.hero h1 { color: #fff; }
.hero p.lead { font-size: 1.14rem; color: rgba(255,255,255,.92); max-width: 62ch; }
.hero .tagline {
  display: inline-block; margin-bottom: .8em;
  font-size: .74rem; letter-spacing: .18em; text-transform: uppercase; font-weight: 700;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28);
  padding: 6px 14px; border-radius: 999px;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }

@keyframes floaty {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(26px, -22px) scale(1.09); }
}

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: #fff; text-decoration: none;
  padding: 11px 22px; border-radius: 999px;
  font-weight: 700; font-size: .95rem; border: 1px solid transparent;
  transition: transform .12s var(--ease), box-shadow .18s var(--ease), background .18s;
  box-shadow: 0 10px 24px -10px var(--accent);
}
.btn:hover { background: var(--accent-hover); transform: translateY(-2px); color: #fff; }
.btn:active { transform: translateY(0); }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.5); color: #fff; box-shadow: none; }
.btn.ghost:hover { background: rgba(255,255,255,.14); }
.btn.dark { background: var(--heading); color: var(--surface); box-shadow: none; }

/* ---------- Layout ---------- */
main { padding: var(--space) 0 calc(var(--space) + 12px); }
.page-title {
  position: relative; padding-bottom: .35em; margin-bottom: .2em;
}
.page-title::after {
  content: ""; display: block; width: 64px; height: 4px; margin-top: .5rem;
  background: var(--grad); border-radius: 999px;
}
.section { margin-top: var(--space); }

.grid { display: grid; gap: 22px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 820px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

/* ---------- Cartes ---------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  transition: transform .18s var(--ease), box-shadow .22s var(--ease), border-color .18s;
}
.card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: var(--grad); border-radius: var(--radius) var(--radius) 0 0;
  opacity: 0; transition: opacity .22s var(--ease);
}
.card h3 { margin-top: 0; }
.card .card-meta { font-size: .8rem; color: var(--muted); margin-bottom: .6em; font-weight: 600; }
.card .card-icon {
  display: inline-grid; place-items: center; width: 46px; height: 46px; margin-bottom: 12px;
  font-size: 1.4rem; border-radius: 14px;
  background: var(--grad-soft); border: 1px solid var(--border);
}
.link-card { cursor: pointer; }
.link-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); border-color: transparent; }
.link-card:hover::before { opacity: 1; }
a.card-cta, .card-cta { font-weight: 700; text-decoration: none; color: var(--accent-hover); }
a.card-cta::after, .card-cta::after { content: " \2192"; transition: margin-left .18s var(--ease); display: inline-block; }
.link-card:hover .card-cta::after { margin-left: 4px; }

/* ---------- Stats ludiques ---------- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 820px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; text-align: center; box-shadow: var(--shadow);
}
.stat .num {
  font-size: 2rem; font-weight: 800; line-height: 1;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat .lbl { font-size: .82rem; color: var(--muted); margin-top: 6px; }

/* ---------- Badges & niveaux ---------- */
.badge {
  display: inline-block; font-size: .72rem; font-weight: 800;
  letter-spacing: .05em; text-transform: uppercase;
  padding: 4px 11px; border-radius: 999px;
  background: var(--grad-soft); color: var(--accent-hover);
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
}
.badge.stage { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-hover); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.badge.projet { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 34%, transparent); }
.badge.perso { background: color-mix(in srgb, var(--accent-3) 14%, transparent); color: var(--accent-3); border-color: color-mix(in srgb, var(--accent-3) 32%, transparent); }

.level { display: inline-block; font-size: .78rem; font-weight: 800; padding: 3px 11px; border-radius: 8px; }
.level.d { background: var(--bad-bg); color: var(--bad); }
.level.a { background: var(--warn-bg); color: var(--warn); }
.level.m { background: var(--ok-bg); color: var(--ok); }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .93rem; }
th, td { text-align: left; padding: 12px 15px; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--heading);
  font-size: .78rem; text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--grad-soft); }

/* ---------- Onglets ---------- */
.tabs { margin-top: 1.5em; }
.tablist {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  width: fit-content; max-width: 100%;
}
.tablist button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-weight: 700; font-size: .92rem; color: var(--muted);
  padding: 9px 18px; border-radius: 999px;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.tablist button:hover { color: var(--heading); }
.tablist button.is-active { background: var(--grad); color: #fff; box-shadow: 0 8px 20px -8px var(--accent); }
.tab-panel { margin-top: 1.6em; animation: fadeUp .4s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Frise chronologique ---------- */
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 10px; top: 6px; bottom: 6px; width: 2px; background: var(--border-strong); }
.timeline li { position: relative; padding: 0 0 28px 42px; }
.timeline li::before {
  content: ""; position: absolute; left: 2px; top: 5px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--grad); border: 4px solid var(--bg);
  box-shadow: 0 0 0 1px var(--border-strong);
}
.timeline .tl-date { font-size: .8rem; color: var(--accent-hover); font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.timeline .tl-title { font-weight: 800; color: var(--heading); }

/* ---------- Fiche situation ---------- */
.fiche-header {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 5px solid var(--accent); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); margin-bottom: 30px;
}
.fiche-header .kv { display: grid; grid-template-columns: 200px 1fr; gap: 8px 18px; margin-top: 14px; font-size: .93rem; }
.fiche-header .kv dt { font-weight: 800; color: var(--heading); }
.fiche-header .kv dd { margin: 0; }
@media (max-width: 640px) { .fiche-header .kv { grid-template-columns: 1fr; } .fiche-header .kv dd { margin-bottom: 8px; } }

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.tag-list li {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  font-size: .82rem; padding: 4px 12px; border-radius: 999px;
}

.callout {
  background: var(--grad-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm); padding: 15px 18px; margin: 20px 0;
}
.callout.todo {
  background: var(--warn-bg);
  border-color: color-mix(in srgb, var(--warn) 34%, transparent);
  border-left-color: var(--warn);
}
.callout strong { color: var(--heading); }

pre, code { font-family: var(--mono); font-size: .88rem; }
pre {
  background: #10151f; color: #e8eef7;
  padding: 18px; border-radius: var(--radius-sm);
  overflow-x: auto; line-height: 1.55;
  border: 1px solid #1e2636;
}
:not(pre) > code {
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 6px; color: var(--accent-hover);
}

.prev-next {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 48px; border-top: 1px solid var(--border); padding-top: 22px; font-size: .92rem;
}
.prev-next a { font-weight: 700; text-decoration: none; }

/* ---------- Filtre (situations) ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 28px; }
.filter-bar button {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--heading);
  padding: 8px 16px; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: .88rem; font-weight: 700;
  transition: transform .12s var(--ease), background .18s, color .18s, border-color .18s;
}
.filter-bar button:hover { transform: translateY(-1px); border-color: var(--accent); }
.filter-bar button.is-active { background: var(--grad); color: #fff; border-color: transparent; }

/* ---------- Pied de page ---------- */
.site-footer {
  background: var(--surface-2); border-top: 1px solid var(--border);
  color: var(--muted); padding: 34px 0; font-size: .9rem; margin-top: var(--space);
}
.site-footer p { margin: .2em 0; }
.site-footer a { color: var(--accent-hover); }

/* ---------- Utilitaires ---------- */
.stack > * + * { margin-top: 1em; }
.mt-0 { margin-top: 0; }

/* Apparition au defilement : visible par defaut, masquee seulement si JS actif */
.reveal { opacity: 1; }
.js .reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.js .reveal.in { opacity: 1; transform: none; }

.back-to-top {
  position: fixed; right: 20px; bottom: 20px;
  width: 46px; height: 46px; border: none; border-radius: 50%;
  background: var(--grad); color: #fff; font-size: 1.15rem; cursor: pointer;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .25s var(--ease), transform .18s var(--ease);
}
.back-to-top:hover { transform: translateY(-3px); }
.back-to-top.show { opacity: 1; pointer-events: auto; }

/* ---------- Mouvement reduit ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; }
}

/* ---------- Impression ---------- */
@media print {
  .site-header, .site-footer, .hero-actions, .nav-toggle, .theme-toggle, .back-to-top, .prev-next { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .card, .fiche-header, .table-wrap, .stat { box-shadow: none; }
  .card::before, .page-title::after { display: none; }
  a { color: #000; text-decoration: none; }
  .hero { background: #fff; color: #000; padding: 0 0 12px; border: 0; }
  .hero h1, .hero p.lead { color: #000; }
  .hero::before, .hero::after { display: none; }
  .tab-panel[hidden] { display: block !important; }
}
