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

/* ── TOKENS ── */
:root {
  --paper: #f5f1eb;
  --paper-2: #ede9e1;
  --paper-3: #e5e0d6;
  --ink: #1a1714;
  --ink-2: #3d3830;
  --ink-3: #7a7268;
  --rule: #cbc5ba;
  --rule-light: #ddd9d2;
  --accent: #b84c27;
  --accent-dim: #d4745a;
  --key-bg: #eae6df;
  --key-border: #b8b2a8;

  --nav-w: 228px;
  --nav-w-col: 48px;
  /* collapsed width */
  --nav-speed: 0.28s;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Source Serif 4', Georgia, serif;
  background: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  line-height: 1.5;
}

/* ══════════════════════════════════════
   SIDEBAR
══════════════════════════════════════ */
nav {
  width: var(--nav-w);
  min-height: 100vh;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  overflow: hidden;
  transition: width var(--nav-speed) cubic-bezier(.4, 0, .2, 1);
  will-change: width;
}

nav.collapsed {
  width: var(--nav-w-col);
}

/* ── toggle button ── */
.nav-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 14px 14px 0;
  flex-shrink: 0;
}

.toggle-btn {
  background: none;
  border: 1px solid #3a342e;
  border-radius: 4px;
  color: #8a8078;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}

.toggle-btn:hover {
  color: var(--paper);
  border-color: #6a6058;
}

.toggle-btn svg {
  transition: transform var(--nav-speed) ease;
  flex-shrink: 0;
}

nav.collapsed .toggle-btn svg {
  transform: rotate(180deg);
}

/* ── brand ── */
.nav-brand {
  padding: 18px 20px 22px;
  border-bottom: 1px solid #3a342e;
  margin-bottom: 20px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  opacity: 1;
  transition: opacity calc(var(--nav-speed) * 0.6) ease;
}

nav.collapsed .nav-brand {
  opacity: 0;
  pointer-events: none;
}

.nav-brand-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--paper);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.nav-brand-title em {
  color: var(--accent-dim);
  font-style: normal;
}

.nav-brand-sub {
  margin-top: 5px;
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #6b6259;
}

/* ── group label ── */
.nav-group-label {
  padding: 0 20px 7px;
  font-family: 'DM Mono', monospace;
  font-size: 8.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #4a4440;
  white-space: nowrap;
  overflow: hidden;
  opacity: 1;
  transition: opacity calc(var(--nav-speed) * 0.6) ease;
  flex-shrink: 0;
}

nav.collapsed .nav-group-label {
  opacity: 0;
}

/* ── links ── */
nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  font-family: 'Source Serif 4', serif;
  font-size: 14px;
  font-weight: 400;
  font-style: italic;
  color: #8a8078;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
  border-left: 2px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  flex-shrink: 0;
}

nav a:hover {
  color: var(--paper);
  background: #26211d;
}

nav a.active {
  color: var(--paper);
  border-left-color: var(--accent);
  background: #26211d;
  font-style: normal;
  font-weight: 600;
}

.mark {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4a4440;
  flex-shrink: 0;
  transition: background 0.15s;
}

nav a.active .mark,
nav a:hover .mark {
  background: var(--accent);
}

.nav-link-text {
  opacity: 1;
  transition: opacity calc(var(--nav-speed) * 0.5) ease;
}

nav.collapsed .nav-link-text {
  opacity: 0;
}

/* ── print button ── */
.nav-print {
  margin: auto 16px 0;
  margin-top: 24px;
  background: transparent;
  border: 1px solid #3a342e;
  border-radius: 4px;
  color: #8a8078;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 11px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: all 0.15s;
  width: calc(100% - 32px);
  white-space: nowrap;
  overflow: hidden;
  flex-shrink: 0;
}

.nav-print:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.nav-print-text {
  opacity: 1;
  transition: opacity calc(var(--nav-speed) * 0.5) ease;
}

nav.collapsed .nav-print-text {
  opacity: 0;
}

/* ══════════════════════════════════════
   MAIN
══════════════════════════════════════ */
main {
  margin-left: var(--nav-w);
  padding: 52px 48px 64px;
  flex: 1;
  transition: margin-left var(--nav-speed) cubic-bezier(.4, 0, .2, 1);
}

body.nav-collapsed main {
  margin-left: var(--nav-w-col);
}

/* ── header ── */
header {
  margin-bottom: 44px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--ink);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  animation: fadeIn 0.5s ease both;
}

header h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(34px, 4.5vw, 58px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}

header h1 em {
  font-style: italic;
  color: var(--ink-2);
  font-weight: 700;
}

.header-right {
  text-align: right;
  flex-shrink: 0;
}

.header-right p {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  line-height: 1.8;
}

/* ── grid ── */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}

/* ── section cards ── */
.section {
  background: transparent;
  border: 1px solid var(--rule);
  border-top: 3px solid var(--ink);
  padding: 22px 24px 20px;
  scroll-margin-top: 28px;
  animation: fadeUp 0.4s ease both;
}

.cat-edition {
  border-top-color: var(--ink);
}

.cat-mise-en-forme {
  border-top-color: var(--ink-2);
}

.cat-systeme {
  border-top-color: var(--ink-3);
}

.cat-accent {
  border-top-color: var(--accent);
}

.section-title {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule-light);
}

.cat-accent .section-title {
  color: var(--accent);
}

/* ── shortcut rows ── */
.shortcut-list {
  display: flex;
  flex-direction: column;
}

.shortcut {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule-light);
  transition: background 0.1s, padding 0.1s;
}

.shortcut:last-child {
  border-bottom: none;
}

.shortcut:hover {
  background: var(--paper-3);
  padding-left: 10px;
  padding-right: 10px;
  margin: 0 -10px;
}

.shortcut-label {
  font-family: 'Source Serif 4', serif;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* ── keys ── */
.keys {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.key {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  background: var(--key-bg);
  border: 1px solid var(--key-border);
  border-bottom: 3px solid var(--key-border);
  border-radius: 4px;
  padding: 3px 9px;
  min-width: 30px;
  text-align: center;
  white-space: nowrap;
  line-height: 1.4;
}

.plus {
  color: var(--ink-3);
  font-size: 11px;
  font-family: 'DM Mono', monospace;
}

/* ── span helpers ── */
.two-col {
  grid-column: span 2;
}

.col-3 {
  grid-column: span 3;
}

/* ── inner grid (Système) ── */
.section-inner-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.section-inner-grid .shortcut {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 10px 11px;
  margin: 0;
  border: 1px solid var(--rule-light);
  background: var(--paper-2);
}

.section-inner-grid .shortcut:hover {
  background: var(--paper-3);
  margin: 0;
  padding: 10px 11px;
}

.section-inner-grid .shortcut-label {
  font-size: 14px;
}

/* ── navigation 3 colonnes ── */
.shortcut-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
}

.shortcut-grid-3 .shortcut {
  border-bottom: 1px solid var(--rule-light);
  border-right: 1px solid var(--rule-light);
  padding: 10px 12px;
}

.shortcut-grid-3 .shortcut:nth-child(3n) {
  border-right: none;
}

.shortcut-grid-3 .shortcut:last-child,
.shortcut-grid-3 .shortcut:nth-last-child(2),
.shortcut-grid-3 .shortcut:nth-last-child(3) {
  border-bottom: none;
}


.accent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.accent-cell {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  padding: 12px 6px 10px;
  text-align: center;
  transition: background 0.1s;
  cursor: default;
}

.accent-cell:hover {
  background: var(--paper-3);
}

.accent-char {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 30px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 7px;
  display: block;
}

.accent-hint {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--ink-3);
}

.accent-note {
  font-family: 'Source Serif 4', serif;
  font-size: 15px;
  font-style: italic;
  color: var(--ink-3);
  background: var(--paper-2);
  border-left: 3px solid var(--accent);
  padding: 10px 16px;
  line-height: 1.6;
}

.accent-note strong {
  font-style: normal;
  color: var(--ink);
  font-weight: 600;
}

.grid > .accent-note {
  grid-column: 1 / -1;
}

/* ── footer ── */
footer {
  margin-top: 52px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  font-family: 'DM Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  animation: fadeIn 0.5s 0.5s ease both;
  opacity: 0;
  animation-fill-mode: both;
}

/* ── animations ── */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section:nth-child(1) {
  animation-delay: 0.05s;
}

.section:nth-child(2) {
  animation-delay: 0.10s;
}

.section:nth-child(3) {
  animation-delay: 0.15s;
}

.section:nth-child(4) {
  animation-delay: 0.20s;
}

.section:nth-child(5) {
  animation-delay: 0.25s;
}

.section:nth-child(6) {
  animation-delay: 0.30s;
}

/* ── responsive ── */
@media (max-width: 920px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .two-col {
    grid-column: span 2;
  }

  .col-3 {
    grid-column: span 2;
  }
}

@media (max-width: 600px) {
  nav {
    display: none;
  }

  main {
    margin-left: 0 !important;
    padding: 28px 18px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .two-col,
  .col-3 {
    grid-column: span 1;
  }

  .section-inner-grid {
    grid-template-columns: 1fr;
  }

  header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ══════════════════════════════════════
   PRINT
══════════════════════════════════════ */
@media print {
  @page {
    size: A4 portrait;
    margin: 5mm;
  }

  html {
    background: #fff !important;
    background-image: none !important;
  }

  body {
    background: #fff !important;
    background-image: none !important;
    color: #111 !important;
    width: 100% !important;
    padding: 0 20mm !important;
    box-sizing: border-box !important;
  }

  nav,
  .nav-print {
    display: none !important;
  }

  main {
    margin-left: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  .grid {
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .shortcut-label {
    white-space: normal !important;
  }

  .keys {
    flex-wrap: wrap !important;
  }

  header {
    margin-bottom: 5mm;
    padding-bottom: 3mm;
    border-bottom: 1.5px solid #111 !important;
    animation: none !important;
    opacity: 1 !important;
  }

  header h1 {
    font-size: 28px !important;
    color: #111 !important;
  }

  header h1 em {
    color: #444 !important;
  }

  .header-right p {
    color: #888 !important;
    font-size: 9px !important;
  }

  .grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 7px !important;
  }

  .two-col {
    grid-column: span 2 !important;
  }

  .col-3 {
    grid-column: span 2 !important;
  }

  .section {
    border: 1px solid #ccc !important;
    border-top: 2px solid #333 !important;
    padding: 5px 7px !important;
    animation: none !important;
    opacity: 1 !important;
    page-break-inside: avoid;
  }

  .cat-accent {
    border-top-color: #b84c27 !important;
  }

  .cat-systeme {
    border-top-color: #888 !important;
  }

  .section-title {
    font-size: 10px !important;
    color: #777 !important;
    margin-bottom: 4px !important;
    padding-bottom: 4px !important;
    border-bottom: 1px solid #e0e0e0 !important;
  }

  .cat-accent .section-title {
    color: #b84c27 !important;
  }

  .shortcut {
    padding: 4px 0 !important;
    border-bottom: 1px solid #ebebeb !important;
  }

  .shortcut:hover {
    background: none !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin: 0 !important;
  }

  .shortcut-label {
    font-size: 11px !important;
    font-weight: 600 !important;
    color: #111 !important;
  }

  .key {
    font-size: 9px !important;
    padding: 2px 6px !important;
    min-width: 22px !important;
    color: #333 !important;
    background: #f2f2f2 !important;
    border: 1px solid #bbb !important;
    border-bottom: 2px solid #bbb !important;
    border-radius: 2px !important;
  }

  .plus {
    font-size: 8px !important;
    color: #999 !important;
  }

  .section-inner-grid {
    gap: 2px !important;
  }

  .section-inner-grid .shortcut {
    background: #f8f8f8 !important;
    border: 1px solid #e8e8e8 !important;
    padding: 3px 5px !important;
    gap: 2px !important;
  }

  .section-inner-grid .shortcut-label {
    font-size: 10px !important;
  }

  .accent-grid {
    gap: 3px !important;
    grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)) !important;
    margin-bottom: 4px !important;
  }

  .accent-cell {
    background: #f8f8f8 !important;
    border: 1px solid #e0e0e0 !important;
    padding: 3px 2px !important;
  }

  .accent-char {
    font-size: 18px !important;
    margin-bottom: 2px !important;
  }

  .accent-hint {
    font-size: 8px !important;
  }

  .accent-note {
    font-size: 9px !important;
    padding: 4px 6px !important;
    border-left: 2px solid #b84c27 !important;
    background: #fdf9f7 !important;
  }

  .accent-note strong {
    color: #333 !important;
  }

  footer {
    font-size: 8px !important;
    color: #aaa !important;
    margin-top: 4mm !important;
    padding-top: 3px !important;
    animation: none !important;
    opacity: 1 !important;
  }
}