/* ==========================================================================
   site.css — interaction states and small additions on top of the compiled
   Tailwind stylesheet (assets/css/base.css). The layout, spacing, colours,
   type scale and components come from the original template; only the
   Base64 workspace behaviour lives here.
   ========================================================================== */

[hidden] {
  display: none !important;
}

:root {
  color-scheme: light;
}

html {
  background-color: hsl(var(--background));
}

.dark {
  color-scheme: dark;
}

/* ---------- brand mark ---------- */

/* The mark is drawn in near-black; invert it in dark mode so it stays visible
   on the dark header without changing the light-mode design. */
.dark img[data-logo] {
  filter: invert(1);
}

/* ---------- upload dropzone ---------- */

#dropzone.is-dragging {
  border-color: rgba(37, 99, 235, 0.75);
  background-color: rgba(37, 99, 235, 0.06);
}

#dropzone:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

#download-btn[disabled] {
  opacity: 0.5;
}

/* ---------- mode switch ---------- */

.b64-mode {
  color: hsl(var(--muted-foreground));
  cursor: pointer;
}

.b64-mode:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.b64-mode[aria-selected="true"] {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}

.b64-mode:focus-visible,
.b64-tab:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

/* ---------- output view tabs ---------- */

.b64-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.75rem;
  padding: 0 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  line-height: 1rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.b64-tab:hover {
  color: hsl(var(--foreground));
}

.b64-tab[aria-selected="true"] {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.06);
}

.dark .b64-tab[aria-selected="true"] {
  background: hsl(var(--accent));
}

/* ---------- monospace output ---------- */

.b64-pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  tab-size: 2;
}

.b64-hex {
  margin: 0;
  white-space: pre;
  overflow-x: auto;
  tab-size: 2;
  line-height: 1.55;
}

/* ---------- status line ---------- */

#output-status.is-ok {
  color: hsl(142 70% 32%);
}

#output-status.is-error {
  color: hsl(var(--destructive));
}

.dark #output-status.is-ok {
  color: hsl(142 65% 60%);
}

/* ---------- clear confirmation ---------- */

#clear-btn.is-armed {
  border-color: hsl(var(--destructive));
  color: hsl(var(--destructive));
  background: hsl(var(--destructive) / 0.08);
}

/* ---------- transparent image backdrop ---------- */

.b64-checker {
  background-color: hsl(var(--muted));
  background-image:
    linear-gradient(45deg, hsl(var(--border)) 25%, transparent 25%),
    linear-gradient(-45deg, hsl(var(--border)) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, hsl(var(--border)) 75%),
    linear-gradient(-45deg, transparent 75%, hsl(var(--border)) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

/* ---------- options switch ---------- */

.b64-switch {
  position: relative;
  display: inline-block;
  width: 2.5rem;
  height: 1.375rem;
  flex: none;
  border-radius: 9999px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--muted));
  transition: background-color 0.15s, border-color 0.15s;
  cursor: pointer;
}

.b64-switch::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 2px;
  width: 1rem;
  height: 1rem;
  border-radius: 9999px;
  background: hsl(var(--background));
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
  transform: translateY(-50%);
  transition: left 0.15s, background-color 0.15s;
}

.b64-switch[aria-checked="true"] {
  background: hsl(var(--primary));
  border-color: hsl(var(--primary));
}

.b64-switch[aria-checked="true"]::after {
  left: calc(100% - 1.125rem);
  background: hsl(var(--primary-foreground));
}

.b64-switch:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

/* ---------- dropdown panels ---------- */

.dropdown-open {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

/* ---------- mobile drawer backdrop ---------- */

#drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(2, 6, 23, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s;
}

#drawer-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

/* ---------- toast ---------- */

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(6px) scale(0.98); }
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: min(92vw, 34rem);
  border-radius: 0.75rem;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.15), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  animation: toast-in 0.2s ease forwards;
}

.toast.is-leaving {
  animation: toast-out 0.18s ease forwards;
}

.toast.is-error {
  border-color: rgba(220, 38, 38, 0.45);
}

/* ---------- fullscreen output ---------- */

#fullscreen-content .b64-pre {
  font-size: 0.9375rem;
  line-height: 1.65;
}

#fullscreen-content .b64-hex {
  font-size: 0.8125rem;
}

#fullscreen-content img {
  max-height: calc(100vh - 12rem);
}

#fullscreen-content .b64-checker {
  border: 1px solid hsl(var(--border));
  border-radius: 0.75rem;
  padding: 1rem;
}

/* ---------- scroll polish ---------- */

#output-pane::-webkit-scrollbar,
#fullscreen-body::-webkit-scrollbar,
#mobile-drawer nav::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

#output-pane::-webkit-scrollbar-thumb,
#fullscreen-body::-webkit-scrollbar-thumb,
#mobile-drawer nav::-webkit-scrollbar-thumb {
  border-radius: 9999px;
  background: hsl(var(--border));
  border: 3px solid transparent;
  background-clip: content-box;
}

/* ---------- focus ring on links and buttons ---------- */

a:focus-visible,
button:focus-visible {
  outline-color: hsl(var(--ring));
}

/* ---------- print: only the tool ---------- */

@media print {
  header, footer, .no-print { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- tablet header fit ---------- */

/* The source design switches to the full desktop header at the `md`
   breakpoint, which pushes the navigation past the viewport between
   768px and ~919px. Tighten the header only inside that band; every other
   width keeps the original spacing. */
@media (min-width: 768px) and (max-width: 919px) {
  header .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  header nav.gap-6 {
    column-gap: 0.6rem;
  }

  header nav a {
    white-space: nowrap;
  }

  header .md\:gap-10 {
    gap: 1rem;
  }

  /* the wordmark would wrap in this band, so show the logo on its own */
  header .text-xl {
    display: none;
  }

  header .h-9.w-9 {
    width: 2rem;
    height: 2rem;
  }
}

/* ---------- small screens: keep the workspace comfortable ---------- */

@media (max-width: 639px) {
  #output-status {
    max-width: 8.5rem;
  }

  .b64-tab {
    padding: 0 0.5rem;
  }

  .b64-hex {
    font-size: 0.6875rem;
  }
}

/* ==========================================================================
   Utility additions
   The compiled stylesheet only contains the classes the source pages used.
   These few utilities are needed by the new workspace and by the shared
   feedback / toast overlays, so they are declared here with identical
   Tailwind semantics.
   ========================================================================== */

.inset-x-0 { left: 0; right: 0; }
.bottom-6 { bottom: 1.5rem; }
.z-\[60\] { z-index: 60; }
.z-\[70\] { z-index: 70; }
.z-\[80\] { z-index: 80; }
.w-72 { width: 18rem; }
.h-7 { height: 1.75rem; }
.leading-4 { line-height: 1rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mb-1\.5 { margin-bottom: 0.375rem; }
.mt-0\.5 { margin-top: 0.125rem; }
.max-h-\[420px\] { max-height: 420px; }
.max-w-\[17rem\] { max-width: 17rem; }
.min-h-\[264px\] { min-height: 264px; }
.bg-black\/40 { background-color: rgba(0, 0, 0, 0.4); }
.break-all { word-break: break-all; }
.backdrop-blur-sm {
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

/* JSON view can hold long strings without widening the pane. */
.b64-error-note {
  color: hsl(var(--destructive));
  border-color: hsl(var(--destructive) / 0.35);
}
