/* =========================================================================
   assets/css/styles.css
   -------------------------------------------------------------------------
   Component layer on top of Tailwind, plus the site look and feel.

   1. tokens
   2. shell: background, chrome
   3. chrome: sidebar, topbar, footer, page heading
   4. components: surfaces, nav, buttons, inputs, alerts, meter, dropzone,
      tables, spinner
   5. route change, motion, print

   A clean, modern light/dark theme. Dark mode lives under html.dark, which
   is the default: index.php ships the class and app.js only drops it when
   a visitor explicitly picks light. Toggling the sun icon still gives the
   original (light) palette.

   Some rules use !important deliberately. The markup carries Tailwind dark:
   utilities (dark:bg-slate-900 and friends) whose compiled selectors outrank
   plain element selectors in this file.

   NOTE: plain CSS on purpose. @apply only works with the Tailwind CLI build.
   ========================================================================= */

:root {
  /* light theme */
  --brand-50: #eef4ff;
  --brand-100: #dbe7ff;
  --brand-400: #5c8cf5;
  --brand-500: #3b6fe0;
  --brand-600: #2c56c9;
  --brand-700: #2545a3;
  --ring: rgba(44, 86, 201, 0.35);

  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: rgb(226 232 240);
  --text: rgb(30 41 59);
  --text-dim: rgb(100 116 139);
  --sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* the accent scale gets a touch brighter in dark mode, still a normal blue */
html.dark {
  --brand-50: #0b1220;
  --brand-100: #111c33;
  --brand-400: #7aa5ff;
  --brand-500: #5c8cf5;
  --brand-600: #4d7ef0;
  --brand-700: #3a63cf;
  --ring: rgba(93, 140, 245, .4);

  --surface: #0f172a;
  --surface-2: rgba(30, 41, 59, .7);
  --border: rgba(148, 163, 184, .16);
  --text: rgb(226 232 240);
  --text-dim: rgb(148 163 184);
}

html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--sans); font-feature-settings: "cv02","cv03","cv04","cv11"; }

/* ----------------------------------------------------------------- shell */
html.dark body {
  background-color: var(--surface) !important;
  color: var(--text) !important;
}

html.dark ::selection { background: rgba(93, 140, 245, .35); color: #fff; }
html.dark * { scrollbar-width: thin; scrollbar-color: rgba(148,163,184,.35) transparent; }
html.dark ::-webkit-scrollbar { width: 10px; height: 10px; }
html.dark ::-webkit-scrollbar-track { background: transparent; }
html.dark ::-webkit-scrollbar-thumb { background: rgba(148,163,184,.28); border-radius: 999px; }
html.dark ::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,.45); }

/* ---------------------------------------------------------------- chrome */
html.dark #sidebar {
  background: rgba(15, 23, 42, .96) !important;
  border-color: var(--border) !important;
}
html.dark #sidebar nav p { color: var(--text-dim) !important; }
html.dark #sidebar input {
  background: rgba(255, 255, 255, .06) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}
html.dark #sidebar span.bg-brand-600 {
  background: rgba(93, 140, 245, .18) !important;
  color: var(--brand-400) !important;
  border: 1px solid var(--border);
}
html.dark header.sticky {
  background: rgba(15, 23, 42, .85) !important;
  border-color: var(--border) !important;
}
html.dark footer {
  background: rgba(15, 23, 42, .92) !important;
  border-color: var(--border) !important;
}
html.dark footer a { color: var(--text-dim) !important; }
html.dark footer a:hover { color: var(--brand-400) !important; }

/* the server rendered page heading */
html.dark [data-seo="category"] {
  color: var(--brand-400) !important;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .75rem;
}
html.dark [data-seo="h1"] { color: #fff !important; }
html.dark [data-seo="intro"] { color: var(--text-dim) !important; }

/* -------------------------------------------------------------- surfaces */
.card {
  position: relative;
  border: 1px solid rgb(226 232 240);
  background: #fff;
  border-radius: 0.875rem;
  padding: 1.25rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
html.dark .card {
  border-color: var(--border) !important;
  background: var(--surface-2) !important;
  border-radius: .875rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

/* ------------------------------------------------------------ navigation */
.nav-link {
  position: relative;
  display: block;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  color: rgb(71 85 105);
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}
.nav-link:hover { background: rgb(241 245 249); color: rgb(15 23 42); }

.nav-link-active,
.nav-link[aria-current="page"] {
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--brand-600);
}
html.dark .nav-link { color: var(--text-dim); }
html.dark .nav-link:hover { background: rgba(93, 140, 245, .08); color: var(--brand-400); }
html.dark .nav-link-active,
html.dark .nav-link[aria-current="page"] {
  background: rgba(93, 140, 245, .12);
  color: var(--brand-400);
  box-shadow: inset 2px 0 0 var(--brand-500);
}

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border-radius: .625rem;
  padding: .55rem 1rem;
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.25rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--brand-600); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-700); }

.btn-ghost { background: transparent; border-color: rgb(203 213 225); color: rgb(51 65 85); }
.btn-ghost:hover:not(:disabled) { background: rgb(241 245 249); }

html.dark .btn-primary {
  background: var(--brand-600);
  color: #fff;
}
html.dark .btn-primary:hover:not(:disabled) { background: var(--brand-700); }
html.dark .btn-ghost { border-color: var(--border); color: var(--text-dim); }
html.dark .btn-ghost:hover:not(:disabled) {
  background: rgba(93, 140, 245, .08);
  border-color: var(--brand-500);
  color: var(--brand-400);
}

/* ---------------------------------------------------------------- inputs */
.field {
  width: 100%;
  border-radius: .625rem;
  border: 1px solid rgb(203 213 225);
  background: #fff;
  padding: .55rem .75rem;
  font-size: .875rem;
  color: rgb(15 23 42);
}
.field:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--ring); }
html.dark .field {
  border-color: var(--border) !important;
  background: rgba(255, 255, 255, .04) !important;
  color: var(--text) !important;
  caret-color: var(--brand-400);
}
html.dark .field:focus {
  border-color: var(--brand-500) !important;
  box-shadow: 0 0 0 3px var(--ring);
}
html.dark .field::placeholder { color: var(--text-dim); }

textarea.field { min-height: 10rem; resize: vertical; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.label { display: block; font-size: .8125rem; font-weight: 600; margin-bottom: .35rem; color: rgb(51 65 85); }
html.dark .label { color: var(--text-dim) !important; }
.hint { font-size: .75rem; color: rgb(100 116 139); }
html.dark .hint { color: var(--text-dim); }

/* ---------------------------------------------------------------- alerts */
.alert { border-radius: .625rem; padding: .75rem 1rem; font-size: .875rem; border: 1px solid; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-info { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-700); }
html.dark .alert-error {
  background: rgba(248, 113, 113, .12) !important;
  border-color: rgba(248, 113, 113, .35) !important;
  color: #fca5a5 !important;
}
html.dark .alert-success {
  background: rgba(74, 222, 128, .12) !important;
  border-color: rgba(74, 222, 128, .3) !important;
  color: #86efac !important;
}
html.dark .alert-info {
  background: rgba(93, 140, 245, .12) !important;
  border-color: rgba(93, 140, 245, .3) !important;
  color: var(--brand-400) !important;
}

/* -------------------------------------------------------------- strength */
.meter { height: .5rem; border-radius: 999px; background: rgb(226 232 240); overflow: hidden; }
html.dark .meter { background: rgba(255, 255, 255, .08); }
.meter > span { display: block; height: 100%; width: 0; transition: width .25s ease, background-color .25s ease; }

/* -------------------------------------------------------------- dropzone */
.dropzone {
  border: 2px dashed rgb(203 213 225);
  border-radius: .875rem;
  padding: 2rem 1rem;
  text-align: center;
  transition: border-color .15s ease, background-color .15s ease;
}
.dropzone.is-dragging { border-color: var(--brand-500); background: var(--brand-50); }
html.dark .dropzone { border-color: var(--border); }
html.dark .dropzone.is-dragging {
  border-color: var(--brand-500);
  background: rgba(93, 140, 245, .08);
}

/* ---------------------------------------------------------------- tables */
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th, .table td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid rgb(226 232 240); vertical-align: top; }
.table th { font-weight: 600; color: rgb(71 85 105); }
html.dark .table th, html.dark .table td { border-color: var(--border) !important; }
html.dark .table th { color: var(--text-dim) !important; }
html.dark .table tbody tr:hover td { background: rgba(255, 255, 255, .03); }

/* --------------------------------------------------------------- spinner */
.spinner {
  width: 1rem; height: 1rem; border-radius: 999px;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: wus-spin .7s linear infinite; display: inline-block;
}
@keyframes wus-spin { to { transform: rotate(360deg); } }
html.dark .spinner { color: var(--brand-400); }

/* ----------------------------------------------------------- route change */
#tool-root { min-height: 12rem; }
#tool-root.is-loading { opacity: .5; pointer-events: none; }

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

/* --------------------------------------------------------- print friendly */
@media print {
  #sidebar, header, footer, .no-print { display: none !important; }
  .card { border: none; box-shadow: none; padding: 0; }
}
