/* Qalam shared styles for the signed-in pages: sign in, book journey,
   book resources and resource lists. The landing page keeps landing.css. */

@font-face { font-family: "Sora"; src: url("../fonts/Sora-Variable.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }
@font-face { font-family: "Somar Sans"; src: url("../fonts/SomarSans-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Somar Sans"; src: url("../fonts/SomarSans-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Somar Sans"; src: url("../fonts/SomarSans-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Somar Sans"; src: url("../fonts/SomarSans-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Gorditas"; src: url("../fonts/Gorditas-Regular.woff2") format("woff2"); font-weight: 400; 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-burgundy: #7a2335;
  --color-qalam-yellow: #f7d352;
  --color-qalam-yellow-hover: #ffe16d;
  --color-qalam-yellow-active: #edc53e;
  --color-text: #17231d;
  --color-text-muted: #56645a;
  --color-border: #d6dbcc;
  --color-border-strong: #aab5a3;
  --color-focus: #1d5796;
  --color-on-dark: #f8f8ef;
  --radius-control: 12px;
  --radius-surface: 16px;
  --radius-panel: 24px;
  --shadow-sm: 0 8px 24px rgba(23, 63, 120, .08);
  --shadow-md: 0 22px 64px rgba(23, 63, 120, .14);
  --header-h: 76px;
  --page: min(80rem, calc(100vw - 3rem));
  --font-latin: "Sora", "Somar Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-arabic: "Somar Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: var(--font-latin);
}
html[lang="ar"] { --font-body: var(--font-arabic); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  color: var(--color-text);
  background: var(--color-paper);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
}
main { flex: 1 0 auto; position: relative; isolation: isolate; padding-bottom: 48px; }
main::after { content: ""; position: absolute; inset: auto -1px -1px; height: calc(clamp(16px, 2.4vw, 34px) + 2px); background: #1768b2; mask: url("../img/decor/wave.svg") center / 100% 100% no-repeat; transform: scaleY(-1); pointer-events: none; z-index: 3; }
body { overflow-x: clip; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 3px; border-radius: 6px; }
.container { width: var(--page); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; inset-inline-start: 12px; top: -60px; z-index: 50; padding: 10px 14px; border-radius: var(--radius-control); background: var(--color-navy); color: #fff; font-weight: 700; }
.skip-link:focus { top: 12px; }

/* Header -------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(244, 244, 230, .94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(23, 63, 120, .08);
}
.nav-wrap { height: var(--header-h); display: flex; align-items: center; gap: 28px; }
.brand { display: inline-flex; align-items: center; flex: none; }
.brand-logo { width: 50px; height: 50px; object-fit: contain; }
.main-nav { display: flex; align-items: center; gap: 28px; margin-inline-start: 12px; }
.main-nav a, .main-nav span { position: relative; padding-block: 12px; font-size: .86rem; font-weight: 700; color: var(--color-text); white-space: nowrap; }
.main-nav [aria-current="page"] { color: var(--color-classroom-blue); }
.main-nav [aria-current="page"]::after { content: ""; position: absolute; inset: auto 0 3px; height: 3px; border-radius: 3px; background: var(--color-qalam-yellow); }
.main-nav a:hover { color: var(--color-classroom-blue); }
.nav-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; }
.user-name { max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-text-muted); font-size: .84rem; font-weight: 600; }

.language-switcher { position: relative; }
.language-button {
  min-width: 52px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(23, 63, 120, .14);
  border-radius: 999px;
  background: rgba(251, 251, 245, .8);
  padding: 0 14px;
  color: var(--color-navy);
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
}
.language-button:hover { background: var(--color-surface); border-color: rgba(23, 63, 120, .3); }
.language-menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  width: 160px;
  padding: 6px;
  border: 1px solid rgba(23, 63, 120, .1);
  border-radius: 14px;
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
}
.language-menu button {
  width: 100%;
  min-height: 40px;
  display: block;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: start;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
}
.language-menu button:hover, .language-menu button[aria-current="true"] { background: #eef1e4; color: var(--color-navy); }

.ghost-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid rgba(23, 63, 120, .18);
  border-radius: 999px;
  background: transparent;
  color: var(--color-navy);
  font-size: .84rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.ghost-button:hover { background: var(--color-surface); border-color: rgba(23, 63, 120, .34); }
.logout-form { margin: 0; }

.pill-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 24px;
  border: 0;
  border-radius: 999px;
  background: var(--color-navy);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: transform .3s cubic-bezier(.32,.72,0,1), background-color .2s ease;
}
.pill-button:hover { background: var(--color-classroom-blue); transform: translateY(-1px); }
.pill-button:active { transform: scale(.98); }

/* Soft paper background, shared with the landing page ------------------ */
.paper-art { position: absolute; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.paper-art span { position: absolute; inset: 0; }
.paper-art .blobs {
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent), linear-gradient(transparent, #000 18%, #000 78%, transparent); mask-composite: intersect;
  background:
    radial-gradient(ellipse 34% 40% at 92% 26%, rgba(200, 224, 244, .9), rgba(200, 224, 244, 0) 70%),
    radial-gradient(ellipse 30% 36% at 8% 78%, rgba(220, 234, 200, .9), rgba(220, 234, 200, 0) 70%),
    radial-gradient(ellipse 22% 28% at 6% 22%, rgba(248, 230, 170, .7), rgba(248, 230, 170, 0) 70%);
}
.paper-art .rings {
  background: #9fb6cf;
  opacity: .5;
  -webkit-mask: url("../img/decor/pencil-tilt-r.svg") 97% 88% / 120px no-repeat;
  mask: url("../img/decor/pencil-tilt-r.svg") 97% 88% / 120px no-repeat;
}
html[dir="rtl"] .paper-art span { transform: scaleX(-1); }

/* Footer --------------------------------------------------------------- */
.site-footer { position: relative; margin-top: 0; color: var(--color-on-dark); background: linear-gradient(180deg, #1768b2, #0b529d); }
.footer-inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 16px 32px;
  padding: calc(clamp(16px, 2.4vw, 34px) + 18px) 0 20px;
}
.footer-brand { display: flex; align-items: center; gap: 14px; }
.footer-brand a:first-child img { width: 40px; height: 40px; }
.footer-brand a:last-child img { width: 84px; height: auto; }
.footer-copy { margin: 0; color: var(--color-qalam-yellow); font-weight: 700; font-size: .98rem; }
.footer-links { display: flex; gap: 22px; font-size: .86rem; font-weight: 600; }
.footer-links a { padding-block: 10px; white-space: nowrap; }
.footer-links a:hover { text-decoration: underline; text-underline-offset: 3px; }
.footer-legal { margin: 0; color: rgba(248, 248, 239, .7); font-size: .8rem; white-space: nowrap; }

@media (max-width: 760px) {
  :root { --header-h: 64px; --page: calc(100vw - 32px); }
  .nav-wrap { gap: 12px; }
  .brand-logo { width: 44px; height: 44px; }
  .main-nav { gap: 16px; margin-inline-start: 4px; }
  .main-nav .nav-optional { display: none; }
  .user-name { display: none; }
  .ghost-button { padding: 0 12px; }
  .footer-inner { grid-template-columns: 1fr auto; }
  .footer-copy { grid-column: 1 / -1; grid-row: 2; }
  .footer-links { grid-column: 1 / -1; }
  .footer-legal { grid-column: 2; grid-row: 1; }
  .paper-art .rings { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Classroom artwork, spacing and reading width. */

h1,h2,h3 { text-wrap: balance; }
.book-focus,.section-copy,.section-intro,.tile-note,.account-card > p,.footer-copy { text-wrap: balance; max-width: 58ch; }
.paper-art .rings { background: url('../img/decor/classroom-objects.svg') right 12px center / 440px auto no-repeat; -webkit-mask: none; mask: none; opacity: .25; }
@media (max-width: 1439px) { .paper-art .rings { display: none; } }
.footer-links { flex-wrap: wrap; }

/* Wording pass: allow phrases to flow at each viewport width. */
h1, h2, h3, .tile-title, .item-title { text-wrap: balance; }
p, li, figcaption, .tile-note { text-wrap: pretty; }
.book-name, .book-level, .stop-level, .about-stage-label, .path-stage-level, [data-count], [data-unit-label], .unit-chip, bdi { white-space: nowrap; }

/* Shared subtle reveal; default content remains visible without scripts. */
@media (prefers-reduced-motion: no-preference) {
 [data-scroll-reveal] { transition: opacity 420ms cubic-bezier(.22,1,.36,1), translate 420ms cubic-bezier(.22,1,.36,1); }
 [data-scroll-reveal].is-reveal-pending { opacity: 0; translate: 0 12px; }
}
@media (prefers-reduced-motion: reduce) { [data-scroll-reveal] { opacity: 1 !important; translate: none !important; } }
