:root {
  --bg: #f8f6f2;
  --bg-deep: #efebe4;
  --panel-strong: rgba(255, 255, 255, 0.96);
  --text-dark: #000000;
  --muted-dark: #444444;
  --line-dark: rgba(22, 22, 22, 0.1);
  --accent: #ed1c24;
  --accent-strong: #c8102e;
  --green: #00a651;
  --peace: #e8e3da;
  --shadow: 0 16px 40px rgba(22, 22, 22, 0.08);
  --radius-xl: 34px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --display: "Inter", sans-serif;
  --display-ar: "IBM Plex Sans Arabic", sans-serif;
  --ui: "Inter", sans-serif;
  --mono: "SFMono-Regular", "Roboto Mono", monospace;
}

* {
  box-sizing: border-box;
}

[dir="rtl"] {
  --display: "IBM Plex Sans Arabic", sans-serif;
  --ui: "IBM Plex Sans Arabic", sans-serif;
}

html {
  min-height: 100%;
  background: linear-gradient(180deg, #fcfbf8 0%, var(--bg) 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--ui);
  color: var(--text-dark);
  background: transparent;
}

button,
input,
a {
  font: inherit;
}

.page-shell {
  width: min(100%, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
  direction: ltr;
}

.topbar-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--line-dark);
  color: var(--text-dark);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  visibility: hidden;
  pointer-events: none;
}

.topbar-back.visible {
  visibility: visible;
  pointer-events: auto;
}

.topbar-actions {
  display: flex;
  align-items: center;
}

.lang-toggle,
.start-button,
.vtimeline-research {
  border-radius: 999px;
  transition: transform 180ms ease, opacity 180ms ease, background-color 180ms ease;
}

.lang-toggle {
  border: 1.5px solid var(--line-dark);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-dark);
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

.story-shell {
  position: relative;
}

.story-stage {
  position: relative;
}

.story-stage.stage-intro,
.story-stage.stage-results {
  min-height: calc(100vh - 72px);
}

.scene {
  position: relative;
  min-height: calc(100vh - 72px);
  animation: scene-rise 320ms ease;
}

.intro-centered,
.results-scene {
  padding: 20px 12px 32px;
}

.intro-centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.intro-content {
  width: min(100%, 19rem);
}

.intro-heading {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.3rem, 12vw, 3.8rem);
  line-height: 0.96;
  letter-spacing: -0.04em;
  color: var(--text-dark);
}

.intro-subtitle {
  margin: 16px auto 0;
  max-width: 22ch;
  text-align: center;
  color: var(--muted-dark);
  font-size: 1rem;
  line-height: 1.55;
}

.intro-form {
  display: grid;
  gap: 14px;
  width: 100%;
  margin-top: 30px;
}

.birthdate-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.birthdate-field {
  display: grid;
  gap: 6px;
  text-align: center;
}

.birthdate-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted-dark);
}

.birthdate-wheel {
  width: 100%;
  height: 150px;
  overflow-y: auto;
  scrollbar-width: none;
  border: 1.5px solid rgba(22, 22, 22, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 30px rgba(22, 22, 22, 0.05);
  scroll-snap-type: y mandatory;
  position: relative;
}

.birthdate-wheel::-webkit-scrollbar {
  display: none;
}

.birthdate-wheel::before,
.birthdate-wheel::after {
  content: "";
  position: sticky;
  left: 0;
  right: 0;
  display: block;
  height: 46px;
  pointer-events: none;
  z-index: 2;
}

.birthdate-wheel::before {
  top: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0) 100%);
}

.birthdate-wheel::after {
  bottom: 0;
  background: linear-gradient(0deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0) 100%);
}

.birthdate-wheel:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(0, 166, 81, 0.12);
}

.birthdate-wheel-spacer {
  height: 46px;
  scroll-snap-align: center;
}

.birthdate-wheel-option {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 10px 10px;
  border: 0;
  background: transparent;
  color: var(--muted-dark);
  font-size: 1rem;
  line-height: 1.2;
  text-align: center;
  scroll-snap-align: center;
  cursor: pointer;
  transition: transform 180ms ease, color 180ms ease, opacity 180ms ease;
}

.birthdate-wheel-option.is-selected {
  color: var(--text-dark);
  font-weight: 700;
  transform: scale(1.02);
}

.start-button {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 14px 32px rgba(200, 16, 46, 0.18);
}

.start-button:hover,
.lang-toggle:hover,
.vtimeline-research:hover {
  transform: translateY(-1px);
}

.form-error {
  min-height: 1.6em;
  margin: 0;
  color: var(--accent-strong);
  font-weight: 700;
  line-height: 1.5;
}

.results-scene {
  min-height: auto;
  padding-bottom: 40px;
}

.results-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  justify-content: center;
  min-height: calc(100vh - 72px);
  min-height: calc(100dvh - 72px);
  padding: 32px 0 40px;
}

.results-kicker {
  margin: 0;
  font-size: 2.34rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.donut-chart {
  position: relative;
  width: min(100%, 260px);
  aspect-ratio: 1;
  margin: 20px auto 16px;
}

.donut-chart svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-track,
.donut-value {
  fill: none;
  stroke-width: 20;
}

.donut-track {
  stroke: var(--peace);
}

.donut-value {
  stroke: var(--accent);
  stroke-linecap: round;
  transform-origin: center;
}

.donut-percent {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: clamp(2.4rem, 14vw, 4rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.results-label,
.results-detail,
.results-detail-sub,
.timeline-empty,
.vtimeline-dates,
.vtimeline-actor-name {
  margin: 0;
  line-height: 1.55;
}

.results-label {
  font-family: var(--display);
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--accent);
}

.results-detail {
  margin-top: 14px;
  font-size: 1rem;
}

.results-detail-sub,
.timeline-empty,
.vtimeline-dates,
.vtimeline-actor-name {
  color: var(--muted-dark);
}

.results-detail-sub {
  margin-top: 4px;
}

.scroll-invite {
  margin-top: auto;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 12px 28px rgba(22, 22, 22, 0.08);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.scroll-invite-icon {
  width: 12px;
  height: 12px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(45deg) translate(-1px, -1px);
  animation: scroll-invite-bounce 1.5s ease-in-out infinite;
}

.vtimeline-section {
  position: relative;
  padding-top: 0;
  background: var(--bg);
}

.vtimeline-section-empty {
  padding-top: 18px;
}

.vtimeline-sticky-head {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 0 16px;
  background: var(--bg);
  direction: ltr;
}

.vtimeline-back {
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-dark);
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted-dark);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.vtimeline-back:active {
  background: var(--line-dark);
}

.vtimeline-title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.8rem, 8vw, 2.6rem);
  line-height: 1.02;
}

.scrubber-body {
  display: grid;
  grid-template-columns: 1fr 100px;
  gap: 0;
  position: relative;
  margin-top: 28px;
}

[dir="rtl"] .scrubber-body {
  grid-template-columns: 100px 1fr;
}

.scrubber-display {
  position: sticky;
  top: 0;
  z-index: 5;
}

.scrubber-age {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  font-family: var(--display);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--accent);
  white-space: nowrap;
  direction: ltr;
}

.scrubber-age-num {
  font-size: 2.8rem;
  line-height: 1;
}

.scrubber-age-bubble {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 3px;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: var(--bg);
  line-height: 1;
}

.scrubber-age::before {
  content: "";
  flex-shrink: 0;
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-right: 14px solid var(--accent);
}

[dir="rtl"] .scrubber-age::before {
  border-right: none;
  border-left: 14px solid var(--accent);
}

[dir="rtl"] .scrubber-age {
  flex-direction: row-reverse;
}

.scrubber-lane {
  position: relative;
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
}

[dir="rtl"] .scrubber-lane {
  grid-column: 2;
}

.scrubber-card {
  position: absolute;
  inset-inline-start: 0;
  inset-inline-end: 0;
  min-height: fit-content;
  overflow: visible;
  padding: 0 4px;
  border-radius: var(--radius-md);
  background: var(--panel-strong);
  border: 1px solid var(--line-dark);
  box-shadow: var(--shadow);
  box-sizing: border-box;
}

.scrubber-card-inner {
  position: sticky;
  top: calc(var(--sticky-head-h, 60px) + var(--sticky-display-h, 60px));
  padding-bottom: 12px;
}

.scrubber-card .vtimeline-card {
  min-width: 0;
  background: none;
  border: none;
  box-shadow: none;
  padding: 12px;
}

.scrubber-card .vtimeline-name {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.scrubber-card[data-cols="2"] .vtimeline-card {
  padding: 10px;
}

.scrubber-card[data-cols="2"] .vtimeline-name {
  font-size: 1rem;
}

.scrubber-card[data-cols="2"] .vtimeline-dates {
  font-size: 0.82rem;
}

.scrubber-card[data-cols="2"] .vtimeline-actor-visual {
  width: 24px;
  height: 24px;
}

.scrubber-card[data-cols="2"] .vtimeline-actor-name {
  font-size: 0.82rem;
}

.scrubber-card[data-cols="2"] .vtimeline-research {
  width: 30px;
  height: 30px;
}

.scrubber-track {
  position: relative;
  grid-column: 2;
  grid-row: 2;
}

[dir="rtl"] .scrubber-track {
  grid-column: 1;
}

.scrubber-ruler-dash {
  position: absolute;
  left: 0;
  height: 1px;
  background: var(--text-dark);
  border-radius: 1px;
}

[dir="rtl"] .scrubber-ruler-dash {
  left: auto;
  right: 0;
}

.scrubber-ruler-dash--month {
  width: 8px;
  opacity: 0.12;
}

.scrubber-ruler-dash--year {
  width: 18px;
  height: 1.5px;
  background: var(--accent);
  opacity: 1;
}

.scrubber-ruler-dash--decade {
  width: 18px;
  height: 1.5px;
  background: var(--accent);
  opacity: 1;
}

.scrubber-ruler-label {
  position: absolute;
  left: 0;
  font-family: var(--display);
  line-height: 1;
  color: var(--muted-dark);
  transform: translateY(-50%);
  white-space: nowrap;
  pointer-events: none;
}

[dir="rtl"] .scrubber-ruler-label {
  left: auto;
  right: 0;
  text-align: right;
}

.scrubber-ruler-label--year {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  left: 24px;
}

[dir="rtl"] .scrubber-ruler-label--year {
  left: auto;
  right: 48px;
}

.scrubber-ruler-label--month {
  font-size: 0.62rem;
  font-weight: 400;
  opacity: 0.3;
  left: 14px;
}

[dir="rtl"] .scrubber-ruler-label--month {
  left: auto;
  right: 14px;
}

.vtimeline-card {
  padding: 16px;
  border: 1px solid var(--line-dark);
  border-radius: var(--radius-md);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  transition: opacity 280ms ease, transform 280ms ease;
}

.vtimeline-name {
  margin: 0;
  font-family: var(--display);
  font-size: 1.4rem;
  line-height: 1.1;
}

.vtimeline-dates {
  margin-top: 8px;
  font-size: 0.92rem;
}

.vtimeline-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 14px;
  gap: 10px;
}

.vtimeline-footer-actors {
  flex: 1;
  min-width: 0;
}

.vtimeline-actors {
  display: grid;
  gap: 10px;
}

.vtimeline-actor {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.vtimeline-actor-visual {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--bg-deep);
  border: 1px solid var(--line-dark);
  flex-shrink: 0;
}

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

.vtimeline-actor-fallback {
  font-family: var(--display);
  font-size: 0.88rem;
}

.vtimeline-actor-name {
  font-size: 0.94rem;
}

.vtimeline-research {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(22, 22, 22, 0.08);
  background: rgba(255, 255, 255, 0.96);
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.vtimeline-research svg {
  width: 18px;
  height: 18px;
}

.timeline-empty {
  padding: 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line-dark);
}


.share-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 20px 0;
}

.share-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  padding: 0;
  transition: transform 180ms ease, opacity 180ms ease;
}

.share-icon:active {
  transform: scale(0.92);
}

.share-facebook {
  background: var(--muted-dark);
}

.share-x {
  background: var(--muted-dark);
}

.share-whatsapp {
  background: var(--muted-dark);
}

.share-instagram {
  background: var(--muted-dark);
}

.share-copy {
  background: var(--muted-dark);
}

.share-native {
  background: var(--muted-dark);
}

.share-copied {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 20;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line-dark);
  background: var(--panel);
  color: var(--muted-dark);
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

[dir="rtl"] .intro-centered,
[dir="rtl"] .results-scene {
  direction: rtl;
}

[dir="rtl"] .birthdate-field {
  text-align: center;
}

@keyframes scene-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scroll-invite-bounce {
  0%,
  100% {
    transform: rotate(45deg) translate(-1px, -1px);
    opacity: 0.85;
  }

  50% {
    transform: rotate(45deg) translate(3px, 3px);
    opacity: 1;
  }
}

/* ---- Hero reveal animation ---- */

@keyframes hero-fade-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-reveal {
  opacity: 0;
  animation: hero-fade-in 600ms ease both;
}

/* ---- Hourglass intro animation ---- */

.donut-wrapper {
  position: relative;
  width: min(100%, 260px);
  aspect-ratio: 1;
  margin: 20px auto 16px;
}

.hero-hourglass {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted-dark);
  animation: hourglass-spin 1.6s ease-in-out both;
  z-index: 2;
  pointer-events: none;
}

.hero-hourglass svg {
  width: 28%;
  height: 28%;
  display: block;
}

.donut-wrapper .donut-chart {
  width: 100%;
  margin: 0;
  opacity: 0;
  animation: hero-fade-in 600ms ease both;
  animation-delay: 1600ms;
}

@keyframes hourglass-spin {
  0% {
    opacity: 0;
    transform: rotate(0deg) scale(0.8);
  }

  15% {
    opacity: 1;
    transform: rotate(0deg) scale(1);
  }

  70% {
    opacity: 1;
    transform: rotate(360deg) scale(1);
  }

  100% {
    opacity: 0;
    transform: rotate(360deg) scale(0.8);
  }
}

.results-hero .donut-percent {
  opacity: 0;
}

@media (min-width: 768px) {
  .page-shell {
    width: min(920px, calc(100% - 40px));
    padding-top: 20px;
  }

  .scene {
    min-height: auto;
  }

  .intro-centered,
  .results-scene {
    padding-left: 20px;
    padding-right: 20px;
  }

  .intro-content {
    width: min(100%, 22rem);
  }

  .results-hero {
    padding-top: 28px;
    padding-bottom: 48px;
  }

  .scrubber-display {
    max-width: none;
  }

  .scrubber-body {
    grid-template-columns: 1fr 120px;
  }

  [dir="rtl"] .scrubber-body {
    grid-template-columns: 120px 1fr;
  }
}
