/* =====================================================================
   Aurum — محوّل العملات
   Minimal-luxury dark · RTL · 8px grid · mobile-first
   System fonts only (100% offline). Page is pinned: no rubber-band.
   ===================================================================== */

:root {
  --bg:          #0E1014;
  --surface:     #15181E;
  --surface-2:   #1B1F27;
  --line:        #272C35;
  --gold:        #C9A86A;
  --gold-soft:   #E4CE9E;
  --gold-dim:    #8C7846;
  --text:        #ECECE6;
  --muted:       #8A8F99;
  --danger:      #D98B7A;

  --s1: 8px;  --s2: 16px; --s3: 24px; --s4: 32px; --s5: 40px;

  --field-h: 52px;
  --radius: 16px;
  --radius-sm: 12px;

  --sans: system-ui, -apple-system, "Segoe UI", Tahoma, Arial, sans-serif;
  --serif: ui-serif, Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; -webkit-text-size-adjust: 100%; }

/* Pin the page so it never scrolls/bounces with the document. */
body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;            /* no double-tap zoom */
  -webkit-user-select: none;             /* prevent copying UI text */
  user-select: none;
  -webkit-touch-callout: none;           /* no long-press menu (iOS) */
  background: radial-gradient(120% 80% at 50% -10%, #161A22 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* The app is the only scroll container, and only if it must. */
.app {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--s2);
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding:
    calc(var(--s3) + env(safe-area-inset-top))
    var(--s3)
    calc(var(--s2) + env(safe-area-inset-bottom));
}

/* Brand -------------------------------------------------------------- */
.brand { text-align: center; }

.brand__rule {
  display: block;
  width: 28px; height: 2px;
  margin: 0 auto var(--s1);
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.brand__name {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--gold-soft);
}

.brand__tag {
  margin-top: 4px;
  font-size: 0.76rem;
  color: var(--muted);
}

/* Card --------------------------------------------------------------- */
.card {
  background: linear-gradient(180deg, var(--surface) 0%, #12151B 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s3) var(--s3);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.03) inset,
    0 24px 48px -24px rgba(0, 0, 0, 0.7);
}

.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2);
}

.card__title { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.card__title .anchor {
  font-family: var(--serif);
  color: var(--gold-soft);
  font-variant-numeric: tabular-nums;
}
.card__hint { font-size: 0.72rem; color: var(--muted); }

.divider {
  height: 0;
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--s1) 0;
}

/* Fields ------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.field__label {
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  padding-inline-start: 2px;
}

.input,
.select {
  width: 100%;
  height: var(--field-h);
  -webkit-user-select: text;   /* editing stays normal inside fields */
  user-select: text;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.05rem;
  padding-inline: var(--s2);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  appearance: none;
  -webkit-appearance: none;
}

.input { font-variant-numeric: tabular-nums; }
.input::placeholder { color: var(--muted); opacity: 0.85; font-size: 0.9rem; }

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px rgba(201, 168, 106, 0.18);
}

/* Select: short codes, caret on the leading (left in RTL) side */
.select {
  cursor: pointer;
  text-align: center;
  text-align-last: center;
  padding-inline: var(--s5) var(--s2);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23C9A86A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left var(--s2) center;
}

.select option { background: var(--surface-2); color: var(--text); }

/* Exchange: from / swap / to side by side --------------------------- */
.exchange {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--s1);
  align-items: end;
}

.swap {
  width: 44px; height: 44px;
  margin-bottom: 4px;            /* center on the 52px selects */
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
              border-color 0.18s ease, color 0.18s ease;
}

.swap:hover { border-color: var(--gold); color: var(--gold-soft); }
.swap:active { transform: scale(0.92); }
.swap.is-spinning { transform: rotate(180deg); }
.swap:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(201, 168, 106, 0.3);
}

/* Convert button ----------------------------------------------------- */
.button {
  height: var(--field-h);
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: #1A1206;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s ease, filter 0.18s ease;
}

.button:hover { filter: brightness(1.04); }
.button:active { transform: translateY(1px); }
.button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--gold);
}

/* Result ------------------------------------------------------------- */
.result {
  border-top: 1px solid var(--line);
  padding-top: var(--s2);
  text-align: center;
}

.result__label {
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.result__value {
  margin-top: 6px;
  direction: ltr;
  font-family: var(--serif);
  font-size: clamp(1.8rem, 7.5vw, 2.4rem);
  font-weight: 600;
  line-height: 1.1;
  color: var(--gold-soft);
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.result__rate {
  margin-top: 6px;
  direction: ltr;
  min-height: 1.1em;
  font-size: 0.84rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Footer ------------------------------------------------------------- */
.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s1);
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
}

.footer__net[data-online="true"]  { color: var(--gold-dim); }
.footer__net[data-online="false"] { color: var(--danger); }
.footer__sep { opacity: 0.5; }

/* Small phones ------------------------------------------------------- */
@media (max-width: 360px) {
  .app { padding-inline: var(--s2); }
  .card { padding: var(--s2); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
