/* Currency — live exchange calculator
 * Palette: terracotta + cream
 * © אופיר ברנס (Ofir Baranes) 2026
 */

* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg-1: #1a0e08;
  --bg-2: #25140c;
  --bg-3: #321a10;
  --terra-300: #fdba74;
  --terra-400: #fb923c;
  --terra-500: #f97316;
  --terra-600: #ea580c;
  --terra-700: #c2410c;
  --terra-800: #9a3412;
  --cream: #fef3c7;
  --cream-soft: #fef9c3;
  --cream-light: #fffbeb;
  --text-primary: #fef9c3;
  --text-secondary: rgba(254,249,195,0.72);
  --text-muted: rgba(254,249,195,0.42);
  --surface: rgba(254,243,199,0.05);
  --surface-strong: rgba(254,243,199,0.10);
  --border: rgba(253,186,116,0.16);
  --border-strong: rgba(253,186,116,0.28);
  --shadow-glass: 0 30px 60px -25px rgba(26,14,8,0.7);
  --bezier: cubic-bezier(.34,1.56,.64,1);
  --bezier-soft: cubic-bezier(.4,0,.2,1);
}

html, body {
  background: var(--bg-1);
  color: var(--text-primary);
  font-family: 'Heebo', system-ui, sans-serif;
  font-weight: 400;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(ellipse 700px 800px at 80% -10%, rgba(249,115,22,0.20), transparent 60%),
    radial-gradient(ellipse 500px 600px at -10% 60%, rgba(194,65,12,0.18), transparent 65%),
    radial-gradient(ellipse 800px 1000px at 50% 110%, rgba(154,52,18,0.18), transparent 70%),
    linear-gradient(180deg, #1a0e08 0%, #25140c 60%, #321a10 110%);
  background-attachment: fixed;
  position: relative;
  padding-bottom: 60px;
}

.ambient-bg {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.orb-blur {
  position: absolute;
  border-radius: 50%;
  filter: blur(85px);
  opacity: 0.45;
}
.orb-blur.o1 { width: 420px; height: 420px; top: -120px; right: -120px; background: radial-gradient(circle, #ea580c 0%, transparent 70%); animation: drift1 26s ease-in-out infinite; }
.orb-blur.o2 { width: 340px; height: 340px; bottom: 5%; left: -100px; background: radial-gradient(circle, #fdba74 0%, transparent 70%); opacity: 0.32; animation: drift2 32s ease-in-out infinite; }
@keyframes drift1 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-30px,40px) scale(1.1); } }
@keyframes drift2 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(40px,-30px) scale(1.08); } }

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.05;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 240 240' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

/* ===== Topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(26,14,8,0.85) 0%, rgba(26,14,8,0.55) 100%);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--cream-light);
  letter-spacing: -0.01em;
}
.mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--terra-400), var(--terra-700));
  color: var(--cream-light);
  box-shadow: 0 0 18px rgba(249,115,22,0.4);
}
.mark svg { width: 18px; height: 18px; }

.header-actions { display: flex; gap: 8px; }
.icon-btn, .install-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  border-radius: 12px;
  padding: 7px 12px;
  cursor: pointer;
  transition: all 0.2s var(--bezier-soft);
  backdrop-filter: blur(10px);
}
.icon-btn { padding: 7px 9px; font-size: 16px; }
.icon-btn:hover, .install-btn:hover {
  background: var(--surface-strong);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.install-btn {
  background: linear-gradient(135deg, var(--terra-400), var(--terra-700));
  border: none;
  color: var(--cream-light);
  font-weight: 600;
}

main {
  position: relative;
  z-index: 1;
  padding: 22px 18px;
  max-width: 540px;
  margin: 0 auto;
}
.hidden { display: none !important; }

/* ===== Convert card ===== */
.convert-card {
  background: linear-gradient(140deg, var(--surface-strong) 0%, var(--surface) 60%, transparent 100%);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border-strong);
  border-radius: 28px;
  padding: 24px 22px 18px;
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-glass);
}
.convert-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 28px;
  padding: 1px;
  background: linear-gradient(135deg, rgba(251,146,60,0.4) 0%, rgba(254,243,199,0.18) 50%, transparent 80%);
  -webkit-mask: linear-gradient(#000,#000) content-box, linear-gradient(#000,#000);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.row-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.curr-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 12px;
  background: rgba(254,243,199,0.04);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--cream);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s var(--bezier-soft);
  flex-shrink: 0;
  min-width: 134px;
}
.curr-btn:hover {
  background: rgba(254,243,199,0.08);
  border-color: var(--terra-400);
}
.cb-flag {
  font-size: 26px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}
.cb-info { display: flex; flex-direction: column; align-items: flex-start; flex: 1; min-width: 0; }
.cb-code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--cream-light);
  letter-spacing: 0.04em;
  line-height: 1.1;
}
.cb-name {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
}
.cb-chev { width: 14px; height: 14px; color: var(--text-muted); flex-shrink: 0; }

.amt-wrap {
  flex: 1;
  text-align: left;
  direction: ltr;
}
.amt-input {
  width: 100%;
  padding: 14px 6px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--cream-light);
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(28px, 7vw, 42px);
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  text-align: left;
  caret-color: var(--terra-400);
}
.amt-input:focus { color: var(--cream-light); }

.result-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 14px 6px;
}
.result-amt {
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(28px, 7vw, 42px);
  font-weight: 300;
  color: var(--terra-300);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
  text-shadow: 0 0 30px rgba(253,186,116,0.2);
}

/* Swap divider */
.swap-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}
.swap-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}
.swap-btn {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--terra-400), var(--terra-700));
  border: 2px solid var(--bg-2);
  border-radius: 50%;
  color: var(--cream-light);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.3s var(--bezier);
  box-shadow: 0 6px 16px rgba(249,115,22,0.4);
}
.swap-btn svg { width: 16px; height: 16px; }
.swap-btn:hover { transform: rotate(180deg) scale(1.1); }

/* Rate info */
.rate-info {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.rate-line {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.rate-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
}
.rate-val {
  color: var(--cream-light);
  font-weight: 600;
  font-size: 14px;
}
.rate-source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
}
.rs-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--terra-400);
  box-shadow: 0 0 8px var(--terra-400);
  animation: rs-pulse 2s ease-in-out infinite;
}
.rs-dot.live { background: #86efac; box-shadow: 0 0 8px #86efac; }
.rs-dot.stale { background: #fcd34d; box-shadow: 0 0 8px #fcd34d; }
.rs-dot.offline { background: #fb7185; box-shadow: 0 0 8px #fb7185; }
@keyframes rs-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== Keypad ===== */
.keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 26px;
}
.key {
  padding: 18px 0;
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--cream-light);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 22px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s var(--bezier);
  display: grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
}
.key:hover {
  background: var(--surface-strong);
  transform: translateY(-2px);
  border-color: var(--border-strong);
}
.key:active { transform: scale(0.96); }
.key.tap {
  animation: key-tap 0.3s var(--bezier);
}
@keyframes key-tap {
  0% { transform: scale(1); background: var(--surface); }
  40% { transform: scale(0.94); background: rgba(251,146,60,0.4); }
  100% { transform: scale(1); }
}
.key.wide {
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  color: var(--terra-300);
}
.key.wide svg { width: 18px; height: 18px; }
.key.accent {
  background: linear-gradient(135deg, var(--terra-700), var(--terra-800));
  border: none;
  color: var(--cream-light);
  box-shadow: 0 6px 18px rgba(194,65,12,0.35);
}
.key.accent:hover {
  background: linear-gradient(135deg, var(--terra-600), var(--terra-700));
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(194,65,12,0.5);
}

/* ===== Favorites ===== */
.favs-section {
  margin-bottom: 22px;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  padding: 0 4px;
}
.section-title {
  font-family: 'Frank Ruhl Libre', 'Heebo', serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--cream-light);
  letter-spacing: -0.015em;
}
.section-sub {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.favs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
@media (max-width: 480px) { .favs-grid { grid-template-columns: repeat(2, 1fr); } }
.fav-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 12px;
  background: var(--surface);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.25s var(--bezier);
  position: relative;
  overflow: hidden;
}
.fav-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(251,146,60,0.12), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}
.fav-card:hover {
  transform: translateY(-3px);
  border-color: var(--terra-400);
  box-shadow: 0 10px 24px rgba(26,14,8,0.5), 0 0 18px rgba(249,115,22,0.18);
}
.fav-card:hover::before { opacity: 1; }
.fav-top {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  z-index: 1;
}
.fav-flag { font-size: 18px; line-height: 1; }
.fav-code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--cream-light);
  letter-spacing: 0.05em;
}
.fav-rate {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: var(--terra-300);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  position: relative;
  z-index: 1;
}
.fav-name {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
  z-index: 1;
}

/* ===== Modal ===== */
.modal {
  position: fixed; inset: 0;
  background: rgba(15,8,4,0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: modal-fade 0.25s var(--bezier-soft);
}
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: 100%;
  max-width: 540px;
  background: linear-gradient(180deg, #2a1810 0%, #1a0e08 100%);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: 28px 28px 0 0;
  padding: 20px 22px 32px;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
  animation: modal-slide 0.4s var(--bezier);
  max-height: 88vh;
  overflow-y: auto;
}
@keyframes modal-slide {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.handle {
  width: 38px; height: 4px;
  background: var(--border-strong);
  border-radius: 4px;
  margin: 0 auto 16px;
}
.modal-card h3 {
  font-family: 'Frank Ruhl Libre', 'Heebo', serif;
  color: var(--cream-light);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 14px;
}
.modal-card p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.65;
  margin-bottom: 14px;
}
.mark-big {
  width: 64px; height: 64px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--terra-400), var(--terra-700));
  border-radius: 18px;
  color: var(--cream-light);
  margin: 4px auto 14px;
  box-shadow: 0 0 30px rgba(249,115,22,0.4);
}
.mark-big svg { width: 32px; height: 32px; }

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(254,243,199,0.05);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 12px;
}
.search-bar:focus-within { border-color: var(--terra-400); }
.search-svg { width: 16px; height: 16px; color: var(--terra-400); flex-shrink: 0; }
.search-bar input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--cream-light);
  font-family: inherit;
  font-size: 14px;
}
.search-bar input::placeholder { color: var(--text-muted); }

.curr-list {
  max-height: 55vh;
  overflow-y: auto;
  padding: 2px 0;
}
.curr-list::-webkit-scrollbar { width: 4px; }
.curr-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.curr-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(254,243,199,0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.curr-row:hover {
  background: rgba(249,115,22,0.10);
  border-color: var(--terra-400);
}
.curr-row.fav-marked { border-color: var(--terra-400); background: rgba(249,115,22,0.06); }
.cr-flag { font-size: 26px; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); }
.cr-info { flex: 1; min-width: 0; }
.cr-code-row { display: flex; align-items: baseline; gap: 8px; }
.cr-code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--cream-light);
  letter-spacing: 0.04em;
}
.cr-rate {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--terra-300);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.cr-name {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.cr-fav {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.2s;
}
.cr-fav:hover { color: var(--terra-300); background: rgba(253,186,116,0.08); }
.cr-fav.active { color: var(--terra-400); }

/* History */
.hist-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 55vh;
  overflow-y: auto;
  margin-bottom: 14px;
}
.hist-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(254,243,199,0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.hr-pair {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  color: var(--cream-light);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.hr-arrow { color: var(--terra-400); margin: 0 4px; }
.hr-meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.modal-actions {
  display: flex;
  gap: 8px;
}
.btn-primary, .btn-secondary, .btn-mini {
  flex: 1;
  padding: 13px 18px;
  border-radius: 14px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s var(--bezier);
  border: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--terra-400), var(--terra-700));
  color: var(--cream-light);
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(249,115,22,0.35);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(249,115,22,0.5); }
.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--cream-light);
}
.btn-secondary:hover { background: var(--surface-strong); }
.btn-mini {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  flex: 0 1 auto;
  padding: 13px 18px;
}
.btn-mini.danger { color: #fda4af; border-color: rgba(253,164,175,0.3); }
.btn-mini.danger:hover { background: rgba(253,164,175,0.1); }

.empty-row {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-muted);
  font-size: 13px;
}
