/* SPDX-License-Identifier: MIT — the drop widget (spec §3.4.4; 14-ghost-design §5; DESIGN.md): what a
   first drop needs. Scoped to the widget's root (.md-root) or to app pages (.a-page), which reuse the
   shared components (a- classes). The rest (the rules panel, the glass box, errors, the send step)
   is in parts.css, which the home page loads the first time one of them shows. Shared tokens only. */

/* --- the root ----------------------------------------------------------------------------------- */
.md-root {
  position: relative; width: 100%; max-width: 720px; margin-inline: auto;
  display: grid; gap: var(--s-4); text-align: left; color: var(--fg); font: var(--t-body);
}
.md-stage { min-height: 300px; display: grid; min-width: 0; }
@media (max-width: 640px) { .md-stage { min-height: 280px; } }

/* --- buttons and links-as-buttons (shared) ---------------------------------------------------- */
:is(.md-root, .a-page) .a-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 0 var(--s-5); border: 1.5px solid var(--line); border-radius: var(--r-pill);
  background: transparent; color: var(--fg); font: var(--t-ui); text-decoration: none; cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), scale var(--dur-1) var(--ease-out);
}
:is(.md-root, .a-page) .a-btn:hover { background: var(--hair); }
:is(.md-root, .a-page) .a-btn:active { scale: .97; }
:is(.md-root, .a-page) .a-btn--primary { background: var(--act); color: var(--on-act); border-color: var(--act); }
:is(.md-root, .a-page) .a-btn--primary:hover { background: var(--act-hover); color: var(--on-act); }
:is(.md-root, .a-page) .a-btn--exit { color: var(--exit-text); border-color: currentColor; }
:is(.md-root, .a-page) .a-btn--exit:hover { background: var(--exit); color: var(--on-exit); border-color: var(--exit); }
:is(.md-root, .a-page) .a-btn--pay { background: var(--pay); color: var(--on-pay); border-color: var(--pay); }
:is(.md-root, .a-page) .a-btn--pay:hover { background: var(--bg); color: var(--pay-text); }
:is(.md-root, .a-page) .a-btn:disabled { opacity: .5; cursor: not-allowed; }
:is(.md-root, .a-page) .a-btn svg { width: 18px; height: 18px; flex: none; }

:is(.md-root, .a-page) .a-linkbtn {
  display: inline-flex; align-items: center; gap: var(--s-1); min-height: 44px; padding: 0;
  background: none; border: 0; color: var(--fg); font: var(--t-ui); cursor: pointer;
  text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: .2em;
}
:is(.md-root, .a-page) .a-linkbtn--exit { color: var(--exit-text); }
:is(.md-root, .a-page) .a-icon { width: 18px; height: 18px; flex: none; }

/* --- the zone: a box with a real input (app pages); on the home page the window is the target ---- */
.md-zone {
  position: relative; min-height: inherit; display: grid; place-items: center; padding: var(--s-6) var(--s-5);
  border: 2px dashed var(--line); border-radius: var(--r-panel); background: var(--bg);
  transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out);
}
.md-zone.md-drag { border-style: solid; border-color: var(--fg); background: var(--bg-sunken); }
.md-idle { display: grid; justify-items: center; gap: var(--s-3); text-align: center; }
.md-hint { font: var(--t-body); color: var(--fg-2); }
.md-choose, .md-choose-alt { position: relative; }
.md-choose:focus-within, .md-choose-alt:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
/* The file input stays focusable for the keyboard where its label is the visible control. */
.md-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
@media (pointer: coarse) { .md-idle { width: 100%; } .md-choose { width: 100%; } }

.md-compose { width: 100%; display: grid; gap: var(--s-3); }
.md-say { font: var(--t-say); text-wrap: balance; }
.md-textarea {
  width: 100%; min-height: 9em; resize: vertical; padding: 16px 18px; border: 2px solid var(--line);
  border-radius: var(--r-input); background: var(--bg-raised); color: var(--fg); font: var(--t-body);
}
.md-textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-color: transparent; }
.md-count { font: var(--t-small); font-family: var(--font-code); color: var(--fg-2); text-align: right; }
.md-count.md-over { color: var(--exit-text); }
.md-keys { font: var(--t-small); color: var(--fg-2); }
:is(.md-root, .a-page) .a-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); }
.md-working { align-self: center; justify-self: center; font: var(--t-small); color: var(--fg-2); }

/* --- busy: the ghost chews; one line, the percent only for a long upload ------------------------ */
.md-sealing { min-height: inherit; display: grid; justify-items: center; align-content: start; gap: var(--s-2); text-align: center; }
.md-progress { font: var(--t-say); color: var(--fg-2); font-variant-numeric: tabular-nums; }

/* --- the photo chip ------------------------------------------------------------------------------ */
.md-chip {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); padding: 6px 14px;
  border-radius: var(--r-pill); background: var(--bg-sunken); font: var(--t-small); color: var(--fg);
}
.md-chip .a-linkbtn { min-height: 32px; font: var(--t-small); }
.md-chip--note { color: var(--fg-2); }

/* --- the result: the ghost holds the rule, the card holds the link ---------------------------- */
.md-result { display: grid; gap: var(--s-5); justify-items: center; min-width: 0; }
.md-result-figure { display: grid; justify-items: center; gap: var(--s-2); }
.md-figure { display: block; inline-size: 128px; padding: 4px; border: 0; border-radius: var(--r-panel); background: none; color: var(--fg); cursor: pointer; }
.md-figure:disabled { cursor: default; }
.md-figure .ghost { filter: var(--glow); }
.md-figure:active:not(:disabled) .ghost { scale: .96; }
.md-counts { display: flex; gap: 4px; padding: 4px; border-radius: var(--r-pill); background: var(--bg-sunken); }
.md-counts label { position: relative; }
.md-counts input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.md-counts span {
  display: flex; align-items: center; min-height: 44px; padding: 0 18px; border-radius: var(--r-pill); font: var(--t-ui); color: var(--fg-2);
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out);
}
.md-counts input:checked + span { background: var(--act); color: var(--on-act); }
.md-counts input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.md-word-btn { min-height: 44px; padding-inline: 14px 18px; }
.md-word-btn[aria-pressed="true"] { background: var(--mark); color: var(--on-mark); border-color: transparent; }
.md-card {
  width: min(100%, 560px); display: grid; gap: var(--s-3); padding: var(--s-5); min-width: 0;
  border-radius: var(--r-panel); background: var(--bg-raised); box-shadow: var(--shadow);
}
.md-card-main { display: grid; gap: var(--s-3); min-width: 0; }
.md-card .md-say { min-height: 2.7em; }
.md-kept { font: var(--t-say); }
.md-link-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-2); align-items: center; }
.md-link-row:has(.md-share) { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 479px) { .md-link-row { grid-template-columns: minmax(0, 1fr); } }
.md-link {
  display: block; width: 100%; min-width: 0; min-height: var(--tap); padding: 12px 14px; border: 0;
  border-radius: var(--r-input); background: var(--bg-sunken); color: var(--fg); font: var(--t-code); text-overflow: ellipsis;
}
.md-link:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.md-link::selection { background: var(--mark); color: var(--on-mark); }
.md-acts { display: flex; gap: var(--s-2); }
.md-acts .a-btn { flex: 1; white-space: nowrap; }
.md-copy { min-width: 9.2em; }
.md-copy svg { display: none; }
.md-copy.md-done svg { display: block; }
.md-copy.md-done { animation: md-pop var(--dur-3) var(--ease-out); }
@keyframes md-pop { from { scale: .8; } }
/* the code to scan: ink on white in both themes, so every camera reads it (DESIGN.md) */
.md-qr { display: grid; justify-items: center; gap: var(--s-2); margin: 0; text-align: center; }
.md-qr svg { width: 200px; height: 200px; border-radius: 14px; background: #fff; }
.md-qr path { fill: #151A3B; }
.md-qr figcaption { font: var(--t-small); color: var(--fg-2); max-width: 22ch; }
/* its place is kept from the first frame, so nothing under the card moves when the code is drawn */
.md-qr-slot { justify-self: center; width: 200px; min-height: 276px; }
.md-next { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--s-2) var(--s-5); max-width: 560px; }
@media (max-width: 899px) { .md-tari { flex-basis: 100%; } }
.md-tari svg { color: var(--tari-text); }
.md-slot { width: min(100%, 560px); min-width: 0; }
.md-slot:empty { display: none; }

@media (min-width: 900px) {
  .md-result { grid-template-columns: auto minmax(0, 700px); justify-content: center; align-items: center; column-gap: var(--s-8); }
  .md-result-figure { grid-row: 1 / span 2; }
  .md-figure { inline-size: 250px; }
  .md-card, .md-slot { width: 100%; }
  .md-next { grid-column: 2; justify-self: start; justify-content: start; max-width: none; }
  .md-slot { grid-column: 2; }
  .md-card:has(.md-qr-slot) { grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--s-6); align-items: center; }
}


/* --- the toast: one line on a phone, never under the thumb's way ------------------------------- */
:is(.md-root, .a-page) .a-toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); z-index: var(--z-toast);
  translate: -50% 0; width: max-content; max-width: calc(100vw - 32px); padding: 12px 20px; text-align: center;
  border-radius: var(--r-pill); background: var(--act); color: var(--on-act); font: var(--t-ui); box-shadow: var(--shadow);
}
@media (max-width: 640px) { .a-page .a-toast { bottom: calc(76px + env(safe-area-inset-bottom)); } }

/* `hidden` always wins: three attribute selectors outrank every component rule in these files. */
:is(.md-root, .a-page) [hidden][hidden][hidden] { display: none; }
