/* iEssam Journey — bilingual AR/EN story
   Mobile-first. Desktop scales up.
   Edit CSS variables in :root to change the whole palette at once. */

:root {
  --bg:        #F7F3E5;
  --card:      #FFFCF1;
  --ink:       #131B2A;
  --muted:     #A5947C;
  --accent:    #BD792F;
  --accent-2:  #E2B783;
  --mint:      #7BA05B;
  --sand:      #E8DCC0;
  --radius:    24px;
  --font-body: 'IBM Plex Sans Arabic', 'IBM Plex Sans', system-ui, sans-serif;
  --font-serif:'IBM Plex Serif', 'Newsreader', Georgia, serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --shadow-card: 0 1px 0 rgba(255,255,255,.6) inset,
                 0 14px 40px -18px rgba(19,27,42,.18),
                 0 2px 6px rgba(19,27,42,.05);
  --shadow-btn:  0 1px 0 rgba(255,255,255,.4) inset,
                 0 8px 18px -10px rgba(189,121,47,.5);
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(circle at 20% 10%, rgba(189,121,47,.04), transparent 50%),
    radial-gradient(circle at 80% 90%, rgba(123,160,91,.04), transparent 50%),
    repeating-linear-gradient(0deg, rgba(19,27,42,.012) 0 1px, transparent 1px 3px);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

/* ═══ App shell ═══ */
.app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

/* ═══ Top bar ═══ */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px 10px;
  position: relative; z-index: 4;
}
.topbar-back {
  width: 38px; height: 38px;
  border: none; background: transparent;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 20px; color: var(--ink);
  opacity: .55;
  cursor: pointer;
  transition: opacity .15s, background .15s;
  flex-shrink: 0;
}
.topbar-back:hover:not(:disabled) { opacity: 1; background: rgba(19,27,42,.05); }
.topbar-back:disabled { opacity: .15; cursor: not-allowed; }
.topbar-counter {
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: .04em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0; font-weight: 500;
}
.topbar-counter span { opacity: .55; }

/* Segmented progress */
.progress-wrap { flex: 1; min-width: 0; }
.progress-segs { display: flex; gap: 5px; align-items: center; }
.seg {
  flex: 1; height: 3px;
  background: rgba(19,27,42,.08);
  border-radius: 999px; overflow: hidden; position: relative;
  transition: height .25s;
}
.seg-active { height: 4px; background: rgba(189,121,47,.12); }
.seg-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .5s cubic-bezier(.4,1.2,.4,1);
}
.seg-active .seg-fill { background: var(--accent); }

/* Thin progress variant */
.progress-thin .progress-segs { gap: 0; }
.progress-thin .seg { background: rgba(19,27,42,.06); border-radius: 0; height: 2px; }
.progress-thin .seg-active { height: 2px; }
.progress-thin .seg-fill { background: var(--accent); }

/* Dots progress variant */
.progress-dots .progress-segs { gap: 10px; justify-content: center; }
.progress-dots .seg {
  flex: 0 0 auto; width: 8px; height: 8px;
  border-radius: 50%; background: rgba(19,27,42,.12); overflow: hidden;
}
.progress-dots .seg-fill { background: var(--accent); height: 100%; }
.progress-dots .seg-active { width: 22px; border-radius: 999px; }

/* ═══ Stage / cards ═══ */
.stage {
  flex: 1; position: relative;
  display: grid; place-items: center;
  padding: 8px 18px 6px; overflow: hidden;
}
.card-shell {
  position: absolute;
  width: min(560px, calc(100% - 36px));
  max-height: calc(100% - 14px);
  display: flex;
  pointer-events: auto;
}
.card {
  width: 100%;
  background: var(--card);
  border-radius: var(--radius);
  border: .5px solid rgba(19,27,42,.06);
  box-shadow: var(--shadow-card);
  padding: 36px 28px 28px;
  overflow-y: auto; overflow-x: hidden;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: rgba(19,27,42,.15) transparent;
}
.card::-webkit-scrollbar { width: 6px; }
.card::-webkit-scrollbar-thumb { background: rgba(19,27,42,.12); border-radius: 999px; }

@media (min-width: 700px) {
  .card { padding: 48px 44px 36px; }
  .card-shell { width: min(620px, calc(100% - 36px)); }
}

/* ═══ Transitions ═══ */
/* Slide (default) — RTL-aware */
@keyframes slide-in-fwd  { from { opacity: 0; transform: translateX(var(--enter-from)); } to { opacity: 1; transform: translateX(0); } }
@keyframes slide-out-fwd { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(var(--exit-to)); } }
@keyframes slide-in-back { from { opacity: 0; transform: translateX(var(--exit-to)); } to { opacity: 1; transform: translateX(0); } }
@keyframes slide-out-back { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(var(--enter-from)); } }

.lang-en .stage { --enter-from: 30px; --exit-to: -30px; }
.lang-ar .stage { --enter-from: -30px; --exit-to: 30px; }

.trans-slide .stage[data-dir="fwd"]  .card-in  { animation: slide-in-fwd  .48s cubic-bezier(.2,.8,.2,1) both; }
.trans-slide .stage[data-dir="fwd"]  .card-out { animation: slide-out-fwd .48s cubic-bezier(.4,0,.5,1) both; }
.trans-slide .stage[data-dir="back"] .card-in  { animation: slide-in-back .48s cubic-bezier(.2,.8,.2,1) both; }
.trans-slide .stage[data-dir="back"] .card-out { animation: slide-out-back .48s cubic-bezier(.4,0,.5,1) both; }

/* Fade */
@keyframes fade-in  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade-out { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-6px); } }
.trans-fade .card-in  { animation: fade-in  .36s cubic-bezier(.2,.8,.2,1) both; }
.trans-fade .card-out { animation: fade-out .36s ease both; }

/* Stack */
@keyframes stack-in  { from { opacity: 0; transform: translateY(40px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes stack-out { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(-30px) scale(.94); } }
.trans-stack .card-in  { animation: stack-in  .52s cubic-bezier(.2,.8,.2,1) both; }
.trans-stack .card-out { animation: stack-out .42s ease both; }

/* ═══ Typography ═══ */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 22px; font-weight: 500;
}
.title-xl {
  font-family: var(--font-body);
  font-size: clamp(28px, 5vw, 38px);
  font-weight: 600; line-height: 1.18;
  letter-spacing: -0.01em; margin: 0 0 18px;
  color: var(--ink); text-wrap: pretty;
}
.title-lg {
  font-family: var(--font-body);
  font-size: clamp(22px, 4vw, 28px);
  font-weight: 600; line-height: 1.22;
  letter-spacing: -0.005em; margin: 0 0 18px;
  color: var(--ink); text-wrap: pretty;
}
.body-lg {
  font-size: clamp(16px, 2.4vw, 18px);
  line-height: 1.7; margin: 0 0 28px;
  color: rgba(19,27,42,.78); text-wrap: pretty;
}
.body-md {
  font-size: 15px; line-height: 1.65;
  margin: 0 0 22px;
  color: rgba(19,27,42,.7); text-wrap: pretty;
}

.lang-en .screen-welcome .title-xl,
.lang-en .screen-final   .title-xl { letter-spacing: -0.02em; }

/* ═══ Buttons ═══ */
.cta-stack { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.btn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; width: 100%; min-height: 56px;
  padding: 14px 22px;
  border-radius: calc(var(--radius) * 0.7);
  border: none; font-family: inherit; font-size: 16px;
  font-weight: 600; letter-spacing: -0.005em;
  cursor: pointer; text-decoration: none;
  transition: transform .15s cubic-bezier(.3,.7,.4,1), box-shadow .2s, background .15s;
  position: relative; user-select: none;
  text-align: center; line-height: 1.3;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--ink); color: var(--card);
  box-shadow: 0 1px 0 rgba(255,255,255,.08) inset, 0 8px 18px -10px rgba(19,27,42,.6);
}
.btn-primary:hover {
  background: #1f2939;
  box-shadow: 0 1px 0 rgba(255,255,255,.08) inset, 0 12px 24px -10px rgba(19,27,42,.5);
}
.btn-secondary {
  background: transparent; color: var(--ink);
  border: 1.5px solid rgba(19,27,42,.14);
}
.btn-secondary:hover { background: rgba(19,27,42,.04); border-color: rgba(19,27,42,.22); }
.btn-ghost {
  background: transparent; color: var(--muted);
  border: none; font-weight: 500; min-height: 44px;
}
.btn-ghost:hover { color: var(--ink); }

/* ═══ Choice cards ═══ */
.choice-stack { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.choice {
  appearance: none;
  display: flex; align-items: center; gap: 16px;
  width: 100%; min-height: 64px; padding: 16px 22px;
  border-radius: calc(var(--radius) * 0.7);
  border: 1.5px solid rgba(19,27,42,.1);
  background: var(--bg); color: var(--ink);
  font-family: inherit; font-size: 16px; font-weight: 500;
  letter-spacing: -0.005em; cursor: pointer; text-align: start;
  transition: transform .15s cubic-bezier(.3,.7,.4,1), border-color .2s, background .15s, box-shadow .2s;
  position: relative;
}
.choice:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: var(--card);
  box-shadow: 0 12px 26px -14px rgba(189,121,47,.4);
}
.choice:active { transform: translateY(0); }
.choice-num {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  color: var(--muted); letter-spacing: 0.03em; flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.choice-label { flex: 1; line-height: 1.4; }
.choice-arrow {
  font-size: 18px; color: var(--muted); opacity: 0;
  transform: translateX(-4px);
  transition: opacity .2s, transform .2s, color .2s;
}
.lang-ar .choice-arrow { transform: translateX(4px); }
.choice:hover .choice-arrow { opacity: 1; transform: translateX(0); color: var(--accent); }
.choice-muted {
  border-style: dashed; border-color: rgba(19,27,42,.12);
  color: var(--muted); background: transparent;
  font-weight: 500; font-size: 15px;
}
.choice-muted:hover { color: var(--ink); border-style: dashed; }

/* ═══ Microcopy quote ═══ */
.microcopy-quote {
  font-family: var(--font-body);
  font-size: clamp(20px, 3vw, 24px);
  font-weight: 500; line-height: 1.5; color: var(--ink);
  padding: 28px 22px;
  border-inline-start: 3px solid var(--accent);
  background: linear-gradient(135deg, rgba(226,183,131,.16), rgba(226,183,131,0));
  border-radius: calc(var(--radius) * 0.55);
  margin: 0 0 28px; text-wrap: pretty; position: relative;
}
.microcopy-quote::before {
  content: '"';
  font-family: var(--font-serif); font-size: 64px;
  position: absolute; top: -8px; inset-inline-end: 14px;
  color: var(--accent); opacity: .25; line-height: 1;
}

/* ═══ Mascot ═══ */
.story-mascot { margin-bottom: 12px; opacity: .9; }
.story-mascot .lemon-svg { display: block; }
.welcome-eye, .final-mascot { display: flex; margin-bottom: 24px; }
.welcome-eye .lemon-svg, .final-mascot .lemon-svg, .lang-mascot .lemon-svg {
  animation: lemon-bob 4s ease-in-out infinite;
}
@keyframes lemon-bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%       { transform: translateY(-6px) rotate(2deg); }
}

/* ═══ Badge screen ═══ */
.screen-badge {
  text-align: center; display: flex; flex-direction: column; align-items: center;
  padding-top: 14px;
}
.badge-medal {
  position: relative; width: 160px; height: 160px;
  display: grid; place-items: center; margin-bottom: 28px;
}
.badge-ring, .badge-ring-2 {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--accent); opacity: 0.3;
  animation: badge-pulse 2.4s ease-out infinite;
}
.badge-ring-2 { animation-delay: 1.2s; }
@keyframes badge-pulse {
  0%   { transform: scale(.6); opacity: .5; }
  100% { transform: scale(1.3); opacity: 0; }
}
.badge-core {
  width: 124px; height: 124px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--accent-2), var(--accent));
  display: grid; place-items: center;
  box-shadow: 0 14px 40px -10px rgba(189,121,47,.5),
              0 0 0 6px rgba(255,252,241,.6),
              0 0 0 7px rgba(189,121,47,.18);
  animation: badge-pop .6s cubic-bezier(.2,1.4,.4,1) both;
}
@keyframes badge-pop {
  0%   { transform: scale(.4); opacity: 0; }
  60%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.badge-sub {
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 12px; font-weight: 500;
}
.badge-title {
  font-family: var(--font-body);
  font-size: clamp(24px, 4vw, 30px);
  font-weight: 600; line-height: 1.25;
  letter-spacing: -0.01em; margin: 0 0 32px;
  max-width: 460px; text-wrap: pretty;
}

/* Confetti */
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti span {
  position: absolute; top: -20px; display: block;
  animation-name: confetti-fall;
  animation-timing-function: cubic-bezier(.2,.6,.4,1);
  animation-fill-mode: forwards;
}
@keyframes confetti-fall {
  0%   { transform: translateY(-20px) rotate(0); opacity: 0; }
  10%  { opacity: 1; }
  100% { transform: translateY(120vh) rotate(720deg); opacity: 0; }
}

/* ═══ Project screen ═══ */
.project-tag {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: .14em; text-transform: uppercase; font-weight: 500;
  padding: 5px 12px; border-radius: 999px;
  margin-bottom: 18px; width: fit-content;
}
.tag-lemon { background: rgba(226,183,131,.3); color: var(--accent); }
.tag-mint  { background: rgba(123,160,91,.18); color: #5C7E3F; }
.tag-sand  { background: rgba(165,148,124,.22); color: var(--muted); }
.tag-ink   { background: rgba(19,27,42,.08); color: var(--ink); }

.project-frame {
  height: 140px; border-radius: calc(var(--radius) * 0.65);
  background: var(--bg); border: 1px dashed rgba(19,27,42,.14);
  display: grid; place-items: center;
  margin: 8px 0 22px; position: relative; overflow: hidden;
}
.project-frame-stripes {
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(45deg, transparent 0 14px, rgba(19,27,42,.025) 14px 28px);
}
.project-frame-label {
  position: relative; font-family: var(--font-mono);
  font-size: 11px; letter-spacing: .06em; color: var(--muted);
  background: var(--card); padding: 4px 10px; border-radius: 4px;
}
.project-frame-image {
  padding: 0;
  border-style: solid;
  overflow: hidden;
  background: var(--bg);
}

.project-frame-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  background: var(--bg);
}

/* ═══ Final screen ═══ */
.screen-final { text-align: center; display: flex; flex-direction: column; align-items: center; }
.screen-final .cta-stack { width: 100%; max-width: 360px; margin: 0 auto; }
.screen-final .body-lg { max-width: 460px; }

/* Socials */
.socials { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; justify-content: center; }
.social-pill {
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: .06em; font-weight: 500; color: var(--muted);
  text-decoration: none; padding: 7px 14px;
  border-radius: 999px; border: 1px solid rgba(19,27,42,.1);
  background: var(--bg); transition: all .2s;
}
.social-pill:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-1px); }
.smalltext {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .03em;
  color: var(--muted); text-align: center; margin-top: 26px;
  font-style: italic; line-height: 1.6;
}

/* ═══ Skip row ═══ */
.skip-row { text-align: center; padding: 8px 0 18px; position: relative; z-index: 3; }
.skip-link {
  appearance: none; background: none; border: none;
  font-family: var(--font-body); font-size: 13px;
  color: var(--muted); text-decoration: underline;
  text-decoration-color: rgba(165,148,124,.4);
  text-underline-offset: 4px; cursor: pointer;
  padding: 6px 14px; letter-spacing: 0.01em;
  transition: color .2s, text-decoration-color .2s;
}
.skip-link:hover { color: var(--ink); text-decoration-color: var(--ink); }

/* ═══ Lang gate ═══ */
.lang-gate { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; }
.lang-card {
  width: 100%; max-width: 480px;
  background: var(--card); border-radius: var(--radius);
  border: .5px solid rgba(19,27,42,.06); box-shadow: var(--shadow-card);
  padding: 56px 36px 40px; text-align: center;
  animation: stack-in .6s cubic-bezier(.2,.8,.2,1) both;
}
.lang-eyebrow {
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--muted); margin: 18px 0; font-weight: 500;
}
.lang-mascot { display: flex; justify-content: center; }
.lang-h1 {
  font-size: clamp(40px, 7vw, 56px); font-weight: 600;
  line-height: 1; letter-spacing: -0.02em; margin: 0 0 14px;
  display: flex; align-items: baseline; justify-content: center; gap: 14px; flex-wrap: wrap;
}
.lang-dot { color: var(--muted); opacity: .5; font-weight: 400; }
.lang-sub {
  font-size: 14px; color: var(--muted); margin: 0 0 30px;
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; align-items: baseline;
}
.lang-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lang-btn { font-size: 17px; font-weight: 600; }

/* ═══ Links overlay ═══ */
.links-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(19,27,42,.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: backdrop-in .22s ease both;
}
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
.links-sheet {
  width: 100%; max-width: 560px;
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  border: .5px solid rgba(19,27,42,.07);
  box-shadow: 0 -14px 40px -8px rgba(19,27,42,.22);
  padding: 12px 24px 32px;
  animation: sheet-up .38s cubic-bezier(.2,.8,.2,1) both;
  max-height: 88vh; overflow-y: auto;
  overscroll-behavior: contain;
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.links-handle {
  width: 40px; height: 4px;
  background: rgba(19,27,42,.14); border-radius: 999px;
  margin: 0 auto 20px;
}
.links-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.links-title {
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); font-weight: 500;
}
.links-close {
  appearance: none; border: none; background: rgba(19,27,42,.06);
  color: var(--ink); border-radius: 50%;
  width: 32px; height: 32px; font-size: 16px;
  display: grid; place-items: center; cursor: pointer;
  transition: background .15s;
}
.links-close:hover { background: rgba(19,27,42,.12); }
.links-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.links-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 14px;

  padding: 14px 18px;
  border-radius: calc(var(--radius) * 0.6);
  border: 1px solid rgba(19,27,42,.08);
  background: var(--bg);
  text-decoration: none;
  color: var(--ink);

  transition:
    transform .15s cubic-bezier(.3,.7,.4,1),
    border-color .2s,
    background .15s,
    box-shadow .2s;
}

.links-item:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: var(--card);
  box-shadow: 0 8px 20px -10px rgba(189,121,47,.35);
}

.links-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(19,27,42,.06);

  display: grid;
  place-items: center;
  flex-shrink: 0;

  font-size: 17px;
}

.links-item-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.links-item-label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
}

.links-item-url {
  display: block;
  max-width: 100%;

  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.35;
  letter-spacing: .02em;
  color: var(--muted);

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  direction: ltr;
  unicode-bidi: isolate;
  text-align: start;
}

.links-item-arrow {
  font-size: 16px;
  color: var(--muted);
  opacity: 0;
  transition: opacity .2s, color .2s;
}

.links-item:hover .links-item-arrow {
  opacity: 1;
  color: var(--accent);
}

/* RTL layout fix */
.lang-ar .links-item {
  direction: rtl;
}

.lang-ar .links-item-text {
  text-align: right;
}

.lang-ar .links-item-url {
  direction: ltr;
  text-align: right;
}

.lang-ar .links-item-arrow {
  transform: scaleX(-1);
}



/* ═══ Mobile-first responsive ═══ */
@media (max-width: 480px) {
  .topbar { padding: 12px 14px 8px; }
  .stage { padding: 4px 12px; }
  .card { padding: 28px 22px 22px; border-radius: calc(var(--radius) * 0.85); }
  .title-xl { font-size: 26px; }
  .title-lg { font-size: 22px; }
  .body-lg { font-size: 16px; }
  .links-sheet { padding: 12px 16px 32px; }
}
