/* ============================================
   PolDoc AI — interactive upload demo
   States on .demo:  data-state="idle | scanning | done"
   ============================================ */

@property --p {
  syntax: "<number>";
  inherits: false;
  initial-value: 0;
}

.demo { position: relative; }

/* --------------------------------------------
   Dropzone: idle ⇄ dragover ⇄ scanning
   -------------------------------------------- */
.dropzone {
  position: relative;
  cursor: pointer;
}

.dropzone__idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 13px;
  transition: opacity .28s var(--ease), transform .28s var(--ease);
}

/* --- drag over --- */
.dropzone.is-dragover {
  border-style: solid;
  border-color: var(--blue);
  background: #F5F6FE;
  transform: scale(1.012);
}
.dropzone.is-dragover .dropzone__idle { transform: scale(1.04); }
.dropzone.is-dragover .dropzone__icon {
  background: var(--blue);
  transform: scale(1.12);
}
.dropzone.is-dragover .dropzone__icon i { background: #fff; }
.dropzone__icon { transition: background var(--t), transform .25s var(--ease); }

/* --- scanning --- */
.demo[data-state="scanning"] .dropzone {
  border-style: solid;
  border-color: var(--blue-30);
  cursor: default;
}
.demo[data-state="scanning"] .dropzone__idle {
  opacity: 0;
  transform: scale(.94);
  pointer-events: none;
}

/* --------------------------------------------
   Circular progress
   -------------------------------------------- */
.scan {
  position: absolute;
  inset: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  opacity: 0;
  transform: scale(.94);
  pointer-events: none;
  transition: opacity .28s var(--ease), transform .28s var(--ease);
}
.demo[data-state="scanning"] .scan {
  opacity: 1;
  transform: none;
}

.scan__ring {
  position: relative;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background: conic-gradient(
    from -90deg,
    var(--blue) calc(var(--p) * 1%),
    rgba(22, 22, 26, .08) 0
  );
  display: flex;
  align-items: center;
  justify-content: center;
  transition: --p .16s linear;
}

/* soft glow that follows the fill */
.scan__ring::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(34, 56, 158, .16), transparent 68%);
  opacity: 0;
  transition: opacity .4s var(--ease);
}
.demo[data-state="scanning"] .scan__ring::before { opacity: 1; }

/* rotating sheen */
.scan__ring::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: rgba(34, 56, 158, .35);
  animation: ring-spin 1.15s linear infinite;
}

@keyframes ring-spin {
  to { transform: rotate(360deg); }
}

.scan__hole {
  position: relative;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.scan__pct {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.scan__pct sup {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-300);
  top: -.5em;
}
.scan__unit {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-300);
}

/* check mark shown at 100% */
.scan__check {
  position: absolute;
  width: 34px;
  height: 34px;
  opacity: 0;
  transform: scale(.5);
  transition: opacity .25s var(--ease), transform .35s var(--ease);
}
.scan__check svg { width: 100%; height: 100%; }
.scan__check path {
  stroke: var(--blue);
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
}
.scan.is-complete .scan__pct,
.scan.is-complete .scan__unit { opacity: 0; transform: scale(.7); transition: .2s var(--ease); }
.scan.is-complete .scan__check { opacity: 1; transform: scale(1); }
.scan.is-complete .scan__check path { animation: check-draw .4s var(--ease) forwards; }
.scan.is-complete .scan__ring::after { animation: none; opacity: 0; }

@keyframes check-draw {
  to { stroke-dashoffset: 0; }
}

/* status line under the ring */
.scan__status {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  min-height: 20px;
}
.scan__status.is-swap { animation: status-swap .32s var(--ease); }
@keyframes status-swap {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.scan__file {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-300);
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --------------------------------------------
   File row reacts to state
   -------------------------------------------- */
.filerow { transition: border-color var(--t), box-shadow var(--t); }
.demo[data-state="scanning"] .filerow {
  border-color: var(--blue-22);
  box-shadow: 0 0 0 3px rgba(34, 56, 158, .06);
}
.filerow__status { transition: color var(--t), background var(--t); }
.filerow__status.is-working { color: var(--blue); background: var(--blue-08); }
.filerow__status.is-waiting { color: var(--ink-300); background: rgba(22, 22, 26, .06); }

/* --------------------------------------------
   Sample document switcher
   -------------------------------------------- */
.samples {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.samples__label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-300);
  margin-right: 2px;
}
.sample {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-600);
  background: #fff;
  border: 1px solid var(--line-08);
  border-radius: var(--r-sm);
  padding: 6px 9px;
  transition: background var(--t), color var(--t), border-color var(--t), transform var(--t);
}
.sample:hover { border-color: var(--blue-35); color: var(--blue); }
.sample:active { transform: translateY(1px); }
.sample[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.demo__note {
  font-size: 11.5px;
  color: var(--ink-300);
  line-height: 1.45;
}

/* --------------------------------------------
   Result stage: skeleton ⇄ content
   -------------------------------------------- */
.result__stage {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.result__content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: opacity .28s var(--ease);
}

.result__skeleton {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s var(--ease);
}
.result__skeleton .sk-title {
  height: 22px;
  width: 76%;
  border-radius: 6px;
  margin-bottom: 6px;
}
.result__skeleton .sk-block {
  border-radius: 14px;
  background: var(--white-06);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.result__skeleton .sk-block i { height: 8px; border-radius: 4px; display: block; }
.result__skeleton .sk-title,
.result__skeleton .sk-block i {
  background: linear-gradient(90deg,
    rgba(255, 255, 255, .07) 0%,
    rgba(255, 255, 255, .17) 50%,
    rgba(255, 255, 255, .07) 100%);
  background-size: 220% 100%;
  animation: sk-shimmer 1.4s var(--ease) infinite;
}
@keyframes sk-shimmer {
  from { background-position: 130% 0; }
  to   { background-position: -30% 0; }
}

.demo[data-state="idle"]     .result__content,
.demo[data-state="scanning"] .result__content { opacity: 0; }

.demo[data-state="idle"]     .result__skeleton,
.demo[data-state="scanning"] .result__skeleton { opacity: 1; }

.result__actions { transition: opacity .28s var(--ease); }
.demo[data-state="idle"]     .result__actions,
.demo[data-state="scanning"] .result__actions { opacity: .22; }

/* --------------------------------------------
   Reveal choreography once analysis is done
   -------------------------------------------- */
@keyframes result-rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.demo[data-state="done"] .result__title          { animation: result-rise .45s var(--ease) both; }
.demo[data-state="done"] .rblock:nth-of-type(1)  { animation: result-rise .45s var(--ease) .09s both; }
.demo[data-state="done"] .rblock:nth-of-type(2)  { animation: result-rise .45s var(--ease) .18s both; }
.demo[data-state="done"] .rblock:nth-of-type(3)  { animation: result-rise .45s var(--ease) .27s both; }
.demo[data-state="done"] .result__actions        { animation: result-rise .45s var(--ease) .36s both; }

.rblock { position: relative; }
.demo[data-state="done"] .rblock--warn::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 14px;
  border: 1px solid var(--yellow);
  opacity: 0;
  animation: warn-ping 1.1s var(--ease) .5s;
  pointer-events: none;
}
@keyframes warn-ping {
  0%   { opacity: 0; transform: scale(1); }
  35%  { opacity: .9; }
  100% { opacity: 0; transform: scale(1.035); }
}

/* --------------------------------------------
   Reduced motion
   -------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .scan__ring::after,
  .result__skeleton .sk-title,
  .result__skeleton .sk-block i,
  .demo[data-state="done"] .rblock--warn::after { animation: none; }
  .scan__ring { transition: none; }
}
