/* 2026 design effects: aurora gradients, glass+noise surfaces, kinetic display
   type, magnetic interactions, scroll reveal. All token-driven so the look
   adapts cleanly between light and dark mode. */

/* ---- Aurora background blobs (used by hero + section bands) ---- */
.dits-aurora {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}
.dits-aurora:not(.dits-hero--photo)::before,
.dits-aurora:not(.dits-hero--photo)::after {
  content: "";
  position: absolute; pointer-events: none; z-index: -1;
  filter: blur(80px); opacity: .55; transform-origin: center;
  animation: dits-aurora-drift 22s var(--ease-out) infinite alternate;
}
.dits-aurora:not(.dits-hero--photo)::before {
  inset-block-start: -20%; inset-inline-start: -10%;
  width: 60vmax; height: 60vmax; border-radius: 50%;
  background: radial-gradient(closest-side, var(--accent-soft), transparent 70%);
}
.dits-aurora:not(.dits-hero--photo)::after {
  inset-block-end: -25%; inset-inline-end: -15%;
  width: 70vmax; height: 70vmax; border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--info) 65%, transparent), transparent 70%);
  animation-duration: 30s; animation-delay: -6s;
}
/* Photo hero gets its own veil instead of aurora blobs */
.dits-hero--photo::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(11,18,32,.35) 0%, rgba(11,18,32,.55) 60%, rgba(11,18,32,.85) 100%),
    radial-gradient(70% 80% at 50% 35%, rgba(0,0,0,0), rgba(11,18,32,.45));
}
@media (prefers-reduced-motion: reduce) {
  .dits-aurora::before, .dits-aurora::after { animation: none; }
}
@keyframes dits-aurora-drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  50%  { transform: translate3d(4vw, -3vw, 0) scale(1.06); }
  100% { transform: translate3d(-3vw, 5vw, 0) scale(.96); }
}

/* ---- SVG noise texture overlay (subtle) ---- */
.dits-noise::after {
  content: "";
  position: absolute; inset: 0; pointer-events: none;
  z-index: 0; opacity: .035; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ---- Glass surface (cards / blocks on top of aurora) ---- */
.dits-glass {
  background:
    linear-gradient(135deg,
      color-mix(in srgb, var(--bg-surface) 75%, transparent),
      color-mix(in srgb, var(--bg-surface) 55%, transparent));
  border: 1px solid color-mix(in srgb, var(--border-soft) 80%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--fg-text) 6%, transparent),
    var(--shadow-md);
}

/* ---- Display kinetic typography ----
   Variable font (Fraunces) opsz/wght for "scroll/cursor breath" effect. */
.dits-display {
  font-family: "Fraunces", Georgia, serif;
  font-variation-settings: "opsz" 144, "wght" 600, "SOFT" 60, "WONK" 1;
  letter-spacing: -0.02em;
  line-height: .98;
  font-size: clamp(44px, 7vw, 96px);
  background: linear-gradient(135deg, var(--fg-text), color-mix(in srgb, var(--fg-text) 60%, var(--accent)));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  text-wrap: balance;
}
.dits-display em {
  font-style: italic;
  font-variation-settings: "opsz" 144, "wght" 700, "SOFT" 100, "WONK" 1;
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

/* ---- Magnetic / shine button ---- */
.dits-mag {
  position: relative; overflow: hidden; isolation: isolate;
  transform: translate3d(var(--mag-x, 0), var(--mag-y, 0), 0);
  transition: transform var(--dur-base) var(--ease-out);
}
.dits-mag::before {
  content: ""; position: absolute; inset: -50%;
  background: conic-gradient(from 220deg at 50% 50%,
    transparent 0deg, var(--accent-soft) 80deg, transparent 160deg, transparent 360deg);
  opacity: 0; transition: opacity var(--dur-base) var(--ease-out);
  z-index: -1; animation: dits-spin 4s linear infinite paused;
}
.dits-mag:hover::before { opacity: .35; animation-play-state: running; }
@keyframes dits-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .dits-mag, .dits-mag::before { transition: none; animation: none; } }

/* ---- Scroll-reveal: starts hidden, JS adds .is-in ---- */
.dits-reveal {
  opacity: 0; transform: translateY(20px);
  transition: opacity .6s var(--ease-out), transform .6s var(--ease-out);
}
.dits-reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .dits-reveal { opacity: 1; transform: none; }
}

/* ---- Bento grid ---- */
.dits-bento {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-auto-rows: minmax(140px, auto);
  gap: 16px;
}
.dits-bento__cell {
  position: relative; overflow: hidden;
  border-radius: var(--radius-lg);
  padding: clamp(16px, 2vw, 28px);
  display: flex; flex-direction: column; justify-content: flex-end;
  color: var(--fg-text);
  isolation: isolate;
  transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.dits-bento__cell:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.dits-bento__cell--lg  { grid-column: span 4; grid-row: span 2; min-height: 320px; }
.dits-bento__cell--md  { grid-column: span 3; grid-row: span 1; min-height: 200px; }
.dits-bento__cell--sm  { grid-column: span 2; grid-row: span 1; min-height: 160px; }
.dits-bento__cell--tall{ grid-column: span 2; grid-row: span 2; min-height: 320px; }
.dits-bento__cell--wide{ grid-column: span 4; grid-row: span 1; min-height: 200px; }
.dits-bento__bg {
  position: absolute; inset: 0; z-index: -2;
  background-size: cover; background-position: center;
  transform: scale(1.02); transition: transform 1.2s var(--ease-out);
}
.dits-bento__cell:hover .dits-bento__bg { transform: scale(1.08); }
.dits-bento__cell::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, transparent 35%, color-mix(in srgb, var(--c-slate-950) 88%, transparent));
}
/* Photo cells: pull every disparate stock photo into one sky-blue duotone so
   the grid reads as a cohesive family. grayscale+sepia makes a warm mono, then
   hue-rotate spins it to the brand sky-blue (--accent ≈ hue 205°). */
.dits-bento__cell--photo .dits-bento__bg {
  filter: grayscale(1) sepia(1) hue-rotate(168deg) saturate(2.2) brightness(.95) contrast(1.04);
}
.dits-bento__cell--text { background: var(--bg-surface); border: 1px solid var(--border-soft); }
.dits-bento__cell--text::after { display: none; }
.dits-bento__cell--text { color: var(--fg-text); }
.dits-bento__eyebrow { font-size: var(--fs-xs); letter-spacing: .2em; text-transform: uppercase; color: var(--accent-soft); }
.dits-bento__cell--text .dits-bento__eyebrow { color: var(--accent); }
.dits-bento__title { margin: 8px 0 0; font-family: "Fraunces", Georgia, serif; font-size: clamp(20px, 2vw, 30px); color: #fff; line-height: 1.05; }
.dits-bento__cell--text .dits-bento__title { color: var(--fg-text); }
.dits-bento__copy { margin: 6px 0 0; color: rgba(255,255,255,.78); font-size: var(--fs-sm); }
.dits-bento__cell--text .dits-bento__copy { color: var(--fg-muted); }

@media (max-width: 960px) {
  .dits-bento { grid-template-columns: repeat(2, 1fr); }
  .dits-bento__cell--lg, .dits-bento__cell--md, .dits-bento__cell--sm, .dits-bento__cell--tall, .dits-bento__cell--wide { grid-column: span 2; grid-row: auto; }
}

/* ---- Card upgrade: glass cover, shine on hover, subtle ring on focus ---- */
.dits-card { background: transparent; border: 0; padding: 0; }
.dits-card__cover {
  background: linear-gradient(135deg, var(--bg-surface-2), var(--bg-surface));
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,.06);
  border: 1px solid var(--border-soft);
}
.dits-card__cover::after {
  content: ""; position: absolute; inset: -40% -10%; pointer-events: none;
  background: linear-gradient(120deg, transparent 35%, rgba(255,255,255,.18) 50%, transparent 65%);
  transform: translateX(-100%);
  transition: transform .9s var(--ease-out); opacity: 0;
}
.dits-card:hover .dits-card__cover::after { transform: translateX(100%); opacity: 1; }

/* ---- View Transitions (2026) — smooth cross-page morph on hx-boost nav ----
   Enabled globally via the htmx-config meta in base.html. We refine the default
   root crossfade to a gentle fade + rise. Gated behind prefers-reduced-motion so
   motion-sensitive users get an instant swap. Unsupported browsers ignore this. */
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) { animation: dits-vt-out .26s var(--ease-out) both; }
  ::view-transition-new(root) { animation: dits-vt-in  .34s var(--ease-out) both; }
}
@keyframes dits-vt-out { to { opacity: 0; } }
@keyframes dits-vt-in  { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---- Scroll-driven reading-progress bar (2026, pure CSS) ----
   A thin sky gradient pinned to the top, scaled by scroll position through the
   native scroll timeline — no JS, runs on the compositor. Progressive
   enhancement: only renders where scroll-timeline exists AND motion is allowed. */
.dits-scroll-progress { display: none; }
@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    .dits-scroll-progress {
      display: block;
      position: fixed; inset-block-start: 0; inset-inline: 0; z-index: 60;
      height: 3px; transform-origin: 0 50%; scale: 0 1; pointer-events: none;
      background: linear-gradient(90deg, var(--c-sky-400), var(--accent), var(--c-cyan-400));
      animation: dits-scroll-progress linear both;
      animation-timeline: scroll(root);
    }
    @keyframes dits-scroll-progress { to { scale: 1 1; } }
  }
}

/* ---- Geometric Islamic motif divider (subtle, decorative) ---- */
.dits-motif {
  --color: var(--accent-soft);
  display: block; width: 100%; height: 24px; opacity: .25;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 24' fill='none' stroke='%232b8fd6' stroke-width='1'><path d='M0 12 Q 16 0 32 12 T 64 12'/><path d='M0 12 Q 16 24 32 12 T 64 12'/></svg>");
  background-repeat: repeat-x;
  background-size: auto 100%;
}

/* ---- Reusable cursor 3D tilt (2026) — add `data-tilt` to any element; tilt.js
   sets --tilt-rx/ry (lean) and --tilt-gx/gy (glare position). Optional child
   `.dits-tilt-glare` adds a pointer-tracking specular highlight. Mouse-only +
   reduced-motion safe (the JS attaches nothing otherwise, so this is the rest
   state). Reused on the home featured tile; drop-in for covers/cards too. ---- */
[data-tilt] {
  transform: perspective(var(--tilt-perspective, 1000px))
             rotateX(var(--tilt-rx, 0deg)) rotateY(var(--tilt-ry, 0deg));
  transition: transform .3s var(--ease-out), box-shadow .3s var(--ease-out);
  will-change: transform;
}
.dits-tilt-glare {
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(40% 52% at var(--tilt-gx, 50%) var(--tilt-gy, 0%),
              rgba(255,255,255,.5), rgba(255,255,255,.12) 40%, transparent 66%);
  mix-blend-mode: soft-light; opacity: 0;
  transition: opacity .3s var(--ease-out), background .15s var(--ease-out);
}
[data-tilt]:hover .dits-tilt-glare { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  [data-tilt] { transition: none; transform: none; }
}

/* ---- Lightbox gallery (lightbox.js) — premium image overlay for card grids ---- */
.dits-lb { position: fixed; inset: 0; z-index: 200; display: none; }
.dits-lb.is-open { display: grid; place-items: center; }
.dits-lb__backdrop {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--c-ink-950) 86%, transparent);
  -webkit-backdrop-filter: blur(10px) saturate(140%); backdrop-filter: blur(10px) saturate(140%);
  animation: dits-lb-fade .3s var(--ease-out);
}
@keyframes dits-lb-fade { from { opacity: 0; } to { opacity: 1; } }
.dits-lb__stage {
  position: relative; z-index: 2; margin: 0; padding: 0;
  max-width: min(92vw, 680px); max-height: 86vh;
  display: grid; place-items: center;
}
.dits-lb__img {
  max-width: 100%; max-height: 86vh; border-radius: var(--radius-lg);
  box-shadow: 0 40px 120px -30px rgba(0, 0, 0, .7); background: var(--bg-surface);
}
.dits-lb__img.is-in { animation: dits-lb-pop .32s var(--ease-out); }
@keyframes dits-lb-pop { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: none; } }
.dits-lb__btn {
  position: absolute; z-index: 3; display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; border-radius: 50%; cursor: pointer; color: #fff; font-size: 17px;
  background: color-mix(in srgb, var(--c-ink-900) 55%, transparent);
  border: 1px solid rgba(255, 255, 255, .22);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: background .2s var(--ease-out), transform .2s var(--ease-out);
}
.dits-lb__btn:hover { background: var(--accent); }
.dits-lb__close { top: clamp(14px, 3vw, 28px); right: clamp(14px, 3vw, 28px); }
.dits-lb__nav { top: 50%; transform: translateY(-50%); }
.dits-lb__nav:hover { transform: translateY(-50%) scale(1.07); }
.dits-lb__prev { left: clamp(10px, 3vw, 32px); }
.dits-lb__next { right: clamp(10px, 3vw, 32px); }
.dits-lb__bar {
  position: absolute; z-index: 3; left: 50%; bottom: clamp(16px, 4vh, 34px); transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 16px;
  padding: 8px 8px 8px 18px; border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--c-ink-900) 55%, transparent);
  border: 1px solid rgba(255, 255, 255, .18); color: #fff;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.dits-lb__count { font-size: var(--fs-sm); font-weight: 600; color: rgba(255, 255, 255, .82); letter-spacing: .02em; }
.dits-lb__dl {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px;
  border-radius: var(--radius-pill); background: var(--accent); color: #fff;
  font-size: var(--fs-sm); font-weight: 600; text-decoration: none;
  transition: background .2s var(--ease-out);
}
.dits-lb__dl:hover { background: var(--accent-strong); }
@media (prefers-reduced-motion: reduce) {
  .dits-lb__backdrop, .dits-lb__img.is-in { animation: none; }
  .dits-lb__btn { transition: none; }
}
@media (max-width: 560px) {
  .dits-lb__nav { width: 40px; height: 40px; }
  .dits-lb__prev { left: 8px; } .dits-lb__next { right: 8px; }
}

/* ---- Modern prose: render a legacy CKEditor blob (book.text, guides, articles)
   in the redesign reading style. Neutralises the editor's baked-in fonts/colours
   /backgrounds so DB content reads cleanly; preserves structure + relative sizes. */
.dits-prose {
  max-width: 72ch; margin-inline: auto;
  font-family: var(--ff-reading), Georgia, serif;
  font-size: var(--fs-lg); line-height: 1.85; color: var(--fg-text);
  text-align: start;
}
.dits-prose * {
  font-family: inherit !important; color: inherit !important;
  background: transparent !important; max-width: 100%;
}
.dits-prose p { margin: 0 0 1.05em; }
/* Legacy CKEditor blobs ship inline `text-align: justify` on paragraphs, which
   beats .dits-prose's `text-align: start` and creates ragged rivers of space.
   Surgically neutralise only the justified nodes (intentional centre/right
   stay) so DB content reads as clean left-aligned prose. */
.dits-prose [style*="justify"] { text-align: start !important; }
.dits-prose h1, .dits-prose h2, .dits-prose h3, .dits-prose h4 {
  font-family: var(--ff-display), Georgia, serif !important;
  font-variation-settings: "opsz" 144, "wght" 600;
  letter-spacing: -0.01em; line-height: 1.2; margin: 1.4em 0 .4em;
}
.dits-prose img, .dits-prose iframe { height: auto; border-radius: var(--radius-md); margin: 1em auto; display: block; }
.dits-prose a { color: var(--accent-strong) !important; text-decoration: underline; text-underline-offset: 2px; }
.dits-prose ul, .dits-prose ol { padding-inline-start: 1.4em; margin: 0 0 1.05em; }
.dits-prose li { margin: .3em 0; }
.dits-prose li::marker { color: var(--accent); }
.dits-prose table { width: 100% !important; border-collapse: collapse; margin: 1em 0; }
.dits-prose td, .dits-prose th { border: 1px solid var(--border-soft); padding: 8px 10px; }

/* New-Muslim guide body (classified4 book-reader layout): a little breathing room
   under the video, and the same sky-blue duotone the hub uses on its figures so the
   section's mismatched step photos + gold ornament dividers read as one designed
   set. Scoped to .dits-bm; hover eases each illustration back toward true colour. */
.dits-guidebody { margin-block: clamp(28px, 5vh, 56px); }
.dits-bm .dits-prose img {
  background: #0a2740;
  filter: grayscale(1) sepia(1) hue-rotate(168deg) saturate(2.05) brightness(1.04) contrast(1.04);
  transition: filter .5s var(--ease-out, ease);
}
.dits-bm .dits-prose img:hover {
  filter: grayscale(.12) sepia(.08) hue-rotate(6deg) saturate(1.15) brightness(1.02);
}

/* ---- Responsive 16:9 frame for video/embeds ---- */
.dits-vframe {
  position: relative; max-width: 900px; margin-inline: auto;
  aspect-ratio: 16 / 9; border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-lg); background: #000;
}
.dits-vframe iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---- Generic content section + header (pages with their own inline .dits-section
   override these; content pages like the New-Muslim guides rely on them). ---- */
.dits-section { padding: clamp(36px, 6vw, 72px) 0; }
.dits-section__header { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.dits-section__title { font-family: var(--ff-display), Georgia, serif; font-variation-settings: "opsz" 144, "wght" 600; font-size: clamp(26px, 3.4vw, 40px); margin: 6px 0 0; color: var(--fg-text); letter-spacing: -0.01em; line-height: 1.12; }
.dits-section__copy { color: var(--fg-muted); margin: 6px 0 0; max-width: 60ch; }
.dits-guide__dl { text-align: center; margin: 4px 0 8px; }
/* New-Muslim guide rail — icon cards on a soft sky surface */
.dits-nm-rail .dits-card__cover { background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 16%, var(--bg-surface)), var(--bg-surface)); }
.dits-nm-rail .dits-card__placeholder { color: var(--accent-strong); font-size: 30px; }
