/* ─── Variables / Design system ───────────────────────────── */
:root {
  --bg:         #0d1117;
  --surface:    #161b22;
  --surface2:   #1f2937;
  --border:     #30363d;
  --text:       #e6edf3;
  --text-muted: #8b949e;
  --blue:       #58a6ff;
  --green:      #3fb950;
  --violet:     #d2a8ff;
  --red:        #f78166;
  --amber:      #e3b341;
  --orange:     #f78c35;
  --font-mono:  'JetBrains Mono', monospace;
  --font-body:  'Inter', sans-serif;
  --radius:     8px;
  --radius-lg:  14px;
  --nav-h:      48px;
  --bottom-h:   64px;
  --ease:       cubic-bezier(.22, .61, .36, 1);
  --shadow-card: inset 0 1px 0 rgba(255,255,255,.04), 0 8px 28px rgba(0,0,0,.35);
  --shadow-lift: 0 18px 48px rgba(0,0,0,.45);
}

/* ─── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Ambient background: soft glows + faint grid */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(640px 420px at 12% 8%,  rgba(88,166,255,.075), transparent 62%),
    radial-gradient(720px 520px at 88% 92%, rgba(210,168,255,.055), transparent 62%),
    linear-gradient(rgba(255,255,255,.016) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.016) 1px, transparent 1px);
  background-size: auto, auto, 52px 52px, 52px 52px;
  pointer-events: none;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: rgba(88,166,255,.3); }

/* ─── Views ───────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: flex; }

/* ─── Shared keyframes ────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(.96) translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ─── Terminal dots (used by login page) ──────────────────── */
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot.red   { background: #ff5f57; }
.dot.amber { background: #ffbd2e; }
.dot.green { background: #28c840; }

/* ─── HERO VIEW ───────────────────────────────────────────── */
#view-hero {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.hero-card {
  width: 100%;
  max-width: 700px;
  background: linear-gradient(180deg, rgba(255,255,255,.018) 0%, transparent 30%), var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card), 0 32px 80px rgba(0,0,0,.55);
  position: relative;
  animation: scaleIn .55s var(--ease) both;
}
.hero-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue) 0%, var(--violet) 55%, var(--orange) 100%);
  z-index: 1;
}

/* Top bar: logos + logout */
.hero-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.9rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,.18);
}

.hero-logos {
  display: flex;
  align-items: center;
  gap: .9rem;
}
.logo-iut {
  height: 38px;
  width: auto;
  object-fit: contain;
  mix-blend-mode: screen;
  opacity: .92;
  transition: opacity .2s;
}
.logo-orange {
  height: 28px;
  width: auto;
  object-fit: contain;
  transition: opacity .2s;
}
.logo-iut:hover, .logo-orange:hover { opacity: 1; }
.logo-sep {
  color: var(--border);
  font-size: 1.2rem;
}

.hero-logout-btn {
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .3rem .85rem;
  cursor: pointer;
  transition: color .18s, border-color .18s, background .18s;
}
.hero-logout-btn:hover {
  color: var(--red);
  border-color: rgba(247,130,102,.5);
  background: rgba(247,130,102,.06);
}

/* Hero body — staggered entrance */
.hero-body {
  padding: 2.6rem 1.9rem 2.3rem;
}
.hero-body > * { animation: fadeUp .55s var(--ease) both; }
.hero-body > *:nth-child(1) { animation-delay: .12s; }
.hero-body > *:nth-child(2) { animation-delay: .22s; }
.hero-body > *:nth-child(3) { animation-delay: .32s; }
.hero-body > *:nth-child(4) { animation-delay: .42s; }

/* Identity row: avatar + name */
.hero-id {
  display: flex;
  align-items: center;
  gap: 1.35rem;
  margin-bottom: 2.1rem;
}
.hero-avatar {
  width: 76px; height: 76px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 1.35rem; font-weight: 700;
  color: var(--text);
  background: linear-gradient(135deg, rgba(88,166,255,.18), rgba(210,168,255,.16));
  border: 1px solid rgba(88,166,255,.4);
  box-shadow: 0 0 0 5px rgba(88,166,255,.06), 0 10px 30px rgba(88,166,255,.18);
  flex-shrink: 0;
  letter-spacing: .02em;
}
.hero-id-text { min-width: 0; }

.hero-eyebrow {
  font-size: .66rem; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--blue);
  margin-bottom: .55rem;
  display: flex; align-items: center; gap: .5rem;
}
.hero-eyebrow::before {
  content: ''; display: block; width: 22px; height: 2px;
  background: linear-gradient(90deg, var(--blue), var(--violet));
  border-radius: 1px;
}

.hero-name {
  font-size: clamp(1.9rem, 5vw, 2.7rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -.03em;
  margin-bottom: .35rem;
  background: linear-gradient(90deg, var(--text) 30%, #aebfd4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-role {
  font-size: .92rem;
  color: var(--text-muted);
}

.accent-orange { color: var(--orange); font-weight: 600; }

/* KPI cards */
.hero-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .65rem;
  margin-bottom: 1.6rem;
}
.hero-kpi {
  display: flex; flex-direction: column; gap: .28rem;
  align-items: center;
  background: rgba(0,0,0,.22);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem .5rem .85rem;
  transition: transform .22s var(--ease), border-color .22s, box-shadow .22s;
}
.hero-kpi:hover {
  transform: translateY(-3px);
  border-color: rgba(88,166,255,.4);
  box-shadow: 0 10px 26px rgba(0,0,0,.35);
}
.hk-val {
  font-family: var(--font-mono);
  font-size: 1.55rem; font-weight: 700;
  line-height: 1;
}
.hk-lbl {
  font-size: .57rem; text-transform: uppercase;
  letter-spacing: .09em; color: var(--text-muted);
  text-align: center;
}
.hk-val.blue   { color: var(--blue); }
.hk-val.violet { color: var(--violet); }
.hk-val.amber  { color: var(--amber); }
.hk-val.green  { color: var(--green); }

/* Badges */
.hero-badges { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: 2.1rem; }
.badge {
  font-family: var(--font-mono);
  font-size: .7rem;
  padding: .24rem .7rem;
  border-radius: 999px;
  border: 1px solid;
  transition: transform .18s var(--ease), box-shadow .18s;
}
.badge:hover { transform: translateY(-2px); }
.badge-blue   { color: var(--blue);   border-color: rgba(88,166,255,.45);  background: rgba(88,166,255,.08); }
.badge-green  { color: var(--green);  border-color: rgba(63,185,80,.45);   background: rgba(63,185,80,.08); }
.badge-violet { color: var(--violet); border-color: rgba(210,168,255,.45); background: rgba(210,168,255,.08); }
.badge-orange { color: var(--orange); border-color: rgba(247,140,53,.45);  background: rgba(247,140,53,.08); }

/* CTA button — premium */
.hero-cta { display: flex; }
.btn-start {
  display: inline-flex; align-items: center; gap: .65rem;
  background: linear-gradient(135deg, var(--blue) 0%, #79baff 100%);
  color: #0d1117;
  border: none;
  border-radius: var(--radius);
  padding: .72rem 1.6rem;
  font-family: var(--font-mono); font-size: .9rem; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 22px rgba(88,166,255,.35);
  transition: transform .2s var(--ease), box-shadow .2s;
}
.btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(88,166,255,.5);
}
.btn-start:active { transform: translateY(0); }
.cta-arrow { transition: transform .2s var(--ease); font-size: 1.05rem; }
.btn-start:hover .cta-arrow { transform: translateX(4px); }

/* ─── UE VIEW ─────────────────────────────────────────────── */
#view-ue { flex-direction: column; min-height: 100vh; }

/* Navbar */
#navbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  background: rgba(13,17,23,.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
}
.nav-inner {
  display: flex; width: 100%; max-width: 1100px;
  margin: 0 auto; padding: 0 1rem; gap: .25rem;
  align-items: center;
}
.nav-ue-btn {
  font-family: var(--font-mono); font-size: .8rem;
  color: var(--text-muted); background: none; border: none;
  border-bottom: 2px solid transparent;
  padding: .5rem 1.1rem; cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
  white-space: nowrap;
  border-radius: var(--radius) var(--radius) 0 0;
}
.nav-ue-btn:hover { color: var(--text); background: rgba(255,255,255,.03); }
.nav-ue-btn.active { color: var(--blue); border-bottom-color: var(--blue); }

.nav-back-btn {
  font-family: var(--font-mono); font-size: .76rem;
  color: var(--text-muted); background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .3rem .75rem; cursor: pointer;
  margin-right: .25rem; flex-shrink: 0;
  transition: color .18s, border-color .18s, background .18s;
}
.nav-back-btn:hover {
  color: var(--blue);
  border-color: rgba(88,166,255,.45);
  background: rgba(88,166,255,.06);
}

.nav-sep-v {
  width: 1px; height: 18px;
  background: var(--border);
  flex-shrink: 0;
  margin-right: .25rem;
}

.nav-logout {
  margin-left: auto;
  font-family: var(--font-mono); font-size: .72rem;
  color: var(--text-muted); background: none;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .28rem .8rem; cursor: pointer; flex-shrink: 0;
  transition: color .18s, border-color .18s, background .18s;
}
.nav-logout:hover {
  color: var(--red);
  border-color: rgba(247,130,102,.45);
  background: rgba(247,130,102,.06);
}

/* Content */
#ue-content {
  flex: 1; max-width: 1100px; width: 100%;
  margin: 0 auto;
  padding: 2.5rem 2rem calc(var(--bottom-h) + 2rem);
}

/* ─── UE Header ───────────────────────────────────────────── */
.ue-header { margin-bottom: 1rem; }
.ue-number {
  font-family: var(--font-mono); font-size: .76rem;
  color: var(--text-muted); margin-bottom: .35rem;
  display: flex; align-items: center; gap: .5rem;
}
.ue-number::before {
  content: ''; display: block; width: 18px; height: 2px;
  background: var(--blue); border-radius: 1px;
}
.ue-title {
  font-size: 1.45rem; font-weight: 800;
  letter-spacing: -.015em; line-height: 1.3;
}

/* ─── Dashboard Stats ─────────────────────────────────────── */
.ue-stats {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.2rem 1.6rem;
  background: linear-gradient(180deg, rgba(255,255,255,.015) 0%, transparent 40%), var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow-card);
}

.stat-total {
  display: flex; flex-direction: column; align-items: center;
  gap: .1rem; padding-right: 1.5rem;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
.stat-n {
  font-family: var(--font-mono); font-size: 2rem; font-weight: 700;
  color: var(--text); line-height: 1;
}
.stat-lbl {
  font-family: var(--font-mono); font-size: .63rem;
  text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted);
}

.stat-levels {
  display: flex; gap: 1rem; flex: 1; flex-wrap: wrap;
}
.stat-lvl-item {
  display: flex; flex-direction: column; align-items: center;
  gap: .2rem; min-width: 72px;
  transition: transform .2s var(--ease);
}
.stat-lvl-item:hover { transform: translateY(-2px); }
.stat-lvl-n {
  font-family: var(--font-mono); font-size: 1.3rem; font-weight: 700; line-height: 1;
}
.stat-lvl-label {
  font-family: var(--font-mono); font-size: .62rem;
  color: var(--text-muted); text-align: center; line-height: 1.3;
}
.stat-lvl-item.lvl-1 .stat-lvl-n { color: var(--red); }
.stat-lvl-item.lvl-2 .stat-lvl-n { color: var(--amber); }
.stat-lvl-item.lvl-3 .stat-lvl-n { color: var(--violet); }
.stat-lvl-item.lvl-4 .stat-lvl-n { color: var(--green); }

.stat-dist-bar {
  width: 100%; height: 7px; border-radius: 99px;
  display: flex; overflow: hidden;
  background: rgba(0,0,0,.35);
  flex-basis: 100%;
}
.stat-dist-seg { height: 100%; transition: width .7s var(--ease); }
.stat-dist-seg.lvl-1 { background: var(--red); }
.stat-dist-seg.lvl-2 { background: var(--amber); }
.stat-dist-seg.lvl-3 { background: var(--violet); }
.stat-dist-seg.lvl-4 { background: var(--green); }

/* ─── Sub-section ─────────────────────────────────────────── */
.sub-section { margin-bottom: 2.8rem; }

.sub-section-label {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-size: .68rem;
  text-transform: uppercase; letter-spacing: .13em; font-weight: 700;
  padding: .32rem .9rem; border-radius: 999px; margin-bottom: 1.1rem;
}
.sub-section-label.label-composantes {
  color: var(--blue); background: rgba(88,166,255,.1); border: 1px solid rgba(88,166,255,.28);
}
.sub-section-label.label-apprentissages {
  color: var(--violet); background: rgba(210,168,255,.1); border: 1px solid rgba(210,168,255,.28);
}
.sub-section-label.label-limites {
  color: var(--amber); background: rgba(227,179,65,.1); border: 1px solid rgba(227,179,65,.28);
}

/* ─── Criteria list ───────────────────────────────────────── */
.criteria-list { display: flex; flex-direction: column; gap: .55rem; }

.criteria-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--radius);
  overflow: hidden;
  opacity: 0; transform: translateY(10px);
  transition: opacity .4s var(--ease), transform .4s var(--ease),
              background .2s, box-shadow .25s, border-color .25s;
}
.criteria-row.visible { opacity: 1; transform: none; }
.criteria-row:hover {
  background: var(--surface2);
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}

.criteria-row.lvl-1 { border-left-color: var(--red); }
.criteria-row.lvl-2 { border-left-color: var(--amber); }
.criteria-row.lvl-3 { border-left-color: var(--violet); }
.criteria-row.lvl-4 { border-left-color: var(--green); }

/* Top row: text | level | ref */
.crit-top {
  display: grid;
  grid-template-columns: 1fr 140px 200px;
  border-bottom: 1px solid var(--border);
}
.crit-top > div { padding: .8rem 1rem; border-right: 1px solid var(--border); }
.crit-top > div:last-child { border-right: none; }

.crit-text-cell { display: flex; align-items: center; }
.crit-text { font-size: .88rem; color: var(--text); font-style: italic; line-height: 1.5; }

/* Level cell */
.level-cell {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: .35rem;
}
.level-bar { display: flex; gap: 3px; }
.level-seg { width: 18px; height: 6px; border-radius: 2px; background: var(--border); }
.level-seg.filled-1 { background: var(--red); }
.level-seg.filled-2 { background: var(--amber); }
.level-seg.filled-3 { background: var(--violet); }
.level-seg.filled-4 { background: var(--green); }
.level-lbl {
  font-family: var(--font-mono); font-size: .64rem;
  text-align: center; line-height: 1.3; max-width: 120px;
}
.lvl-lbl-1 { color: var(--red); }
.lvl-lbl-2 { color: var(--amber); }
.lvl-lbl-3 { color: var(--violet); }
.lvl-lbl-4 { color: var(--green); }

/* Reference cell */
.crit-ref-cell { display: flex; align-items: center; }
.crit-ref {
  font-family: var(--font-mono); font-size: .72rem;
  color: var(--blue); line-height: 1.4; word-break: break-word;
}

/* ─── Code comment block ──────────────────────────────────── */
.code-block {
  background: rgba(0,0,0,.28);
  padding: .5rem 0;
  font-family: var(--font-mono);
}
.code-line {
  display: flex; align-items: baseline; gap: .6rem;
  padding: .18rem 1rem;
  font-size: .78rem; line-height: 1.55;
}
.code-line-hidden { display: none; }

.cc-num {
  min-width: 1.8rem; text-align: right;
  color: var(--text-muted); opacity: .35;
  user-select: none; flex-shrink: 0;
}
.cc-slash { color: var(--green); flex-shrink: 0; }
.cc-text  { color: #a8b8c8; }

.code-toggle {
  cursor: pointer; border-top: 1px dashed rgba(48,54,61,.6); margin-top: .2rem;
  transition: background .15s;
}
.code-toggle:hover { background: rgba(88,166,255,.04); }
.code-toggle:hover .cc-slash,
.code-toggle:hover .cc-expand-btn { color: var(--blue); }
.cc-expand-btn { color: var(--blue); }

/* ─── Bottom nav bar ──────────────────────────────────────── */
#ue-nav-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2rem;
  background: rgba(13,17,23,.92); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border); z-index: 99;
}
.nav-arrow {
  font-family: var(--font-mono); font-size: .82rem; color: var(--blue);
  background: none; border: 1px solid var(--border); border-radius: var(--radius);
  padding: .45rem 1.1rem; cursor: pointer;
  transition: background .18s, border-color .18s, transform .18s var(--ease);
}
.nav-arrow:hover:not(:disabled) {
  background: rgba(88,166,255,.1);
  border-color: var(--blue);
  transform: translateY(-1px);
}
.nav-arrow:disabled { color: var(--border); cursor: default; }
#ue-indicator {
  font-family: var(--font-mono); font-size: .8rem; color: var(--text-muted);
}

/* ─── Detail page link button ────────────────────────────── */
.detail-page-link {
  display: inline-flex; align-items: center; gap: .6rem;
  font-family: var(--font-mono); font-size: .82rem; font-weight: 700;
  color: #0d1117;
  background: linear-gradient(135deg, var(--blue) 0%, #79baff 100%);
  border-radius: var(--radius); padding: .62rem 1.35rem;
  text-decoration: none; margin-bottom: 1.5rem; margin-top: .25rem;
  transition: transform .18s var(--ease), box-shadow .18s;
  box-shadow: 0 3px 18px rgba(88,166,255,.35);
}
.detail-page-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 26px rgba(88,166,255,.5);
  text-decoration: none;
}
.detail-link-arrow { font-size: 1rem; transition: transform .18s var(--ease); }
.detail-page-link:hover .detail-link-arrow { transform: translateX(4px); }

/* ─── Slide animations ────────────────────────────────────── */
.ue-enter      { animation: slideIn .3s var(--ease) forwards; }
.ue-enter-back { animation: slideInBack .3s var(--ease) forwards; }
@keyframes slideIn     { from { opacity:0; transform:translateX(24px);  } to { opacity:1; transform:none; } }
@keyframes slideInBack { from { opacity:0; transform:translateX(-24px); } to { opacity:1; transform:none; } }

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 860px) {
  .crit-top { grid-template-columns: 1fr 130px; }
  .crit-top > div:nth-child(3) { display: none; }
}
@media (max-width: 640px) {
  #view-hero { padding: 1rem; }
  .hero-body { padding: 1.9rem 1.3rem 1.8rem; }
  .hero-top-bar { padding: .9rem 1.3rem; }
  .hero-kpis { grid-template-columns: repeat(2, 1fr); }
  .hero-id { gap: 1rem; }
  .hero-avatar { width: 60px; height: 60px; font-size: 1.1rem; }
  .nav-ue-btn { padding: .5rem .6rem; font-size: .72rem; }
}
@media (max-width: 540px) {
  .crit-top { grid-template-columns: 1fr; }
  .crit-top > div { border-right: none; }
  .crit-top > div:nth-child(2) { border-top: 1px solid var(--border); }
  .ue-title { font-size: 1.1rem; }
  #ue-content { padding: 1.5rem 1rem calc(var(--bottom-h) + 1.5rem); }
  #ue-nav-bar { padding: 0 1rem; }
  .nav-arrow { padding: .4rem .7rem; font-size: .76rem; }
  .ue-stats { gap: 1rem; padding: 1rem; }
}
