/* Arabic letters: Noto Naskh Arabic (SIL OFL 1.1, see fonts/OFL.txt), bundled so every device shows the same letters */
@font-face { font-family: 'ArabicGlyph'; src: url('../fonts/NotoNaskhArabic-Regular.ttf') format('truetype'); font-weight: 400; font-style: normal; font-display: swap; }
body { margin: 0; font-family: system-ui, sans-serif; }

:root { --bg:#f6f3ee; --ink:#1e2a38; --paper:#fffdf8; --accent:#2f7d5b; --guide:#d9d2c3; --draw:#1e2a38; --bad:#c0392b; --ok:#2f7d5b; --radius:14px; }
body { background: var(--bg); color: var(--ink); }
button { font: inherit; cursor: pointer; color: inherit; }
.stage { width: 100%; max-width: 480px; display: block; margin: 0 auto; touch-action: none; overflow: visible; }
.stage .paper { fill: var(--paper); stroke: #e3dccd; stroke-width: .6; }
.stage .guide-stroke { fill: none; stroke: var(--guide); stroke-linecap: round; stroke-linejoin: round; }
.stage .guide-dot { fill: var(--guide); }
.stage .ink-stroke { fill: none; stroke: var(--draw); stroke-linecap: round; stroke-linejoin: round; }
.stage .ink-dot { fill: var(--draw); }
.stage .arrow { fill: var(--accent); opacity: .55; }
.stage .marker circle { fill: var(--accent); }
.stage .marker.spot circle { fill: #e08e2b; }
.stage .marker text { fill: #fff; font-size: 4px; font-weight: 700; pointer-events: none; }
.stage .marker.active circle { animation: pulse 0.9s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 50% { transform: scale(1.6); opacity: .6; } }
.stage .hand-shadow { fill: #000; }
.stage[data-mode=trace] .ink, .stage[data-mode=trace] .hand, .stage[data-mode=write] .ink, .stage[data-mode=write] .hand { display: none; }
.stage[data-mode=write] .guide, .stage[data-mode=write] .marks { display: none; }
.stage[data-mode=write][data-reveal] .guide, .stage[data-mode=write][data-reveal] .marks { display: inline; }
.stage[data-mode=trace] .guide-stroke { stroke: #b9b09c; stroke-dasharray: 1 2.5; }
.stage .user-stroke { fill: none; stroke: #3b6fd1; stroke-linecap: round; stroke-linejoin: round; opacity: .9; }
.stage .user-stroke.ok { stroke: var(--ok); }
.stage .user-stroke.bad { stroke: var(--bad); }
.caption { text-align: center; font-size: 1.25rem; min-height: 2.8em; margin: .75rem 0; }
.controls { display: grid; gap: .6rem; justify-items: center; }
.controls input[type=range] { width: min(480px, 90%); }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; }
.btn { padding: .6rem 1rem; border-radius: 999px; border: 1px solid #cfc7b6; background: #fff; text-decoration: none; color: var(--ink); display: inline-block; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.speed { display: flex; gap: .4rem; }
.chip { padding: .3rem .8rem; border-radius: 999px; border: 1px solid #cfc7b6; background: #fff; }
.chip.on { background: var(--ink); color: #fff; }

.screen { max-width: 960px; margin: 0 auto; padding: 1rem 1rem 3rem; }
.center { text-align: center; }
h1 { text-align: center; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .8rem; margin-top: 1rem; }
.tile { display: grid; justify-items: center; gap: .2rem; padding: 1rem; background: #fff; border: 1px solid #e3dccd; border-radius: var(--radius); text-decoration: none; color: inherit; position: relative; }
.tile .glyph, .title .glyph { font-size: 3.2rem; line-height: 1.2; }
.title { text-align: center; }
.tile .star { position: absolute; top: .3rem; right: .4rem; }
.tabs { display: flex; gap: .4rem; justify-content: center; margin: .5rem 0 1rem; }
.tab { padding: .5rem 1rem; border-radius: 999px; border: 1px solid #cfc7b6; background: #fff; }
.tab.on { background: var(--ink); color: #fff; }
.tab:disabled { opacity: .4; cursor: not-allowed; }
.steps { max-width: 560px; margin: 0 auto; padding-left: 0; list-style: none; display: grid; gap: .5rem; }
.theme-waliid .steps { list-style: decimal; padding-left: 1.4rem; }
.steps li { padding: .4rem .6rem; border-radius: 8px; }
.steps li.current { background: #e8f3ed; }
.rounds { text-align: center; font-size: 1.2rem; }
[hidden] { display: none !important; }

.theme-waliid { --bg: #fff8dc; --accent: #ef7d00; --draw: #2a2a72; --guide: #ffe28a; font-size: 1.2rem; }
.theme-waliid .stage { max-width: 640px; }
.theme-waliid .btn, .theme-waliid .tab { padding: .9rem 1.4rem; font-size: 1.15rem; }
.theme-waliid .steps li { font-size: 1.25rem; }
.theme-amiira { --bg: #eef4ff; --accent: #3b6fd1; --draw: #1b2d6b; --guide: #cfdcf7; }
.theme-suad { --bg: #f6f3ee; --accent: #2f7d5b; --draw: #1e2a38; --guide: #e1dbcd; }
.theme-suad .caption { font-size: 1.1rem; }
@media (max-width: 480px) { .btn { padding: .55rem .8rem; } }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin-top: 1rem; align-items: start; }
.col { background: var(--bg); border: 1px solid #e3dccd; border-radius: var(--radius); padding: 1rem; }
.col .avatar { font-size: 1.8rem; }
.col .meta { font-size: .85rem; opacity: .75; }
.col .plan { padding-left: 1.2rem; }
.compare .btn-row { margin: .5rem 0; }

.col { overflow: hidden; }

/* writing book */
.stage .cover { fill: var(--cover, #8a5a3c); }
.stage .pages-under { fill: #efe7d6; stroke: #d8cdb6; stroke-width: .4; }
.stage .paper { fill: var(--paper); stroke: #e6dcc6; stroke-width: .3; }
.stage .rule { stroke: #c4d8ea; stroke-width: .35; }
.stage .rule.base { stroke: #8fb2d1; stroke-width: .5; }
.stage .margin { stroke: #e9a0a0; stroke-width: .4; }
.stage .spine { fill: var(--cover, #8a5a3c); filter: brightness(.78); }
.stage .stitch { stroke: #f4e9cf; stroke-width: .7; stroke-linecap: round; opacity: .9; }
.stage { filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .18)); }
.theme-neutral { --cover: #8a5a3c; }
.theme-suad { --cover: #2f7d5b; }
.theme-amiira { --cover: #3b6fd1; }
.theme-waliid { --cover: #ef7d00; }

/* language switch, sound, tiles */
.bar-right { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.lang { display: flex; gap: .25rem; }
.sound { position: relative; display: inline-block; }
.sound-btn { border: 1px solid #cfc7b6; background: #fff; border-radius: 999px; padding: .25rem .6rem; font-size: 1.1rem; }
.sound-note { position: absolute; bottom: 2.4rem; right: 0; width: 220px; background: #fff; border: 1px solid #cfc7b6; border-radius: 8px; padding: .4rem .6rem; font-size: .8rem; z-index: 5; text-align: left; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
.tile { padding: .8rem .5rem 2.6rem; }
.tile .tile-link { display: grid; justify-items: center; gap: .2rem; text-decoration: none; color: inherit; }
.tile .sound { position: absolute; bottom: .4rem; right: .4rem; }
.tile .star { top: .3rem; right: .4rem; left: auto; }
.title .sound { vertical-align: middle; }
.letter-switch { max-width: 960px; margin: .5rem auto; }

.glyph { font-family: 'ArabicGlyph', 'Noto Naskh Arabic', 'Geeza Pro', serif; }

.stage .glyph-guide, .stage .glyph-ink { font-family: 'ArabicGlyph', 'Noto Naskh Arabic', 'Geeza Pro', serif; stroke-linejoin: round; }
.stage .glyph-guide { fill: var(--guide); }
.stage .glyph-ink { fill: var(--draw); stroke: var(--draw); }
.stage[data-mode=trace] .glyph-guide { fill: #cfc6b2; }

/* ---------- profile screen ---------- */
html { background: #f7f3ec; }
body { min-height: 100vh; }
body.theme-neutral { --brand: #0f766e; background-attachment: fixed; background:
  radial-gradient(900px 420px at 85% -10%, rgba(15,118,110,.10), transparent 60%),
  radial-gradient(800px 420px at 0% 0%, rgba(239,125,0,.08), transparent 55%),
  #f7f3ec; background-attachment: fixed; }
.select { max-width: 1040px; padding: 1.2rem 1.25rem 3rem; }
.select-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .75rem; }
.brand-mark { width: 46px; height: 46px; filter: drop-shadow(0 3px 6px rgba(15,118,110,.25)); }
.brand-letter { font-family: 'ArabicGlyph', serif; }
.brand-name { font-weight: 800; font-size: 1.1rem; letter-spacing: .01em; color: #14302d; }
.brand-tag { font-size: .85rem; color: #5b6b69; }
.select-head { text-align: center; margin: 2.2rem 0 1.6rem; }
.select-head h1 { margin: 0; font-size: clamp(1.8rem, 4.4vw, 2.6rem); letter-spacing: -.01em; color: #14302d; }
.select-head .subtitle { margin: .6rem auto 0; max-width: 34rem; color: #5b6b69; font-size: 1.05rem; line-height: 1.45; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 1.4rem; margin: 0 0 1.8rem; }

.profile-card { --card-bg: #f4eee5; --portrait: linear-gradient(180deg, #f0e5d3, #e7d8c0); --accent: #8b6f57;
  appearance: none; border: 0; padding: 0; text-align: left; cursor: pointer; overflow: hidden; display: flex; flex-direction: column;
  border-radius: 24px; background: var(--card-bg); box-shadow: 0 1px 0 rgba(255,255,255,.7) inset, 0 10px 28px rgba(31,41,55,.10), 0 2px 6px rgba(31,41,55,.06);
  transition: transform .22s ease, box-shadow .22s ease; animation: card-in .55s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i) * 90ms); }
.profile-card:hover { transform: translateY(-6px); box-shadow: 0 1px 0 rgba(255,255,255,.7) inset, 0 18px 38px rgba(31,41,55,.16), 0 4px 10px rgba(31,41,55,.08); }
.profile-card:active { transform: translateY(-2px); }
.profile-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.profile-card .portrait { display: grid; place-items: end center; height: 210px; background: var(--portrait); position: relative; overflow: hidden; }
.profile-card .portrait::after { content: ''; position: absolute; inset: auto -20% -60% -20%; height: 90%; border-radius: 50%; background: rgba(255,255,255,.35); }
.profile-card .avatar-svg { width: 190px; height: 190px; position: relative; z-index: 1; transition: transform .3s ease; }
.profile-card:hover .avatar-svg { transform: scale(1.05) translateY(-3px); }
.profile-card .card-body { display: flex; flex-direction: column; gap: .35rem; padding: 1.05rem 1.3rem 1.3rem; position: relative; flex: 1; }
.profile-card .pname { font-size: 1.55rem; font-weight: 800; color: #1c2732; line-height: 1.1; }
.profile-card .prole { align-self: flex-start; font-size: .85rem; font-weight: 700; padding: .18rem .65rem; border-radius: 999px; background: color-mix(in srgb, var(--accent) 16%, white); color: color-mix(in srgb, var(--accent) 80%, black); }
.profile-card .points { list-style: none; margin: .7rem 0 0; padding: 0; display: grid; gap: .45rem; color: #34414d; font-size: .95rem; }
.profile-card .points li { display: flex; align-items: center; gap: .55rem; }
.profile-card .points li::before { content: '✓'; display: inline-grid; place-items: center; flex: none; width: 1.3rem; height: 1.3rem; border-radius: 50%; font-size: .75rem; font-weight: 800; color: #fff; background: var(--accent); }
.profile-card .go { position: absolute; right: 1.1rem; bottom: 1.1rem; width: 2.4rem; height: 2.4rem; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-size: 1.2rem; transition: transform .2s ease; }
.profile-card:hover .go { transform: translateX(4px); }

.p-suad { --card-bg: #f6efe6; --portrait: linear-gradient(180deg, #f5e7d2, #ead7bb); --accent: #9a6b3f; }
.p-amiira { --card-bg: #fdecf1; --portrait: linear-gradient(180deg, #fde0e9, #f8c9d8); --accent: #d6537f; }
.p-waliid { --card-bg: #e8f4f2; --portrait: linear-gradient(180deg, #d5eeea, #bfe3dd); --accent: #1f8f7f; }

.compare-link { margin: 0; }
.pill { display: inline-flex; align-items: center; gap: .5rem; padding: .7rem 1.3rem; border-radius: 999px; background: #fff; color: #14302d; font-weight: 700; text-decoration: none;
  border: 1px solid #d8e2e0; box-shadow: 0 2px 8px rgba(31,41,55,.06); transition: box-shadow .2s ease, transform .2s ease; }
.pill:hover { box-shadow: 0 6px 16px rgba(31,41,55,.12); transform: translateY(-2px); }
.select .lang .chip { background: #fff; }
.select .lang .chip.on { background: #14302d; border-color: #14302d; }
@keyframes card-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .profile-card { animation: none; transition: none; } .profile-card:hover { transform: none; } }
@media (max-width: 560px) { .select-top { flex-direction: column; align-items: flex-start; } .profile-card .portrait { height: 180px; } .profile-card .avatar-svg { width: 160px; height: 160px; } }

/* ---------- credit ---------- */
.credit { text-align: center; padding: 1.4rem 1rem 2rem; font-size: .88rem; color: #6b7775; }
.credit a { color: #2a3a38; font-weight: 700; }
.credit a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(107,119,117,.5); }
.credit a:hover, .credit a:focus-visible { color: #0f766e; text-decoration-color: currentColor; }

.sound-btn.speaking { background: #14302d; color: #fff; border-color: #14302d; animation: sound-pulse 0.8s ease-in-out infinite; }
@keyframes sound-pulse { 50% { transform: scale(1.12); } }
@media (prefers-reduced-motion: reduce) { .sound-btn.speaking { animation: none; } }
