/* Carnet — styles. Valeurs issues de « Système de design.md ». */

:root {
  --bg: #ECEEF2;
  --wash:
    radial-gradient(60% 60% at 8% 0%, oklch(0.85 0.08 262 / 0.6), transparent 70%),
    radial-gradient(55% 55% at 100% 100%, oklch(0.87 0.07 190 / 0.55), transparent 70%),
    radial-gradient(40% 40% at 70% 15%, oklch(0.9 0.06 330 / 0.35), transparent 70%);
  --glass: rgba(255, 255, 255, 0.58);
  --glass2: rgba(255, 255, 255, 0.74);
  --edge: rgba(255, 255, 255, 0.85);
  --shine: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --shadow: 0 1px 2px rgba(20, 24, 36, 0.05), 0 8px 28px rgba(20, 24, 36, 0.08);
  --blur: blur(24px) saturate(180%);
  --fill: rgba(17, 19, 24, 0.06);
  --line: rgba(17, 19, 24, 0.08);
  --ink: #111318;
  --ink2: #464A54;
  --ink3: #646976;
  --accent: oklch(0.52 0.18 262);
  --onaccent: #FFFFFF;
  --accentsoft: oklch(0.52 0.18 262 / 0.12);
  --accentink: oklch(0.45 0.18 262);
  --c1: oklch(0.62 0.17 45);
  --c2: oklch(0.52 0.18 262);
  --c3: oklch(0.55 0.18 330);
  --cgrey: rgba(17, 19, 24, 0.2);
  --tab-shadow: var(--shine), 0 2px 8px rgba(0, 0, 0, 0.08);

  --m-maths: oklch(0.68 0.15 255);
  --m-physique: oklch(0.72 0.15 150);
  --m-chimie: oklch(0.82 0.12 70);
  --m-info: oklch(0.68 0 0);
  --m-si: #000000;
  --m-francais: oklch(0.65 0.19 25);
  --m-anglais: oklch(0.65 0.17 300);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Helvetica Neue", sans-serif;
  --font-num: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0A0B0F;
    --wash:
      radial-gradient(60% 60% at 8% 0%, oklch(0.36 0.11 262 / 0.7), transparent 70%),
      radial-gradient(55% 55% at 100% 100%, oklch(0.33 0.08 190 / 0.6), transparent 70%),
      radial-gradient(40% 40% at 70% 15%, oklch(0.32 0.09 330 / 0.4), transparent 70%);
    --glass: rgba(34, 36, 46, 0.52);
    --glass2: rgba(32, 34, 44, 0.72);
    --edge: rgba(255, 255, 255, 0.12);
    --shine: inset 0 1px 0 rgba(255, 255, 255, 0.12);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.35);
    --blur: blur(24px) saturate(160%);
    --fill: rgba(255, 255, 255, 0.08);
    --line: rgba(255, 255, 255, 0.08);
    --ink: #F2F3F6;
    --ink2: #BCC0CA;
    --ink3: #9399A6;
    --accent: oklch(0.72 0.14 262);
    --onaccent: #0A0B0F;
    --accentsoft: oklch(0.72 0.14 262 / 0.2);
    --accentink: oklch(0.8 0.11 262);
    --c1: oklch(0.77 0.14 55);
    --c2: oklch(0.74 0.13 262);
    --c3: oklch(0.74 0.15 330);
    --cgrey: rgba(255, 255, 255, 0.22);
  }
}

/* Repli « Réduire la transparence » */
@media (prefers-reduced-transparency: reduce) {
  :root {
    --glass: #FFFFFF; --glass2: #F7F8FA; --edge: rgba(17, 19, 24, 0.1);
    --shine: inset 0 0 0 transparent; --blur: none;
    --wash: linear-gradient(transparent, transparent);
  }
}
@media (prefers-reduced-transparency: reduce) and (prefers-color-scheme: dark) {
  :root { --glass: #1A1C23; --glass2: #22252E; --edge: rgba(255, 255, 255, 0.1); }
}

@media (prefers-contrast: more) {
  :root { --ink2: var(--ink); --ink3: var(--ink); --edge: rgba(17, 19, 24, 0.25); }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root { --edge: rgba(255, 255, 255, 0.3); }
}

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

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--wash), var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 21px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
main:focus { outline: none; }

.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

/* ---------- Mise en page ---------- */

#page {
  padding: calc(env(safe-area-inset-top) + 24px) 16px calc(120px + env(safe-area-inset-bottom));
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (min-width: 1024px) {
  #page {
    max-width: none;
    margin: 0;
    padding: calc(env(safe-area-inset-top) + 36px) 32px 32px 292px;
  }
}

/* ---------- Verre ---------- */

.glass {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--edge);
  box-shadow: var(--shine), var(--shadow);
}

/* ---------- Typographie ---------- */

.kicker {
  font-size: 13px; line-height: 16px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink3);
}
.title { font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: -0.02em; }
.title2 { font-size: 20px; line-height: 25px; font-weight: 600; letter-spacing: -0.01em; }
.title3 { font-size: 17px; line-height: 22px; font-weight: 600; }
.note { font-size: 13px; line-height: 18px; color: var(--ink3); }
.lead { font-size: 15px; line-height: 20px; color: var(--ink2); }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.page-head > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

/* ---------- Carte, grilles ---------- */

.card { border-radius: 24px; padding: 20px 22px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card--small { border-radius: 22px; padding: 14px 16px 16px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }

.grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.cols { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

@media (min-width: 700px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--subjects { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid--subjects { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cols--home { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
  .cols--journal { grid-template-columns: minmax(0, 1fr) 380px; }
}

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border: none; border-radius: 999px;
  font-size: 15px; font-weight: 600; cursor: pointer; background: var(--fill); color: var(--ink);
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn--glass {
  background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--edge); box-shadow: var(--shine), var(--shadow); color: var(--accentink);
}

/* ---------- Puces de filtre ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 16px;
  border-radius: 999px; background: var(--glass); border: 1px solid var(--edge);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  font-size: 15px; font-weight: 600; color: var(--ink); cursor: pointer;
  transition: background 0.2s var(--ease);
}
.chip[aria-pressed="true"], .chip[aria-current="page"] { background: var(--accent); color: var(--onaccent); border-color: transparent; }

/* ---------- Étiquette, pastille, barre ---------- */

.tag {
  display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px;
  background: var(--fill); color: var(--ink2); font-size: 12px; font-weight: 600; white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--dot, var(--m-info)); }
.dot--si { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55); }

.bar { height: 6px; border-radius: 999px; background: var(--fill); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }

/* ---------- Listes ---------- */

.row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px;
  min-height: 44px; padding: 11px 0; border-top: 1px solid var(--line);
}
.row:first-child { border-top: none; }
a.row { color: inherit; text-decoration: none; }
.row-title { font-size: 16px; line-height: 21px; font-weight: 600; }
.row-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; line-height: 18px; color: var(--ink3); }

.empty { padding: 8px 0 12px; display: flex; flex-direction: column; gap: 2px; }
.empty .row-title { font-size: 15px; line-height: 20px; }

/* Carte-lien (matières) */
a.card--link { flex-direction: row; align-items: center; gap: 12px; min-height: 64px; cursor: pointer; transition: transform 0.2s var(--ease); }
a.card--link:active { transform: scale(0.97); }
a.card--link .dot { width: 10px; height: 10px; }
a.card--link .chev { margin-left: auto; color: var(--ink3); }

/* Série de jours */
.streak { display: flex; align-items: center; gap: 16px; padding: 10px 18px; border-radius: 22px; }
.streak .big { font-size: 28px; line-height: 32px; font-weight: 700; }
.week { display: flex; gap: 6px; }
.week > div { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; line-height: 12px; font-weight: 600; color: var(--ink3); }
.week i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); }

/* Journal : liste « Par type » */
.types { display: flex; flex-direction: column; padding: 4px; }
.types .t { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 14px; font-size: 15px; font-weight: 500; }
.types .t i { width: 16px; height: 3px; border-radius: 2px; background: var(--cgrey); }
.chart-empty { height: 150px; border-radius: 16px; background: var(--fill); display: flex; align-items: center; justify-content: center; padding: 0 16px; text-align: center; }

/* ---------- Navigation ---------- */

.nav { position: fixed; z-index: 10; color: var(--ink); background: var(--glass2);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--edge); box-shadow: var(--shine), var(--shadow); }
.nav a { display: flex; align-items: center; cursor: pointer; transition: background 0.2s var(--ease); }
.nav a[aria-current="page"] { background: var(--accentsoft); color: var(--accentink); font-weight: 600; }
.nav svg { flex: none; }

.sidebar { display: none; top: calc(env(safe-area-inset-top) + 36px); left: 12px; bottom: 12px; width: 248px;
  padding: 18px 12px; flex-direction: column; gap: 2px; border-radius: 28px; overflow-y: auto; }
.sidebar .brand { padding: 4px 12px 16px; display: flex; flex-direction: column; gap: 2px; }
.sidebar .brand b { font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -0.02em; }
.sidebar a { gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 14px; font-size: 16px; font-weight: 500; }
.sidebar .sub { font-size: 15px; color: var(--ink2); }
.sidebar .sub[aria-current="page"] { background: var(--fill); color: var(--ink); }
.sidebar .sub .dot { width: 10px; height: 10px; margin: 0 6px; }
.sidebar h2 { padding: 18px 12px 6px; font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink3); }

.tabbar { left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom));
  width: calc(100% - 24px); max-width: 620px; padding: 4px; border-radius: 32px;
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tabbar a { flex-direction: column; justify-content: center; gap: 3px; min-height: 56px; border-radius: 26px;
  font-size: 10.5px; font-weight: 500; letter-spacing: 0.01em; color: var(--ink2); white-space: nowrap; }
.tabbar a[aria-current="page"] { font-weight: 600; }

@media (min-width: 1024px) {
  .sidebar { display: flex; }
  .tabbar { display: none; }
}
@media (max-width: 700px) {
  .tabbar { bottom: calc(22px + env(safe-area-inset-bottom)); }
  .title { font-size: 30px; line-height: 37px; }
}

/* ---------- Animations ---------- */

@keyframes appear { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#page > * { animation: appear 0.25s var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  @keyframes appear { from { opacity: 0; } to { opacity: 1; } }
  .btn:active, a.card--link:active { transform: none; }
}

.pdf-pages { display: flex; flex-direction: column; gap: 12px; }
.pdf-page { background: #fff; border-radius: 8px; overflow: hidden; min-height: 120px; }
.pdf-viewer .chip[aria-current] { background: var(--accent); color: var(--onaccent); border-color: transparent; }

.fc { display: flex; flex-direction: column; gap: 12px; }
.fc { align-items: center; }
.fc-carte { --fc-duree: 0.5s; width: min(100%, 560px, calc((100dvh - 420px) * 4 / 3)); aspect-ratio: 4 / 3; perspective: 1200px; -webkit-perspective: 1200px; cursor: pointer; position: relative; touch-action: pan-y; overscroll-behavior: none; user-select: none; -webkit-user-select: none; }
.fc-carte.sans-defilement { touch-action: none; }
.fc-carte.sort { transition: transform 0.25s var(--ease); }
.fc-teinte { position: absolute; inset: 0; border-radius: 28px; pointer-events: none; }
.fc-inner { position: relative; width: 100%; height: 100%; transition: transform var(--fc-duree) var(--ease); -webkit-transition: -webkit-transform var(--fc-duree) var(--ease); transform-style: preserve-3d; -webkit-transform-style: preserve-3d; }
.fc-carte.retournee .fc-inner { transform: rotateY(180deg); -webkit-transform: rotateY(180deg); }
.fc-face { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 8px; padding: 20px; box-sizing: border-box; overflow-y: auto; -webkit-overflow-scrolling: touch; overflow-wrap: anywhere; text-align: center; align-items: center; border: 1px solid var(--line, currentColor); border-radius: 28px; background: var(--bg, Canvas); -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.fc-verso { transform: rotateY(180deg); -webkit-transform: rotateY(180deg); }
.fc-face .katex-display { overflow-x: auto; overflow-y: hidden; max-width: 100%; }
.fc-face > :first-child { margin-top: auto; }
.fc-face > :last-child { margin-bottom: auto; }
.fc-notes { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.fc-notes[hidden] { display: none; }
.fc-resume { list-style: none; margin: 0; padding: 0; display: flex; gap: 20px; }
.fc-note--sais { color: rgb(46, 160, 80); }
.fc-note--moyen { color: rgb(240, 150, 30); }
.fc-note--revoir { color: rgb(220, 60, 60); }
@media (prefers-reduced-motion: reduce) {
  .fc-inner, .fc-carte.retournee .fc-inner, .fc-verso { transform: none; -webkit-transform: none; transition: none; }
  .fc-face { -webkit-backface-visibility: visible; backface-visibility: visible; transition: opacity 0.15s linear; }
  .fc-verso, .fc-carte.retournee .fc-recto { opacity: 0; pointer-events: none; }
  .fc-carte.retournee .fc-verso { opacity: 1; pointer-events: auto; }
}
