/* Secret Language (Tool 11, prefix sl-) — the four states: the Forge, the Artifact, the Threshold, the Revelation, then the proof.
   Loaded through the `styles:` list in secret-language.njk, so it sits in <head>, BEFORE the tool kit's inline <style> blocks.
   Rules are scoped `.sl .x`; where one restyles a kit class it adds a class (`.sl .input.sl-text`, `.sl .rk-bento.sl-bento`) so it outranks the
   kit's `.tk .x`. Token overrides use `.tk.sl`. Depends on tokens.css, partials/tool-kit-css.njk and partials/result-kit-css.njk.

   The page accent is Cinnabar (--c-accent). The one dark surface is the night ink of the share card: the Moon Script plates and the Threshold
   sit on it, so the lock always looks like the card. The runes take their colours from two custom properties (--rune-ink, --rune-accent). */
.tk.sl {
  --tk-accent: var(--accent-love, #E11D48);
  --tone-flow: #0284C7;
  --tone-friction: #D97706;
  --tone-fusion: #7C3AED;
  --tone-quiet: #94A3B8;
  --night: #0B1020;
  --night-raised: #141B30;
  --on-night: #F8FAFC;
  --on-night-muted: #94A3B8;
  --on-night-soft: #CBD5E1;
  --night-accent: #FB7185;
  --rune-ink: var(--on-night);
  --rune-accent: var(--night-accent);
}

/* ---- the rune colour roles (core/moon-glyph.js writes classes, not colours) ---- */
.sl .g-stroke-ink { stroke: var(--rune-ink); }
.sl .g-fill-ink { fill: var(--rune-ink); }
.sl .g-stroke-accent { stroke: var(--rune-accent); }
.sl .g-fill-accent { fill: var(--rune-accent); }

/* ---- shapes: colour never works alone ---- */
.sl .sl-sh { display: inline-block; flex: none; width: 11px; height: 11px; background: var(--tone); }
.sl .sl-sh.fusion { --tone: var(--tone-fusion); border-radius: 50%; }
.sl .sl-sh.flow { --tone: var(--tone-flow); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.sl .sl-sh.friction { --tone: var(--tone-friction); border-radius: 2px; }
.sl .sl-sh.quiet { --tone: var(--tone-quiet); background: transparent; border: 2.5px solid var(--tone); border-radius: 50%; }

.sl .sl-kick { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--c-accent-ink); margin-bottom: 4px; }
.sl .sl-kick.on-ink { color: var(--night-accent); }
.sl .sl-stage { max-width: 760px; margin: 0 auto 20px; container: slstage / inline-size; }
.sl .sl-notice { max-width: 760px; margin: 0 auto 16px; }
.sl .sl-stage > [hidden] { display: none; }

/* ================= State 1: the Forge ================= */
.sl .sl-forge { padding: 22px 16px 20px; }
@media (min-width: 720px) { .sl .sl-forge { padding: 32px 36px 26px; } }
.sl .input.sl-text { height: auto; min-height: 136px; padding: 12px 14px; line-height: 1.5; resize: vertical; font-size: 1.0625rem; }
.sl .sl-count { justify-self: end; font-size: 0.8125rem; font-weight: 600; color: var(--c-muted); }
.sl .sl-count.is-near { color: var(--tone-friction); }
.sl .sl-count.is-over { color: #9F1239; }
.sl .sl-keyrow { display: flex; gap: 8px; }
.sl .sl-keyrow .input { flex: 1 1 auto; min-width: 0; font-family: var(--font-ui); letter-spacing: 0.02em; }
.sl .sl-eye { height: 48px; flex: none; min-width: 48px; justify-content: center; }
@media (max-width: 420px) { .sl .sl-eye span { display: none; } .sl .sl-eye { padding: 0; } }

.sl .sl-strength { display: flex; align-items: center; gap: 12px; margin-top: 2px; font-size: 0.8125rem; }
.sl .sl-strength-label { font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--c-muted); font-size: 0.6875rem; }
.sl .sl-meter { display: grid; grid-template-columns: repeat(4, 34px); gap: 4px; }
.sl .sl-meter i { display: block; height: 6px; border-radius: 999px; background: #E6EBF1; }
.sl .sl-strength[data-level="1"] .sl-meter i:nth-child(-n+1) { background: #E11D48; }
.sl .sl-strength[data-level="2"] .sl-meter i:nth-child(-n+2) { background: var(--tone-friction); }
.sl .sl-strength[data-level="3"] .sl-meter i:nth-child(-n+3) { background: var(--tone-flow); }
.sl .sl-strength[data-level="4"] .sl-meter i:nth-child(-n+4) { background: var(--tone-flow); }
.sl .sl-strength-name { font-weight: 800; }

/* the live transliteration: a plate on night ink */
.sl .sl-preview { margin-top: 22px; padding: 16px 16px 14px; border-radius: var(--r-box); background: var(--night); color: var(--on-night); position: relative; overflow: hidden; }
.sl .sl-preview::before { content: ""; position: absolute; inset: -40% -10% auto auto; width: 70%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--night-accent) 22%, transparent), transparent); pointer-events: none; }
.sl .sl-preview-head { position: relative; display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 2px 12px; }
.sl .sl-preview-head h3 { font-size: 1.0625rem; font-weight: 800; letter-spacing: -0.01em; color: var(--on-night); }
.sl .sl-preview-body { position: relative; margin-top: 12px; min-height: 96px; max-height: 420px; overflow-y: auto; padding: 4px 2px; }
.sl .sl-preview-body .sl-script { display: block; width: 100%; height: auto; }
.sl .sl-preview-body.is-empty .sl-script { opacity: 0.22; }
.sl .sl-preview-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 8px; text-align: center; font-size: 0.9375rem; font-weight: 700; color: var(--on-night-soft); }
.sl .sl-preview-note { position: relative; margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(217, 119, 6, 0.14); color: #FBBF24; font-size: 0.8125rem; font-weight: 600; }
.sl .sl-preview-sub { position: relative; margin-top: 10px; font-size: 0.8125rem; line-height: 1.45; color: var(--on-night-muted); }
.sl .sl-go { display: flex; }
.sl .sl-foot { margin-top: 10px; text-align: center; }
.sl .sl-forge .form-error { margin-top: 16px; }
.sl .sl-forge .btn[disabled] { opacity: 0.7; cursor: progress; }

/* ================= State 2: the Artifact ================= */
.sl .sl-artifact { container: slart / inline-size; padding: 20px 16px; text-align: center; }
@media (min-width: 720px) { .sl .sl-artifact { padding: 32px 36px 28px; } }
.sl .sl-art-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; text-align: left; }
.sl .sl-art-top .sl-kick { margin: 0; }
.sl .sl-badge { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px 0 12px; border-radius: 999px; background: var(--c-accent); color: #fff; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--c-accent) 80%, transparent); }
.sl .sl-badge svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sl .sl-badge.on-ink { background: var(--night-accent); color: var(--night); }

.sl .sl-plate { position: relative; margin-top: 16px; padding: 22px 18px; border-radius: 18px; background: var(--night); border: 1px solid color-mix(in srgb, var(--night-accent) 38%, transparent); overflow: hidden; }
.sl .sl-plate::before { content: ""; position: absolute; inset: -30% auto auto 50%; width: 90%; aspect-ratio: 1; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--night-accent) 20%, transparent), transparent); pointer-events: none; }
.sl .sl-plate .sl-script { position: relative; display: block; width: min(100%, 560px); height: auto; margin: 0 auto; }
.sl .sl-seal { margin-top: 12px; font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.06em; color: var(--c-muted); }
.sl .sl-verdict { margin-top: 14px; font-size: clamp(2.75rem, 15cqw, 5.5rem); font-weight: 800; letter-spacing: -0.045em; line-height: 1; text-wrap: balance; color: var(--c-ink); outline: none; }
.sl .sl-vw { display: inline-block; }
.sl .sl-vw.hl > span {
  display: inline-block; margin-left: -0.05em; padding: 0 0.07em; border-radius: 0.08em;
  background: linear-gradient(transparent 52%, color-mix(in srgb, var(--c-accent) 38%, #fff) 52%, color-mix(in srgb, var(--c-accent) 38%, #fff) 93%, transparent 93%) no-repeat 0 0 / 100% 100%;
}
.sl .sl-drive { margin: 14px auto 0; max-width: 26ch; font-size: clamp(1.25rem, 1rem + 1.4vw, 1.75rem); font-weight: 800; letter-spacing: -0.025em; line-height: 1.15; text-wrap: balance; }

.sl .sl-link { margin-top: 26px; text-align: left; }
.sl .sl-link label { display: block; margin-bottom: 8px; font-weight: 700; font-size: 0.9375rem; }
.sl .sl-linkrow { display: flex; gap: 8px; }
.sl .sl-linkrow .input { flex: 1 1 auto; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8125rem; color: #334155; background: #F8FAFC; text-overflow: ellipsis; }
.sl .sl-linkrow .btn-sm { height: 48px; flex: none; }
.sl .sl-link .hint { margin-top: 8px; }
.sl .sl-link .warn { color: #B45309; font-weight: 700; }

.sl .sl-steps { list-style: none; counter-reset: sl; margin-top: 22px; padding: 14px 16px; border-radius: var(--r-box); background: #F8FAFC; border: 1px solid var(--c-line); text-align: left; display: grid; gap: 8px; }
.sl .sl-steps-k { font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--c-muted); }
.sl .sl-steps li { counter-increment: sl; display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: baseline; font-size: 0.9375rem; font-weight: 600; }
.sl .sl-steps li::before { content: "0" counter(sl); font-weight: 800; font-size: 0.8125rem; color: var(--c-accent-ink); font-variant-numeric: tabular-nums; }
.sl .sl-actions { justify-content: center; }
.sl .sl-warn { margin-top: 16px; font-size: 0.8125rem; font-weight: 600; color: var(--c-muted); }

/* ================= State 3: the Threshold ================= */
.sl .sl-threshold { border-radius: var(--r-card); background: var(--night); color: var(--on-night); padding: 28px 16px 24px; text-align: center; position: relative; overflow: hidden; }
@media (min-width: 720px) { .sl .sl-threshold { padding: 44px 48px 36px; } }
.sl .sl-threshold::before { content: ""; position: absolute; inset: -20% -10% auto -10%; height: 70%; background: radial-gradient(closest-side at 50% 40%, color-mix(in srgb, var(--night-accent) 18%, transparent), transparent); pointer-events: none; }
.sl .sl-th { position: relative; max-width: 520px; margin: 0 auto; display: grid; justify-items: center; }
.sl .sl-th .sl-plate { width: 100%; margin-top: 18px; background: var(--night-raised); }
.sl .sl-th .sl-seal { color: var(--on-night-muted); }
.sl .sl-th-title { margin-top: 18px; font-size: clamp(2.25rem, 8cqw + 1rem, 3.75rem); font-weight: 800; letter-spacing: -0.04em; line-height: 1; outline: none; color: var(--on-night); }
.sl .sl-th-sub { margin-top: 12px; max-width: 36ch; font-size: 1rem; color: var(--on-night-soft); }
.sl .sl-th-form { width: 100%; margin-top: 24px; text-align: left; }
.sl .sl-th .input { background: var(--night-raised); border-color: rgba(248, 250, 252, 0.22); color: var(--on-night); height: 52px; font-size: 1.0625rem; }
.sl .sl-th .input::placeholder { color: var(--on-night-muted); }
.sl .sl-th .input:hover:not(:disabled) { border-color: rgba(248, 250, 252, 0.5); }
.sl .sl-th .input:focus { border-color: var(--night-accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--night-accent) 28%, transparent); }
.sl .sl-th .sl-eye { height: 52px; background: var(--night-raised); border-color: rgba(248, 250, 252, 0.22); color: var(--on-night); }
.sl .sl-th .sl-eye:hover:not(:disabled) { background: color-mix(in srgb, var(--night-accent) 16%, var(--night-raised)); }
.sl .sl-th-error { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: rgba(251, 113, 133, 0.12); border: 1px solid rgba(251, 113, 133, 0.4); color: #FDA4AF; font-size: 0.9375rem; font-weight: 700; }
.sl .sl-th-go { margin-top: 14px; background: var(--night-accent); color: var(--night); }
.sl .sl-th-go[disabled] { opacity: 0.7; cursor: progress; }
.sl .sl-th-hint { margin-top: 14px; max-width: 40ch; font-size: 0.8125rem; line-height: 1.45; color: var(--on-night-muted); }
.sl .sl-th-links { margin-top: 18px; padding-top: 14px; border-top: 1px solid rgba(248, 250, 252, 0.12); width: 100%; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 22px; }
.sl .sl-th-link { all: unset; box-sizing: border-box; cursor: pointer; display: grid; gap: 1px; font-size: 0.9375rem; font-weight: 800; color: var(--on-night); border-bottom: 1px solid transparent; }
.sl .sl-th-link small { font-size: 0.75rem; font-weight: 600; color: var(--on-night-muted); }
.sl .sl-th-link:hover { border-bottom-color: var(--night-accent); }
.sl .sl-th-link:focus-visible { outline: 3px solid color-mix(in srgb, var(--night-accent) 60%, transparent); outline-offset: 3px; border-radius: 4px; }

/* ================= State 4: the Revelation ================= */
.sl .sl-reveal { --rune-ink: var(--c-ink); --rune-accent: var(--c-accent); padding: 22px 16px 20px; }
@media (min-width: 720px) { .sl .sl-reveal { padding: 32px 36px 26px; } }
.sl .sl-rv-title { margin-top: 2px; font-size: 1.0625rem; font-weight: 800; letter-spacing: -0.01em; outline: none; }
.sl .sl-msg { margin-top: 18px; padding: 22px 6px 24px; border-top: 1px solid var(--c-line); border-bottom: 1px solid var(--c-line); }
.sl .sl-msg-text { font-size: clamp(1.875rem, 1.2rem + 3vw, 3.25rem); font-weight: 800; letter-spacing: -0.035em; line-height: 1.12; overflow-wrap: anywhere; text-wrap: pretty; color: var(--c-ink); }
.sl .sl-w { display: inline-block; white-space: nowrap; }
.sl .sl-ch { position: relative; display: inline-block; }
.sl .sl-ch .sl-r { display: none; }
.sl .sl-rv-sub { margin-top: 14px; font-size: 0.875rem; font-weight: 600; color: var(--c-muted); }
.sl .sl-reveal .rk-actions { justify-content: flex-start; }

/* ================= The proof ================= */
.sl .sl-proof { max-width: 760px; margin: 0 auto 20px; }
.sl .rk-bento.sl-bento { grid-template-columns: minmax(0, 1fr); margin-top: 14px; }
@media (min-width: 640px) { .sl .rk-bento.sl-bento { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.sl .sl-tile { --tone: var(--tone-quiet); border-top: 3px solid var(--tone); }
.sl .sl-tile.flow { --tone: var(--tone-flow); }
.sl .sl-tile.fusion { --tone: var(--tone-fusion); }
.sl .sl-tile.friction { --tone: var(--tone-friction); }
.sl .sl-tile h3 { display: flex; align-items: center; gap: 8px; }
.sl .sl-tile p { margin-top: 10px; font-size: 0.9375rem; font-weight: 600; line-height: 1.4; letter-spacing: -0.005em; }
.sl .sl-limits { margin-top: 16px; padding: 12px 14px; border-radius: var(--r-box); background: #FFF7ED; border: 1px solid #FED7AA; color: #7C2D12; font-size: 0.875rem; font-weight: 600; line-height: 1.45; }
.sl .sl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 18px; }
.sl .sl-atable { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.sl .sl-atable caption { text-align: left; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--c-muted); padding-bottom: 6px; }
.sl .sl-atable th, .sl .sl-atable td { padding: 8px; text-align: left; border-top: 1px solid var(--c-line); font-weight: 500; vertical-align: top; }
.sl .sl-atable thead th { border-top: 0; font-size: 0.6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--c-muted); }
.sl .sl-atable tbody th { font-weight: 800; white-space: nowrap; }
.sl .sl-atable td.num { font-weight: 800; white-space: nowrap; }
.sl .sl-anatomy-total { margin-top: 8px; font-size: 0.8125rem; font-weight: 700; color: var(--c-muted); }
.sl .sl-alpha { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--c-line); --rune-ink: var(--c-ink); --rune-accent: var(--c-accent); }
.sl .sl-alpha summary { cursor: pointer; font-size: 0.9375rem; font-weight: 700; color: var(--c-accent-ink); min-height: 32px; }
.sl .sl-alpha-h { margin-top: 12px; font-size: 1.0625rem; font-weight: 800; }
.sl .sl-alpha-sub, .sl .sl-alpha-note { margin-top: 8px; font-size: 0.875rem; line-height: 1.45; color: #475569; max-width: 70ch; }
.sl .sl-alpha-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-top: 14px; }
@media (min-width: 640px) { .sl .sl-alpha-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); } }
.sl .sl-cell { margin: 0; padding: 8px 4px 6px; border: 1px solid var(--c-line); border-radius: 10px; background: #F8FAFC; text-align: center; }
.sl .sl-mini { display: block; width: 100%; max-width: 34px; height: auto; margin: 0 auto; }
.sl .sl-cell figcaption { margin-top: 4px; font-size: 0.8125rem; font-weight: 800; }
.sl .sl-nexts { max-width: 760px; margin: 0 auto; display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .sl .sl-nexts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---- Motion: the state rises in, the plate settles, a wrong key shakes the seal, the message resolves rune by rune ---- */
@keyframes sl-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes sl-plate { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes sl-shake { 0%, 100% { transform: none; } 18% { transform: translateX(-9px); } 36% { transform: translateX(8px); } 54% { transform: translateX(-5px); } 72% { transform: translateX(3px); } }
@keyframes sl-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@keyframes sl-seal-out { from { opacity: 1; transform: translate(-50%, -50%) scale(1); } to { opacity: 0; transform: translate(-50%, -50%) scale(0.8); } }
@keyframes sl-true { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); } 35%, 62% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.15); } }
@keyframes sl-plain { from { opacity: 0; filter: blur(5px); } to { opacity: 1; filter: none; } }
@media (prefers-reduced-motion: no-preference) {
  .sl .sl-stage > .is-in { animation: sl-in 0.25s var(--ease) both; }
  .sl .sl-plate.is-shake { animation: sl-shake 0.3s ease-in-out; }
  .sl .sl-artifact.is-in .sl-plate .sl-script { animation: sl-plate 0.4s var(--ease) 0.05s backwards; }

  /* the sealed rune gives way to the true rune, which gives way to the character, one cell after another */
  .sl .sl-reveal.is-open .sl-ch .sl-r { display: block; position: absolute; left: 50%; top: 50%; height: 1.05em; width: auto; opacity: 0; pointer-events: none; transform: translate(-50%, -50%); }
  .sl .sl-reveal.is-open .sl-ch .sl-r-seal { animation: sl-seal-out 0.35s ease-in calc(var(--i) * var(--step)) both; opacity: 1; }
  .sl .sl-reveal.is-open .sl-ch .sl-r-true { animation: sl-true 0.8s ease-in-out calc(var(--i) * var(--step) + 0.2s) both; }
  .sl .sl-reveal.is-open .sl-ch .sl-t { animation: sl-plain 0.4s ease-out calc(var(--i) * var(--step) + 0.7s) both; }
}
