/*
 * SAB Gold Screen — TV display. Sized in rem (screen.js sets it from the stage:
 * 2% of the short side, or of the width when squarer than 16:9; the rules below
 * are the fallback). Flexbox only, no flex gap, no CSS variables: old TV browsers.
 * Themes: body.theme-dark (default) / theme-light / theme-gold; body.lay-portrait
 * when the stage is taller than wide (portrait TV, or a landscape TV rotated 90°).
 */
html { font-size: 2vmin; }
@media (orientation: landscape) and (max-aspect-ratio: 16/9) {
  html { font-size: 1.125vw; }
}
html, body { margin: 0; height: 100%; overflow: hidden; }
* { box-sizing: border-box; }

body {
  background: #0A2026;
  background: radial-gradient(ellipse at 85% -10%, #14424a 0%, #0A2026 48%, #051216 100%);
  color: #F3F4F2;
  font-family: "Tajawal", "Segoe UI", Tahoma, sans-serif;
  -webkit-font-smoothing: antialiased;
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
}
body.idle, body.idle * { cursor: none !important; }

.num, .time, .price .v {
  font-family: "IBM Plex Mono", "Courier New", monospace;
  direction: ltr;
  unicode-bidi: embed;
}

/* the stage is what rotates; the background photo and the stopped page live inside it */
.stage {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  -webkit-transform-origin: 0 0; transform-origin: 0 0;
}
.bg {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  background-size: cover; background-position: center; background-repeat: no-repeat;
  display: none;
}
.bg:after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: rgba(5, 18, 22, 0.78); }
body.has-bg .bg { display: block; }
body.has-bg .board { background: rgba(10, 32, 38, 0.55); }

.app {
  position: relative;
  z-index: 1;
  height: 100%;
  display: -webkit-box; display: -webkit-flex; display: flex;
  -webkit-flex-direction: column; flex-direction: column;
}

/* ---------- header ---------- */
.top {
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  -webkit-justify-content: space-between; justify-content: space-between;
  padding: 1.1rem 2rem 0.9rem;
  border-bottom: 1px solid rgba(184, 154, 94, 0.28);
  -webkit-flex-shrink: 0; flex-shrink: 0;
}
.brand { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; min-width: 0; }
.logo { height: 4.6rem; max-width: 12rem; object-fit: contain; margin-left: 1.2rem; }
.shop-ar { font-size: 2.3rem; font-weight: 800; line-height: 1.15; color: #fff; }
.shop-en { font-size: 1.15rem; font-weight: 500; color: #CDB57E; letter-spacing: 0.08em; direction: ltr; text-align: right; }
.clock { text-align: left; }
.time { font-size: 2.6rem; font-weight: 600; color: #E7D3A1; line-height: 1.1; }
.time .colon { -webkit-animation: blink 2s steps(1) infinite; animation: blink 2s steps(1) infinite; }
.time small { font-family: "Tajawal", sans-serif; font-size: 1.2rem; margin-right: 0.4rem; color: #CDB57E; }
.dates { font-size: 1.1rem; color: #A9BCBF; margin-top: 0.2rem; }
.dates .sep { color: #B89A5E; margin: 0 0.6rem; font-size: 0.7rem; vertical-align: middle; }
@-webkit-keyframes blink { 50% { opacity: 0.25; } }
@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- body ---------- */
.body {
  -webkit-flex: 1; flex: 1;
  min-height: 0;
  display: -webkit-flex; display: flex;
  padding: 1.2rem 1.6rem;
}
.board {
  -webkit-flex: 1.2; flex: 1.2;
  min-width: 0;
  display: -webkit-flex; display: flex;
  -webkit-flex-direction: column; flex-direction: column;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(184, 154, 94, 0.3);
  border-radius: 1.2rem;
  padding: 1.2rem 1.6rem 0.8rem;
  box-shadow: inset 0 0 4rem rgba(184, 154, 94, 0.05);
}
.ads {
  -webkit-flex: 1; flex: 1;
  min-width: 0;
  margin-right: 1.4rem;
  border-radius: 1.2rem;
  overflow: hidden;
  border: 1px solid rgba(184, 154, 94, 0.3);
  background: #061519;
  position: relative;
}
body.no-ads .board { -webkit-flex: 1; flex: 1; }

.board-head {
  display: -webkit-flex; display: flex;
  -webkit-align-items: baseline; align-items: baseline;
  -webkit-justify-content: space-between; justify-content: space-between;
  margin-bottom: 0.6rem;
}
.board-head h1 {
  margin: 0;
  font-size: 2.1rem;
  font-weight: 800;
  color: #E7D3A1;
}
.board-head h1 span, .unit span {
  display: block;
  font-size: 0.95rem;
  font-weight: 500;
  color: #8FA5A9;
  letter-spacing: 0.12em;
  direction: ltr;
  text-align: right;
}
.unit { font-size: 1.1rem; color: #CDB57E; text-align: left; }
.unit span { text-align: left; }

/* price grid */
.grid { -webkit-flex: 1; flex: 1; min-height: 0; display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; }
.rows { -webkit-flex: 1; flex: 1; min-height: 0; display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; }
.row {
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  border-bottom: 1px solid rgba(184, 154, 94, 0.16);
}
.rows .row { -webkit-flex: 1; flex: 1; max-height: 7.2rem; min-height: 3.6rem; }
.rows .row:last-child { border-bottom: 0; }
.row.head { padding: 0.3rem 0 0.5rem; border-bottom-color: rgba(184, 154, 94, 0.4); }
.row.head > div { font-size: 1.35rem; font-weight: 700; color: #CDB57E; }
.row.head small { display: block; font-size: 0.85rem; font-weight: 500; color: #7F9599; letter-spacing: 0.1em; }
.c-karat { width: 28%; }
.c-price { width: 36%; text-align: center; }

.karat { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; }
.karat b {
  font-family: "IBM Plex Mono", monospace;
  font-size: 3.3rem;
  font-weight: 600;
  line-height: 1;
  color: #E3CB8F;
  background: linear-gradient(180deg, #F4E2B2 0%, #C9A866 55%, #A88A4E 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  min-width: 4.6rem;
}
.karat span { margin-right: 0.8rem; font-size: 1.3rem; font-weight: 700; color: #DCE4E4; line-height: 1.2; }
.karat small { display: block; font-size: 0.9rem; font-weight: 500; color: #7F9599; letter-spacing: 0.1em; direction: ltr; text-align: right; }

.price {
  position: relative;
  border-radius: 0.8rem;
  padding: 0.2rem 0;
  -webkit-transition: background-color 1.2s ease; transition: background-color 1.2s ease;
}
.price .v { font-size: 3.5rem; font-weight: 600; line-height: 1.1; letter-spacing: 0.02em; }
.price.sell .v { color: #FFFFFF; }
.price.buy .v { color: #E7D3A1; }
.price .arrow {
  position: absolute;
  top: 50%;
  left: 0.6rem;
  margin-top: -0.75rem;
  font-style: normal;
  font-size: 1.2rem;
  line-height: 1.5rem;
}
.price .arrow.up { color: #3FCB7E; }
.price .arrow.down { color: #F06A5D; }
.price.flash-up { background-color: rgba(63, 203, 126, 0.22); -webkit-transition: none; transition: none; }
.price.flash-down { background-color: rgba(240, 106, 93, 0.22); -webkit-transition: none; transition: none; }

/* silver rows: same columns as gold, smaller */
.rows-silver { -webkit-flex-shrink: 0; flex-shrink: 0; }
.rows-silver .row { height: 3.5rem; }
.rows-silver .row:first-child { border-top: 1px solid rgba(184, 154, 94, 0.4); }
.rows-silver .row:last-child { border-bottom: 0; }
.rows-silver .karat b {
  font-size: 1.9rem;
  background: linear-gradient(180deg, #F4F6F7 0%, #B9C2C6 60%, #8E999E 100%);
  -webkit-background-clip: text;
}
.rows-silver .karat span { font-size: 1.05rem; }
.rows-silver .karat small { font-size: 0.8rem; }
.rows-silver .price .v { font-size: 2.1rem; }
.rows-silver .price.sell .v { color: #EEF2F3; }
.rows-silver .price.buy .v { color: #C9D2D5; }

/* bottom line: status, ounce prices, brand */
.foot {
  display: -webkit-flex; display: flex;
  -webkit-flex-wrap: wrap; flex-wrap: wrap;
  -webkit-justify-content: space-between; justify-content: space-between;
  -webkit-align-items: center; align-items: center;
  -webkit-flex-shrink: 0; flex-shrink: 0;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(184, 154, 94, 0.16);
  font-size: 0.95rem;
  color: #7F9599;
}
.ounce span { margin: 0 0.9rem; white-space: nowrap; }
.ounce small { font-size: 0.75rem; letter-spacing: 0.06em; margin-right: 0.3rem; display: inline-block; direction: ltr; }
.ounce b {
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.3rem;
  font-weight: 600;
  color: #E7D3A1;
  margin-right: 0.4rem;
  display: inline-block;
  direction: ltr;
}
/* the day change sits under the ounce price so the line keeps its width */
.ounce .val { display: inline-block; vertical-align: middle; text-align: center; font-style: normal; margin-right: 0.4rem; }
.ounce .val b { display: block; margin: 0; line-height: 1.15; }
.ounce .chg {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-style: normal;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.1;
  direction: ltr;
}
.ounce .chg.up { color: #3FCB7E; }
.ounce .chg.down { color: #F06A5D; }
.ounce .chg.flat { color: #7F9599; }
.status { white-space: nowrap; }
.status .live {
  display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%;
  background: #3FCB7E; margin-left: 0.5rem; vertical-align: middle;
  box-shadow: 0 0 0 0.25rem rgba(63, 203, 126, 0.18);
}
.status.warn { color: #F2C46D; }
.status.warn .live { background: #F2C46D; box-shadow: 0 0 0 0.25rem rgba(242, 196, 109, 0.2); }
.status.off { color: #F06A5D; }
.status.off .live { background: #F06A5D; box-shadow: 0 0 0 0.25rem rgba(240, 106, 93, 0.2); }
.status .by { letter-spacing: 0.06em; opacity: 0.7; }
.foot .sources { font-size: 0.8rem; font-size: max(0.8rem, 11px); letter-spacing: 0; opacity: 0.85; } /* readable on a phone too; old TVs skip max() */
.foot .sources a { color: #CDB680; text-decoration: none; direction: ltr; unicode-bidi: embed; }
body.theme-light .foot .sources a { color: #0F4F4F; }

/* ---------- ads ---------- */
.ad-stage { position: absolute; top: 0; right: 0; bottom: 0; left: 0; }
.slide {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  opacity: 0;
  -webkit-transition: opacity 0.9s ease; transition: opacity 0.9s ease;
  overflow: hidden;
}
.slide.on { opacity: 1; }
.slide .blur {
  position: absolute; top: -10%; right: -10%; bottom: -10%; left: -10%;
  background-size: cover; background-position: center;
  -webkit-filter: blur(2.4rem) brightness(0.55); filter: blur(2.4rem) brightness(0.55);
}
.slide img, .slide video {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: contain;
}

/* ---------- ticker ---------- */
.ticker {
  -webkit-flex-shrink: 0; flex-shrink: 0;
  height: 3.4rem;
  background: linear-gradient(90deg, #A88A4E 0%, #D9C08A 50%, #A88A4E 100%);
  color: #0A2026;
  overflow: hidden;
  position: relative;
}
.ticker-track { position: absolute; top: 0; right: 0; bottom: 0; left: 0; direction: ltr; overflow: hidden; }
.ticker-text {
  position: absolute; top: 0; left: 0;
  white-space: nowrap;
  direction: rtl;
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 3.4rem;
  will-change: transform;
}
.ticker-text .dot { font-style: normal; font-size: 0.9rem; margin: 0 1.6rem; color: #0F4F4F; vertical-align: middle; }

/* ---------- stopped ---------- */
.stopped {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  -webkit-justify-content: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #14424a 0%, #0A2026 55%, #051216 100%);
  text-align: center;
  z-index: 50;
}
.stopped .logo { height: 9rem; max-width: 26rem; margin: 0 auto 1.6rem; display: block; }
.stopped .shop-ar { font-size: 3rem; }
.stopped .msg { font-size: 2rem; color: #E7D3A1; margin-top: 1.4rem; font-weight: 700; }
.stopped .sub { font-size: 1.1rem; color: #7F9599; margin-top: 0.4rem; letter-spacing: 0.12em; }

/* ---------- portrait (tall stage) ---------- */
body.lay-portrait .body { -webkit-flex-direction: column; flex-direction: column; }
body.lay-portrait .board { -webkit-flex: 0 0 auto; flex: 0 0 auto; }
body.lay-portrait .rows .row { -webkit-flex: 0 0 auto; flex: 0 0 auto; height: 6.2rem; }
body.lay-portrait .ads { margin: 1.2rem 0 0; -webkit-flex: 1; flex: 1; min-height: 0; }
body.lay-portrait.no-ads .board { -webkit-flex: 1; flex: 1; }
body.lay-portrait.no-ads .rows .row { -webkit-flex: 1; flex: 1; height: auto; max-height: 9rem; }

/* ---------- light theme (pearl) ---------- */
body.theme-light { background: #F3F4F2; background: radial-gradient(ellipse at 85% -10%, #FFFFFF 0%, #F3F4F2 50%, #E4E8E4 100%); color: #0A2026; }
body.theme-light .bg:after { background: rgba(243, 244, 242, 0.8); }
body.theme-light .top { border-bottom-color: rgba(15, 79, 79, 0.18); }
body.theme-light .shop-ar { color: #0A2026; }
body.theme-light .shop-en { color: #8A6E3A; }
body.theme-light .time { color: #0F4F4F; }
body.theme-light .time small { color: #8A6E3A; }
body.theme-light .dates { color: #4A6166; }
body.theme-light .board { background: #FFFFFF; border-color: rgba(15, 79, 79, 0.16); box-shadow: 0 0.4rem 2rem rgba(10, 32, 38, 0.08); }
body.theme-light.has-bg .board { background: rgba(255, 255, 255, 0.9); }
body.theme-light .ads { background: #E4E8E4; border-color: rgba(15, 79, 79, 0.16); }
body.theme-light .board-head h1 { color: #0F4F4F; }
body.theme-light .board-head h1 span, body.theme-light .unit span { color: #6B7F83; }
body.theme-light .unit { color: #8A6E3A; }
body.theme-light .row { border-bottom-color: rgba(15, 79, 79, 0.1); }
body.theme-light .row.head { border-bottom-color: rgba(15, 79, 79, 0.25); }
body.theme-light .row.head > div { color: #8A6E3A; }
body.theme-light .row.head small, body.theme-light .karat small { color: #6B7F83; }
body.theme-light .karat b { color: #8A6E3A; background: linear-gradient(180deg, #C9A866 0%, #9A7B40 55%, #6E5528 100%); -webkit-background-clip: text; }
body.theme-light .karat span { color: #0A2026; }
body.theme-light .price.sell .v { color: #0A2026; }
body.theme-light .price.buy .v { color: #8A6E3A; }
body.theme-light .price .arrow.up, body.theme-light .ounce .chg.up { color: #1E9E5A; }
body.theme-light .price .arrow.down, body.theme-light .ounce .chg.down { color: #D64545; }
body.theme-light .rows-silver .row:first-child { border-top-color: rgba(15, 79, 79, 0.25); }
body.theme-light .rows-silver .karat b { color: #6B777C; background: linear-gradient(180deg, #A9B3B7 0%, #78858A 60%, #56636A 100%); -webkit-background-clip: text; }
body.theme-light .rows-silver .price.sell .v { color: #2A3A3F; }
body.theme-light .rows-silver .price.buy .v { color: #5E6A6F; }
body.theme-light .foot { color: #6B7F83; border-top-color: rgba(15, 79, 79, 0.12); }
body.theme-light .ounce b { color: #8A6E3A; }
body.theme-light .status.warn { color: #B7791F; }
body.theme-light .status.off { color: #C0392B; }
body.theme-light .stopped { background: radial-gradient(ellipse at 50% 30%, #FFFFFF 0%, #F3F4F2 55%, #E4E8E4 100%); }
body.theme-light .stopped .shop-ar { color: #0A2026; }
body.theme-light .stopped .msg { color: #0F4F4F; }

/* ---------- gold theme ---------- */
body.theme-gold { background: #24190B; background: radial-gradient(ellipse at 85% -10%, #6B5124 0%, #2E2110 48%, #140E06 100%); color: #FFF6E0; }
body.theme-gold .bg:after { background: rgba(20, 14, 6, 0.76); }
body.theme-gold .top { border-bottom-color: rgba(232, 200, 119, 0.4); }
body.theme-gold .shop-ar { color: #FFF6E0; }
body.theme-gold .shop-en, body.theme-gold .time small, body.theme-gold .unit, body.theme-gold .row.head > div { color: #E8C877; }
body.theme-gold .time, body.theme-gold .board-head h1 { color: #F2D58C; }
body.theme-gold .dates { color: #CBB78E; }
body.theme-gold .dates .sep { color: #E8C877; }
body.theme-gold .board { background: rgba(255, 220, 150, 0.05); border-color: rgba(232, 200, 119, 0.5); box-shadow: inset 0 0 4rem rgba(232, 200, 119, 0.08); }
body.theme-gold.has-bg .board { background: rgba(20, 14, 6, 0.55); }
body.theme-gold .ads { background: #1A1309; border-color: rgba(232, 200, 119, 0.5); }
body.theme-gold .board-head h1 span, body.theme-gold .unit span, body.theme-gold .row.head small, body.theme-gold .karat small { color: #B9A37A; }
body.theme-gold .row { border-bottom-color: rgba(232, 200, 119, 0.2); }
body.theme-gold .row.head, body.theme-gold .rows-silver .row:first-child { border-color: rgba(232, 200, 119, 0.45); }
body.theme-gold .karat b { color: #F2D58C; background: linear-gradient(180deg, #FFF3CC 0%, #E8C26A 55%, #B8892F 100%); -webkit-background-clip: text; }
body.theme-gold .karat span { color: #F7EEDC; }
body.theme-gold .price.sell .v { color: #FFF6E0; }
body.theme-gold .price.buy .v { color: #F2D58C; }
body.theme-gold .foot { color: #B9A37A; border-top-color: rgba(232, 200, 119, 0.2); }
body.theme-gold .ounce b { color: #F2D58C; }
body.theme-gold .ounce .chg.flat { color: #B9A37A; }
body.theme-gold .ticker { background: linear-gradient(90deg, #8C6A2C 0%, #E8C877 50%, #8C6A2C 100%); color: #1A1309; }
body.theme-gold .ticker-text .dot { color: #5A4018; }
body.theme-gold .stopped { background: radial-gradient(ellipse at 50% 30%, #6B5124 0%, #2E2110 55%, #140E06 100%); }
body.theme-gold .stopped .msg { color: #F2D58C; }
