/* =========================================================
   PARTITION MAGIQUE — Design System
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=Quicksand:wght@400;500;600;700&family=Caveat:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Surface */
  --bg: #FBF6EC;            /* warm cream */
  --bg-soft: #F4ECDC;
  --paper: #FFFDF8;
  --ink: #2A2418;           /* warm near-black */
  --ink-soft: #5C5240;
  --ink-mute: #8C8270;
  --line: #E8DEC9;
  --line-strong: #D4C7A8;

  /* The 5 magic colors — finger 1 to 5 */
  --c1: #E86A5C;            /* corail (pouce) */
  --c2: #F4A24A;            /* ambre (index) */
  --c3: #F0CB47;            /* jaune doré (majeur) */
  --c4: #7DB87B;            /* vert sauge (annulaire) */
  --c5: #7B9CD4;            /* bleu lavande (auriculaire) */

  --c1-soft: #FAD9D3;
  --c2-soft: #FBE4C8;
  --c3-soft: #FAF1C4;
  --c4-soft: #D4E6CE;
  --c5-soft: #D4DFEF;

  /* Type */
  --serif: 'DM Serif Display', Georgia, serif;
  --sans: 'Quicksand', system-ui, sans-serif;
  --hand: 'Caveat', cursive;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Page geometry — A4 = 210 × 297 mm @ 96dpi → 794 × 1123 px */
  --page-w: 794px;
  --page-h: 1123px;
  --page-pad: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #E8DEC9;
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Page (A4) ---------- */
.page {
  width: var(--page-w);
  height: var(--page-h);
  background: var(--paper);
  margin: 24px auto;
  padding: var(--page-pad);
  position: relative;
  overflow: hidden;
  box-shadow: 0 24px 60px -20px rgba(60, 40, 10, 0.18),
              0 4px 12px -4px rgba(60, 40, 10, 0.08);
  display: flex;
  flex-direction: column;
}

.page-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Page header (small label + brand) */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
  margin-bottom: 28px;
  flex-shrink: 0;
}

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

.page-header .brand-dots {
  display: inline-flex;
  gap: 3px;
}
.page-header .brand-dots span {
  width: 7px; height: 7px; border-radius: 2px;
}

.page-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
  margin-top: auto;
  padding-top: 24px;
  flex-shrink: 0;
}

.page-num {
  font-family: var(--serif);
  font-size: 24px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-soft);
  line-height: 1;
}
.page-num small {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--ink-mute);
  margin-left: 4px;
}

/* ---------- Type ---------- */
h1, h2, h3 { margin: 0; font-weight: 400; font-family: var(--serif); }

.h-eyebrow {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--c1);
}

.h-display {
  font-family: var(--serif);
  font-size: 88px;
  line-height: 0.92;
  letter-spacing: -0.01em;
}

.h-title {
  font-family: var(--serif);
  font-size: 48px;
  line-height: 1.02;
  letter-spacing: -0.01em;
}

.h-section {
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: -0.005em;
}

.h-sub {
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.15;
}

.text-body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-soft);
  font-weight: 500;
  text-wrap: pretty;
}

.text-lead {
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink-soft);
  font-weight: 500;
  text-wrap: pretty;
}

.hand {
  font-family: var(--hand);
  color: var(--c1);
}

.mono-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
  text-transform: uppercase;
  font-weight: 500;
}

/* ---------- Magic Square (the colored finger square) ---------- */
.sq {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 22px;
  color: #2A2418;
  position: relative;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.08),
              inset 0 1px 0 rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}
.sq.c1 { background: var(--c1); }
.sq.c2 { background: var(--c2); }
.sq.c3 { background: var(--c3); }
.sq.c4 { background: var(--c4); color: #1F2E1E; }
.sq.c5 { background: var(--c5); color: #1A2638; }

.sq-lg { width: 64px; height: 64px; font-size: 30px; border-radius: 12px; }
.sq-xl { width: 88px; height: 88px; font-size: 42px; border-radius: 16px; }
.sq-sm { width: 32px; height: 32px; font-size: 16px; border-radius: 6px; }

/* The legend strip 1-5 */
.legend {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ---------- Score line (a row of squares = a partition line) ---------- */
.score-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.score-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}
.score-row .lyric {
  font-family: var(--hand);
  font-size: 22px;
  color: var(--ink-soft);
  font-weight: 500;
  margin-left: 4px;
  line-height: 1;
}

/* ---------- Decorative star ---------- */
.star {
  display: inline-block;
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2 L14 9 L21 10 L16 15 L17.5 22 L12 18.5 L6.5 22 L8 15 L3 10 L10 9 Z'/></svg>") center/contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2 L14 9 L21 10 L16 15 L17.5 22 L12 18.5 L6.5 22 L8 15 L3 10 L10 9 Z'/></svg>") center/contain no-repeat;
}

/* ---------- Placeholder image (striped) ---------- */
.placeholder {
  position: relative;
  background-image: repeating-linear-gradient(
    -45deg,
    var(--bg-soft) 0,
    var(--bg-soft) 12px,
    var(--bg) 12px,
    var(--bg) 24px
  );
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  color: var(--ink-mute);
  text-align: center;
  padding: 16px;
}
.placeholder .ph-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.placeholder .ph-sub {
  font-family: var(--sans);
  font-size: 12px;
  font-style: italic;
}

/* ---------- Tip / callout box ---------- */
.tip {
  background: var(--bg);
  border-radius: 14px;
  padding: 18px 22px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.tip-mark {
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
}
.tip-mark.c1 { color: var(--c1); }
.tip-mark.c4 { color: var(--c4); }
.tip-mark.c5 { color: var(--c5); }
.tip-body { flex: 1; }
.tip-title {
  font-family: var(--serif);
  font-size: 18px;
  margin-bottom: 4px;
  color: var(--ink);
}

/* ---------- Divider ---------- */
.divider {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 0;
}
.divider-dotted {
  border: 0;
  height: 0;
  border-top: 1.5px dashed var(--line-strong);
  margin: 0;
}

/* ---------- Cut line (scissors) ---------- */
.cut-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-mute);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  margin: 14px 0;
}
.cut-line::before,
.cut-line::after {
  content: '';
  flex: 1;
  border-top: 1.5px dashed var(--line-strong);
}

/* ---------- Two col helpers ---------- */
.row { display: flex; }
.col { display: flex; flex-direction: column; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.gap-24 { gap: 24px; }
.gap-32 { gap: 32px; }

/* ---------- Print ---------- */
@page {
  size: A4;
  margin: 0;
}
@media print {
  html, body { background: white; }
  .page {
    margin: 0;
    box-shadow: none;
    page-break-after: always;
    break-after: page;
    width: 210mm;
    height: 297mm;
  }
  .page:last-child {
    page-break-after: auto;
    break-after: auto;
  }
  .no-print { display: none !important; }

  /* Videos: hide the interactive player, show the poster image */
  .video-embed-screen { display: none !important; }
  .video-embed-print { display: block !important; }
}

/* On screen: show the player, hide the print-only poster */
@media screen {
  .video-embed-print { display: none !important; }
}

/* ---------- Toolbar (no-print) ---------- */
.toolbar {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 50;
  display: flex;
  gap: 8px;
  background: var(--paper);
  padding: 8px;
  border-radius: 12px;
  box-shadow: 0 8px 24px -6px rgba(60, 40, 10, 0.2);
  font-family: var(--sans);
}
.toolbar button {
  border: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.toolbar button.ghost {
  background: var(--bg);
  color: var(--ink);
}

/* ---------- Responsive preview (A4 pages on small screens) ---------- */
/* The .page nodes have fixed 794×1123 px (A4) so they can be print-perfect.
   On small viewports we scale `main` down with CSS `zoom` so the preview fits
   the screen without horizontal scroll. `zoom` (vs. transform) also collapses
   the page heights so the document flow stays compact.
   `zoom` requires a unitless number, so we use stepped breakpoints. */
@media screen and (max-width: 850px) {
  body { padding: 0; }
  main { zoom: 0.95; margin: 0 auto; }
  .page { margin: 12px auto; }
}
@media screen and (max-width: 800px) { main { zoom: 0.88; } }
@media screen and (max-width: 720px) { main { zoom: 0.80; } }
@media screen and (max-width: 640px) { main { zoom: 0.72; } }
@media screen and (max-width: 560px) { main { zoom: 0.62; } }
@media screen and (max-width: 480px) { main { zoom: 0.54; } }
@media screen and (max-width: 420px) { main { zoom: 0.47; } }
@media screen and (max-width: 360px) { main { zoom: 0.42; } }

/* Toolbar mobile-friendly — must come AFTER the base .toolbar rule above */
@media screen and (max-width: 640px) {
  .toolbar {
    top: auto;
    bottom: 12px;
    right: 12px;
    left: 12px;
    justify-content: center;
    padding: 6px;
  }
  .toolbar button {
    padding: 12px 14px;
    font-size: 13px;
    flex: 1;
    max-width: 180px;
  }
  body { padding-bottom: 64px; }
}
