/* KWTVA — Art. The weaving tool, in the site's own look: dark ground, paper text, gold accents, square corners.
   Every class of the tool starts with a- (or art-) so nothing here touches the other pages. */
.page-art [hidden] { display: none !important; }

.art { max-width: 82rem; margin: 0 auto; padding: 3rem 1.25rem 1rem; }
.art-grid { display: grid; gap: 1.25rem; }
.art-stagewrap { position: sticky; top: 0; z-index: 5; display: grid; gap: .6rem; padding: .5rem 0 .6rem; background: var(--ink); min-width: 0; }
.art-stagewrap.has-full { z-index: 90; }
/* The frame takes the photo's own shape (set from the script as --ar), so the photo fills it instead of sitting small inside a fixed box. */
.art-stage { position: relative; width: min(100%, calc(58svh * var(--arn, .8))); justify-self: center; aspect-ratio: var(--ar, 4 / 5); max-height: 58svh; min-height: 12rem; overflow: hidden; background: #0a0908; border: 1px solid var(--line); }
/* Enlarged: the frame covers the whole screen and the photo fills it. */
.art-stage.is-full { position: fixed; inset: 0; z-index: 90; width: 100vw !important; height: 100vh; height: 100dvh; max-height: none; min-height: 0; aspect-ratio: auto; border: 0; background: #0a0908; }
.art-stage canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.art-stage.textmode canvas { cursor: grab; }
.art-stage.drop { outline: 2px dashed var(--accent); outline-offset: -6px; }
.art-stage:focus { outline: none; }
.art-stage:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }
.art-fit { position: absolute; top: .5rem; left: .5rem; display: grid; place-items: center; width: 2.4rem; height: 2.4rem; color: var(--paper); background: #0c0b09b8; border: 1px solid var(--line); cursor: pointer; transition: border-color .18s, color .18s; }
.art-fit:hover { color: var(--accent-light); border-color: var(--accent); }
.art-fit svg { width: 1.1rem; height: 1.1rem; }
.art-zoom { left: 3.2rem; }
.art-zoom .z-close { display: none; }
.art-stage.is-full .art-zoom .z-open { display: none; }
.art-stage.is-full .art-zoom .z-close { display: block; }
.art-stage.is-full .art-fit { top: max(.5rem, env(safe-area-inset-top, 0px)); left: max(.5rem, env(safe-area-inset-left, 0px)); }
.art-stage.is-full .art-zoom { top: max(.5rem, env(safe-area-inset-top, 0px)); left: calc(max(.5rem, env(safe-area-inset-left, 0px)) + 2.7rem); }
.art-stage.is-full .art-fit, .art-stage.is-full .art-zoom { width: 2.8rem; height: 2.8rem; }
.art-busy { position: absolute; inset: auto .5rem .5rem; display: flex; justify-content: center; pointer-events: none; }
.art-busy span { padding: .3rem .85rem; color: var(--paper); font-size: .78rem; background: #0c0b09d6; border: 1px solid var(--line); }
.art-bar { display: flex; gap: .5rem; align-items: stretch; }
.art-bar .copy-button.art-save { flex: none; width: auto; min-width: 6.5rem; min-height: 2.9rem; padding: .5rem 1.2rem; }
.art .art-status { max-width: none; min-height: 1.7em; text-align: start; }
.art .art-status strong { color: var(--paper); font-weight: 600; }

/* buttons, chips, switches */
.a-btn, .a-chip { appearance: none; -webkit-appearance: none; font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; color: var(--paper-dim); background: transparent; border: 1px solid var(--line); border-radius: 0; cursor: pointer; transition: border-color .18s, color .18s, background .18s; }
.a-btn { min-height: 2.9rem; padding: 0 1rem; font-size: .8rem; font-weight: 500; white-space: nowrap; }
.a-chip { min-height: 2.5rem; padding: .3rem .85rem; font-size: .8rem; font-weight: 500; line-height: 1.3; }
.a-btn:hover, .a-chip:hover { color: var(--accent-light); border-color: var(--accent); }
.a-chip[aria-pressed="true"] { color: var(--ink); background: var(--paper); border-color: var(--paper); }
.a-btn:disabled, .a-chip:disabled { opacity: .38; cursor: default; }
.a-btn:disabled:hover, .a-chip:disabled:hover { color: var(--paper-dim); border-color: var(--line); }
.a-upload { position: relative; overflow: hidden; flex: none; color: var(--paper); }
.a-upload input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }
.a-seg { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); }
.a-seg button { min-height: 2.9rem; padding: 0 .5rem; color: var(--paper-dim); font-size: .8rem; font-weight: 500; cursor: pointer; transition: background .18s, color .18s; }
.a-seg button + button { border-inline-start: 1px solid var(--line); }
.a-seg button:hover { color: var(--accent-light); }
.a-seg button[aria-pressed="true"] { color: var(--ink); background: var(--paper); }
.a-chip.a-font { padding: .2rem .9rem; gap: .5rem; }
.a-chip.a-font { min-height: 2.9rem; }
.a-chip.a-font .a-fa { font-size: 1.3rem; line-height: 1.5; }
.a-chip.a-font[data-font="nastaliq"] { padding-top: .55rem; }
.a-chip.a-font[data-font="nastaliq"] .a-fa { font-size: 1.15rem; line-height: 1.9; }
.a-chip.a-font .a-fc { font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; opacity: .7; }
html[lang="ar"] .a-fc { display: none; }
.a-chip.a-slot { font-family: "Amiri", "IBM Plex Sans Arabic", serif; font-size: 1.3rem; line-height: 1.25; padding: .15rem .9rem; }
.a-kn { display: inline-grid; place-items: center; min-width: 1.2rem; height: 1.2rem; padding: 0 .25rem; color: var(--ink); font: 600 .72rem/1 Manrope, "IBM Plex Sans Arabic", sans-serif; background: var(--accent-light); }
.a-chip[aria-pressed="true"] .a-kn { background: var(--ink); color: var(--paper); }
.a-sw { width: 2.1rem; height: 2.1rem; padding: 0; border: 1px solid #ffffff3a; border-radius: 0; cursor: pointer; box-shadow: inset 0 0 0 1px #0000004d; }
.a-sw[aria-pressed="true"] { outline: 2px solid var(--accent-light); outline-offset: 2px; }
.a-sw.a-pick { position: relative; overflow: hidden; background: conic-gradient(#e6c06a, #e0705a, #7a6ee0, #5ab8e0, #7ad08a, #e6c06a); }
.a-sw.a-pick input { position: absolute; inset: -8px; width: 3.4rem; height: 3.4rem; opacity: 0; cursor: pointer; }
.a-switch { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3.2rem; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--paper); font-size: .86rem; cursor: pointer; }
.a-switch + .a-switch { border-top: 0; }
.a-switch input { appearance: none; -webkit-appearance: none; flex: none; display: grid; place-items: center; width: 1.15rem; height: 1.15rem; margin: 0; border: 1px solid var(--paper-dim); border-radius: 0; background: transparent; cursor: pointer; transition: background .18s, border-color .18s; }
.a-switch input:checked { background: var(--accent-light); border-color: var(--accent-light); }
.a-switch input:checked::after { content: ""; width: .3rem; height: .58rem; border: solid var(--ink); border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.a-switch input:disabled { opacity: .35; cursor: default; }

/* panels */
.a-panel { display: grid; align-content: start; gap: 1.6rem; min-width: 0; padding: 1.1rem; border: 1px solid var(--line); }
.a-group { display: grid; gap: .6rem; min-width: 0; }
.a-glabel { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; color: var(--accent-light); font-size: .66rem; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; }
.a-glabel output { color: var(--paper); font-size: .78rem; font-weight: 500; letter-spacing: 0; text-transform: none; font-variant-numeric: tabular-nums; }
.a-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.a-two { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem 1.1rem; }
.a-note { margin: 0; color: var(--paper-dim); font-size: .8rem; line-height: 1.7; }
.a-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.a-actions .a-btn { flex: 1 1 9rem; }
.art textarea { width: 100%; min-height: 10.5rem; resize: vertical; padding: .6rem 1rem; color: var(--paper); font-family: "Amiri", "Aref Ruqaa", serif; font-size: 1.6rem; line-height: 1.5; background: var(--field); border: 1px solid var(--line); border-radius: 0; outline: none; transition: border-color .18s; }
.art textarea:focus { border-color: var(--accent); }
.art input[type="range"] { width: 100%; height: 1.8rem; accent-color: var(--accent); }
.art :focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; }
.a-panel .a-group > .a-group { padding-top: 1.1rem; border-top: 1px solid var(--line); }
#lineGroup { padding-top: 1.4rem; border-top: 1px solid var(--line); }

/* keeps the photo pinned while the shorter Weave panel is used */
.art-panelcol { min-height: 70svh; }

/* arrow pad + kashida stepper */
.a-move { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.a-move .a-side { flex: 1 1 9rem; display: grid; gap: .6rem; min-width: 0; }
.a-pad { display: grid; grid-template-columns: repeat(3, 3rem); grid-auto-rows: 3rem; gap: .35rem; direction: ltr; }
.a-pb { appearance: none; -webkit-appearance: none; display: grid; place-items: center; padding: 0; color: var(--paper); background: transparent; border: 1px solid var(--line); border-radius: 0; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; transition: border-color .18s, background .18s, color .18s; }
.a-pb:hover { border-color: var(--accent); }
.a-pb:active { color: var(--ink); background: var(--accent-light); border-color: var(--accent-light); }
.a-pb svg { width: 1.3rem; height: 1.3rem; pointer-events: none; }
.a-pb.a-mid { color: var(--paper-dim); }
.a-kstep { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.a-kstep .a-btn { width: 3rem; padding: 0; font-size: 1.3rem; line-height: 1; }
.a-kval { min-width: 4rem; color: var(--paper-dim); font-size: .74rem; text-align: center; }
.a-kval b { display: block; color: var(--paper); font-size: 1.25rem; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }

/* save sheet + press-and-hold sheet */
.a-sheet { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: max(1rem, env(safe-area-inset-top, 0px)) max(1rem, env(safe-area-inset-right, 0px)) max(1rem, env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px)); background: #0c0b09eb; }
.a-card { display: grid; gap: 1.1rem; width: 100%; max-width: 32rem; max-height: 100%; overflow: auto; padding: 1.1rem; background: #14120e; border: 1px solid var(--line); }
.a-card img { display: block; width: 100%; height: auto; -webkit-touch-callout: default; }
.a-card p { margin: 0; color: var(--paper-dim); font-size: .85rem; line-height: 1.7; }
.a-card .a-actions .copy-button { flex: 1 1 9rem; width: auto; min-width: 0; }

.page-art .how { padding-top: 6rem; }

/* Arabic */
html[lang="ar"] .a-glabel { font-size: .9rem; letter-spacing: 0; }
html[lang="ar"] .a-btn, html[lang="ar"] .a-chip, html[lang="ar"] .a-seg button { font-size: .98rem; }
html[lang="ar"] .a-note, html[lang="ar"] .art .art-status { font-size: .98rem; line-height: 1.85; }
html[lang="ar"] .a-switch, html[lang="ar"] .a-kval { font-size: 1rem; }
html[lang="ar"] .a-card p { font-size: 1rem; }
html[lang="ar"] .art-bar .copy-button { font-size: .95rem; }
html[lang="ar"] .a-chip.a-slot { font-size: 1.35rem; }

@media (min-width: 900px) {
  .art { padding: 5rem 2.5rem 2rem; }
  .art-grid { grid-template-columns: minmax(0, 1fr) 26rem; column-gap: 3rem; align-items: start; }
  .art-stagewrap { top: 1.25rem; padding-top: 0; }
  .art-stage { width: min(100%, calc((100svh - 9.5rem) * var(--arn, .8))); max-height: calc(100svh - 9.5rem); min-height: 22rem; }
  .page-art .how { padding-top: 8rem; }
}
@media (prefers-reduced-motion: reduce) { .art * { transition: none !important; } }
