/* 1. Tokens & Theme */
:root {
  --bg: #0b0a14;
  --bg-2: #14121d;
  --text: #e8eaff;
  --muted: #b7bdd0;
  --accent: #7a5cff;
  --accent-2: #cdd3ff;
  --glass: rgba(22, 20, 40, 0.28);
  --glass-fallback: rgba(22, 20, 40, 0.72);
  --border: rgba(140, 150, 190, 0.6);
  --shadow: 0 8px 20px rgba(0,0,0,.38);
  --ring: 0 0 0 3px rgba(122,92,255,.65);
}

/* 2. Global & Layout boilerplate */
* { box-sizing: border-box; }
html, body { height: 100%; }
html { color-scheme: dark; }
body {
  margin: 0;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
  line-height: 1.5;
  font-size: clamp(14px, 0.9vw + 12px, 18px);
  background-color: var(--bg);
  /* Layered background: gradient + scanline/noise */
  background-image:
    linear-gradient(135deg, rgba(60,0,80,.90) 0%, rgba(20,0,40,.95) 60%, rgba(6,0,20,.95) 100%),
    repeating-linear-gradient(to bottom,
      rgba(255,255,255,0.04) 0px,
      rgba(255,255,255,0.04) 1px,
      transparent 1px,
      transparent 2px);
  background-blend-mode: overlay;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-y: auto;
}
@media (max-width: 720px) {
  body { background-attachment: scroll; }
}

/* 3. Section helpers (structure) */
.container { max-width: clamp(320px, 90vw, 1100px); margin-inline: auto; padding-inline: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid.auto { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card { background: var(--glass); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; box-shadow: var(--shadow); }

/* 4. Core page elements */
html, body, header, nav, main, article, footer, aside { display: block; }

/* 5. Glass panels (frosted) with fallback */
.glass {
  background: rgba(18, 20, 38, 0.28);
  border: 1px solid rgba(120, 140, 210, 0.50);
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(0,0,0,.35);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
}
.no-backdrop .glass {
  background: rgba(18,20,38,0.72);
  border-color: rgba(120,140,210,0.75);
  box-shadow: 0 6px 16px rgba(0,0,0,.45);
  backdrop-filter: none;
}
@supports not (backdrop-filter: blur(12px)) {
  .glass { background: rgba(18,20,38,0.75); }
  .no-backdrop { background: rgba(18,20,38,0.88); }
}

/* 6. Header & hero pattern */
header {
  padding: 2rem 0;
  text-align: center;
}
header h1 {
  margin: 0 0 .25rem;
  font-size: clamp(1.75rem, 4vw, 3.75rem);
  line-height: 1.04;
  letter-spacing: .3px;
}
header .meta {
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.8rem, 0.8vw, 0.95rem);
}
main { padding: 2rem 0; }

/* 7. Featured image frame */
.image-frame {
  aspect-ratio: 16 / 9;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(180, 190, 210, 0.6);
  background: #0b0b15;
  position: relative;
  box-shadow: 0 6px 16px rgba(0,0,0,.35);
}
.image-frame img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  image-rendering: auto;
  transform: translateZ(0);
}
.image-frame::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
  pointer-events: none;
}
.image-frame:hover { transform: translateZ(0); }

/* 8. Content typography and sections */
.content { color: var(--text); }
.content h2, .content h3 { color: #e9eaff; margin: .75rem 0 0.5rem; }
.content p { margin: .75rem 0; color: #e9eaff; opacity: .95; }

/* 9. Lists & inline elements */
ul { margin: .75rem 0; padding-left: 1.25rem; }
li { margin: .25rem 0; }

/* 10. Links & buttons (accessibility) */
a, button, .btn, .cta {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  outline: none;
}
a { color: var(--accent); }
a:hover, a:focus { color: var(--accent-2); text-decoration: underline; }

/* Focus visibility (WCAG AA-ish) */
:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: 6px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(120,140,210,.6);
  background: linear-gradient(180deg, rgba(120,70,210,.95), rgba(60,40,120,.95));
  color: #f8f8ff;
  font-weight: 600;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
  box-shadow: 0 6px 14px rgba(0,0,0,.25);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 3px solid rgba(122,92,255,.85); outline-offset: 2px; }
.btn--outline {
  background: rgba(20,20,40,.24);
  border: 1px solid rgba(120,140,210,.6);
  color: var(--text);
}
.btn + .btn { margin-left: .5rem; }

.cta { display:inline-flex; }

/* 11. Utility: tags & badges */
.tag {
  display:inline-block;
  padding:.25rem .55rem;
  border-radius:999px;
  font-size:.75rem;
  line-height:1;
  border:1px solid rgba(120,140,210,.6);
  background: rgba(120,140,210,.25);
  color: #f0f1ff;
}

/* 12. Product ad & sponsor sections (footer) */
.product-ad {
  display:flex; gap:.75rem; align-items:center; justify-content: center;
  padding: .6rem; border-radius: 12px;
  background: rgba(14,16,36,.35);
  border: 1px solid rgba(120,140,210,.5);
  margin: 0.75rem 0;
}
.product-ad a {
  display:flex; align-items:center; justify-content:center;
  padding:.6rem 1rem; border-radius:999px;
  text-decoration:none; color: var(--text);
  background: linear-gradient(180deg, rgba(120,70,210,.95), rgba(60,40,120,.92));
  border:1px solid rgba(120,140,210,.6);
}
.product-ad p { margin:0; font-weight:600; }

/* 13. Layout helpers for main sections */
header, main, footer { width: 100%; }
aside { display: block; }

/* 14. Print styles (basic readability) */
@media print {
  body { background: #fff; color: #000; }
  a { text-decoration: underline; color: #000; }
  .glass { background: #fff; border-color: #000; }
}

/* 15. Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f4f9;
    --bg-2: #e9ebf5;
    --text: #11131a;
    --muted: #51566a;
    --accent: #4b3a9a;
    --accent-2: #2a2a2a;
    --glass: rgba(255,255,255,0.85);
    --glass-fallback: rgba(255,255,255,0.95);
    --border: rgba(0,0,0,.15);
  }
  body {
    background-image:
      linear-gradient(135deg, rgba(180,160,240,.25), rgba(200,200,210,.25)),
      repeating-linear-gradient(to bottom, rgba(0,0,0,.03) 0 1px, transparent 1px 2px);
    background-attachment: scroll;
    color: var(--text);
  }
  .glass { background: rgba(255,255,255,.75); border-color: rgba(0,0,0,.15); }
  a { color: var(--accent); }
}
