/* tara.css (belge tarama, doc_scan): "Kamerayla tara" under the drop zone, the scan editor in the chosen-files state
   (page bar, the photo with its four corners + loupe, the page as it will come out on a sheet, the page strip), the
   side options, the result preview and the full-screen live camera (tara-cam.js). Builds on tool.css + local.css
   (seg, lcheck, lnote, lfacts). Radius 0–2 px, 1 px hairlines, hard ink shadows; details show on hover. */

/* ------------------------------------------------------------------ idle: camera next to the drop zone */
.tara-cam { display: grid; grid-template-columns: auto auto; justify-content: center; align-items: center; gap: 6px 14px; margin-top: 14px; }
.tara-cam__or { font: 600 12px/1 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
html[lang="ar"] .tara-cam__or, html[lang="ja"] .tara-cam__or { text-transform: none; letter-spacing: 0; }
.tara-cam__b { gap: 10px; }
.tara-cam__b .ico { width: 20px; height: 20px; }
.tara-cam__d { grid-column: 1 / -1; text-align: center; font-size: var(--t-meta); color: var(--ink-2); }
@media (max-width: 599px) {
  .tara-cam { grid-template-columns: 1fr; }
  .tara-cam__or { text-align: center; }
  .tara-cam__b { width: 100%; justify-content: center; min-height: 54px; }
}

/* ------------------------------------------------------------------ the editor */
.tara { display: grid; gap: 0; min-width: 0; border: 1px solid var(--ink); background: var(--paper); }
.tara__top { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--ink); flex-wrap: wrap; min-width: 0; }
[dir="rtl"] .tara__top { padding: 8px 14px 8px 8px; }
.tara__k { display: flex; align-items: baseline; gap: 10px; min-width: 0; margin: 0; }
.tara__no { font: 600 12.5px/1.2 var(--f-mono); letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
html[lang="ar"] .tara__no, html[lang="ja"] .tara__no { text-transform: none; letter-spacing: 0; }
.tara__fn { font-size: var(--t-meta); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22ch; }
.tara__acts { display: flex; gap: 6px; flex-wrap: wrap; }
.tara__b { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 11px; border: 1px solid var(--ink); border-radius: var(--r-1); font-size: 13.5px; font-weight: 560; background: var(--paper); color: var(--ink); transition: background-color .25s var(--e-out), color .25s var(--e-out); }
.tara__b .ico { width: 16px; height: 16px; flex: none; }
.tara__b--i { width: 40px; padding: 0; }
.tara__b:hover:not([disabled]) { background: var(--ink); color: var(--paper); }
.tara__b--x:hover:not([disabled]) { background: var(--signal-strong); border-color: var(--signal-strong); }
.tara__b[disabled] { opacity: .35; cursor: default; }
.tara__b:focus-visible, .tara__th:focus-visible, .tara__ab:focus-visible { outline: 2px solid var(--signal-strong); outline-offset: 2px; }
[dir="rtl"] .tara__b--i .ico { transform: scaleX(-1); }

.tara__ed { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); min-width: 0; }
.tara__src { position: relative; min-width: 0; min-height: 220px; border-inline-end: 1px solid var(--ink); background: var(--paper-2);
  background-image: linear-gradient(45deg, var(--paper-3) 25%, transparent 25%, transparent 75%, var(--paper-3) 75%), linear-gradient(45deg, var(--paper-3) 25%, transparent 25%, transparent 75%, var(--paper-3) 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px; }
.tara__cv { display: block; width: 100%; touch-action: none; cursor: crosshair; }
.tara__cv:focus-visible { outline: 2px solid var(--signal-strong); outline-offset: -2px; }
.tara__loupe { position: absolute; top: 8px; width: 112px; height: 112px; border: 2px solid #fff; box-shadow: 4px 4px 0 var(--ink); pointer-events: none; z-index: 2; }
.tara__st { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 16px; text-align: center; font-size: 15px; font-weight: 560; background: var(--paper-2); }
.tara[data-st="busy"] .tara__st { color: var(--ink-2); }
.motion .tara[data-st="busy"] .tara__st { animation: taraPulse 1.1s var(--e-io) infinite alternate; }
@keyframes taraPulse { to { background: var(--paper-3); } }
.tara[data-st="err"] .tara__st { color: var(--signal-ink); }
.tara[data-st="err"] .tara__st a { color: var(--ink); font-weight: 600; }
.tara:not([data-st="ok"]) .tara__out { opacity: .3; }

/* the page as it will come out: a sheet with the site's hard shadow; it lifts a little on hover */
.tara__out { display: grid; align-content: center; justify-items: center; gap: 12px; padding: 18px 16px 14px; min-width: 0; background: var(--paper); }
.tara__sheet { display: inline-block; max-width: 100%; line-height: 0; background: #fff; box-shadow: 5px 5px 0 var(--ink); transition: transform .35s var(--e-out), box-shadow .35s var(--e-out); }
[dir="rtl"] .tara__sheet { box-shadow: -5px 5px 0 var(--ink); }
.tara__pv { display: block; max-width: 100%; max-height: 56vh; width: auto; height: auto; }
@media (hover: hover) {
  .tara__sheet:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 var(--ink); }
  [dir="rtl"] .tara__sheet:hover { transform: translate(2px, -2px); box-shadow: -8px 8px 0 var(--ink); }
}
.tara__note { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 11.5px; line-height: 1.35; color: var(--ink-2); text-align: center; overflow-wrap: anywhere; }
.tara__note::before { content: ""; flex: none; width: 8px; height: 8px; background: var(--ink-3); }
.tara__note[data-k="ok"]::before { background: var(--ok); }
.tara__note[data-k="no"]::before { background: var(--signal); }
.tara__note[data-k="m"]::before { background: var(--ink); }

/* the page strip */
.tara__strip { display: flex; gap: 10px; margin: 0; padding: 12px; list-style: none; overflow-x: auto; border-top: 1px solid var(--ink); scrollbar-width: thin; }
.tara__pg { position: relative; flex: none; transition: opacity .2s var(--e-out), transform .2s var(--e-out); }
.tara__th { position: relative; display: grid; place-items: center; width: 76px; height: 98px; padding: 4px; border: 1px solid var(--rule); border-radius: var(--r-1); background: var(--paper-2); overflow: hidden; cursor: pointer; transition: border-color .2s var(--e-out), box-shadow .2s var(--e-out), transform .2s var(--e-out); }
.tara__tc { display: block; max-width: 100%; max-height: 100%; background: #fff; box-shadow: 0 0 0 1px var(--rule); }
.tara__tn { position: absolute; left: 0; top: 0; padding: 1px 5px; font-size: 10.5px; line-height: 1.4; background: var(--ink); color: var(--paper); }
[dir="rtl"] .tara__tn { left: auto; right: 0; }
.tara__ts { position: absolute; inset-inline: 0; bottom: 0; padding: 2px 0; font-size: 10.5px; font-weight: 600; text-align: center; background: rgba(242, 240, 234, .92); }
@media (hover: hover) { .tara__th:hover { border-color: var(--ink); transform: translateY(-2px); } }
.tara__pg.is-on .tara__th { border: 2px solid var(--signal); box-shadow: 3px 3px 0 var(--ink); }
.tara__pg.is-on .tara__tn { background: var(--signal-strong); }
.tara__pg[data-st="busy"] .tara__th { opacity: .55; }
.motion .tara__pg[data-st="busy"] .tara__th { animation: taraPulse 1.1s var(--e-io) infinite alternate; }
.tara__pg[data-st="err"] .tara__th { border-color: var(--signal-strong); background: repeating-linear-gradient(135deg, var(--signal-lt) 0 6px, var(--paper-2) 6px 12px); }
.tara__pg.is-drag { opacity: .35; }
.tara__pg.is-over .tara__th { outline: 2px dashed var(--ink); outline-offset: 2px; }
.tara__add { flex: none; display: grid; grid-template-rows: auto 1fr 1fr; gap: 4px; width: 92px; height: 98px; padding: 4px; border: 1px dashed var(--ink); border-radius: var(--r-1); }
.tara__ak { font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); text-align: center; }
html[lang="ar"] .tara__ak, html[lang="ja"] .tara__ak { text-transform: none; letter-spacing: 0; }
.tara__ab { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 34px; padding: 0 4px; border: 1px solid var(--rule); border-radius: var(--r-1); font-size: 12px; font-weight: 560; background: var(--paper); transition: background-color .2s var(--e-out), color .2s var(--e-out); }
.tara__ab .ico { width: 14px; height: 14px; flex: none; }
.tara__ab:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tara__hint { margin: 0; padding: 0 14px 12px; }

@media (max-width: 719px) {
  .tara__ed { grid-template-columns: minmax(0, 1fr); }
  .tara__src { border-inline-end: 0; border-bottom: 1px solid var(--ink); }
  .tara__pv { max-height: 46vh; }
  .tara__b:not(.tara__b--i) span { font-size: 13px; }
  .tara__fn { max-width: 14ch; }
}
@media (max-width: 420px) {
  .tara__b:not(.tara__b--i) { padding: 0 8px; }
  .tara__b[data-a="full"] span, .tara__b[data-a="auto"] span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .tara__b[data-a="full"], .tara__b[data-a="auto"] { width: 40px; padding: 0; }
}

/* ------------------------------------------------------------------ side options */
.tara-look .seg__row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tara-look .seg__o:nth-child(n+3) { border-top: 1px solid var(--ink); }
.tara-look .seg__o:nth-child(3) { border-inline-start: 0; }
.tara-out { display: flex; flex-wrap: wrap; gap: 6px 18px; border: 0; padding: 0; margin: 0; min-width: 0; }
.tara-out .seg__lg { width: 100%; }
.tara-idnote a { color: var(--ink); font-weight: 600; }

/* ------------------------------------------------------------------ result */
.tara__res { margin: 4px 0 14px; line-height: 0; }
.tara__res img { display: block; max-width: min(100%, 260px); max-height: 340px; width: auto; height: auto; background: #fff; box-shadow: 5px 5px 0 var(--ink); }
[dir="rtl"] .tara__res img { box-shadow: -5px 5px 0 var(--ink); }

/* ------------------------------------------------------------------ live camera (full screen) */
html.tcam-open, html.tcam-open body { overflow: hidden; }
.tcam { position: fixed; inset: 0; z-index: 2147483000; background: #000; color: #fff; overflow: hidden; }
.tcam__v { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tcam__ov { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.tcam__fl { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.tcam__fl.is-on { animation: tcamFlash .28s ease-out; }
@keyframes tcamFlash { from { opacity: .85; } to { opacity: 0; } }
.tcam__top { position: absolute; inset: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 12px 26px; background: linear-gradient(rgba(0, 0, 0, .6), transparent); }
.tcam__x, .tcam__torch { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; height: 44px; padding: 0 10px; border: 1px solid rgba(255, 255, 255, .6); border-radius: var(--r-1); color: #fff; background: rgba(0, 0, 0, .25); font-size: 13px; font-weight: 600; }
.tcam__x .ico, .tcam__torch .ico { width: 20px; height: 20px; }
.tcam__torch[aria-pressed="true"] { background: #fff; color: #000; }
.tcam__msg { flex: 1; margin: 0; text-align: center; font-size: 15px; font-weight: 600; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.tcam__bot { position: absolute; inset: auto 0 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 30px 20px calc(20px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0, 0, 0, .65)); }
.tcam__last { position: relative; justify-self: start; width: 54px; height: 54px; border: 2px solid #fff; background: #222; }
.tcam__last[hidden] { display: block; visibility: hidden; }
.tcam__last img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tcam__last b { position: absolute; top: -9px; right: -9px; min-width: 22px; height: 22px; padding: 0 5px; display: grid; place-items: center; font-size: 12px; background: var(--signal); color: #fff; }
[dir="rtl"] .tcam__last b { right: auto; left: -9px; }
.tcam__shut { width: 76px; height: 76px; display: grid; place-items: center; border: 4px solid #fff; border-radius: 50%; background: transparent; transition: transform .12s var(--e-out); }
.tcam__shut i { width: 58px; height: 58px; border-radius: 50%; background: #fff; transition: background-color .2s var(--e-out); }
.tcam__shut:hover i { background: var(--signal); }
.tcam__shut:active { transform: scale(.93); }
.tcam__shut[disabled] { opacity: .4; }
.tcam__shut:focus-visible, .tcam__done:focus-visible, .tcam__x:focus-visible, .tcam__torch:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }
.tcam__done { justify-self: end; min-height: 46px; padding: 0 18px; border: 1px solid #fff; border-radius: var(--r-1); background: #fff; color: #000; font-size: 15px; font-weight: 650; }
.tcam__done:hover { background: var(--signal); border-color: var(--signal); color: #fff; }
.tcam__err { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(360px, calc(100% - 32px)); display: grid; gap: 14px; padding: 22px 20px; background: var(--paper); color: var(--ink); box-shadow: 6px 6px 0 var(--signal); }
.tcam__em { margin: 0; font-size: 15px; line-height: 1.45; font-weight: 560; }
.tcam__eb { width: 100%; justify-content: center; }
.tcam__ec { justify-self: center; }
@media (prefers-reduced-motion: reduce) { .tcam__fl.is-on { animation: none; } .tcam__shut { transition: none; } }
