/* ==========================================================================
   Hero demo: manuscript image, line polygons on hover, recognized text.
   Ported from the "Laboratoire" mockup. Every rule is scoped to .calfa-demo
   so the Landkit theme is left untouched.
   ========================================================================== */

/* Arabic font, self-hosted subset limited to the characters of the demo page. */
@font-face { font-family: 'Calfa Demo Arabic'; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/demo/ibm-plex-sans-arabic-subset-00.woff2) format('woff2'); unicode-range: U+20, U+621, U+623-624, U+626-63a, U+641-64a, U+654; }

.calfa-demo {
  --night: #0B1B2B;
  --panel: #10263D;
  --panel-2: #14304C;
  --deep: #07131F;
  --on-night: #EAF2FA;
  --muted-n: #9DB4CB;
  --sky: #71ABE0;
  --ochre: #D8A72A;
  --vermilion: #F26D5B;
  --hair-n: rgba(157, 180, 203, .18);
  --hair-n2: rgba(157, 180, 203, .30);
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  min-width: 0;
  color: var(--on-night);
  text-align: left;
  background: transparent;
  border: 1px solid var(--hair-n);
  border-radius: 18px;
  box-shadow: 0 40px 80px -24px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .04);
  overflow: hidden;
}
.calfa-demo img, .calfa-demo svg { display: block; max-width: 100%; }
.calfa-demo p { margin: 0; }
.calfa-demo button { font-family: inherit; }
.calfa-demo button:focus { outline: none; }
.calfa-demo button:focus-visible { outline: 2px solid var(--ochre); outline-offset: 2px; }

/* Script font */
.calfa-demo .f-ar { font-family: 'Calfa Demo Arabic', sans-serif; }


/* Stage: image with the selected line polygon; every line is a hover target */
.calfa-demo .stage { position: relative; margin: 12px 12px 0; background: var(--deep); border-radius: 10px; overflow: hidden; }
.calfa-demo .doc { position: relative; width: 100%; aspect-ratio: var(--ar, 1100 / 634); }
.calfa-demo .doc > picture, .calfa-demo .doc > picture img, .calfa-demo .doc > svg { position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; }
.calfa-demo .doc > picture img { object-fit: fill; }
.calfa-demo .selo polygon { fill: rgba(216, 167, 42, .14); stroke: var(--ochre); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.calfa-demo .hit polygon { fill: transparent; pointer-events: all; cursor: pointer; }
.calfa-demo .hit polygon:hover { fill: rgba(113, 171, 224, .12); stroke: var(--sky); stroke-width: 1.4; vector-effect: non-scaling-stroke; stroke-linejoin: round; }

/* Selected line */
.calfa-demo .bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; margin: 12px; padding: 12px 12px 12px 16px; min-height: 76px; background: var(--deep); border: 1px solid var(--hair-n); border-radius: 10px; }
/* Two columns: line number / transcription, then language label / translation */
.calfa-demo .bar-live { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; align-items: baseline; align-self: start; min-width: 0; transition: transform .45s cubic-bezier(.65, 0, .35, 1), opacity .45s ease; }
/* Autoplay slider: the line leaves to the left, the next one comes in from the right (duration = SLIDE in hero-demo.js) */
/* Horizontal clip only, so the label above a name on the first line is not cut off */
.calfa-demo .bar { overflow-x: clip; }
.calfa-demo .bar-live.is-out { transform: translateX(-110%); opacity: 0; }
.calfa-demo .bar-live.is-in { transform: translateX(110%); opacity: 0; }
.calfa-demo .bar-live.no-anim { transition: none; }
.calfa-demo .bar-num { flex: none; font-family: var(--mono); font-weight: 500; font-size: .75rem; color: var(--ochre); letter-spacing: .03em; }
.calfa-demo .bar-text { min-width: 0; font-size: 1.0625rem; line-height: 1.45; color: var(--on-night); overflow-wrap: anywhere; }
/* Right-to-left scripts (Arabic) are right-aligned */
.calfa-demo .bar-text[dir="rtl"] { text-align: right; }
.calfa-demo .bar-tr { font-size: .875rem; line-height: 1.45; color: var(--muted-n); text-align: left; }
/* Proper names in the transcription and the translation (hidden while still empty during the typing intro) */
.calfa-demo .ent:empty { display: none; }
.calfa-demo .ent { position: relative; padding: 0 3px; white-space: nowrap; border: 1px solid var(--vermilion); border-radius: 3px; color: var(--on-night); }
/* While a text is being typed, its frames are hidden (transparent border, no layout shift) and fade in once it is complete */
.calfa-demo .ent { transition: border-color .4s ease; }
.calfa-demo .is-typing .ent { border-color: transparent; }
.calfa-demo .is-typing .ent[data-label]:hover::after { display: none; }
/* In right-to-left text the label is aligned on the right edge of the name */
.calfa-demo [dir="rtl"] .ent[data-label]:hover::after { left: auto; right: -1px; }
.calfa-demo .ent[data-label]:hover::after { content: attr(data-label); position: absolute; left: -1px; bottom: calc(100% + 4px); z-index: 2; padding: 2px 6px; font: 500 .6875rem/1.3 var(--mono); letter-spacing: .03em; color: #fff; white-space: nowrap; background: var(--vermilion); border-radius: 3px; pointer-events: none; }
.calfa-demo .bar-nav { display: flex; gap: 6px; }
.calfa-demo .bar-nav button { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border-radius: 8px; border: 1px solid var(--hair-n2); background: var(--panel); color: var(--on-night); cursor: pointer; font-size: 1.125rem; }
.calfa-demo .bar-nav button:hover { border-color: var(--sky); }

/* Mobile: the arrows go to the bottom of the block, the text and its translation take the full width */
@media (max-width: 767.98px) {
  .calfa-demo .bar { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .calfa-demo .bar-nav { justify-content: center; padding-top: 10px; border-top: 1px solid var(--hair-n); }
}
@media (max-width: 520px) {
  .calfa-demo { border-radius: 14px; }
  .calfa-demo .stage { margin: 8px 8px 0; }
  .calfa-demo .bar { margin: 10px 8px 8px; padding: 10px 10px 10px 12px; min-height: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .calfa-demo *, .calfa-demo *::before, .calfa-demo *::after { transition: none !important; animation: none !important; }
}
