/* ==========================================================================
   The Free AI Tools - PHP Monochrome Studio Pro Stylesheet
   --------------------------------------------------------------------------
   Mirrors src/app/globals.css from the Next.js Studio Pro architecture so
   Hostinger PHP deployments render identical monochrome tokens, self-hosted
   variable fonts, 3-column Studio Pro application windows (.studio-app-window),
   recessed artboard stages (.studio-stage-ground), tabular readouts (.readout),
   and RTL Arabic typography.

   NOTE: tailwind.css is linked directly in app/partials/head.php with its own
   content-hash ?v= query parameter so immutable browser/CDN caches never hold
   a stale Tailwind stylesheet across deployments.
   ========================================================================== */

/* Self-hosted variable fonts (SIL Open Font License 1.1) — zero third-party requests. */
@font-face {
  font-family: "Geist";
  src: url("../fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: optional;
}

@font-face {
  font-family: "Geist Mono";
  src: url("../fonts/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: optional;
}

@font-face {
  font-family: "Noto Sans Arabic";
  src: url("../fonts/NotoSansArabic-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0600-06FF,U+0750-077F,U+0870-088E,U+0890-0891,U+0897-08E1,U+08E3-08FF,U+200C-200E,U+2010-2011,U+204F,U+2E41,U+FB50-FDFF,U+FE70-FE74,U+FE76-FEFC,U+102E0-102FB,U+10E60-10E7E,U+10EC2-10EC4,U+10EFC-10EFF,U+1EE00-1EEFF;
}

:root {
  color-scheme: light;

  /* ── Type ─────────────────────────────────────────────────────────────── */
  --font-geist: "Geist";
  --font-sans-stack: var(--font-geist), "Noto Sans Arabic", ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono-stack: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;

  /* ── Studio Pro Monochrome Surfaces ───────────────────────────────────── */
  --background: #ffffff;
  --paper: #f7f7f7;
  --panel: #ffffff;
  --ink: #000000;
  --rule: #d4d4d4;
  --grid: rgba(0, 0, 0, 0.05);
  --muted-ink: #4b4b4b;

  /* ── Accents ──────────────────────────────────────────────────────────── */
  --signal: #111111;
  --signal-foreground: #ffffff;
  --signal-soft: #f2f2f2;
  --beam: #525252;
  --alert: #525252;

  /* ── shadcn / component bridge ────────────────────────────────────────── */
  --radius: 0.75rem;
  --foreground: var(--ink);
  --card: var(--panel);
  --card-foreground: var(--ink);
  --popover: var(--panel);
  --popover-foreground: var(--ink);
  --primary: var(--signal);
  --primary-foreground: var(--signal-foreground);
  --secondary: #f2f2f2;
  --secondary-foreground: var(--ink);
  --muted: #f2f2f2;
  --muted-foreground: var(--muted-ink);
  --accent: var(--signal-soft);
  --accent-foreground: #000000;
  --destructive: #111111;
  --border: var(--rule);
  --input: #d4d4d4;
  --ring: var(--signal);
  --chart-1: #111111;
  --chart-2: #444444;
  --chart-3: #6b6b6b;
  --chart-4: #909090;
  --chart-5: #b5b5b5;
  --sidebar: #ffffff;
  --sidebar-foreground: var(--ink);
  --sidebar-primary: var(--signal);
  --sidebar-primary-foreground: var(--signal-foreground);
  --sidebar-accent: var(--signal-soft);
  --sidebar-accent-foreground: #000000;
  --sidebar-border: var(--rule);
  --sidebar-ring: var(--signal);

  /* Motion & elevation */
  --ease-out-soft: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow-rest: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lift: 0 10px 30px -12px rgba(0, 0, 0, 0.16), 0 2px 6px rgba(0, 0, 0, 0.05);
}

* {
  border-color: var(--border);
}

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

body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans-stack);
  overflow-x: hidden;
}

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring);
  border-radius: 4px;
}

[id] {
  scroll-margin-top: 4.5rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.sr-only:focus,
.focus\:not-sr-only:focus {
  position: fixed !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  overflow: visible !important;
  clip: auto !important;
}

::selection {
  background: rgba(17, 17, 17, 0.14);
}

/* ─── Studio Pro Application Window & Artboard Primitives ──────────────── */
.studio-app-window {
  background: var(--panel);
  border: 1px solid color-mix(in oklab, var(--ink) 20%, var(--rule));
  border-radius: 12px;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.06),
    0 12px 32px -12px rgba(0, 0, 0, 0.12);
}

.studio-stage-ground {
  background-color: #f2f2f2;
  background-image: radial-gradient(#d4d4d4 1px, transparent 1px);
  background-size: 16px 16px;
}

.grid-ground {
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 8px 8px;
  background-position: center;
}

.grid-ground-lg {
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, #000 0%, #000 55%, transparent 100%);
}

.plate {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 10px;
  transition: border-color 150ms ease-out, transform 150ms ease-out;
}

.plate-hover:hover {
  border-color: color-mix(in oklab, var(--signal) 45%, var(--rule));
}

.plate-rail {
  position: relative;
}

.plate-rail::after {
  content: "";
  position: absolute;
  inset-inline: -1px;
  bottom: -1px;
  height: 2px;
  background: var(--rule);
  border-radius: 0 0 10px 10px;
  transition: background-color 150ms ease-out;
}

.plate:hover .plate-rail::after,
.plate:focus-visible .plate-rail::after {
  background: var(--signal);
}

.surface {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition:
    border-color 150ms ease-out,
    box-shadow 150ms ease-out,
    transform 150ms ease-out;
}

.surface-hover:hover,
.surface-hover:focus-within {
  border-color: color-mix(in oklab, var(--signal) 38%, var(--rule));
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
  transform: translateY(-1px);
}

.tint-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 12px;
}

.browser-window {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.05),
    0 12px 32px -12px rgba(0, 0, 0, 0.14);
}

.brand-mark {
  background: var(--signal);
}

.led {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--beam);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--beam) 18%, transparent);
  flex: none;
}

.led-signal {
  background: var(--signal);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--signal) 16%, transparent);
}

.led-alert {
  background: var(--alert);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--alert) 16%, transparent);
}

.readout {
  font-family: var(--font-mono-stack);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.hairline {
  height: 1px;
  background: var(--rule);
  border: 0;
}

[data-slot="card"] select,
[role="tabpanel"] select {
  max-width: 100%;
  min-width: 0;
}

.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}

/* ─── Leaflet Map Safeguards ───────────────────────────────────────────── */
.leaflet-container {
  isolation: isolate;
  z-index: 0;
  font-family: var(--font-sans-stack);
}

.leaflet-container img.leaflet-tile,
.leaflet-container img.leaflet-marker-icon,
.leaflet-container img.leaflet-image-layer {
  max-width: none !important;
  max-height: none !important;
}

.leaflet-container .leaflet-control-attribution {
  font-size: 10px;
  line-height: 1.35;
  max-width: 78vw;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(4px);
  border-top-left-radius: 6px;
}

/* ─── Motion ───────────────────────────────────────────────────────────── */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.rise {
  animation: rise-in 0.52s var(--ease-out-soft);
}
.rise-1 { animation-delay: 60ms; }
.rise-2 { animation-delay: 120ms; }
.rise-3 { animation-delay: 180ms; }
.rise-4 { animation-delay: 240ms; }

.js [data-reveal] {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.45s var(--ease-out-soft), transform 0.45s var(--ease-out-soft);
}
.js [data-reveal].is-visible {
  opacity: 1;
  transform: none;
}
.stagger > * {
  transition: opacity 0.45s var(--ease-out-soft), transform 0.45s var(--ease-out-soft);
}
.js .stagger[data-reveal] > * {
  opacity: 0;
  transform: translateY(10px);
}
.js .stagger[data-reveal].is-visible > * {
  opacity: 1;
  transform: none;
}
.js .stagger[data-reveal].is-visible > *:nth-child(2) { transition-delay: 60ms; }
.js .stagger[data-reveal].is-visible > *:nth-child(3) { transition-delay: 120ms; }
.js .stagger[data-reveal].is-visible > *:nth-child(4) { transition-delay: 180ms; }
.js .stagger[data-reveal].is-visible > *:nth-child(5) { transition-delay: 240ms; }
.js .stagger[data-reveal].is-visible > *:nth-child(6) { transition-delay: 300ms; }
.js .stagger[data-reveal].is-visible > *:nth-child(n + 7) { transition-delay: 360ms; }

.lift {
  transition: transform 0.18s var(--ease-out-soft), box-shadow 0.18s var(--ease-out-soft),
    border-color 0.18s var(--ease-out-soft), background-color 0.18s var(--ease-out-soft);
}
a.lift:hover,
.lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
}
a.lift:active,
.lift:active {
  transform: translateY(0);
}

@keyframes sweep-once {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}
.sweep {
  position: relative;
  overflow: hidden;
}
.sweep::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(17, 17, 17, 0.08) 50%, transparent 80%);
  transform: translateX(-100%);
}
.sweep.is-running::after {
  animation: sweep-once 0.9s var(--ease-out-soft);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js [data-reveal],
  .js .stagger[data-reveal] > * {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  .rise { animation: none; }
  a.lift:hover, .lift:hover { transform: none; box-shadow: var(--shadow-rest); }
  .sweep::after { display: none; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* Monochrome bridge for precompiled editorial/blog PHP templates */
.bg-\[\#F7F9FC\] { background-color: var(--paper) !important; }
.text-blue-600,
.text-blue-700,
.text-blue-500 { color: var(--ink) !important; }
.hover\:text-blue-700:hover,
.hover\:text-blue-600:hover { color: #000000 !important; }
.bg-blue-600 { background-color: var(--signal) !important; }
.hover\:bg-blue-700:hover { background-color: #000000 !important; }
.ring-blue-600 { --tw-ring-color: var(--signal) !important; }
.border-blue-200,
.border-blue-300,
.border-blue-100 { border-color: var(--rule) !important; }
.hover\:border-blue-200:hover,
.hover\:border-blue-300:hover { border-color: #737373 !important; }
.bg-blue-50,
.bg-blue-100 { background-color: var(--paper) !important; }
.hover\:bg-blue-100:hover { background-color: #eaeaea !important; }

.shadow-sm,
.shadow-xs {
  box-shadow: var(--shadow-rest);
}

/* ─── Editorial / Article Typography ───────────────────────────────────── */
.article-body {
  font-size: 1rem;
  line-height: 1.75;
  color: #262626;
}
.article-body > * + * { margin-top: 1.15em; }
.article-body h2 {
  margin-top: 2.25em;
  margin-bottom: 0.6em;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.3;
  color: var(--ink);
}
.article-body h3 {
  margin-top: 1.9em;
  margin-bottom: 0.5em;
  font-size: 1.175rem;
  font-weight: 650;
  line-height: 1.4;
  color: #171717;
}
.article-body h2 + *,
.article-body h3 + * { margin-top: 0.5em; }
.article-body p,
.article-body li { text-wrap: pretty; }
.article-body a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.article-body a:hover { text-decoration-thickness: 2px; }
.article-body strong { font-weight: 650; color: var(--ink); }
.article-body ul { list-style: disc; padding-left: 1.4em; }
.article-body ol { list-style: decimal; padding-left: 1.4em; }
.article-body li + li { margin-top: 0.4em; }
.article-body li > ul,
.article-body li > ol { margin-top: 0.4em; }
.article-body blockquote {
  border-left: 3px solid var(--signal);
  padding-left: 1em;
  font-style: italic;
  color: var(--muted-ink);
}
.article-body code {
  font-family: var(--font-mono-stack);
  font-size: 0.875em;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 0.3rem;
  padding: 0.12em 0.35em;
  white-space: break-spaces;
}
.article-body pre {
  overflow-x: auto;
  background: #111111;
  color: #f7f7f7;
  border-radius: 0.75rem;
  padding: 1rem 1.15rem;
  font-size: 0.85rem;
  line-height: 1.6;
}
.article-body pre code {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font-size: inherit;
}
.article-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  display: block;
  overflow-x: auto;
}
.article-body th,
.article-body td {
  border: 1px solid var(--rule);
  padding: 0.55rem 0.75rem;
  text-align: left;
  vertical-align: top;
}
.article-body th {
  background: var(--paper);
  font-weight: 600;
}
.article-body img,
.article-body video,
.article-body iframe {
  max-width: 100%;
  height: auto;
  border-radius: 0.75rem;
}
.article-body hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2em 0;
}

/* ─── PHP Component Primitives ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.625rem 1rem;
  transition: background-color 0.16s var(--ease-out-soft), border-color 0.16s var(--ease-out-soft),
    color 0.16s var(--ease-out-soft), transform 0.16s var(--ease-out-soft), box-shadow 0.16s var(--ease-out-soft);
  cursor: pointer;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--signal);
  color: var(--signal-foreground);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14);
}
.btn-primary:hover {
  background: #000000;
}
.btn-outline {
  border: 1px solid var(--rule);
  background: var(--panel);
  color: var(--ink);
}
.btn-outline:hover {
  border-color: #737373;
  background: var(--paper);
}
.btn-ghost { color: var(--ink); }
.btn-ghost:hover { background: var(--paper); }
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.8rem 1.4rem; font-size: 0.95rem; }

.card {
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-rest);
}
.card-pad { padding: 1.25rem; }
@media (min-width: 640px) {
  .card-pad { padding: 1.5rem; }
}

.tool-tile {
  display: flex;
  gap: 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  background: var(--panel);
  padding: 0.9rem;
  transition: border-color 0.18s var(--ease-out-soft), background-color 0.18s var(--ease-out-soft),
    box-shadow 0.18s var(--ease-out-soft), transform 0.18s var(--ease-out-soft);
}
.tool-tile:hover {
  border-color: #737373;
  background: var(--panel);
  box-shadow: var(--shadow-lift);
  transform: translateY(-2px);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  padding: 0.15rem 0.6rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.badge-blue,
.badge-emerald,
.badge-amber {
  border-color: var(--rule);
  background: var(--paper);
  color: var(--ink);
}

[data-studio-root]:empty::after {
  content: "";
  display: block;
  height: 220px;
  border-radius: 0.75rem;
  background: linear-gradient(90deg, #f5f5f5 25%, #ebebeb 37%, #f5f5f5 63%);
  background-size: 400% 100%;
  animation: studio-skeleton 1.4s ease infinite;
}
@keyframes studio-skeleton {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.code-panel {
  font-family: var(--font-mono-stack);
  font-size: 0.8125rem;
  line-height: 1.7;
  background: #111111;
  color: #f5f5f5;
  border-radius: var(--radius);
  border: 1px solid #262626;
}
.code-panel .tok-key { color: #e5e5e5; }
.code-panel .tok-str { color: #d4d4d4; }
.code-panel .tok-dim { color: #8a8a8a; }

.endpoint-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono-stack);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 0.375rem;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  padding: 0.2rem 0.5rem;
}

.spec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.spec-table th,
.spec-table td {
  border-bottom: 1px solid var(--rule);
  padding: 0.65rem 0.5rem;
  text-align: left;
  vertical-align: top;
}
.spec-table th {
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.prose-page :where(h2) {
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.6rem;
  letter-spacing: -0.01em;
}
.prose-page :where(h3) {
  font-size: 1.08rem;
  font-weight: 650;
  margin-top: 1.5rem;
  margin-bottom: 0.4rem;
}
.prose-page :where(p, li) {
  font-size: 0.9375rem;
  line-height: 1.75;
  color: var(--muted-ink);
}
.prose-page :where(ul) { list-style: disc; padding-left: 1.3em; }
.prose-page :where(ol) { list-style: decimal; padding-left: 1.3em; }
.prose-page :where(li + li) { margin-top: 0.35rem; }
.prose-page :where(a) { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }

.toc a {
  display: block;
  border-radius: 0.4rem;
  padding: 0.25rem 0.4rem;
  font-size: 0.8125rem;
  color: var(--muted-ink);
}
.toc a:hover { background: var(--paper); color: var(--ink); }

/* ─── Arabic / RTL Support ─────────────────────────────────────────────── */
[dir="rtl"] {
  font-family: "Noto Sans Arabic", var(--font-geist), "Segoe UI", Tahoma, "Arial", sans-serif;
  line-height: 1.85;
  letter-spacing: 0;
  font-kerning: normal;
  text-align: start;
  overflow-wrap: break-word;
}
[dir="rtl"] :where(*:not(code):not(pre):not(kbd):not(samp):not(.font-mono):not([data-ltr]):not([dir="ltr"])) {
  letter-spacing: 0 !important;
  text-transform: none !important;
}
[dir="rtl"] :where(code, pre, kbd, samp, .font-mono, [data-ltr], [dir="ltr"]) {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: start;
}
[dir="rtl"] body { text-align: right; }
[dir="rtl"] .article-body ul,
[dir="rtl"] .article-body ol,
[dir="rtl"] .prose-page ul,
[dir="rtl"] .prose-page ol { padding-left: 0; padding-right: 1.4em; }
[dir="rtl"] .article-body blockquote { border-left: 0; border-right: 3px solid var(--signal); padding-left: 0; padding-right: 1em; }
[dir="rtl"] .spec-table th,
[dir="rtl"] .spec-table td,
[dir="rtl"] .article-body th,
[dir="rtl"] .article-body td { text-align: right; }
[dir="rtl"] .article-body,
[dir="rtl"] .prose-page :where(p, li) { line-height: 1.9; }

@media (max-width: 640px) {
  [dir="rtl"] h1 { font-size: 1.85rem; }
  [dir="rtl"] h2 { font-size: 1.4rem; }
  [dir="rtl"] a, [dir="rtl"] button { overflow-wrap: anywhere; }
}

/* Embed preview (`?embed=1`): hide global chrome */
html[data-embed-preview="1"] header[role="banner"],
html[data-embed-preview="1"] footer {
  display: none !important;
}
html[data-embed-preview="1"] #main-content {
  padding-top: 0 !important;
}

@media print {
  header[role="banner"],
  footer,
  .no-print { display: none !important; }
  main { padding-top: 0 !important; }
  body { background: #fff; color: #000; }
  .article-body a { color: #000; text-decoration: underline; }
  .article-body a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.75em; }
}
