/* ============================================================================
   qbwfileunlock.com - terminal drop-box component
   Pairs with terminal_dropbox.html

   Every selector is scoped under .tdbx, so the component can neither leak
   into the rest of the page nor be reshaped by it. The .m-drop / .m-drop-ico /
   .m-drop-title / .m-drop-sub / .m-drop-btn rules that already exist in the
   page stylesheet are deliberately overridden here (the site versions are the
   plain light theme; this window carries its own white card, warm bar and the
   deep-red drop border).
   ============================================================================ */

.tdbx {
  /* supplied colour tokens - the LIGHT theme */
  --td-bg-panel: #ffffff;
  --td-bg-bar: #f3dedd;
  --td-accent: #a32020;
  --td-accent-soft: rgba(163, 32, 32, 0.45);
  --td-border: #e2bdb7;
  --td-ink: #16110d;
  --td-muted: #5d544c;
  --td-danger: #ef4444;
  --td-warn: #f59e0b;
  --td-ok: #22c55e;

  /* component-private extras */
  --tdbx-radius: 14px;
  --tdbx-radius-sm: 10px;
  --tdbx-gap: 0.8rem;
  --tdbx-pad-y: clamp(1.35rem, 5vw, 2.4rem);
  --tdbx-pad-x: clamp(0.9rem, 4vw, 1.75rem);
  --tdbx-inset: clamp(0.6rem, 2.5vw, 1rem);
  --tdbx-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  --tdbx-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  color: var(--td-ink);
  font-family: var(--tdbx-font);
  font-size: 1rem;
  line-height: 1.5;
  text-align: left;
  -webkit-text-size-adjust: 100%;
}

.tdbx *,
.tdbx *::before,
.tdbx *::after {
  box-sizing: border-box;
}

/* --------------------------------------------------------------- window --- */

.tdbx .tdbx-window {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  background: var(--td-bg-panel);
  border: 1px solid var(--td-border);
  border-radius: var(--tdbx-radius);
  box-shadow: 0 22px 46px -30px var(--td-accent-soft);
}

/* ------------------------------------------------------------------ bar --- */

.tdbx .tdbx-bar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 2.9rem;
  margin: 0;
  padding: 0.45rem clamp(0.65rem, 3vw, 1rem);
  background: var(--td-bg-bar);
  border: 0;
  border-bottom: 1px solid var(--td-border);
  border-radius: var(--tdbx-radius) var(--tdbx-radius) 0 0;
  color: var(--td-muted);
  font-family: var(--tdbx-mono);
  /* the chrome is presentation only: it must not open the file picker and
     must never intercept a drag/drop aimed at the drop surface */
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

.tdbx .tdbx-lights {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
}

.tdbx .tdbx-light {
  display: block;
  width: 0.75rem;
  height: 0.75rem;
  min-width: 0.75rem;
  min-height: 0.75rem;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
}

.tdbx .tdbx-light--close { background: var(--td-danger); }
.tdbx .tdbx-light--min   { background: var(--td-warn); }
.tdbx .tdbx-light--max   { background: var(--td-ok); }

.tdbx .tdbx-bar-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  margin: 0 auto;
  padding: 0;
  color: var(--td-muted);
}

.tdbx .tdbx-lock {
  flex: 0 0 auto;
  display: block;
  color: var(--td-accent);
}

.tdbx .tdbx-bar-text {
  display: block;
  min-width: 0;
  margin: 0;
  padding: 0;
  font-family: var(--tdbx-mono);
  font-size: clamp(0.64rem, 2.8vw, 0.76rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tdbx .tdbx-motif {
  flex: 0 0 auto;
  display: block;
  color: var(--td-border);
}

/* ------------------------------------------------------------ drop zone --- */

/* NOTE ON !important
   The page stylesheet already ships light-theme .m-drop / .m-drop-title /
   .m-drop-sub / .m-drop-btn / .m-file-hidden rules. This component is a dark
   panel dropped onto a light page, so the colour-critical declarations are
   pinned with !important: a site rule (or one added later) must not be able
   to repaint the panel, restyle the approved copy, or re-hide the file
   input. Layout spacing is left at normal specificity so the component
   still yields to sensible page-level tweaks. */

.tdbx .tdbx-window .m-drop.upload-area {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--tdbx-gap);
  width: auto;
  max-width: 100%;
  min-height: 0;
  height: auto;
  margin: var(--tdbx-inset);
  padding: var(--tdbx-pad-y) var(--tdbx-pad-x);
  background: var(--td-bg-panel) !important;
  border: 1.5px dashed var(--td-accent-soft) !important;
  border-radius: var(--tdbx-radius-sm);
  color: var(--td-ink) !important;
  font-family: var(--tdbx-font) !important;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  text-transform: none;
  opacity: 1;
  filter: none;
  transform: none;
  box-shadow: none;
  cursor: pointer;
  outline: none;
  overflow-wrap: break-word;
  transition: border-color 0.18s ease, box-shadow 0.18s ease,
    background-color 0.18s ease;
}

/* corner brackets - geometric motif, never interactive */
.tdbx .tdbx-window .m-drop.upload-area::before,
.tdbx .tdbx-window .m-drop.upload-area::after {
  content: "";
  position: absolute;
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid var(--td-accent-soft);
  pointer-events: none;
}

.tdbx .tdbx-window .m-drop.upload-area::before {
  top: 0.6rem;
  left: 0.6rem;
  border-right: 0;
  border-bottom: 0;
  border-top-left-radius: 4px;
}

.tdbx .tdbx-window .m-drop.upload-area::after {
  right: 0.6rem;
  bottom: 0.6rem;
  border-left: 0;
  border-top: 0;
  border-bottom-right-radius: 4px;
}

/* the file input: visually hidden but still focusable and still a descendant
   of .upload-area (the DOM contract depends on both) */
.tdbx .tdbx-window .m-drop.upload-area #qbw-file {
  display: block !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 1px !important;
  height: 1px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  visibility: visible !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  cursor: pointer;
}

/* focus rings - the input itself is clipped, so the visible blue loop is
   delivered by :focus-within on the label (and by the input's own ring) */
.tdbx .tdbx-window .m-drop.upload-area:focus-within {
  border-color: var(--td-accent);
  box-shadow: 0 0 0 3px var(--td-accent), 0 0 0 7px rgba(163, 32, 32, 0.18),
    0 0 34px 8px var(--td-accent-soft);
}

.tdbx .tdbx-window .m-drop.upload-area #qbw-file:focus {
  border-color: var(--td-accent);
  box-shadow: 0 0 0 3px var(--td-accent), 0 0 22px 6px var(--td-accent-soft);
}

/* drag-over state toggled by the payment script */
.tdbx .tdbx-window .m-drop.upload-area.drag-over {
  border-color: var(--td-accent);
  background: var(--td-bg-panel);
  box-shadow: 0 0 0 3px var(--td-accent), 0 0 0 7px rgba(163, 32, 32, 0.18),
    0 0 34px 8px var(--td-accent-soft);
}

.tdbx .tdbx-window .m-drop.upload-area.drag-over .m-drop-ico {
  color: var(--td-ink);
  transform: translateY(-2px);
}

/* --------------------------------------------------------------- pieces --- */

.tdbx .tdbx-window .m-drop.upload-area .m-drop-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.4rem;
  height: 3.4rem;
  min-width: 3.4rem;
  min-height: 3.4rem;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  background: transparent !important;
  border: 1px solid var(--td-accent-soft) !important;
  border-radius: 50%;
  color: var(--td-accent) !important;
  transition: transform 0.18s ease, color 0.18s ease;
}

.tdbx .tdbx-window .m-drop.upload-area .m-drop-ico svg {
  display: block;
  width: 28px;
  height: 28px;
}

.tdbx .tdbx-window .m-drop.upload-area .m-drop-title {
  display: block;
  max-width: 34ch;
  margin: 0;
  padding: 0;
  background: transparent !important;
  border: 0;
  color: var(--td-ink) !important;
  font-family: var(--tdbx-font) !important;
  font-size: clamp(1.02rem, 3.5vw, 1.2rem);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0 !important;
  text-align: center;
  text-transform: none !important;
}

.tdbx .tdbx-window .m-drop.upload-area .m-drop-sub {
  display: block;
  max-width: 42ch;
  margin: 0;
  padding: 0;
  background: transparent !important;
  border: 0;
  color: var(--td-muted) !important;
  font-family: var(--tdbx-font) !important;
  font-size: clamp(0.84rem, 3.1vw, 0.94rem);
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: 0 !important;
  text-align: center;
  text-transform: none !important;
}

/* ---------------------------------------------------------------- button --- */

.tdbx .tdbx-window .m-drop.upload-area .m-drop-btn,
.tdbx .tdbx-window .m-drop.upload-area #upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 0.3rem 0 0;
  padding: 0.7rem 1.4rem;
  background: var(--td-accent) !important;
  border: 1px solid var(--td-accent) !important;
  border-radius: 8px;
  color: #ffffff !important;
  font-family: var(--tdbx-font) !important;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0 !important;
  text-align: center;
  text-decoration: none;
  text-transform: none !important;
  white-space: nowrap;
  box-shadow: none !important;
  opacity: 1;
  cursor: pointer;
  transition: filter 0.15s ease, box-shadow 0.15s ease;
}

.tdbx .tdbx-window .m-drop.upload-area .m-drop-btn:hover,
.tdbx .tdbx-window .m-drop.upload-area #upload-btn:hover {
  filter: brightness(1.12);
}

.tdbx .tdbx-window .m-drop.upload-area .m-drop-btn:focus-visible,
.tdbx .tdbx-window .m-drop.upload-area #upload-btn:focus-visible {
  outline: 3px solid var(--td-ink);
  outline-offset: 2px;
  filter: brightness(1.12);
}

/* ------------------------------------------------------------ responsive --- */

@media (max-width: 26rem) {
  .tdbx .tdbx-motif { display: none; }
  .tdbx .tdbx-bar-text { letter-spacing: 0.06em; }
  .tdbx .tdbx-window .m-drop.upload-area { gap: 0.65rem; }
}

@media (max-width: 21rem) {
  .tdbx .tdbx-bar { gap: 0.45rem; }
  .tdbx .tdbx-bar-text { letter-spacing: 0.02em; }
}

@media (prefers-reduced-motion: reduce) {
  .tdbx *,
  .tdbx *::before,
  .tdbx *::after {
    transition: none !important;
    animation: none !important;
  }
}
