/* Calma — app shell, tokens and shared components */

:root {
  --cream: #f3ebdd;
  --cream-2: #fbf7ee;
  --cream-3: #fffdf8;
  --sand: #efe5d3;
  --sand-2: #e8dcc6;
  --olive: #5e6135;
  --olive-2: #6f7243;
  --olive-dark: #494b27;
  --ink: #2b2a22;
  --ink-2: #4d493a;
  --muted: #8d8674;
  --muted-2: #a59c88;
  --line: #e6dcc9;
  --line-2: #eee5d5;
  --gold: #c79a3e;
  --white: #fffdf8;
  --shadow-soft: 0 10px 26px rgba(70, 60, 38, 0.12);
  --font-ar: "Tajawal", "Segoe UI", system-ui, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-num: "Inter", "Segoe UI", system-ui, sans-serif;
  --r-xl: 28px;
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: #e7ddcc;
  color: var(--ink);
  font-family: var(--font-ar);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

img {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
p {
  margin: 0;
}

:focus-visible {
  outline: 2px solid var(--olive-2);
  outline-offset: 2px;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* ---------- icons ---------- */

.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.12em;
}

.icon--11 { font-size: 11px; }
.icon--12 { font-size: 12px; }
.icon--16 { font-size: 16px; }
.icon--17 { font-size: 17px; }
.icon--18 { font-size: 18px; }
.icon--20 { font-size: 20px; }
.icon--22 { font-size: 22px; }
.icon--24 { font-size: 24px; }
.icon--28 { font-size: 28px; }
.icon--30 { font-size: 30px; }

.icon.star {
  fill: var(--gold);
  stroke: none;
}

/* ---------- desktop stage ---------- */

.app-viewport {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 0%, #f7f0e4 0%, #e9dfce 55%, #ddd1bc 100%);
}

.app-viewport::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../img/backdrop.webp") center / cover no-repeat;
  opacity: 0.3;
  filter: blur(1px) saturate(0.9);
}

.app-viewport::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(247, 240, 228, 0.74), rgba(233, 223, 206, 0.88));
}

.device {
  position: relative;
  z-index: 1;
  width: min(390px, 100vw);
  height: min(844px, calc(100dvh - 48px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--cream-2);
  border-radius: 48px;
  box-shadow:
    0 0 0 10px #191813,
    0 0 0 12px #3a372e,
    0 40px 90px rgba(47, 40, 26, 0.32);
  --safe-top: 0px;
  --safe-bottom: 24px;
}

.app {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--cream-2);
}

.home-indicator {
  position: absolute;
  z-index: 90;
  left: 50%;
  bottom: 8px;
  width: 134px;
  height: 5px;
  border-radius: 4px;
  background: #1e1d18;
  transform: translateX(-50%);
  opacity: 0.9;
  pointer-events: none;
}

.device[data-screen="splash"] .home-indicator {
  background: rgba(255, 253, 248, 0.86);
}

.island {
  position: absolute;
  z-index: 95;
  top: 11px;
  left: 50%;
  width: 112px;
  height: 31px;
  border-radius: 20px;
  background: #0b0a08;
  transform: translateX(-50%);
  pointer-events: none;
}

/* ---------- screens ---------- */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--cream-2);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.screen.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  animation: screen-in 0.34s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.screen.is-active.is-back {
  animation-name: screen-in-back;
}

@keyframes screen-in {
  from { opacity: 0; transform: translate3d(-16px, 0, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes screen-in-back {
  from { opacity: 0; transform: translate3d(16px, 0, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

.scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
}

.scroll::-webkit-scrollbar {
  display: none;
}

/* ---------- status bar ---------- */

.statusbar {
  position: relative;
  z-index: 20;
  flex: none;
  height: 44px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  direction: ltr;
  color: var(--ink);
  font-family: var(--font-num);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1px;
}

.statusbar--light {
  color: #fffdf8;
}

.statusbar--overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}

.statusbar__icons {
  display: flex;
  align-items: center;
  gap: 5px;
}

.statusbar__icon {
  display: block;
  height: 11px;
  width: auto;
}

.statusbar__icon--signal { width: 17px; }
.statusbar__icon--wifi { width: 15px; }
.statusbar__icon--battery { width: 24px; }

/* ---------- shared controls ---------- */

.iconbtn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--ink);
  transition: background-color 0.16s ease, transform 0.16s ease;
}

.iconbtn:active {
  transform: scale(0.94);
  background: rgba(94, 97, 53, 0.08);
}

.iconbtn--back {
  position: absolute;
  right: 12px;
  left: auto;
  top: 2px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 50px;
  padding: 2px 0 4px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.1px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.btn:active {
  transform: scale(0.985);
}

.btn--olive {
  background: var(--olive);
  color: #f8f2e4;
  box-shadow: 0 10px 22px rgba(74, 76, 39, 0.22);
}

.btn--ghost {
  background: rgba(20, 18, 12, 0.12);
  border: 1px solid rgba(255, 253, 248, 0.62);
  color: #fffdf8;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.btn--cta {
  height: 52px;
  border-radius: 15px;
  font-size: 14.5px;
}

/* ---------- toast ---------- */

.toast {
  position: absolute;
  z-index: 120;
  left: 50%;
  bottom: calc(84px + var(--safe-bottom));
  max-width: 78%;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(43, 42, 34, 0.92);
  color: #fffdf8;
  font-size: 11.5px;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- success overlay ---------- */

.success {
  position: absolute;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(35, 32, 23, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade-in 0.24s ease both;
}

.success[hidden] {
  display: none;
}

.success__card {
  width: 100%;
  max-width: 300px;
  padding: 26px 24px 22px;
  border-radius: 24px;
  background: var(--cream-3);
  box-shadow: 0 26px 60px rgba(30, 26, 16, 0.32);
  text-align: center;
  animation: card-in 0.34s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.success__mark {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--olive);
  color: #f8f2e4;
}

.success__card h2 {
  font-size: 19px;
  font-weight: 700;
}

.success__card p {
  margin: 6px 0 18px;
  color: var(--muted);
  font-size: 12px;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

/* ---------- mobile full-screen app ---------- */

@media (max-width: 599px) {
  .app-viewport {
    display: block;
    padding: 0;
    background: var(--cream-2);
  }

  .app-viewport::before,
  .app-viewport::after {
    display: none;
  }

  .device {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
  }

  .statusbar {
    display: none;
  }

  .home-indicator {
    display: none;
  }

  .island {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

[hidden] {
  display: none !important;
}
