/* superniche.im design system — editorial utility
   Linked by home + /fx/ sample pages. Tokens + components.
   Fonts: IBM Plex Sans/Mono, Noto Sans Arabic — OFL 1.1 (see fonts/LICENSES.md)
*/

@font-face {
  font-family: "IBM Plex Sans";
  src: url("/assets/fonts/IBMPlexSans-Variable.ttf") format("truetype");
  font-weight: 100 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/assets/fonts/IBMPlexMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/assets/fonts/IBMPlexMono-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Noto Sans Arabic";
  src: url("/assets/fonts/NotoSansArabic-Variable.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0B0C0E;
  --surface: #12141A;
  --surface-2: #191C24;
  --border: #2C3140;
  --text: #F0EDE6;
  --muted: #9B9AA3;
  --accent: #E5A33D;
  --accent-hover: #F0B85A;
  --accent-ink: #0B0C0E;
  --ok: #3D9B6E;
  --warn: #D4A017;
  --danger: #D45B5B;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-ar: "Noto Sans Arabic", "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-md: 1.125rem;
  --fs-lg: clamp(1.25rem, 1.1rem + 0.4vw, 1.5rem);
  --fs-xl: clamp(1.6rem, 1.2rem + 1.2vw, 2.25rem);
  --fs-display: clamp(2rem, 1.4rem + 2.2vw, 3.25rem);
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4rem;
  --measure: 1120px;
  --tool-max: 720px;
  --r-sm: 4px;
  --r-md: 6px;
  --shadow-lift: 0 12px 40px rgba(0, 0, 0, 0.35);
  --rule: 2px solid var(--accent);
  --header-h: 3.25rem;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #F5F2EB;
  --surface: #FFFFFF;
  --surface-2: #EDE9E1;
  --border: #D4CFC4;
  --text: #12141A;
  --muted: #5C5A55;
  --accent: #8B5A0A;
  --accent-hover: #6B4509;
  --accent-ink: #F5F2EB;
  --ok: #1F7A4D;
  --warn: #8A6A00;
  --danger: #B33A3A;
  --shadow-lift: 0 12px 32px rgba(18, 20, 26, 0.08);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #F5F2EB;
    --surface: #FFFFFF;
    --surface-2: #EDE9E1;
    --border: #D4CFC4;
    --text: #12141A;
    --muted: #5C5A55;
    --accent: #8B5A0A;
    --accent-hover: #6B4509;
    --accent-ink: #F5F2EB;
    --ok: #1F7A4D;
    --warn: #8A6A00;
    --danger: #B33A3A;
    --shadow-lift: 0 12px 32px rgba(18, 20, 26, 0.08);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html {
  overflow-x: clip;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
[dir="rtl"] body { font-family: var(--font-ar); }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}
a:hover { color: var(--accent-hover); }
img { max-width: 100%; height: auto; }

.skip {
  position: absolute;
  inset-inline-start: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: var(--s-2) var(--s-4);
  z-index: 100;
  font-weight: 600;
}
.skip:focus { inset-inline-start: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) { outline: none; }

/* —— Nav —— */
.site-header {
  background: var(--surface);
  border-block-end: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: var(--measure);
  margin-inline: auto;
  padding: var(--s-3) var(--s-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  min-height: var(--header-h);
}
.logo {
  font-weight: 650;
  font-size: var(--fs-md);
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
  unicode-bidi: isolate;
  direction: ltr;
}
.logo span {
  color: var(--accent);
  font-weight: 700;
}
.logo:hover { color: var(--text); }

.nav-tools {
  display: none;
  flex-wrap: wrap;
  gap: var(--s-1) var(--s-3);
  font-size: var(--fs-xs);
  font-family: var(--mono);
  justify-content: flex-end;
  max-width: 70%;
}
.nav-tools a {
  color: var(--muted);
  text-decoration: none;
}
.nav-tools a:hover,
.nav-tools a[aria-current="page"] {
  color: var(--accent);
}
@media (min-width: 900px) {
  .nav-tools { display: flex; }
}

.nav-menu {
  position: relative;
}
.nav-menu > summary {
  list-style: none;
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--s-2) var(--s-3);
  background: var(--surface-2);
}
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-menu > summary::after {
  content: " ▾";
  color: var(--muted);
  font-size: var(--fs-xs);
}
.nav-menu[open] > summary {
  border-color: var(--accent);
}
.nav-menu-panel {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + var(--s-2));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3);
  min-width: 14rem;
  max-height: min(70vh, 28rem);
  overflow: auto;
  box-shadow: var(--shadow-lift);
  display: grid;
  gap: var(--s-1);
  z-index: 60;
}
.nav-menu-panel a {
  color: var(--text);
  text-decoration: none;
  font-size: var(--fs-sm);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
}
.nav-menu-panel a:hover,
.nav-menu-panel a[aria-current="page"] {
  background: var(--surface-2);
  color: var(--accent);
}
@media (min-width: 900px) {
  .nav-menu { display: none; }
}

.theme-toggle {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-xs);
  font-family: var(--mono);
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

/* —— Main / hero —— */
main {
  flex: 1;
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding: var(--s-6) var(--s-5) var(--s-8);
}
.hero {
  margin-block-end: var(--s-6);
  max-width: 40rem;
  border-inline-start: var(--rule);
  padding-inline-start: var(--s-5);
}
.hero .eyebrow,
.hero .badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-block-end: var(--s-3);
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
}
.hero h1 {
  margin: 0 0 var(--s-3);
  font-size: var(--fs-display);
  line-height: 1.1;
  letter-spacing: -0.035em;
  font-weight: 650;
}
.hero .lead {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-md);
  max-width: 36rem;
  line-height: 1.5;
}
@keyframes hero-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.hero {
  animation: hero-in 0.18s ease-out both;
}
@media (prefers-reduced-motion: reduce) {
  .hero { animation: none; }
}

.breadcrumb {
  font-size: var(--fs-sm);
  color: var(--muted);
  margin: 0 0 var(--s-4);
}
.breadcrumb ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb li:not(:last-child)::after {
  content: "/";
  margin-inline-start: var(--s-2);
  color: var(--border);
}

/* —— Home tool grid —— */
.card-grid {
  display: grid;
  gap: var(--s-3);
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4) var(--s-4) var(--s-3);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
  min-height: 8.5rem;
}
.card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  color: inherit;
}
.card .card-slug {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--accent);
  letter-spacing: 0.02em;
}
.card h3 {
  margin: 0;
  font-size: var(--fs-base);
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.3;
}
.card p {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--muted);
  flex: 1;
  line-height: 1.45;
}
.card .card-link {
  font-size: var(--fs-xs);
  font-weight: 600;
  font-family: var(--mono);
  color: var(--muted);
  margin-block-start: var(--s-2);
}
.card:hover .card-link { color: var(--accent); }

.section-label {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 var(--s-3);
}

/* —— Tool box (forms) —— */
.tool-box,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-5);
  margin-block-end: var(--s-5);
  max-width: var(--tool-max);
}
.tool-box h2,
.panel h2 {
  margin: 0 0 var(--s-4);
  font-size: var(--fs-lg);
  letter-spacing: -0.02em;
  font-weight: 650;
}

label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-block-end: var(--s-1);
}
.hint {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: var(--fs-xs);
  margin-block-start: var(--s-1);
}

input[type="text"], input[type="url"], input[type="number"], input[type="email"],
input[type="search"], input[type="date"], input[type="color"],
select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 0.65rem 0.75rem;
  font: inherit;
  margin-block-end: var(--s-3);
}
textarea {
  min-height: 140px;
  resize: vertical;
  font-family: var(--mono);
  font-size: var(--fs-sm);
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: flex-end;
}
.row > * { flex: 1; min-width: 140px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  font: inherit;
  font-weight: 700;
  padding: 0.65rem 1.15rem;
  border-radius: var(--r-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.btn:hover {
  background: var(--accent-hover);
  color: var(--accent-ink);
}
.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
}
.btn-upgrade {
  background: var(--accent);
  color: var(--accent-ink);
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin: var(--s-2) 0 0;
}

.tool-answer,
.output {
  background: var(--bg);
  border: 1px solid var(--border);
  border-inline-start: var(--rule);
  border-radius: var(--r-sm);
  padding: var(--s-4);
  font-family: var(--mono);
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: pre-wrap;
  word-break: break-word;
  margin-block-start: var(--s-4);
  box-shadow: var(--shadow-lift);
}
.output:empty { display: none; }

.status {
  font-size: var(--fs-sm);
  color: var(--muted);
  margin: var(--s-2) 0;
  font-family: var(--mono);
}
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }
.status.warn { color: var(--warn); }

.table-wrap { overflow-x: auto; margin-block-start: var(--s-3); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
th, td {
  text-align: start;
  padding: var(--s-2) var(--s-3);
  border-block-end: 1px solid var(--border);
}
th {
  color: var(--muted);
  font-weight: 600;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.attr {
  font-size: var(--fs-xs);
  color: var(--muted);
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: var(--s-3) var(--s-4);
  margin-block-start: var(--s-4);
}

.upgrade-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4) var(--s-5);
  margin: var(--s-5) 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  max-width: var(--tool-max);
}
.upgrade-box p {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-sm);
  max-width: 36rem;
}
.upgrade-box strong { color: var(--text); }

/* —— Facts table —— */
.facts {
  margin: var(--s-5) 0;
  max-width: var(--tool-max);
}
.facts h2 {
  font-size: var(--fs-lg);
  margin: 0 0 var(--s-3);
  letter-spacing: -0.02em;
}
.facts table { font-size: var(--fs-sm); }
.facts td a { word-break: break-word; }

/* —— FAQ —— */
.faq {
  margin-block-start: var(--s-6);
  max-width: var(--tool-max);
}
.faq h2 {
  margin-block-end: var(--s-4);
  font-size: var(--fs-lg);
  letter-spacing: -0.02em;
}
.faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--s-3) var(--s-4);
  margin-block-end: var(--s-2);
}
.faq summary {
  cursor: pointer;
  font-weight: 600;
  list-style-position: outside;
}
.faq details[open] summary { margin-block-end: var(--s-2); }
.faq p { margin: 0; color: var(--muted); font-size: var(--fs-sm); }

.note {
  font-size: var(--fs-sm);
  color: var(--muted);
  border-inline-start: 3px solid var(--border);
  padding-inline-start: var(--s-3);
  margin: var(--s-4) 0;
}

.direct-answer {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  margin: 0 0 var(--s-5);
  font-size: var(--fs-md);
  max-width: 46rem;
}

.lang-switch {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  font-size: var(--fs-xs);
  margin: var(--s-3) 0 0;
}
.lang-switch a {
  color: var(--muted);
  text-decoration: none;
  padding: var(--s-1) var(--s-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.lang-switch a:hover,
.lang-switch a[aria-current="page"] {
  color: var(--accent);
  border-color: var(--accent);
}

/* —— Footer —— */
.site-footer {
  border-block-start: 1px solid var(--border);
  background: var(--surface);
  padding: var(--s-6) var(--s-5) var(--s-7);
  margin-block-start: auto;
}
.footer-inner {
  max-width: var(--measure);
  margin-inline: auto;
}
.footer-inner h2 {
  font-size: var(--fs-xs);
  margin: 0 0 var(--s-3);
  color: var(--muted);
  font-weight: 600;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-4);
  font-size: var(--fs-sm);
  font-family: var(--mono);
  margin-block-end: var(--s-4);
}
.footer-links a {
  color: var(--muted);
  text-decoration: none;
}
.footer-links a:hover,
.footer-links a[aria-current="page"] { color: var(--accent); }
.footer-copy {
  font-size: var(--fs-xs);
  color: var(--muted);
  margin: 0;
  max-width: 40rem;
}

.related { margin: var(--s-5) 0; }
.related h2 { font-size: var(--fs-md); }
.related ul { padding-inline-start: 1.1rem; }

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

.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: var(--s-2) 0; }
.chip {
  font-size: var(--fs-xs);
  font-family: var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  color: var(--muted);
}

.list-clean { list-style: none; padding: 0; margin: 0; }
.list-clean li {
  padding: var(--s-2) var(--s-3);
  border-block-end: 1px solid var(--border);
  font-size: var(--fs-sm);
}
.list-clean li:last-child { border-block-end: none; }

.sev-high { color: var(--danger); }
.sev-med { color: var(--warn); }
.sev-low { color: var(--ok); }

.canvas-wrap {
  background: #fff;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  max-width: 100%;
}
canvas { display: block; max-width: 100%; height: auto; }

.tool-grid { display: grid; gap: var(--s-4); }
@media (min-width: 720px) {
  .tool-grid.two { grid-template-columns: 1fr 1fr; }
}

/* RTL extras — logical props cover most; keep brand LTR */
[dir="rtl"] .logo { direction: ltr; unicode-bidi: isolate; }

/* —— FX history chart (eadb: #fx-chart-wrap / #fx-chart SVG via fx.js) ——
   SVG emits: line (grid), text (axis labels), path area (fill), path stroke (series).
   All use currentColor in markup; we recolor via element selectors. */
#fx-chart-wrap[hidden] {
  display: none !important;
}
#fx-chart-wrap:not([hidden]) {
  display: block;
  margin: var(--s-4) 0 0;
  padding: var(--s-4);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  max-width: 100%;
}
#fx-chart-caption {
  margin: 0 0 var(--s-3);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
  line-height: 1.4;
}
#fx-chart {
  width: 100%;
  line-height: 0;
}
#fx-chart svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 220px;
  direction: ltr;
  color: var(--muted);
  overflow: visible;
}
#fx-chart svg line {
  stroke: var(--muted);
}
#fx-chart svg text {
  fill: var(--muted);
  font-family: var(--mono), ui-monospace, monospace;
  font-size: 10px;
}
#fx-chart svg path[fill="none"] {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
}
#fx-chart svg path:not([fill="none"]) {
  fill: var(--accent);
}
