/* Coded Dreams — shared shell for every page.
   Colours come from the page skin (home.css, islam-habits.css); this file only lays things out. */

@font-face {
  font-family: "Audiowide";
  src: url("/assets/fonts/audiowide.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-display: "Audiowide", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* 8px spacing scale */
  --s1: 0.5rem;
  --s2: 1rem;
  --s3: 1.5rem;
  --s4: 2rem;
  --s5: 3rem;
  --s6: 4rem;
  --s7: 6rem;

  --radius: 20px;
  --radius-pill: 999px;
  --max: 1120px;
  --theme-ms: 450ms; /* THEME_TRANSITION_MS in the Islam Habits app */

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

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font: 400 1rem/1.6 var(--font-body);
  color: var(--text);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--link); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }

/* Theme switch animation: only while switching, so page loads never animate. */
.theme-anim, .theme-anim *, .theme-anim *::before, .theme-anim *::after {
  transition: background-color var(--theme-ms) ease, color var(--theme-ms) ease,
    border-color var(--theme-ms) ease, box-shadow var(--theme-ms) ease, fill var(--theme-ms) ease !important;
}
/* ...but the switch keeps its own motion: the knob slides (tween(300) in the app) and the glyph colours fade */
.theme-anim .theme-switch .knob {
  transition: transform 300ms ease-in-out, background-color var(--theme-ms) ease, box-shadow var(--theme-ms) ease !important;
}
.theme-anim .theme-switch .glyph {
  transition: --gl var(--theme-ms) ease, --gm var(--theme-ms) ease, --gd var(--theme-ms) ease !important;
}

.wrap { width: min(var(--max), 100% - 32px); margin-inline: auto; }
.skip {
  position: absolute; left: -999px; top: 8px; z-index: 50;
  padding: var(--s1) var(--s2); border-radius: 8px;
  background: var(--surface); color: var(--text);
}
.skip:focus { left: 8px; }

/* Type: tracking and leading change with size */
h1, h2, h3 { text-wrap: balance; margin: 0 0 var(--s2); font-family: var(--font-display); font-weight: 400; color: var(--heading, var(--text)); }
h1 { font-size: clamp(2rem, 5.5vw, 3.5rem); line-height: 1.1; letter-spacing: -0.01em; }
h2 { font-size: clamp(1.5rem, 3.5vw, 2.25rem); line-height: 1.2; letter-spacing: 0; }
h3 { font-size: 1.125rem; line-height: 1.35; letter-spacing: 0.01em; }
p { margin: 0 0 var(--s2); }
.lead { font-size: 1.1875rem; line-height: 1.55; max-width: 62ch; }
.muted, .note { color: var(--muted); }
.note { font-size: 0.875rem; letter-spacing: 0.01em; }
.eyebrow {
  display: inline-flex; align-items: center; gap: var(--s1);
  font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
}
/* "Live" dot: the app's green, glowing and fading like a recording light */
.live-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  background: #00f000;
  box-shadow: 0 0 4px 1px rgba(0, 240, 0, 0.9), 0 0 10px 3px rgba(0, 240, 0, 0.45);
  animation: live-glow 1.2s ease-in-out infinite alternate;
}
@keyframes live-glow {
  from { background: #00aa00; box-shadow: 0 0 1px 0 rgba(0, 240, 0, 0.3); }
  to   { background: #00f000; box-shadow: 0 0 4px 1px rgba(0, 240, 0, 0.9), 0 0 10px 3px rgba(0, 240, 0, 0.45); }
}

section { padding-block: var(--s6); }
.section-lead { color: var(--muted); max-width: 60ch; margin-bottom: var(--s4); }
.grid { display: grid; gap: var(--s3); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }
.icon { width: 24px; height: 24px; flex: none; }

/* Header */
/* The bar has the same box on every page, so nothing shifts when moving between them; skins only paint it */
.site-header { position: sticky; top: 12px; z-index: 10; padding-block: var(--s2); }
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap;
  padding: 8px 10px 8px 16px; border-radius: 28px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-size: 1.125rem; color: var(--brand-text, var(--text)); text-decoration: none;
}
.brand img { width: 56px; height: 36px; }
.nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-left: auto; }
/* Phones: logo and switch share the top row, nav links get their own row */
@media (max-width: 640px) {
  .site-header .theme-switch { order: 1; }
  .site-header .nav { order: 2; flex-basis: 100%; margin-left: 0; }
  .site-header .wrap { padding-inline: 12px 8px; }
  .brand { font-size: 1rem; gap: 8px; }
}
.nav a {
  padding: 8px 14px; border-radius: var(--radius-pill);
  color: var(--nav-text, var(--text)); font-weight: 600; text-decoration: none;
}
.nav a[aria-current="page"] { background: var(--nav-current-bg); }

/* Light/dark switch: the app's ThemeSwitch (ui/elements/ThemeSwitch.kt), scaled to S = 48px.
   Track = in3d (inner highlight/shade), knob = glass3d in the gray tokens, sun left / moon right.
   Glyph colours follow TabLogoIcon: selected = black tones, unselected = gray tones. */
@property --gl { syntax: "<color>"; inherits: true; initial-value: #aaaaaa; }
@property --gm { syntax: "<color>"; inherits: true; initial-value: #646464; }
@property --gd { syntax: "<color>"; inherits: true; initial-value: #373737; }
.theme-switch {
  --S: 48px;
  --k: 3.2px; /* knob depth: 4px resting depth x its 35px / 44px reference */
  position: relative; display: inline-flex; flex: none;
  width: calc(var(--S) * 2); height: var(--S); padding: 0;
  border: 0; border-radius: var(--radius-pill); cursor: pointer;
  background: var(--bg);
  box-shadow: inset -4px -4px 4px var(--bg-hi), inset 4px 4px 4px var(--bg-lo);
}
.theme-switch .knob {
  position: absolute; top: calc(var(--S) * 8 / 60); left: calc(var(--S) * 8 / 60);
  width: calc(var(--S) * 44 / 60); height: calc(var(--S) * 44 / 60); border-radius: 50%;
  background: var(--gray);
  box-shadow:
    calc(var(--k) / 2) var(--k) calc(var(--k) * 2) var(--cast),
    inset calc(var(--k) * -1) calc(var(--k) * -1) var(--k) var(--gray-hi),
    inset var(--k) var(--k) var(--k) var(--gray-lo);
}
.theme-switch[aria-checked="true"] .knob { transform: translateX(var(--S)); }
.theme-switch .glyph {
  position: relative; z-index: 1; width: calc(var(--S) / 2); height: calc(var(--S) / 2);
  margin: calc(var(--S) / 4); overflow: visible;
  transition: --gl var(--theme-ms) ease, --gm var(--theme-ms) ease, --gd var(--theme-ms) ease;
}
.theme-switch .sun { --gl: #646464; --gm: #373737; --gd: #1e1e1e; --go: #1e1e1e; }
.theme-switch .moon { --gl: #aaaaaa; --gm: #646464; --gd: #373737; --go: #1e1e1e; }
:root[data-theme="dark"] .theme-switch .sun { --gl: #e2e2e2; --gm: #aaaaaa; --gd: #505050; --go: #232323; }
:root[data-theme="dark"] .theme-switch .moon { --gl: #373737; --gm: #2d2d2d; --gd: #232323; --go: #232323; }

/* Social logos: official full-colour marks on round neumorphic buttons */
.social { display: flex; flex-wrap: wrap; gap: 12px; }
.social-btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; }
.social-btn svg { width: 22px; height: 22px; }
.social-btn .logo-ink { fill: #000000; }
:root[data-theme="dark"] .social-btn .logo-ink { fill: #ffffff; }

/* Scrollbars: transparent track, quiet thumb, so they blend into each page's background */
::-webkit-scrollbar { width: 12px; height: 12px; background: transparent; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb {
  background-color: var(--sb-thumb); border-radius: 999px;
  border: 3px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--sb-thumb-hover); }
/* Every page sits on the app background, so the root (and its scrollbar) is set once, here,
   for all pages alike: #F1F1F1 with a #B9B9B9 thumb, or #2C2C2C with #4A4A4A in dark. */
/* --theme-color feeds <meta name="theme-color"> (theme.js); Safari paints its window edges
   and scrollbar track with it, so it must match the page too. */
:root { --sb-thumb: #b9b9b9; --sb-thumb-hover: #969696; --theme-color: #f1f1f1; background: #f1f1f1; }
:root[data-theme="dark"] { --sb-thumb: #4a4a4a; --sb-thumb-hover: #5c5c5c; --theme-color: #2c2c2c; background: #2c2c2c; }
html { scrollbar-color: var(--sb-thumb) transparent; }

/* Buttons (skins set the colours) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s1);
  min-height: 48px; padding: 0 var(--s3); border-radius: var(--radius-pill);
  font-weight: 700; text-decoration: none; letter-spacing: 0.01em;
}

/* Footer */
.site-footer { padding-block: var(--s4); font-size: 0.9375rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); justify-content: space-between; align-items: center; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); }
.site-footer a { color: var(--footer-link, var(--link)); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}
@media (prefers-contrast: more) {
  .card, .neu { outline: 2px solid var(--text); }
}
