/* ==========================================================================
   SEKER — Base layer (public/css/base.css)
   Foundation every page builds on. Loads after tokens.css and (where the
   layout ships it) Bootstrap — but is written to STAND ALONE on the public
   profile page, which loads no Bootstrap CSS at all.

   Conventions:
   - Element-level selectors for anything that must work without Bootstrap.
   - `se-*` is the shared utility namespace owned by this file.
   - Tokens only: zero hex, zero magic numbers that a token already covers.
   - Logical properties (inline-start/end, block) for RTL safety.

   Sections
   01 Reset & normalization      11 Scrollbars & selection
   02 Document & body defaults   12 Utilities (Bootstrap-free)
   03 Headings — fluid scale     13 Scroll reveal
   04 Links                      14 Skeleton shimmer keyframes
   05 Focus visibility           15 Glass surface
   06 Skip link & SR helpers     16 RTL typography
   07 Media                      17 Small screens (≤575px)
   08 Forms (element level)      18 Reduced motion
   09 Text blocks                19 Print
   10 Tables
   ========================================================================== */

/* --- 01 Reset & normalization (layered on top of Bootstrap) --- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  tab-size: 4;
  /* Brand-tinted tap flash instead of the OS gray */
  -webkit-tap-highlight-color: rgba(var(--se-primary-rgb), .18);
}

/* `hidden` must always win — mobile menus/offcanvases toggle this attribute */
[hidden]:not([hidden="until-found"]) {
  display: none !important;
}

/* Anchor targets clear a sticky topbar */
:target {
  scroll-margin-block-start: calc(var(--se-topbar-h) + var(--se-s-4));
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button:not(:disabled),
[role="button"]:not(:disabled) {
  cursor: pointer;
}

textarea {
  resize: vertical;
  overflow: auto;
}

iframe {
  border: 0; /* phone-preview + embed iframes render clean with no Bootstrap */
}

abbr[title] {
  text-decoration: underline dotted;
  text-underline-offset: .15em;
  cursor: help;
}

mark {
  background: var(--se-warning-tint);
  color: var(--se-text);
  padding-inline: .2em;
  border-radius: 4px;
}

sub,
sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sub { bottom: -.25em; }
sup { top: -.5em; }

::placeholder {
  color: var(--se-text-3);
  opacity: 1;
}

/* Native controls follow the active theme (scrollbars, form fills, popups) */
:root {
  color-scheme: light;
}

[data-bs-theme="dark"] {
  color-scheme: dark;
}

/* --- 02 Document & body defaults --- */

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--se-font-sans);
  font-size: var(--se-fs-base);
  line-height: var(--se-lh-base);
  color: var(--se-text);
  background-color: var(--se-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* Long handles/URLs and user strings never blow out a layout */
  overflow-wrap: break-word;
}

/* --- 03 Headings — fluid display scale --- */

h1, h2, h3, h4, h5, h6 {
  margin-block: 0 var(--se-s-2);
  font-family: var(--se-font-display);
  font-weight: 700;
  line-height: var(--se-lh-tight);
  letter-spacing: var(--se-ls-tight);
  color: var(--se-text);
  text-wrap: balance;
}

/* Fluid: token-defined min/max, viewport-fluid middle step */
h1 { font-size: clamp(var(--se-fs-4xl), 1.75rem + 3vw,   var(--se-fs-6xl)); }
h2 { font-size: clamp(var(--se-fs-3xl), 1.4rem + 2.2vw,  var(--se-fs-5xl)); }
h3 { font-size: clamp(var(--se-fs-2xl), 1.2rem + 1.4vw,  var(--se-fs-4xl)); }
h4 { font-size: clamp(var(--se-fs-xl),  1.05rem + .8vw,  var(--se-fs-3xl)); }
h5 { font-size: clamp(var(--se-fs-lg),  1rem + .4vw,      var(--se-fs-2xl)); }
h6 { font-size: var(--se-fs-lg); }

/* --- 04 Links --- */

a {
  color: var(--se-primary);
  text-decoration: none;
  background-color: transparent;
}

a:hover {
  color: var(--se-primary-hover);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: .2em;
}

/* Classed links (.btn, .nav-link, .dropdown-item, …) own their hover look —
   the base layer must never underline or recolor a component. */
a[class]:hover {
  text-decoration: none;
}

/* Prose links: inherit the surrounding color (never break paragraph contrast)
   but always keep an underline affordance in the brand tint. */
:where(p, li, dd, figcaption, blockquote) a:not([class]) {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1.25px;
  text-decoration-color: rgba(var(--se-primary-rgb), .55);
  text-underline-offset: .2em;
}

:where(p, li, dd, figcaption, blockquote) a:not([class]):hover {
  color: var(--se-primary);
  text-decoration-color: currentColor;
}

/* --- 05 Focus visibility --- */

:focus-visible {
  outline: 2px solid var(--se-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Dark canvas: soft halo so the ring never disappears into the surface */
[data-bs-theme="dark"] :focus-visible {
  box-shadow: 0 0 0 3px rgba(var(--se-primary-rgb), .30);
}

/* Opt-out for composite widgets that draw their own indicator */
.focus-ring-reset:focus-visible {
  outline: 0;
  box-shadow: none;
}

/* --- 06 Skip link & screen-reader helpers --- */

/* Visually hidden until focused; self-contained (works with no Bootstrap). */
.se-skip {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
  font-size: var(--se-fs-sm);
  color: var(--se-on-primary);
}

.se-skip:focus,
.se-skip:focus-visible {
  position: fixed;
  inset-block-start: var(--se-s-3);
  inset-inline-start: var(--se-s-3);
  z-index: 2000;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip-path: none;
  white-space: normal;
  padding: var(--se-s-3) var(--se-s-5);
  font-size: var(--se-fs-base);
  font-weight: 600;
  color: var(--se-on-primary);
  background: var(--se-primary);
  border-radius: var(--se-r-md);
  box-shadow: var(--se-shadow-lg);
  text-decoration: none;
}

/* --- 07 Media --- */

img,
svg,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Inline icon carve-out: Bootstrap Icons (`svg.bi`) and sized glyphs (the
   `<x-icon>` component emits width/height attrs) stay in the text flow at
   their declared size. Note: `height:auto` re-derives an SVG's height from
   its viewBox ratio — charts/embeds sized with `width="100%"` must also set
   an explicit height in CSS or as a fixed width+height attribute pair. */
.bi,
svg.bi,
svg[width][height] {
  display: inline;
}

figure {
  margin: 0;
}

figcaption {
  margin-block-start: var(--se-s-2);
  font-size: var(--se-fs-sm);
  color: var(--se-text-2);
}

/* --- 08 Forms (element level) --- */

fieldset {
  min-width: 0; /* fieldsets default to min-content and can overflow */
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
}

input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}

/* --- 09 Text blocks — lists, quotes, code, rules --- */

p {
  margin-block: 0 var(--se-s-4);
}

p:last-child {
  margin-block-end: 0;
}

ul,
ol {
  margin-block: 0 var(--se-s-4);
  padding-inline-start: var(--se-s-8);
}

dd {
  margin-inline-start: 0;
  margin-block-end: var(--se-s-2);
}

address {
  font-style: normal;
  color: var(--se-text-2);
}

blockquote {
  margin-block: 0 var(--se-s-4);
  padding-inline-start: var(--se-s-4);
  border-inline-start: 3px solid var(--se-border-strong);
  color: var(--se-text-2);
  font-size: var(--se-fs-lg);
  line-height: var(--se-lh-snug);
}

strong, b { font-weight: 700; }
small { font-size: .875em; }

code, kbd, samp, pre {
  font-family: var(--se-font-mono);
  font-size: .9em;
}

code:not(pre code) {
  color: var(--se-text-2);
  background: var(--se-surface-2);
  padding: .15em .4em;
  border-radius: var(--se-r-sm);
}

pre {
  margin-block: 0 var(--se-s-4);
  padding: var(--se-s-4);
  overflow: auto;
  background: var(--se-surface-2);
  border: 1px solid var(--se-border);
  border-radius: var(--se-r-md);
  line-height: var(--se-lh-snug);
}

kbd {
  display: inline-block;
  padding: .1em .45em;
  background: var(--se-surface-3);
  border: 1px solid var(--se-border-strong);
  border-radius: var(--se-r-sm);
  box-shadow: inset 0 -1px 0 var(--se-border-strong);
  font-size: .85em;
  color: var(--se-text-2);
}

hr {
  margin-block: var(--se-s-6);
  border: 0;
  border-top: 1px solid var(--se-border);
  opacity: 1;
}

/* --- 10 Tables --- */

table {
  width: 100%;
  border-collapse: collapse;
  text-indent: 0;
}

th {
  text-align: start;
  font-weight: 600;
}

caption {
  padding-block: var(--se-s-2);
  text-align: start;
  color: var(--se-text-2);
  font-size: var(--se-fs-sm);
}

/* --- 11 Scrollbars & selection --- */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--se-gray-400) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--se-gray-300);
  background-clip: padding-box;
  border: 3px solid transparent;
  border-radius: var(--se-r-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--se-gray-400);
  background-clip: padding-box;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

[data-bs-theme="dark"] * {
  scrollbar-color: var(--se-gray-600) transparent;
}

[data-bs-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--se-gray-700);
  background-clip: padding-box;
}

[data-bs-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: var(--se-gray-600);
  background-clip: padding-box;
}

::selection {
  background: rgba(var(--se-primary-rgb), .22);
  color: var(--se-text);
}

[data-bs-theme="dark"] ::selection {
  background: rgba(var(--se-primary-rgb), .38);
  color: var(--se-text);
}

/* --- 12 Utilities (no Bootstrap required) --- */

.se-text-muted { color: var(--se-text-2); }   /* AA-safe muted body text */
.se-text-brand { color: var(--se-primary); }
.se-nowrap     { white-space: nowrap; }
.se-center     { text-align: center; }

.se-gradient-text {
  background: var(--se-grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

/* Never ship invisible brand text where background-clip:text is unsupported */
@supports not (background-clip: text) {
  .se-gradient-text {
    background: none;
    color: var(--se-primary);
    -webkit-text-fill-color: currentColor;
  }
}

.se-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --- 13 Scroll reveal ([data-reveal] + .is-visible, §3.11) --- */

@media (prefers-reduced-motion: no-preference) {
  [data-reveal] {
    opacity: 0;
    transform: translateY(14px);
    transition:
      opacity var(--se-dur-slow) var(--se-ease),
      transform var(--se-dur-slow) var(--se-ease);
  }

  [data-reveal="left"]  { transform: translateX(-16px); }
  [data-reveal="right"] { transform: translateX(16px); }
  [data-reveal="scale"] { transform: scale(.96); }

  [data-reveal].is-visible {
    opacity: 1;
    transform: none;
  }

  /* Grouped children stagger automatically; app.js may override the delay
     inline (which always wins over this fallback). */
  [data-reveal-group] > [data-reveal] {
    transition-delay: calc(var(--se-reveal-i, 0) * 70ms);
  }

  [data-reveal-group] > [data-reveal]:nth-child(1) { --se-reveal-i: 0; }
  [data-reveal-group] > [data-reveal]:nth-child(2) { --se-reveal-i: 1; }
  [data-reveal-group] > [data-reveal]:nth-child(3) { --se-reveal-i: 2; }
  [data-reveal-group] > [data-reveal]:nth-child(4) { --se-reveal-i: 3; }
  [data-reveal-group] > [data-reveal]:nth-child(5) { --se-reveal-i: 4; }
  [data-reveal-group] > [data-reveal]:nth-child(6) { --se-reveal-i: 5; }
  [data-reveal-group] > [data-reveal]:nth-child(7) { --se-reveal-i: 6; }
  [data-reveal-group] > [data-reveal]:nth-child(8) { --se-reveal-i: 7; }
}

/* No-JS safety: never leave content hidden when the observer can't run */
@media (scripting: none) {
  [data-reveal] {
    opacity: 1;
    transform: none;
  }
}

/* --- 14 Skeleton shimmer keyframes (§3.10) --- */
/* `.se-skeleton` (gradient, sizes, variants) lives in components.css;
   it animates `se-shimmer` defined here. */

@keyframes se-shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* --- 15 Glass surface (§3.12 — navbar/modal backdrops only) --- */

.se-glass {
  background: var(--se-glass-bg);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid var(--se-glass-border);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .se-glass {
    background: var(--se-surface);
  }
}

/* --- 16 RTL typography (re-asserts the token-layer font swap for the
       standalone public page, where headings keep the display stack) --- */

[dir="rtl"] body,
[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] h4,
[dir="rtl"] h5,
[dir="rtl"] h6,
[dir="rtl"] p,
[dir="rtl"] span,
[dir="rtl"] a,
[dir="rtl"] li,
[dir="rtl"] blockquote,
[dir="rtl"] q,
[dir="rtl"] figure,
[dir="rtl"] figcaption,
[dir="rtl"] button,
[dir="rtl"] input,
[dir="rtl"] select,
[dir="rtl"] textarea,
[dir="rtl"] .btn,
[dir="rtl"] .form-control {
  font-family: var(--se-font-arabic);
}

/* --- 17 Small screens (≤575px) — cap hero/heading sizes --- */

@media (max-width: 575.98px) {
  h1 { font-size: var(--se-fs-4xl); letter-spacing: calc(var(--se-ls-tight) - .01em); }
  h2 { font-size: var(--se-fs-3xl); }
  h3 { font-size: var(--se-fs-2xl); }
  h4 { font-size: var(--se-fs-xl); }

  blockquote { font-size: var(--se-fs-base); }
}

/* --- 18 Reduced motion kill-switch --- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }

  html {
    scroll-behavior: auto;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* --- 19 Print --- */

@media print {
  /* Force the light palette regardless of the on-screen theme */
  :root,
  [data-bs-theme="dark"] {
    --se-bg: var(--se-gray-25);
    --se-surface: var(--se-gray-25);
    --se-surface-2: var(--se-gray-100);
    --se-surface-3: var(--se-gray-200);
    --se-text: var(--se-gray-900);
    --se-text-2: var(--se-gray-700);
    --se-text-3: var(--se-gray-600);
    --se-border: var(--se-gray-300);
    --se-border-strong: var(--se-gray-400);
    --se-overlay: transparent;
    --se-shadow-xs: none;
    --se-shadow-sm: none;
    --se-shadow-md: none;
    --se-shadow-lg: none;
    --se-shadow-brand: none;
  }

  /* Chrome and skippables never print */
  .se-skip,
  .se-toasts,
  .se-sidebar,
  .se-topbar,
  .seker-bottomnav {
    display: none !important;
  }

  .se-shell {
    display: block;
  }

  /* Nothing stays mid-animation on paper */
  [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
  }

  img,
  table,
  blockquote,
  pre {
    break-inside: avoid;
  }
}
