/* =========================================================
   Mobius | موبيوس
   A night-sky library: an interactive star chart on the home
   page, one live figure per subject, books on level shelves.
   ========================================================= */

:root {
  color-scheme: dark;

  /* night sky */
  --space-0: #070618;      /* deepest sky */
  --space-1: #100d2c;      /* indigo, top of the page */
  --panel: #131034;        /* figure panels */
  --panel-2: #1a1642;      /* panel on hover */
  --line: rgba(196, 186, 255, 0.12);
  --line-2: rgba(196, 186, 255, 0.22);

  /* light */
  --star: #f4efe4;         /* text */
  --dust: #a49fc4;         /* secondary text */
  --faint: #7d78a0;        /* captions */
  --brass: #f0b44a;        /* accent */
  --rose: #ff7a93;
  --ice: #8fd3ff;

  /* five levels, inner orbit to outer */
  --lv-beginner: #6fe3b4;
  --lv-easy: #77c6ff;
  --lv-medium: #f0b44a;
  --lv-hard: #ff7a6b;
  --lv-extreme: #c39bff;

  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --arabic: "Readex Pro", "Onest", system-ui, sans-serif;

  --max: 1180px;
}

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

html {
  background: var(--space-0);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--space-1) 0, var(--space-0) 560px) var(--space-0);
  color: var(--star);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* paints the phone status-bar band behind the sticky header */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 30;
  background: var(--space-1);
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
}

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

::selection {
  background: var(--brass);
  color: var(--space-0);
}

[lang="ar"] {
  font-family: var(--arabic);
}

[hidden] {
  display: none !important;
}

.wrap {
  width: min(100% - 32px, var(--max));
  margin-inline: auto;
}

main {
  flex: 1;
}

h1,
h2,
h3 {
  text-wrap: balance;
  font-weight: 500;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  background: rgba(16, 13, 44, 0.8);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

/* on the home page the header floats over the sky, and gets its background back once you scroll */
.page-home .site-header {
  position: fixed;
  inset: env(safe-area-inset-top, 0px) 0 auto;
  background: transparent;
  border-bottom-color: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.page-home .site-header.is-solid {
  background: rgba(16, 13, 44, 0.84);
  border-bottom-color: var(--line);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand svg {
  width: 30px;
  height: 30px;
  flex: none;
}

.brand-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.3rem;
  letter-spacing: 0.01em;
  line-height: 1;
}

.brand-ar {
  color: var(--dust);
  font-size: 0.92rem;
}

.nav {
  display: flex;
  gap: 22px;
}

.nav a {
  position: relative;
  padding: 8px 0;
  color: var(--dust);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  white-space: nowrap;
  transition: color 0.2s ease;
}

.nav a:hover {
  color: var(--star);
}

.nav a[aria-current="page"] {
  color: var(--star);
}

.nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  height: 2px;
  background: var(--brass);
}

@media (max-width: 440px) {
  .brand-ar {
    display: none;
  }
  .nav {
    gap: 16px;
  }
  .nav a {
    font-size: 0.9rem;
  }
}

/* ---------- Home: hero ---------- */
.hero {
  position: relative;
  min-height: clamp(540px, 84vh, 800px);
  min-height: clamp(540px, 84svh, 800px); /* phones: ignore the browser bar so the hero does not jump */
  display: grid;
  align-items: center;
  overflow: hidden;
  isolation: isolate;
}

.hero-sky {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  touch-action: pan-y;
}

/* keeps the words readable over the sky */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 55% 50% at 20% 52%, rgba(7, 6, 24, 0.7), transparent 72%),
    linear-gradient(180deg, transparent 72%, var(--space-0));
}

.hero-copy {
  padding-block: 112px 104px;
  pointer-events: none;
}

.wordmark {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(3.4rem, 12.5vw, 8rem);
  line-height: 0.95;
  letter-spacing: 0.04em;
  color: var(--star);
}

.hero-ar {
  margin: 10px 0 0;
  font-weight: 500;
  font-size: clamp(1.25rem, 3.8vw, 1.7rem);
  color: var(--brass);
}

.hero-line {
  margin: 22px 0 0;
  max-width: 25rem;
  font-size: clamp(1.08rem, 2.6vw, 1.22rem);
  line-height: 1.5;
  color: var(--star);
}

/* ---------- Home: the two ways in ---------- */
.doors {
  display: grid;
  gap: 16px;
  margin-top: -48px;
  position: relative;
  z-index: 2;
}

@media (min-width: 760px) {
  .doors {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }
}

.door {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  text-decoration: none;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.door canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
}

.door-text {
  padding: 16px 22px 20px;
  border-top: 1px solid var(--line);
}

.door h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.5rem, 3.6vw, 1.9rem);
  line-height: 1.15;
  transition: color 0.2s ease;
}

.door p {
  margin: 4px 0 0;
  color: var(--dust);
}

.door:hover,
.door:focus-visible {
  border-color: color-mix(in srgb, var(--brass) 55%, transparent);
  background: var(--panel-2);
}

.door:hover h2,
.door:focus-visible h2 {
  color: var(--brass);
}

/* ---------- Home: the five orbits ---------- */
.orbits {
  display: grid;
  gap: 24px;
  align-items: center;
  padding-block: 96px 104px;
}

@media (min-width: 860px) {
  .orbits {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 64px;
  }
}

.orbit-art {
  width: min(100%, 500px);
  justify-self: center;
}

.orbit-art svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.orbit-ring {
  fill: none;
  stroke: var(--line-2);
  stroke-width: 1;
}

.orbit-spin {
  transform-origin: 300px 300px;
  animation: spin linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.section-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 5vw, 2.8rem);
  line-height: 1.1;
}

.section-sub {
  margin: 10px 0 0;
  color: var(--dust);
  font-size: 1.05rem;
  max-width: 30rem;
}

.level-list {
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
}

.level-list li {
  display: grid;
  grid-template-columns: 16px auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.level-list li:first-child {
  border-top: 1px solid var(--line);
}

.planet {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff 0 8%, var(--lv) 42%, color-mix(in srgb, var(--lv) 55%, #000) 100%);
}

.level-list strong {
  font-weight: 600;
  color: var(--lv);
}

.level-list span:last-child {
  color: var(--dust);
  text-align: right;
}

.lv-beginner { --lv: var(--lv-beginner); }
.lv-easy     { --lv: var(--lv-easy); }
.lv-medium   { --lv: var(--lv-medium); }
.lv-hard     { --lv: var(--lv-hard); }
.lv-extreme  { --lv: var(--lv-extreme); }

/* ---------- Subject index pages ---------- */
.page-top {
  padding-block: 40px 4px;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 0.875rem;
  color: var(--faint);
}

.crumbs a {
  color: var(--dust);
  text-decoration: none;
}

.crumbs a:hover {
  color: var(--brass);
}

.crumbs [aria-current] {
  color: var(--star);
}

.page-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.4rem, 7vw, 4.2rem);
  line-height: 1.02;
}

.page-sub {
  margin: 12px 0 0;
  color: var(--dust);
  font-size: 1.08rem;
}

.jump {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin-top: 20px;
}

.jump a {
  color: var(--star);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--line-2);
  text-underline-offset: 5px;
}

.jump a:hover {
  color: var(--brass);
  text-decoration-color: var(--brass);
}

.field {
  padding-block: 40px 8px;
  scroll-margin-top: 80px;
}

.field-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.6rem, 4.4vw, 2.1rem);
}

.field-title small {
  margin-left: auto;
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--dust);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 900px) {
  .tiles--three {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 560px) {
  .tiles {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
}

.tile {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  text-decoration: none;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.tile canvas {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
}

.tile-text {
  display: block;
  padding: 12px 16px 15px;
  border-top: 1px solid var(--line);
}

.tile-name {
  display: block;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.3;
  transition: color 0.2s ease;
}

.tile-cap {
  display: block;
  margin-top: 3px;
  color: var(--faint);
  font-size: 0.84rem;
  line-height: 1.35;
}

@media (max-width: 560px) {
  .tile {
    border-radius: 8px;
  }
  .tile-text {
    padding: 9px 11px 11px;
  }
  .tile-name {
    font-size: 0.9rem;
  }
  .tile-cap {
    display: none;
  }
}

.tile:hover,
.tile:focus-visible {
  border-color: color-mix(in srgb, var(--brass) 50%, transparent);
  background: var(--panel-2);
}

.tile:hover .tile-name,
.tile:focus-visible .tile-name {
  color: var(--brass);
}

/* ---------- Subject page ---------- */
.banner {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  margin-top: 20px;
}

.banner canvas {
  display: block;
  width: 100%;
  height: clamp(240px, 40vw, 380px);
  touch-action: pan-y;
}

.banner-text {
  position: absolute;
  inset: auto 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 24px;
  padding: 64px 28px 22px;
  background: linear-gradient(180deg, transparent, rgba(7, 6, 24, 0.86));
  pointer-events: none;
}

.banner .crumbs {
  margin-bottom: 6px;
  pointer-events: auto;
}

.banner h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 6vw, 3.6rem);
  line-height: 1.04;
}

/* the equation behind the picture, set like a figure caption */
.figure-cap {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--dust);
}

.figure-cap sub {
  font-size: 0.7em;
}

@media (max-width: 560px) {
  .banner {
    margin-top: 14px;
    border-radius: 12px;
  }
  .banner canvas {
    height: 200px;
  }
  /* on phones the title sits under the picture, so the whole figure stays visible */
  .banner-text {
    position: static;
    display: block;
    padding: 6px 16px 16px;
    background: none;
  }
  .figure-cap {
    margin: 6px 0 0;
    font-size: 0.95rem;
  }
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 26px 0 6px;
}

.pill {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--star);
  font: inherit;
  font-weight: 500;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.pill .n {
  color: var(--dust);
  font-variant-numeric: tabular-nums;
}

.pill:hover {
  border-color: var(--lv, var(--brass));
}

.pill[aria-pressed="true"] {
  background: color-mix(in srgb, var(--lv, var(--brass)) 16%, transparent);
  border-color: var(--lv, var(--brass));
}

.pill-all .planet {
  --lv: var(--brass);
}

/* shelves sit side by side, so the levels read left to right like a path */
.shelves {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 44px 40px;
  padding-top: 30px;
}

.shelf {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}

.shelf:not(:has(.book)) {
  display: none;
}

.shelf-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--lv);
}

.shelf-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.45rem;
  line-height: 1.1;
  color: var(--star);
}

.books {
  --book-w: 160px;
  display: flex;
  flex-wrap: wrap;
  gap: 28px 22px;
}

@media (max-width: 560px) {
  .shelves {
    gap: 34px 16px;
  }
  .books {
    --book-w: calc((100vw - 48px) / 2);
    gap: 22px 16px;
  }
}

.book {
  display: flex;
  flex-direction: column;
  width: var(--book-w);
  max-width: 100%;
  min-width: 0;
  text-decoration: none;
  perspective: 800px;
}

.cover {
  --rx: 0deg;
  --ry: 0deg;
  --gx: 50%;
  --gy: 30%;
  position: relative;
  display: block;
  aspect-ratio: 2 / 3;
  max-width: 100%;
  overflow: hidden;
  border-radius: 3px;
  background: var(--panel-2);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 14px 26px -16px rgba(0, 0, 0, 0.9);
  transform: rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform 0.18s ease-out, box-shadow 0.2s ease;
}

.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* a faint sheen that follows the pointer */
.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--gx) var(--gy), rgba(255, 255, 255, 0.18), transparent 55%);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.book:hover .cover,
.book:focus-visible .cover {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.14),
    0 22px 34px -18px rgba(0, 0, 0, 0.95);
}

.book:hover .cover::after {
  opacity: 1;
}

.cover-blank {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: 14px 12px;
  border-top: 3px solid var(--lv, var(--brass));
  background: linear-gradient(170deg, var(--panel-2), var(--panel));
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.2;
  color: var(--star);
}

.book-title {
  margin-top: 12px;
  font-weight: 600;
  font-size: 0.93rem;
  line-height: 1.3;
}

.book:hover .book-title {
  text-decoration: underline;
  text-decoration-color: var(--lv, var(--brass));
  text-underline-offset: 3px;
}

.book-author {
  margin-top: 2px;
  color: var(--dust);
  font-size: 0.84rem;
  line-height: 1.35;
}

.book-note {
  margin-top: 6px;
  align-self: flex-start;
  padding: 1px 8px;
  border-radius: 4px;
  border: 1px solid var(--line-2);
  color: var(--dust);
  font-size: 0.75rem;
}

.page-end {
  height: 96px;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 44px 28px;
  color: var(--dust);
  font-size: 0.92rem;
}

.footer-grid {
  display: grid;
  gap: 28px 40px;
}

@media (min-width: 720px) {
  .footer-grid {
    grid-template-columns: 1.6fr 1fr 1fr;
  }
}

.footer-grid h2 {
  margin: 0 0 10px;
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--faint);
}

.footer-about {
  margin: 0;
  max-width: 24rem;
}

.footer-about strong {
  display: block;
  margin-bottom: 6px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.35rem;
  color: var(--star);
}

.footer-links {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.footer-links a {
  color: var(--star);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--brass);
}

.credits {
  margin: 0;
  display: grid;
  gap: 10px;
}

.credits div {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  align-items: baseline;
  gap: 12px;
}

.credits dt {
  color: var(--faint);
  font-size: 0.875rem;
}

.credits dd {
  margin: 0;
  color: var(--star);
  font-weight: 500;
}

.credit {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--star);
  text-decoration: none;
}

.credit svg {
  width: 14px;
  height: 14px;
  color: var(--dust);
}

.credit:hover,
.credit:hover svg {
  color: var(--brass);
}

.footer-base {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.84rem;
}

.footer-base p {
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
