@font-face {
  font-family: "DG Shamael";
  src: url("../fonts/DGShamael-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Somar Sans";
  src: url("../fonts/SomarSans-Regular.otf") format("opentype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Somar Sans";
  src: url("../fonts/SomarSans-SemiBold.otf") format("opentype");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "Somar Sans";
  src: url("../fonts/SomarSans-Bold.otf") format("opentype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --color-paper: #f4f4e6;
  --color-surface: #fbfbf5;
  --color-surface-subtle: #e8ecd8;
  --color-navy: #173f78;
  --color-classroom-blue: #1d5796;
  --color-green: #466428;
  --color-qalam-yellow: #f7d352;
  --color-text: #17231d;
  --color-text-muted: #56645a;
  --color-border: #cbd2c1;
  --color-focus: #1d5796;
  --color-focus-inner: #f4f4e6;
  --color-on-dark: #f8f8ef;
  --radius-control: 12px;
  --radius-surface: 16px;
  --radius-panel: 24px;
  --site-header-height: 76px;
  --library-footer-height: 72px;
  --container-width: min(80rem, calc(100vw - 3rem));
  --font-display: "DG Shamael", "Somar Sans", system-ui, sans-serif;
  --font-body: "Somar Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  min-height: 100%;
  overflow-x: clip;
  background: var(--color-paper);
}

body {
  height: 100vh;
  height: 100svh;
  min-height: 100svh;
  margin: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  color: var(--color-text);
  background:
    linear-gradient(90deg, rgba(23, 63, 120, .018) 1px, transparent 1px) 0 0 / 48px 48px,
    var(--color-paper);
  font: 400 16px/1.5 var(--font-body);
  overflow-x: hidden;
}

button, a { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 4px;
  box-shadow: 0 0 0 2px var(--color-focus-inner);
}

::selection { color: var(--color-text); background: #dfe8f1; }
.container { width: var(--container-width); margin-inline: auto; }

.skip-link {
  position: fixed;
  inset-inline-start: 16px;
  top: -80px;
  z-index: 999;
  padding: 12px 18px;
  border-radius: 10px;
  color: var(--color-on-dark);
  background: var(--color-text);
}

.skip-link:focus { top: 16px; }

.site-header {
  width: 100%;
  height: var(--site-header-height);
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(244, 244, 230, .96);
  border-bottom: 1px solid rgba(23, 63, 120, .08);
  box-shadow: 0 8px 24px rgba(23, 63, 120, .055);
}

.nav-wrap {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(112px, 1fr) auto minmax(112px, 1fr);
  align-items: center;
  gap: clamp(22px, 3vw, 48px);
}

.brand { display: inline-flex; align-items: center; width: fit-content; }
.brand-logo { width: 50px; height: 50px; object-fit: contain; }

.main-nav {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: clamp(24px, 2.7vw, 42px);
  font-size: .86rem;
  font-weight: 700;
}

.main-nav a, .main-nav span { position: relative; white-space: nowrap; }
.main-nav span { color: var(--color-classroom-blue); }

.main-nav span::after,
.main-nav a::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: -8px;
  height: 2px;
  border-radius: 999px;
  background: var(--color-classroom-blue);
  transform: scaleX(0);
  transition: transform 240ms var(--ease-out);
}

.main-nav span::after,
.main-nav a:hover::after { transform: scaleX(1); }
.nav-actions { justify-self: end; display: flex; align-items: center; }
.language-switcher { position: relative; }

.language-button {
  min-width: 62px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(23, 63, 120, .15);
  border-radius: 999px;
  padding: 0 14px;
  color: var(--color-navy);
  background: rgba(251, 251, 245, .82);
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 200ms var(--ease-out), background-color 200ms var(--ease-out), border-color 200ms var(--ease-out);
}

.language-button::after {
  content: "";
  width: 5px;
  height: 5px;
  border-inline-end: 1px solid currentColor;
  border-block-end: 1px solid currentColor;
  transform: translateY(-1px) rotate(45deg);
}

.language-button:hover {
  transform: translateY(-1px);
  border-color: rgba(23, 63, 120, .3);
  background: var(--color-surface);
}

.language-button:active { transform: scale(.98); }

.language-menu {
  width: 170px;
  position: absolute;
  top: calc(100% + 10px);
  inset-inline-end: 0;
  z-index: 100;
  padding: 8px;
  border: 1px solid rgba(23, 63, 120, .1);
  border-radius: var(--radius-surface);
  background: rgba(251, 251, 245, .99);
  box-shadow: 0 22px 50px rgba(23, 63, 120, .12);
}

.language-menu button {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  padding: 0 12px;
  text-align: start;
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}

.language-menu button:hover,
.language-menu button[aria-current="true"] { background: var(--color-surface-subtle); }

.library-main {
  min-height: calc(100svh - var(--site-header-height) - var(--library-footer-height));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: clamp(14px, 2vh, 22px) 0 12px;
  isolation: isolate;
}

.library-intro { position: relative; z-index: 4; text-align: center; }

.library-intro h1 {
  width: fit-content;
  margin: 0 auto;
  position: relative;
  z-index: 0;
  isolation: isolate;
  color: var(--color-text);
  font: 700 clamp(2.2rem, 3.2vw, 3.35rem)/1.08 var(--font-display);
  letter-spacing: -.015em;
}

.library-title-text {
  position: relative;
  z-index: 2;
  display: inline-block;
}

html[lang="ar"] .library-intro h1 {
  font-family: var(--font-body);
  font-weight: 700;
}

.library-intro h1::after {
  content: "";
  width: 86%;
  height: 7px;
  position: absolute;
  z-index: 0;
  inset-inline-start: 10%;
  bottom: -1px;
  border-radius: 70% 45% 55% 60%;
  background: linear-gradient(
    90deg,
    rgba(247, 194, 37, 0) 0%,
    rgba(247, 194, 37, .02) 3%,
    rgba(247, 194, 37, .09) 7%,
    rgba(247, 194, 37, .24) 12%,
    rgba(247, 194, 37, .5) 19%,
    rgba(247, 194, 37, .82) 28%,
    var(--color-qalam-yellow) 42%,
    var(--color-qalam-yellow) 62%,
    rgba(247, 194, 37, .82) 74%,
    rgba(247, 194, 37, .5) 83%,
    rgba(247, 194, 37, .22) 90%,
    rgba(247, 194, 37, .07) 96%,
    rgba(247, 194, 37, 0) 100%
  );
  clip-path: polygon(0 44%, 18% 31%, 43% 39%, 68% 25%, 100% 49%, 100% 76%, 72% 63%, 44% 77%, 17% 66%, 0 72%);
  pointer-events: none;
  transform: rotate(-1.2deg);
}

html[dir="rtl"] .library-intro h1::after { transform: rotate(1.2deg); }

.library-intro p {
  margin: 12px 0 0;
  color: var(--color-text-muted);
  font-size: clamp(.95rem, 1.2vw, 1.08rem);
  font-weight: 600;
}

.journey-shell {
  width: min(calc(100% - 32px), 1360px);
  height: 100%;
  min-height: 500px;
  max-height: 560px;
  margin-inline: auto;
  position: relative;
  isolation: isolate;
  overflow: visible;
}

.journey-route-clip {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.journey-route {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  overflow: visible;
  opacity: 0;
}

.journey-route.is-route-ready { opacity: 1; }

.route-path,
.route-reveal-mask {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.route-road-shape {
  fill: #aebab7;
  opacity: .18;
}

.route-path {
  stroke-width: 3px;
}

.route-path--base {
  stroke: #aebab7;
  stroke-dasharray: 3 11;
  opacity: .5;
}

.route-path--progress {
  stroke: #247db1;
  opacity: .88;
}

.route-reveal-mask {
  stroke: #fff;
  stroke-width: 10px;
}

.journey-grid {
  height: 100%;
  position: relative;
  z-index: 2;
  display: grid;
  direction: ltr;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 4px clamp(16px, 1.25vw, 24px);
  padding: 6px clamp(28px, 2.5vw, 40px) 4px;
}

.level-group {
  min-width: 0;
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  place-items: center;
  align-self: stretch;
  padding: 10px 12px 6px;
  --blob-rgb: 151 166 221;
  --blob-duration: 13.5s;
  --blob-delay: -3.2s;
  --level-y: 0px;
  transform: translateY(var(--level-y));
}

.level-group::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 50%;
  left: 50%;
  width: 138%;
  height: 134%;
  border-radius: 56% 44% 61% 39% / 46% 58% 42% 54%;
  background: radial-gradient(
    ellipse at 49% 49%,
    rgb(var(--blob-rgb) / .14) 0%,
    rgb(var(--blob-rgb) / .128) 14%,
    rgb(var(--blob-rgb) / .105) 28%,
    rgb(var(--blob-rgb) / .078) 42%,
    rgb(var(--blob-rgb) / .052) 54%,
    rgb(var(--blob-rgb) / .032) 64%,
    rgb(var(--blob-rgb) / .017) 73%,
    rgb(var(--blob-rgb) / .008) 81%,
    rgb(var(--blob-rgb) / .003) 88%,
    rgb(var(--blob-rgb) / .001) 94%,
    transparent 100%
  );
  mix-blend-mode: normal;
  opacity: 1;
  filter: blur(4px);
  transform: translate3d(calc(-50% - 4px), calc(-50% + 2px), 0) scale3d(.99, 1.025, 1);
  transform-origin: center;
  will-change: transform, border-radius;
  pointer-events: none;
  transition: opacity 220ms var(--ease-out);
}

.level-group:has(.book-button:is(:hover, :focus-visible))::before { animation-play-state: paused; }
.level-group[data-stage="Pre-A1"] { grid-column: 5 / span 2; grid-row: 1; --blob-rgb: 126 145 213; --blob-duration: 14.8s; --blob-delay: -9.4s; }
.level-group[data-stage="A1"] { grid-column: 3 / span 2; grid-row: 1; --blob-rgb: 142 169 78; --blob-duration: 16.3s; --blob-delay: -4.8s; }
.level-group[data-stage="A2"] { grid-column: 1 / span 2; grid-row: 1; --blob-rgb: 233 174 53; --blob-duration: 13.1s; --blob-delay: -11.7s; }
.level-group[data-stage="B1"] { grid-column: 2 / span 2; grid-row: 2; --blob-rgb: 57 164 180; --blob-duration: 17.2s; --blob-delay: -6.3s; --level-y: 8px !important; }
.level-group[data-stage="B2"] { grid-column: 4 / span 2; grid-row: 2; --blob-rgb: 205 91 116; --blob-duration: 15.6s; --blob-delay: -13.2s; --level-y: 11px !important; }

.level-heading,
.level-books { position: relative; z-index: 1; }

.level-heading {
  margin: 0;
  direction: ltr;
  color: var(--color-text);
  font-size: clamp(1.25rem, 1.55vw, 1.65rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.02em;
  text-shadow: 0 1px rgba(255, 255, 255, .72);
}

.level-books {
  min-width: 0;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, .8vw, 14px);
}

.level-group[data-stage="B1"] .level-books {
  flex-direction: row;
}

.book-button {
  width: clamp(104px, 8.1vw, 144px);
  min-height: clamp(188px, 14vw, 218px);
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  border: 0;
  border-radius: var(--radius-surface);
  padding: 10px 8px 22px;
  background: transparent;
  cursor: pointer;
  --book-x: 0px;
  --book-y: 0px;
  transform: translate3d(var(--book-x), var(--book-y), 0) rotate(var(--rest-rotation, 0deg));
  transform-origin: 50% 82%;
  transition: transform 220ms var(--ease-out), filter 220ms var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.book-button:hover {
  z-index: 4;
  transform: translate3d(var(--book-x), calc(var(--book-y) - 8px), 0) rotate(0deg) scale(1.02);
}

.book-button:focus-visible {
  z-index: 4;
  outline-offset: 2px;
  transform: translate3d(var(--book-x), calc(var(--book-y) - 8px), 0) rotate(0deg) scale(1.02);
  transition-duration: 0s;
}

.book-button:active { transform: translate3d(var(--book-x), calc(var(--book-y) - 1px), 0) rotate(0deg) scale(.975); }

.book-cover-wrap { position: relative; display: grid; place-items: center; }

.book-cover {
  width: auto;
  height: clamp(142px, 11vw, 174px);
  max-width: 100%;
  object-fit: contain;
  border-radius: 2px 4px 4px 2px;
  filter:
    drop-shadow(0 1px 0 rgba(255, 255, 255, .82))
    drop-shadow(0 10px 10px rgba(23, 63, 120, .15))
    drop-shadow(0 3px 3px rgba(23, 35, 29, .13));
  transition: filter 220ms var(--ease-out);
}

.book-button:hover .book-cover,
.book-button:focus-visible .book-cover {
  filter:
    drop-shadow(0 1px 0 rgba(255, 255, 255, .88))
    drop-shadow(0 18px 15px rgba(23, 63, 120, .22))
    drop-shadow(0 5px 4px rgba(23, 35, 29, .15));
}

.book-number {
  min-width: 44px;
  height: 44px;
  margin-top: -7px;
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, .8);
  border-radius: 50%;
  color: #fff;
  background: var(--book-color, var(--color-classroom-blue));
  box-shadow: 0 4px 10px color-mix(in srgb, var(--book-color, var(--color-classroom-blue)) 28%, transparent);
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1;
}

.last-used-locator {
  width: 20px;
  height: 20px;
  position: absolute;
  top: -7px;
  inset-inline-end: -8px;
  z-index: 3;
  border: 3px solid var(--color-surface);
  border-radius: 50%;
  background: var(--color-qalam-yellow);
  box-shadow: 0 0 0 1px rgba(23, 35, 29, .14), 0 4px 8px rgba(23, 63, 120, .15);
  opacity: 0;
}

.book-button.is-last-used .book-cover-wrap::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 3px solid var(--book-color, var(--color-classroom-blue));
  border-radius: 7px;
  pointer-events: none;
}

.book-button.is-last-used .last-used-locator { opacity: 1; }

.site-footer {
  min-height: var(--library-footer-height);
  position: relative;
  z-index: 5;
  color: var(--color-on-dark);
  background: var(--color-navy);
}

.footer-pencil {
  min-height: var(--library-footer-height);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .025), rgba(255, 255, 255, .07) 31%, rgba(255, 255, 255, .018) 64%, rgba(3, 49, 101, .06)),
    linear-gradient(180deg, #1768b2 0 18%, #1261ab 18% 49%, #0f5ba7 49% 66%, #0b529d 66% 100%);
  box-shadow: inset 0 1px 0 rgba(248, 248, 239, .17), 0 -8px 24px rgba(23, 63, 120, .05);
}

.footer-inner {
  min-height: var(--library-footer-height);
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto auto;
  align-items: center;
  gap: clamp(20px, 3vw, 50px);
}

.footer-brand-lockup { display: flex; align-items: center; gap: 16px; }
.footer-brand-lockup .brand-logo { width: 42px; height: 42px; }
.publisher-link { display: block; }
.publisher-link img { width: 72px; height: auto; }
.footer-copy, .footer-copyright { margin: 0; font-size: .76rem; }
.footer-copy { color: rgba(248, 248, 239, .84); }
.footer-copyright { direction: ltr; unicode-bidi: isolate; color: rgba(248, 248, 239, .76); white-space: nowrap; }
.footer-links { display: flex; gap: 20px; font-size: .78rem; font-weight: 600; }
.footer-links a { color: rgba(248, 248, 239, .84); }
.footer-links a:hover { color: #fff; }

@media (prefers-reduced-motion: no-preference) {
  .journey-route.is-route-ready .route-reveal-mask {
    stroke-dasharray: var(--route-length) var(--route-length);
    stroke-dashoffset: var(--route-length);
    animation: route-draw 1.45s var(--ease-out) forwards;
  }

  .level-group::before {
    animation: level-field-morph var(--blob-duration) cubic-bezier(.45, .05, .55, .95) var(--blob-delay) infinite alternate both;
  }

  .level-group {
    animation: level-enter 460ms var(--ease-out) both;
    animation-delay: calc(150ms + var(--journey-index, 0) * 60ms);
  }

}

@keyframes route-draw { to { stroke-dashoffset: 0; } }

@keyframes level-enter {
  from { opacity: 0; transform: translateY(calc(var(--level-y) + 8px)); filter: blur(4px); }
  to { opacity: 1; transform: translateY(var(--level-y)); filter: blur(0); }
}

@keyframes level-field-morph {
  0% {
    border-radius: 56% 44% 61% 39% / 46% 58% 42% 54%;
    transform: translate3d(calc(-50% - 4px), calc(-50% + 2px), 0) scale3d(.99, 1.025, 1);
  }
  33% {
    border-radius: 46% 54% 43% 57% / 58% 42% 60% 40%;
    transform: translate3d(calc(-50% + 6px), calc(-50% - 4px), 0) scale3d(1.04, .985, 1);
  }
  66% {
    border-radius: 63% 37% 52% 48% / 41% 61% 39% 59%;
    transform: translate3d(calc(-50% - 2px), calc(-50% - 5px), 0) scale3d(.98, 1.045, 1);
  }
  100% {
    border-radius: 42% 58% 56% 44% / 55% 45% 57% 43%;
    transform: translate3d(calc(-50% + 4px), calc(-50% + 4px), 0) scale3d(1.03, .99, 1);
  }
}

.level-group.no-entry-motion {
  animation: none;
  opacity: 1;
  transform: translateY(var(--level-y));
  filter: none;
}

@media (max-width: 1180px) {
  .journey-grid { padding-inline: 52px; gap-inline: 18px; }
  .book-button { width: clamp(96px, 9vw, 112px); min-height: 196px; }
  .book-cover { height: clamp(138px, 12.5vw, 158px); }
  .level-group { padding-inline: 4px; }
  .footer-copy { display: none; }
  .footer-inner { grid-template-columns: auto 1fr auto; }
}

@media (max-width: 760px) {
  :root { --site-header-height: 64px; --library-footer-height: auto; --container-width: calc(100vw - 28px); }
  .site-header { height: var(--site-header-height); }
  html { height: auto; min-height: 100%; overflow-x: clip; overflow-y: auto; }
  body { height: auto; min-height: 100svh; overflow-x: hidden; overflow-y: auto; }
  .nav-wrap { grid-template-columns: 1fr auto; }
  .brand-logo { width: 46px; height: 46px; }
  .main-nav { display: none; }
  .library-main { min-height: 0; gap: 22px; padding: 24px 0 34px; }
  .library-intro { padding-inline: 18px; }
  .library-intro h1 { font-size: clamp(2.15rem, 11vw, 3rem); }
  .library-intro p { margin-top: 14px; }

  .journey-shell {
    width: min(calc(100% - 20px), 430px);
    height: auto;
    min-height: 1510px;
    max-height: none;
    overflow: visible;
  }

  .route-path { stroke-width: 2px; }
  .route-reveal-mask { stroke-width: 8px; }

  .journey-grid {
    height: auto;
    min-height: 1510px;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(5, 286px);
    gap: 18px;
    padding: 0 22px;
  }

  .level-group,
  .level-group[data-stage] {
    grid-column: 1;
    grid-row: auto;
    width: 100%;
    max-width: 340px;
    min-height: 286px;
    justify-self: center;
    padding: 17px 10px 4px;
    --level-y: 0px !important;
  }

  .level-group::before { width: 132%; height: 128%; }
  .level-heading { font-size: 1.52rem; }
  .book-button { width: 132px; min-height: 222px; --book-x: 0px !important; --book-y: 0px !important; }
  .book-cover { height: 166px; }

  .footer-inner {
    min-height: 168px;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 12px 20px;
    padding-block: 22px;
  }

  .footer-links { justify-self: end; flex-direction: column; align-items: end; gap: 5px; }
  .footer-copyright { grid-column: 1 / -1; justify-self: center; }
}

@media (max-width: 390px) {
  .journey-shell { width: 100%; }
  .journey-grid { padding-inline: 15px; }
  .level-group { max-width: 310px; }
  .book-button { width: 126px; }
}

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

  .route-reveal-mask { stroke-dasharray: none; stroke-dashoffset: 0; }
  .level-group { opacity: 1; transform: translateY(var(--level-y)); filter: none; }
  .level-group::before {
    border-radius: 56% 44% 61% 39% / 46% 58% 42% 54%;
    transform: translate3d(-50%, -50%, 0) scale3d(1, 1, 1);
  }
  .book-button,
  .book-button:hover,
  .book-button:focus-visible,
  .book-button:active { transform: translate3d(var(--book-x), var(--book-y), 0) rotate(var(--rest-rotation, 0deg)); }
}

@media (min-width: 761px) {
  html, body { height: 100%; overflow: hidden; }
  .library-main { min-height: 0; overflow: hidden; }
  .journey-shell { min-height: 0; }
}

@media (min-width: 761px) and (max-height: 820px) {
  .level-group[data-stage="B1"] { --level-y: -8px !important; }
  .level-group[data-stage="B2"] { --level-y: -5px !important; }
}

@media (min-width: 761px) and (max-height: 740px) {
  .level-group[data-stage="B1"] { --level-y: -24px !important; }
  .level-group[data-stage="B2"] { --level-y: -21px !important; }
}

.library-empty { text-align: center; max-width: 38rem; margin: 3rem auto; padding: 1.5rem; border-radius: var(--radius-panel); background: var(--color-surface); }
.logout-button { width: auto; padding-inline: .8rem; white-space: nowrap; }

.logout-button::after { content: none; }
