:root {
  --color-primary: #2f5fdd;
  --color-primary-dark: #1e40af;
  --color-bg: #f4f6fb;
  --color-surface: #ffffff;
  --color-text: #1c2331;
  --color-muted: #667085;
  --color-border: #e2e6f0;
  --color-danger: #d1453b;
  --color-success: #1a8f5e;
  --radius: 0;
  --shadow: 0 2px 10px rgba(20, 30, 60, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 150%;
}
body.front {
  margin: 0;
  font-family:
    'Segoe UI',
    system-ui,
    -apple-system,
    sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

input[type='checkbox'],
input[type='radio'] {
  width: 1.15rem;
  height: 1.15rem;
  vertical-align: middle;
}
/* intégrer la police OpenDyslexic pour le mode accessibilité */
@font-face {
  font-family: 'OpenDyslexic';
  src: url('../fonts/dyslexic/OpenDyslexic-Regular.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'OpenDyslexic';
  src: url('../fonts/dyslexic/OpenDyslexic-Bold.otf') format('opentype');
  font-weight: bold;
  font-style: normal;
}

@font-face {
  font-family: 'OpenDyslexic';
  src: url('../fonts/dyslexic/OpenDyslexic-Italic.otf') format('opentype');
  font-weight: normal;
  font-style: italic;
}

@font-face {
  font-family: 'OpenDyslexic';
  src: url('../fonts/dyslexic/OpenDyslexic-BoldItalic.otf') format('opentype');
  font-weight: bold;
  font-style: italic;
}

[x-cloak] {
  display: none !important;
}

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

.front-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.front-header__brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--color-primary-dark);
  text-decoration: none;
}

.front-header__nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.front-header__dyslexie-toggle {
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  padding: 0;
}

.front-header__dyslexie-toggle:hover {
  background: var(--color-bg);
}

.front-header__dyslexie-toggle svg {
  width: 1.1rem;
  height: 1.1rem;
}

.front-header__theme-toggle {
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}

.front-header__theme-toggle:hover {
  background: var(--color-bg);
}

.front-header__theme-toggle .bi {
  font-size: 1rem;
}

.front-header__user {
  color: var(--color-muted);
}
.front-header__logout {
  padding: 6px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.front-header__logout:hover {
  text-decoration: none;
  background: var(--color-bg);
}

.front-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 1300px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.front-footer {
  text-align: center;
  padding: 20px;
  color: var(--color-muted);
  font-size: 0.85rem;
}

.flash-container {
  margin-bottom: 20px;
}
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  font-size: 0.95rem;
}
.flash--error {
  background: #fdecea;
  color: var(--color-danger);
}
.flash--success {
  background: #e8f7ef;
  color: var(--color-success);
}

/* --- Login --- */
.login-wrap {
  height: 100vh;
  padding: 2rem;

  .login-card {
    height: 100%;
    background: var(--color-surface);
    display: flex;
    align-items: center;
    gap: 1rem;

    .login-card__illustration {
      flex: 0 0 55%;
      max-width: 55%;
      min-width: 55%;
      height: 100%;
      background-size: contain;
      background-repeat: no-repeat;
      pointer-events: auto;
      background-size: 85%;
      background-image: url(../images/login-illustration.svg);
      background-position: 50% 50%;
    }

    .login-card__form {
      padding: 0.25rem;
      .warning {
        padding: 0.25rem;
        background: #fff3cd;
        color: #856404;
      }

      h1 {
        margin-top: 0;
      }
      .login-card__hint {
        color: var(--color-muted);
        font-size: 0.9rem;
      }
      .login-form {
        display: flex;
        flex-direction: column;
        gap: 6px;

        label {
          font-weight: 600;
          margin-top: 10px;
          font-size: 0.9rem;
        }

        input {
          padding: 10px 12px;
          border: 1px solid var(--color-border);
          border-radius: var(--radius);
          font-size: 1rem;
        }

        [type='submit'] {
          align-self: self-start;
          display: flex;
          gap: 1rem;
          align-items: center;
          margin-top: 1rem;
          font-size: 1.5rem;
          padding: 0.75rem;
        }

        button {
          border: none;
          border-radius: var(--radius);
          background: var(--color-primary);
          color: #fff;
          font-size: 1rem;
          cursor: pointer;
        }
        button:hover {
          background: var(--color-primary-dark);
        }
      }
    }

    /* .login-illustration {
      width: 60%;

      .login-illustration__image {
        display: block;
        width: 100%;
        max-width: 100%;
        height: auto;
      }
    } */
  }
}

.password-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.password-field input {
  flex: 1;
}

.password-toggle {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}

.password-toggle:hover {
  background: var(--color-bg);
}

/* --- Maintenance --- */
.maintenance-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(18px, 4vw, 42px);
  overflow: hidden;
}
.maintenance-illustration {
  width: 50%;
  img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: fill;
  }
}
.maintenance-card {
  width: min(760px, 50%);
  text-align: center;
  background:
    linear-gradient(145deg, rgba(25, 147, 240, 0.08) 0%, rgba(255, 255, 255, 0.98) 46%, rgba(239, 202, 8, 0.1) 100%),
    var(--color-surface);
  border: 1px solid rgba(25, 147, 240, 0.18);
  padding: clamp(26px, 4vw, 54px);
  margin: 1rem;
  border-radius: 14px;
  box-shadow:
    0 24px 50px rgba(25, 147, 240, 0.16),
    0 8px 18px rgba(20, 30, 60, 0.08);
}
.maintenance-card h1 {
  margin: 0;
  font-size: clamp(1.7rem, 2vw + 1rem, 2.5rem);
  line-height: 1.12;
  color: #10243a;
}

.maintenance-message {
  margin: 1rem auto 0;
  max-width: 60ch;
  color: #2a3e54;
  line-height: 1.6;
  font-size: clamp(0.96rem, 0.25vw + 0.92rem, 1.08rem);
}

.maintenance-meta {
  margin-top: clamp(18px, 3.2vw, 30px);
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.maintenance-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid rgba(16, 36, 58, 0.16);
  background: #f4f9fe;
  color: #17324f;
  font-size: 0.84rem;
  font-weight: 600;
}

.maintenance-pill--progress {
  border-color: rgba(25, 147, 240, 0.2);
  background: linear-gradient(130deg, #1993f0 0%, #41abf6 72%);
  color: #fff;
}

body.front.theme-dark {
  --color-bg: #0f1724;
  --color-surface: #162033;
  --color-text: #e6edf7;
  --color-muted: #a5b2c8;
  --color-border: #2c3a52;
  --color-primary: #75a0ff;
  --color-primary-dark: #4f7de2;
  --shadow: 0 0.25rem 1rem rgba(4, 8, 15, 0.5);
}

html:has(body.dyslexie) {
  font-size: 110%;
}
body.front.dyslexie {
  font-family: 'OpenDyslexic', Arial, sans-serif;
}

body.front.dyslexie p,
body.front.dyslexie li,
body.front.dyslexie label,
body.front.dyslexie .flash,
body.front.dyslexie .module-card__body,
body.front.dyslexie .doc-list__item,
body.front.dyslexie .front-header__user {
  line-height: 1.8;
}

body.front.dyslexie .front-header__dyslexie-toggle {
  border-color: var(--color-primary);
  color: var(--color-primary);
  box-shadow: inset 0 0 0 0.0625rem rgba(47, 95, 221, 0.18);
}

.maintenance-footnote {
  margin: clamp(14px, 2vw, 20px) 0 0;
  color: #4d6377;
  font-size: 0.92rem;
}

@media (max-width: 720px) {
  .maintenance-wrap {
    flex-direction: column;
    min-height: 0;
    padding: 8px 0 4px;
  }

  .maintenance-card {
    border-radius: 10px;
    width: 100%;
  }
  .maintenance-illustration {
    width: 100%;
  }
}

/* --- Modules --- */
.semestre-block {
  margin-bottom: 40px;
}
.semestre-block__title {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
  font-size: 0.95rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 8px;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 16px;
}

.module-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-decoration: none;
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}
.module-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(20, 30, 60, 0.12);
}
.module-card__image {
  aspect-ratio: 16 / 9;
  background: var(--color-bg);
}
.module-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.module-card__placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-muted);
  font-weight: 600;
  padding: 12px;
  text-align: center;
  background: linear-gradient(135deg, #eef2fb, #e4e9fa);
}
.module-card__body {
  padding: 14px 16px;
}
.module-card__body h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}
.module-card__body p {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.85rem;
}

.empty-state {
  color: var(--color-muted);
  font-style: italic;
}

/* --- 404 Not Found --- */
.notfound-wrap {
  height: 100vh;
}

.notfound-card {
  display: flex;
  align-items: center;
  height: 100%;
  width: 100%;
  background: var(--color-surface);

  .notfound-card__description {
    flex: 0 0 45%;
    max-width: 45%;
    min-width: 45%;
    margin: 1rem auto 0;

    color: var(--color-muted);
    max-width: 60ch;
    text-align: center;

    .notfound-code {
      margin: 0;
      font-size: 4rem;
      line-height: 1;
      font-weight: 700;
      color: var(--color-primary-dark);
    }

    .notfound-card h1 {
      margin: 0.5rem 0 0;
    }

    .notfound-message {
      margin: 0.8rem auto 1.25rem;
      color: var(--color-muted);
      max-width: 42ch;
    }
  }
  .notfound-card__illustration {
    flex: 0 0 55%;
    max-width: 55%;
    min-width: 55%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    margin: 0 auto 1.5rem;
    pointer-events: auto;
    background-image: url(../images/error-404.webp);
    background-position: 50% 50%;
  }
}

/* --- Module detail --- */
.back-link {
  display: inline-block;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.module-page__header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}
.module-page__image {
  width: 140px;
  height: 90px;
  object-fit: cover;
  border-radius: var(--radius);
}
.module-page__header h1 {
  margin: 6px 0 0;
}
.badge {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.module-tabs__nav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.module-tabs__nav button {
  padding: 10px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--color-muted);
  border-bottom: 2px solid transparent;
}
.module-tabs__nav button.is-active {
  color: var(--color-primary-dark);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}
.module-tabs__count {
  color: var(--color-muted);
  font-size: 0.8rem;
}

.document-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.document-item {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
}
.document-item__header {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.document-item__header h3 {
  margin: 0;
  font-size: 1.05rem;
}
.document-item__numero {
  color: var(--color-muted);
  font-size: 0.85rem;
}
.document-item__description {
  color: var(--color-text);
  font-size: 0.92rem;
  margin-top: 8px;
}
.document-item__description :first-child {
  margin-top: 0;
}
.document-item__download {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  font-size: 0.88rem;
  font-weight: 600;
}
.document-item__download:hover {
  text-decoration: none;
  background: #e9edf8;
}

.code-preview {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.code-preview__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 12, 24, 0.82);
  backdrop-filter: blur(4px);
}

.code-preview__dialog {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #101722;
  color: #e6edf7;
}

.code-preview__toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.code-preview__eyebrow {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: #8aa4cf;
}

.code-preview__toolbar h2 {
  margin: 0;
  font-size: 1.05rem;
  word-break: break-word;
}

.code-preview__meta,
.code-preview__status {
  margin: 0;
  color: #b7c4d8;
  font-size: 0.86rem;
}

.code-preview__status {
  padding: 0.85rem 1.25rem 0;
}

.code-preview__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.65rem;
}

.code-preview__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.7rem 1rem;
  border: 1px solid transparent;
  background: #2f5fdd;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.code-preview__button:hover {
  text-decoration: none;
  background: #1e40af;
}

.code-preview__button--ghost {
  border-color: rgba(255, 255, 255, 0.18);
  background: transparent;
  color: #e6edf7;
}

.code-preview__button--ghost:hover {
  background: rgba(255, 255, 255, 0.08);
}

.code-preview__body {
  flex: 1;
  min-height: 0;
  padding: 1rem 1.25rem 1.25rem;
}

.code-preview__panel {
  height: 100%;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: auto;
}

.code-preview__panel[class],
.code-preview__panel code[class*='language-'],
.code-preview__panel pre[class*='language-'] {
  background: #0a0f17;
}

.has-code-preview {
  overflow: hidden;
}

@media (max-width: 600px) {
  .front-header {
    padding: 12px 16px;
  }
  .front-main {
    padding: 20px 16px 48px;
  }
  .module-page__header {
    flex-direction: column;
    align-items: flex-start;
  }

  .code-preview__toolbar {
    flex-direction: column;
  }

  .code-preview__actions {
    width: 100%;
    justify-content: stretch;
  }

  .code-preview__button {
    flex: 1 1 100%;
  }
}
