/* ==========================================================================
   Base64Toolbox — style.css
   Design system: lean, modern SaaS-style dark UI with indigo/violet accent.
   Mobile-first responsive. All colors, spacing, and type via custom properties.
   ========================================================================== */

:root {
  /* Colors */
  --bg: #0d1020;
  --bg-soft: #141831;
  --surface: #1a1f3d;
  --surface-2: #222848;
  --border: #2c3460;
  --text: #eef0ff;
  --text-muted: #a6adce;
  --accent: #6366f1;
  --accent-strong: #8b5cf6;
  --accent-soft: #2e3460;
  --success: #34d399;
  --error: #f87171;
  --focus: #a5b4fc;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);

  /* Spacing */
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --space-5: 3rem;
  --space-6: 4rem;
  --radius: 16px;
  --radius-sm: 10px;

  /* Type */
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --mono: "Cascadia Code", "Consolas", "SFMono-Regular", Menlo, monospace;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --speed: 0.18s;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: linear-gradient(180deg, var(--bg) 0%, #0a0d1c 100%);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

#app-root {
  display: none; /* reserved for any dynamic app mount point */
}

h1, h2, h3, h4 {
  line-height: 1.25;
  margin: 0 0 var(--space-2);
}

p {
  margin: 0 0 var(--space-2);
}

code {
  font-family: var(--mono);
  background: var(--surface-2);
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  font-size: 0.9em;
}

a {
  color: var(--accent-strong);
}

a:hover {
  color: var(--focus);
}

/* Container */
.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 var(--space-2);
}

/* Visually hidden but available to screen readers */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 0 0 8px 0;
  z-index: 100;
}

.skip-link:focus {
  left: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  padding: 0.7rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  text-decoration: none;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease),
    transform var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}

.btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 8px 26px rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--accent);
}

.btn-lg {
  padding: 0.9rem 1.6rem;
  font-size: 1.05rem;
}

/* Focusable elements that are not <button> */
[role="tab"]:focus-visible,
.drop-zone:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(13, 16, 32, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-top: 0.8rem;
  padding-bottom: 0.8rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.85rem;
}

.brand-name {
  font-size: 1.1rem;
  letter-spacing: -0.3px;
}

.site-nav {
  display: flex;
  gap: var(--space-2);
}

.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  padding: 0.4rem 0.2rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--text);
}

.site-nav a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Hero */
.hero {
  padding: var(--space-5) var(--space-2) var(--space-4);
  text-align: center;
  background:
    radial-gradient(600px 260px at 50% 0%, rgba(99, 102, 241, 0.18), transparent 70%),
    transparent;
}

.hero-inner {
  max-width: 720px;
}

.eyebrow {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-strong);
  margin-bottom: var(--space-1);
}

.hero h1 {
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.5px;
}

.hero-sub {
  color: var(--text-muted);
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  max-width: 600px;
  margin: 0 auto var(--space-3);
}

/* Ad slots */
.ad-slot {
  padding: var(--space-1) 0;
}

.ad-slot .container {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
}

.ad-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Sections */
.section {
  padding: var(--space-5) var(--space-2);
}

.section-alt {
  background: var(--bg-soft);
}

.section h2 {
  font-size: clamp(1.4rem, 3.5vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: var(--space-3);
}

/* Tool card */
.tool-section {
  padding: 0 var(--space-2) var(--space-5);
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tool-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.tool-tabs [role="tab"] {
  flex: 1;
  padding: 1rem;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  position: relative;
  min-height: 48px;
}

.tool-tabs [role="tab"][aria-selected="true"] {
  color: var(--text);
}

.tool-tabs [role="tab"][aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 20%;
  right: 20%;
  bottom: -1px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
}

.tool-body {
  padding: var(--space-3);
}

.panel .mode-intro {
  color: var(--text-muted);
}

/* Fields */
.field {
  margin-bottom: var(--space-2);
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.io-input,
.io-output {
  width: 100%;
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  resize: vertical;
  min-height: 120px;
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}

.io-input:focus,
.io-output:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
  outline: none;
}

.io-output {
  background: var(--surface-2);
  cursor: default;
}

.hint {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  text-align: center;
  background: var(--bg-soft);
  cursor: pointer;
  transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease);
  margin-bottom: var(--space-2);
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-icon {
  font-size: 1.8rem;
  display: block;
  margin-bottom: 0.3rem;
}

.drop-zone p {
  margin-bottom: 0.4rem;
}

.drop-zone .hint {
  margin: 0.2rem 0;
}

.sr-input {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* File chip */
.file-chip {
  display: inline-block;
  margin-bottom: var(--space-2);
  background: var(--accent-soft);
  color: var(--text);
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

/* Actions row */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
}

/* Output */
.output {
  border-top: 1px solid var(--border);
  padding-top: var(--space-2);
}

.output-mode {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.output-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-1);
}

.status {
  margin-top: var(--space-1);
  font-weight: 600;
  min-height: 1.4em;
}

.status.error {
  color: var(--error);
}

.status.success {
  color: var(--success);
}

.status.info {
  color: var(--accent-strong);
}

/* Privacy note */
.privacy-note {
  margin-top: var(--space-2);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Mono output views (JSON, JWT, SHA result) */
.json-view,
.sha-result {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  min-height: 120px;
  max-height: 360px;
  overflow: auto;
  margin: 0;
}

.sha-result {
  min-height: 60px;
}

/* JWT decoded sections */
.jwt-sections {
  display: grid;
  gap: var(--space-2);
}

.jwt-block {
  margin: 0;
}

.jwt-block .output-mode {
  margin-bottom: 0.3rem;
}

.jwt-note {
  margin-top: var(--space-1);
  font-size: 0.85rem;
  color: var(--text-muted);
}

@media (min-width: 1024px) {
  .jwt-sections {
    grid-template-columns: 1fr 1fr;
  }

  .jwt-block:first-child {
    grid-column: 1 / -1;
  }

  .jwt-block:nth-child(2),
  .jwt-block:nth-child(3) {
    grid-row: 2;
  }
}

/* Responsive output views */
@media (max-width: 600px) {
  .json-view,
  .sha-result {
    max-height: 280px;
  }
}

/* Steps */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  position: relative;
}

.step-num {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.step h3 {
  padding-left: 3rem;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.step p {
  margin: 0;
  color: var(--text-muted);
}

/* Features */
.features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.features li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
}

.features strong {
  color: var(--text);
}

/* FAQ */
.faq-container {
  max-width: 760px;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  padding: var(--space-2);
}

.faq-item summary {
  font-weight: 600;
  cursor: pointer;
  padding: 0.2rem 0;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "\002B";
  font-size: 1.3rem;
  color: var(--accent-strong);
  flex-shrink: 0;
}

.faq-item[open] summary::after {
  content: "\2212";
}

.faq-item summary:focus-visible {
  outline: 2px solid var(--focus);
  border-radius: 6px;
}

.faq-item p {
  margin: var(--space-1) 0 0;
  color: var(--text-muted);
}

/* Related tools */
.related-grid {
  display: grid;
  gap: var(--space-2);
}

.related-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  transition: transform var(--speed) var(--ease), border-color var(--speed) var(--ease);
}

.related-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.related-card h3 {
  font-size: 1.05rem;
}

.related-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  flex: 1;
}

.related-card a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent-strong);
}

.related-card a:hover {
  color: var(--focus);
}

.related-card a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Legal note */
.legal-note {
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
  border-top: 1px solid var(--border);
}

.legal-note .container {
  max-width: 760px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Footer */
.site-footer {
  background: #080a15;
  border-top: 1px solid var(--border);
  padding: var(--space-4) var(--space-2);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: center;
  text-align: center;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
}

.footer-nav a {
  color: var(--text-muted);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.footer-nav a:hover {
  color: var(--text);
}

.footer-nav a:focus-visible {
  outline: 2px solid var(--focus);
  border-radius: 6px;
}

.footer-copy,
.footer-legal {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}

/* Legal pages typography */
.legal-body {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-2);
}

.legal-body h1 {
  font-size: 2rem;
}

.legal-body h2 {
  font-size: 1.3rem;
  margin-top: var(--space-4);
}

.legal-body p,
.legal-body ul {
  color: var(--text-muted);
}

.legal-body ul {
  padding-left: var(--space-3);
}

.legal-body a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

/* Responsive: tablet and up */
@media (min-width: 601px) {
  .container {
    padding: 0 var(--space-3);
  }

  .tool-body {
    padding: var(--space-4);
  }

  .steps,
  .features,
  .related-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .brand-name {
    font-size: 1.2rem;
  }
}

/* Responsive: desktop */
@media (min-width: 1024px) {
  .tool-card {
    max-width: 860px;
    margin: 0 auto;
  }

  .steps,
  .related-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .features {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero {
    padding-top: var(--space-6);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
