/* Section 02-writing — fichier propre à la section (base commune : ../styles.css).
   « Le studio d'écriture », porte d'entrée du produit, mis en scène comme un bureau de nuit :
   - en-tête : le titre (« vraiment » souligné à la plume) face à un manuscrit vivant posé sur
     une pile de feuillets (vers tapés, syllabes découpées en pastilles, rime reliée par un fil) ;
   - scène : la vraie démo du studio, inclinée vers les atouts, sous une aura tournante ; des fils
     lumineux (dessinés par js/02-writing.js) la relient aux quatre atouts, chacun avec son glyphe.
   Avec « réduire les animations » : tout est figé dans son état final (vers écrits, fils tracés). */

.writing { position: relative; overflow: hidden; isolation: isolate;
  background:
    linear-gradient(var(--canvas), transparent 160px), /* fondu depuis l'en-tête : pas de marche de couleur */
    radial-gradient(40% 38% at 84% 12%, rgb(0 194 180 / 13%), transparent 70%),
    radial-gradient(46% 42% at 10% 70%, rgb(167 139 250 / 10%), transparent 70%),
    radial-gradient(36% 30% at 70% 88%, rgb(26 255 234 / 6%), transparent 70%),
    linear-gradient(180deg, var(--canvas) 0%, #0A0D11 55%, var(--canvas) 100%); }

/* ------------------------------------------------------------------ ciel et lignes de cahier */
.writing-sky { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.writing-stars { opacity: .42; }
.writing-stars::after { transform: translate(-9%, 31%) scale(1.25); }
.writing-ruled { position: absolute; inset: 34% 0 0;
  background: repeating-linear-gradient(to bottom, transparent 0 47px, rgb(120 133 153 / 8%) 47px 48px);
  -webkit-mask-image: radial-gradient(70% 60% at 50% 45%, #000 20%, transparent 75%);
  mask-image: radial-gradient(70% 60% at 50% 45%, #000 20%, transparent 75%); }
.writing-ruled::before { content: ""; position: absolute; top: 0; bottom: 0; left: max(var(--gutter), calc(50% - 600px + var(--gutter) - 26px)); width: 1px;
  background: linear-gradient(to bottom, transparent, rgb(167 139 250 / 35%) 25%, rgb(167 139 250 / 35%) 75%, transparent); }

/* ------------------------------------------------------------------ en-tête : titre et manuscrit */
.writing-head { display: grid; gap: 44px; grid-template-columns: minmax(0, 1fr); align-items: end; }
@media (min-width: 1080px) { .writing-head { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 56px; } }
@media (min-width: 1280px) { .writing-head { grid-template-columns: minmax(0, 1.18fr) minmax(0, .9fr); gap: 72px; } }

.writing-eyebrow { display: inline-flex; align-items: center; gap: 10px; }
.writing-nib { width: 22px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--brand-bright)); box-shadow: 0 0 10px rgb(26 255 234 / 60%); }
.writing-title { font-size: clamp(32px, 4.4vw, 54px); line-height: 1.06; letter-spacing: -0.025em; max-width: 19ch; }
.writing-ink { position: relative; white-space: nowrap; color: transparent;
  background: linear-gradient(100deg, var(--fg) 0%, var(--brand-bright) 45%, #9ff7ee 70%, var(--fg) 100%) 0 0 / 220% 100%;
  -webkit-background-clip: text; background-clip: text; }
.writing-ink-line { position: absolute; left: -3%; bottom: -.16em; width: 106%; height: .36em; overflow: visible; pointer-events: none; }
.writing-ink-line path { fill: none; stroke: var(--brand-bright); stroke-width: 3.2; stroke-linecap: round; vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 6px rgb(26 255 234 / 70%)); stroke-dasharray: 1; stroke-dashoffset: 0; }
.js .writing-title .writing-ink-line path { stroke-dashoffset: 1; transition: stroke-dashoffset 1.1s cubic-bezier(.6,.1,.2,1) .75s; }
.js .writing-title.is-visible .writing-ink-line path { stroke-dashoffset: 0; }
.js .writing-title.is-visible .writing-ink { animation: writing-ink-shine 7s ease-in-out 1.4s infinite; }
@keyframes writing-ink-shine { 0%, 100% { background-position: 0 0; } 50% { background-position: 100% 0; } }

/* Manuscrit posé sur une pile de feuillets (les feuillets = pseudo-éléments de l'enveloppe) */
.ms-col { width: 100%; max-width: 500px; justify-self: start; }
@media (min-width: 1080px) { .ms-col { justify-self: end; margin-bottom: 6px; } }
.ms-wrap { position: relative; isolation: isolate; }
.ms-wrap::before, .ms-wrap::after { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: var(--radius);
  border: 1px solid var(--border); background: linear-gradient(180deg, #1A1F28, #12161C); }
.ms-wrap::before { transform: rotate(-5deg) translate(-14px, 14px); opacity: .45; }
.ms-wrap::after { transform: rotate(2.6deg) translate(10px, 9px); opacity: .75; box-shadow: 0 30px 60px rgb(0 0 0 / 45%); }

.manuscript { padding: 18px 22px 18px 18px; border-radius: var(--radius); border: 1px solid var(--border-strong); font-variant-numeric: tabular-nums;
  background:
    repeating-linear-gradient(to bottom, transparent 0 31px, rgb(120 133 153 / 7%) 31px 32px),
    radial-gradient(90% 70% at 100% 0%, rgb(0 194 180 / 10%), transparent 70%),
    linear-gradient(180deg, #1C212B, #151920);
  box-shadow: 0 34px 80px rgb(0 0 0 / 60%), 0 0 0 1px rgb(0 194 180 / 10%), inset 0 1px 0 rgb(255 255 255 / 4%); }
.typer-head { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; column-gap: 14px; padding-bottom: 8px;
  font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--subtle); }
.typer-head span:first-child { grid-column: 2; }
.ms-lines { position: relative; }
.typer-line { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; column-gap: 14px; align-items: start; padding: 14px 0 13px; border-top: 1px dashed var(--border); }
.ms-num { padding-top: .45em; font-size: 12px; color: var(--subtle); text-align: right; }
.ms-verse { min-width: 0; padding-right: 34px; border-left: 1px solid rgb(167 139 250 / 28%); padding-left: 12px; }
.typer-text { display: block; min-height: 1.45em; font-size: clamp(17px, 1.75vw, 21px); line-height: 1.45; font-weight: 500; letter-spacing: -.005em; }
.typer-text .caret { display: inline-block; width: 2px; height: 1.05em; margin-left: 2px; vertical-align: -3px; background: var(--brand-bright);
  box-shadow: 0 0 8px var(--brand-bright); animation: writing-blink 1s steps(1) infinite; }
/* La rime, ce qu'on doit voir le mieux : « en » (avant-dernière syllabe) en orange modéré,
   « dre » (dernière) en cyan vif, la plus lumineuse de la ligne. Chacune s'allume quand elle est tapée. */
.typer-text .rhyme { font-weight: 700; }
.typer-text .rh-pre, .typer-text .rh-end { color: var(--fg); transition: color .45s, text-shadow .45s; }
.typer-text .rh-pre.is-lit { color: var(--warm); text-shadow: 0 0 10px rgb(255 136 79 / 50%); }
.typer-text .rh-end.is-lit { color: #B8FFF8;
  text-shadow: 0 0 6px rgb(26 255 234 / 90%), 0 0 16px rgb(26 255 234 / 65%), 0 0 30px rgb(26 255 234 / 35%); }
@keyframes writing-blink { 50% { opacity: 0; } }

/* Découpage en syllabes : une pastille par syllabe. Syllabes ordinaires en retrait, rime éclairée
   (orange puis cyan plein). Non comptée (e muet, e élidé) : petit trait sous la pastille, repris dans la légende. */
.ms-cut { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 9px; padding-bottom: 5px; }
.ms-cut i { position: relative; font-style: normal; font-size: 11px; line-height: 1; padding: 4px 5px 5px; border-radius: 6px; border: 1px solid var(--border);
  color: var(--subtle); background: rgb(13 16 20 / 55%); transition: color .3s, border-color .3s, background-color .3s, box-shadow .3s, transform .3s; }
.ms-cut b { font-weight: inherit; }
.ms-cut i.on { color: #BDEDE8; border-color: rgb(26 255 234 / 24%); background: rgb(0 194 180 / 8%); }
.ms-cut i.mute.on { border-style: dashed; color: var(--subtle); border-color: var(--border-strong); background: transparent; }
.ms-cut i.mute::after, .ms-mute-mark { content: ""; width: 8px; height: 2px; border-radius: 2px; background: var(--muted); opacity: .75; }
.ms-cut i.mute::after { position: absolute; left: 50%; bottom: -6px; translate: -50% 0; opacity: 0; transition: opacity .3s; }
.ms-cut i.mute.on::after { opacity: .75; }
.ms-cut i.rh-pre.on { color: #FFC4A6; font-weight: 600; border-color: rgb(255 136 79 / 60%); background: rgb(255 136 79 / 16%);
  box-shadow: 0 0 12px rgb(255 136 79 / 30%); }
.ms-cut i.rh-pre.on b { color: var(--warm); text-shadow: 0 0 8px rgb(255 136 79 / 55%); }
.ms-cut i.rh-end.on { color: var(--canvas-deep); font-weight: 700; border-style: solid; border-color: #B8FFF7; background: var(--brand-bright);
  box-shadow: 0 0 10px rgb(26 255 234 / 75%), 0 0 22px rgb(26 255 234 / 40%); }

.typer-count { min-width: 2ch; text-align: right; font-size: 30px; line-height: 1.1; font-weight: 700; color: var(--accent);
  text-shadow: 0 0 20px rgb(196 240 0 / 35%); }

/* Fil de la rime, tracé par le script entre les deux terminaisons */
.ms-arc { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.ms-arc path { fill: none; stroke-linecap: round; }
.ms-arc-glow { stroke: rgb(26 255 234 / 22%); stroke-width: 6; filter: blur(3px); opacity: 0; transition: opacity .8s .5s; }
.ms-arc-line { stroke: var(--brand-bright); stroke-width: 1.6; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 1s cubic-bezier(.6,.1,.2,1); }
.ms-arc-dot { fill: var(--brand-bright); opacity: 0; transition: opacity .4s; filter: drop-shadow(0 0 5px var(--brand-bright)); }
.manuscript.is-done .ms-arc-line { stroke-dashoffset: 0; }
.manuscript.is-done .ms-arc-glow, .manuscript.is-done .ms-arc-dot { opacity: 1; }
.manuscript.is-done .ms-arc-dot:last-of-type { transition-delay: .9s; }

.typer-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 4px; padding-top: 12px; border-top: 1px dashed var(--border);
  font-size: 13px; color: var(--muted); transition: opacity .6s, transform .6s; }
.js .manuscript:not(.is-done) .typer-foot { opacity: 0; transform: translateY(4px); }
/* Légende du comptage, sous la pile de feuillets (qui déborde d'une quinzaine de pixels vers le bas) */
.ms-legend { display: flex; align-items: baseline; gap: 9px; margin-top: 30px; padding-left: 4px; font-size: 12.5px; line-height: 1.5; color: var(--subtle); }
.ms-legend em { font-style: italic; color: var(--muted); }
.ms-mute-mark { flex: none; display: inline-block; translate: 0 -3px; }
.rhyme-chip { display: inline-block; padding: 2px 9px; border-radius: 7px; background: var(--brand-deep); color: var(--brand-bright); font-weight: 600;
  border: 1px solid rgb(26 255 234 / 30%); box-shadow: 0 0 14px rgb(0 194 180 / 25%); }

/* ------------------------------------------------------------------ scène : démo et atouts */
.writing-stage { position: relative; margin-top: clamp(64px, 9vw, 120px); display: grid; gap: 56px; grid-template-columns: minmax(0, 1fr); align-items: center; }
@media (min-width: 1080px) { .writing-stage { grid-template-columns: minmax(0, 1.34fr) minmax(0, 1fr); gap: 92px; } }

.writing-threads { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 0; display: none; }
@media (min-width: 1080px) { .writing-threads { display: block; } }
.writing-threads path { fill: none; stroke-linecap: round; }
.thread-base { stroke: url(#wr-thread-grad); stroke-width: 1.3; stroke-dasharray: 1; stroke-dashoffset: 0; }
.thread-pulse { stroke: var(--brand-bright); stroke-width: 2.4; stroke-dasharray: .07 1.2; stroke-dashoffset: .07; opacity: 0;
  filter: drop-shadow(0 0 4px rgb(26 255 234 / 90%)); }
.js .writing-threads .thread-base { stroke-dashoffset: 1; transition: stroke-dashoffset 1.4s cubic-bezier(.6,.1,.2,1); transition-delay: calc(var(--i, 0) * 160ms + .5s); }
.js .writing-threads.is-drawn .thread-base { stroke-dashoffset: 0; }
.writing-threads.is-drawn .thread-pulse { opacity: 1; animation: writing-pulse 5.2s cubic-bezier(.5,0,.5,1) infinite; animation-delay: calc(var(--i, 0) * 1.3s + 2s); }
@keyframes writing-pulse { 0% { stroke-dashoffset: .07; } 55%, 100% { stroke-dashoffset: -1.13; } }

/* La démo : inclinée vers les atouts, aura tournante, reflet au sol */
.demo-stage { position: relative; z-index: 1; }
.demo-tilt { position: relative; max-width: 680px; margin: 0 auto; }
@media (min-width: 1080px) { .demo-tilt { margin: 0; transform: perspective(1500px) rotateY(9deg) rotateX(2deg); transform-origin: 30% 50%; } }
.demo-aura { position: absolute; inset: -14% -10%; z-index: -1; border-radius: 50%; opacity: .55; filter: blur(46px); will-change: transform;
  background: conic-gradient(from 0deg, rgb(0 194 180 / 0%), rgb(0 194 180 / 70%) 12%, rgb(0 194 180 / 0%) 28%, rgb(167 139 250 / 60%) 46%, rgb(167 139 250 / 0%) 60%, rgb(26 255 234 / 55%) 78%, rgb(0 194 180 / 0%) 92%);
  animation: writing-aura 22s linear infinite; }
@keyframes writing-aura { to { transform: rotate(1turn); } }
.demo-floor { position: absolute; left: 8%; right: 8%; bottom: -46px; height: 60px; z-index: -1; border-radius: 50%;
  background: radial-gradient(closest-side, rgb(0 194 180 / 32%), transparent); filter: blur(8px); }

.demo-window { overflow: hidden; border-radius: 18px; border: 1px solid var(--border-strong); background: var(--surface);
  box-shadow: 0 40px 100px rgb(0 0 0 / 65%), 0 0 0 1px rgb(26 255 234 / 14%), 0 0 70px rgb(0 194 180 / 14%); }
/* Liseré tournant autour de la fenêtre */
.demo-window::after { content: ""; position: absolute; inset: 0; z-index: 2; border-radius: inherit; padding: 1px; pointer-events: none;
  background: conic-gradient(from var(--wr-angle, 0deg), transparent 0 62%, rgb(26 255 234 / 85%) 74%, rgb(167 139 250 / 70%) 82%, transparent 92%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: writing-border 8s linear infinite; }
@property --wr-angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes writing-border { to { --wr-angle: 360deg; } }
.demo-bar { display: flex; align-items: center; gap: 7px; padding: 11px 14px; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #252B36, var(--elevated)); }
.demo-bar span { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); }
.demo-bar span:first-child { background: rgb(255 136 79 / 75%); }
.demo-bar span:nth-child(2) { background: rgb(196 240 0 / 60%); }
.demo-bar span:nth-child(3) { background: rgb(0 194 180 / 75%); }
.demo-bar em { margin-left: 8px; font-style: normal; font-size: 12px; color: var(--muted); letter-spacing: .02em; }
.demo-screen { position: relative; background: #0E1116; }
.demo-screen video { width: 100%; aspect-ratio: 460 / 348; object-fit: cover; }
.demo-screen::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 40px rgb(0 0 0 / 35%); }
.demo-window figcaption { display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-size: 13px; color: var(--muted);
  border-top: 1px solid var(--border); background: var(--surface); }
.demo-live { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--warm); box-shadow: 0 0 10px var(--warm); animation: writing-live 2.2s ease-in-out infinite; }
@keyframes writing-live { 50% { opacity: .35; } }

/* Les atouts : un nœud lumineux (point d'arrivée d'un fil) et son glyphe */
.features { position: relative; z-index: 1; list-style: none; display: grid; gap: 30px; }
.features li { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 18px; align-items: start; }
.feat-node { position: relative; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
  color: var(--brand-bright); background: radial-gradient(circle at 35% 30%, #1E3A3A, #0F1418 70%);
  border: 1px solid rgb(26 255 234 / 32%); box-shadow: 0 0 0 5px rgb(0 194 180 / 6%), 0 0 26px rgb(0 194 180 / 22%), inset 0 0 14px rgb(0 194 180 / 18%);
  transition: box-shadow .35s, transform .35s; }
.features li:hover .feat-node { transform: scale(1.06); box-shadow: 0 0 0 7px rgb(0 194 180 / 10%), 0 0 36px rgb(26 255 234 / 38%), inset 0 0 14px rgb(0 194 180 / 26%); }
.feat-glyph { width: 30px; height: 30px; overflow: visible; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.feat-body h3 { font-size: 19px; letter-spacing: -.005em; }
.feat-body p { margin-top: 6px; color: var(--muted); max-width: 46ch; }
.features li:nth-child(4) .feat-node { color: var(--accent); border-color: rgb(196 240 0 / 32%);
  background: radial-gradient(circle at 35% 30%, #2C3414, #11140C 70%); box-shadow: 0 0 0 5px rgb(196 240 0 / 5%), 0 0 26px rgb(196 240 0 / 16%), inset 0 0 14px rgb(196 240 0 / 12%); }

/* Glyphes */
.glyph-metric rect { fill: currentColor; stroke: none; opacity: .9; transform-box: fill-box; transform-origin: 50% 100%; }
.glyph-metric .g-arc { stroke: var(--violet); }
.glyph-versions .g-sheet { fill: #10161A; }
.glyph-versions .g-sheet-3 { opacity: .45; }
.glyph-versions .g-sheet-2 { opacity: .7; }
.glyph-words path { stroke-width: 1.1; opacity: .7; }
.glyph-words .g-core { fill: currentColor; stroke: none; }
.glyph-words .g-star { fill: #10161A; }
.glyph-choice .g-knob { fill: currentColor; stroke: none; }

@media (prefers-reduced-motion: no-preference) {
  .glyph-metric rect { animation: writing-bar 2.6s ease-in-out infinite; }
  .glyph-metric rect:nth-of-type(2) { animation-delay: -.6s; }
  .glyph-metric rect:nth-of-type(3) { animation-delay: -1.3s; }
  .glyph-metric rect:nth-of-type(4) { animation-delay: -1.9s; }
  .glyph-words .g-star { animation: writing-star 3.4s ease-in-out infinite; }
  .glyph-words .g-star:nth-of-type(3) { animation-delay: -.7s; }
  .glyph-words .g-star:nth-of-type(4) { animation-delay: -1.4s; }
  .glyph-words .g-star:nth-of-type(5) { animation-delay: -2.1s; }
  .glyph-words .g-star:nth-of-type(6) { animation-delay: -2.8s; }
  .glyph-choice .g-knob { animation: writing-knob 6s cubic-bezier(.7,0,.3,1) infinite; }
  .glyph-versions .g-sheet-1 { animation: writing-sheet 5s ease-in-out infinite; }
}
@keyframes writing-bar { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.62); } }
@keyframes writing-star { 0%, 100% { fill: #10161A; } 50% { fill: currentColor; } }
@keyframes writing-knob { 0%, 38% { transform: translateX(0); } 50%, 88% { transform: translateX(12px); } 100% { transform: translateX(0); } }
@keyframes writing-sheet { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-1.5px, 1.5px); } }

/* Moyens écrans : atouts en deux colonnes ; petits écrans : une colonne reliée par un fil vertical */
@media (min-width: 720px) and (max-width: 1079px) { .features { grid-template-columns: 1fr 1fr; gap: 36px 32px; } }
@media (max-width: 719px) {
  .features { gap: 28px; }
  .features::before { content: ""; position: absolute; left: 27px; top: 28px; bottom: 28px; width: 1px; z-index: -1;
    background: linear-gradient(to bottom, rgb(26 255 234 / 55%), rgb(167 139 250 / 40%), rgb(196 240 0 / 45%)); }
  .features li { grid-template-columns: 56px minmax(0, 1fr); gap: 16px; }
  .feat-body h3 { font-size: 18px; }
}
@media (max-width: 479px) {
  .manuscript { padding: 16px 14px 16px 12px; }
  .typer-head, .typer-line { grid-template-columns: 12px minmax(0, 1fr) auto; column-gap: 10px; }
  .ms-verse { padding-left: 10px; padding-right: 26px; }
  .typer-text { font-size: 17px; }
  .typer-count { font-size: 26px; }
  .ms-cut { gap: 3px; }
  .ms-cut i { font-size: 10.5px; padding: 3px 4px 4px; border-radius: 5px; }
  .ms-wrap::before { transform: rotate(-3deg) translate(-6px, 12px); }
  .ms-wrap::after { transform: rotate(1.6deg) translate(5px, 8px); }
  .demo-window { border-radius: 14px; }
}

/* ------------------------------------------------------------------ réduire les animations : état final figé */
@media (prefers-reduced-motion: reduce) {
  .demo-aura, .demo-window::after, .demo-live, .typer-text .caret { animation: none !important; }
  .js .writing-title.is-visible .writing-ink { animation: none; }
  .js .writing-title .writing-ink-line path { stroke-dashoffset: 0; transition: none; }
  .writing-threads .thread-pulse { display: none; }
  .js .writing-threads .thread-base { stroke-dashoffset: 0; transition: none; }
  .ms-arc path, .ms-arc-dot, .typer-foot, .ms-cut i, .ms-cut i::after, .typer-text .rh-pre, .typer-text .rh-end { transition: none; }
}
