/* ==========================================================================
   MEKHFON · ROYAL FINISH
   A refinement layer on top of the base theme: gold hairlines, layered depth, ornament, and small motions.
   Everything that moves uses transform / opacity only and stops under prefers-reduced-motion.
   ========================================================================== */
:root {
  --rb-gold-hair: linear-gradient(90deg, transparent 0, rgba(210, 166, 74, .0) 4%, rgba(210, 166, 74, .75) 50%, rgba(210, 166, 74, .0) 96%, transparent 100%);
  --rb-lift: 0 1px 0 rgba(255, 255, 255, .95) inset, 0 1px 1px rgba(60, 40, 8, .05), 0 3px 8px -3px rgba(111, 78, 20, .12), 0 20px 34px -22px rgba(111, 78, 20, .38);
  --rb-lift-hi: 0 1px 0 #fff inset, 0 2px 3px rgba(60, 40, 8, .07), 0 8px 18px -6px rgba(111, 78, 20, .22), 0 30px 46px -24px rgba(111, 78, 20, .5), 0 0 0 1px rgba(225, 190, 111, .35);
  --rb-spring: cubic-bezier(.2, 1.1, .3, 1);
}

/* ---- atmosphere: delicate Thai pattern watermark on royal cream paper ---- */
body.rb {
  background: #F9F5EB url("/static/royal-barge/assets/art/thai-pattern-bg.webp") repeat 0 0 / 256px 256px;
  background-attachment: scroll;
}
body.rb::before {
  display: none;
}
::selection { background: rgba(225, 190, 111, .55); color: #2a1c05; }
:focus-visible { outline: 2px solid #D2A64A; outline-offset: 2px; box-shadow: 0 0 0 5px rgba(210, 166, 74, .22); border-radius: 8px; }
* { scrollbar-width: thin; scrollbar-color: rgba(185, 138, 51, .55) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; } ::-webkit-scrollbar-thumb { background: linear-gradient(180deg, #E1BE6F, #B98A33); border-radius: 9px; border: 2px solid transparent; background-clip: content-box; } ::-webkit-scrollbar-track { background: transparent; }

/* ---- masthead: the barge floats, the brand catches the light once in a while ---------------------------- */
.rb-brand-mark { transform-origin: 50% 82%; animation: rb-float 7s ease-in-out infinite; will-change: transform; }
@keyframes rb-float { 0%, 100% { transform: translateY(0) rotate(0deg); } 33% { transform: translateY(-2.5px) rotate(.55deg); } 66% { transform: translateY(1.2px) rotate(-.45deg); } }
.rb-brand-name {
  /* a band of gold light travelling over solid ink (the ink layer is always there, so no letter ever disappears) */
  background: linear-gradient(100deg, transparent 0 42%, rgba(244, 205, 105, .95) 50%, transparent 58% 100%) 150% 0 / 260% 100% no-repeat, linear-gradient(#14202c, #14202c);
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
  animation: rb-glint 11s ease-in-out 1.2s infinite;
}
@keyframes rb-glint { 0%, 62% { background-position: 150% 0; } 82%, 100% { background-position: -60% 0; } }
.rb-header-art { animation: rb-art-drift 24s ease-in-out infinite alternate; }
@keyframes rb-art-drift { from { background-position: right bottom; } to { background-position: 98% bottom; } }
.rb-header::before { /* a slow band of light crossing the river scene */
  content: ""; position: absolute; top: 0; bottom: 0; right: 0; width: min(33vw, 780px); z-index: 1; pointer-events: none; opacity: .0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 244, 205, .5) 50%, transparent 65%); background-size: 260% 100%;
  animation: rb-sunbeam 14s ease-in-out 2s infinite;
}
@keyframes rb-sunbeam { 0% { opacity: 0; background-position: 130% 0; } 12% { opacity: .85; } 40% { opacity: .85; background-position: -30% 0; } 52%, 100% { opacity: 0; background-position: -30% 0; } }
.rb-header::after { background-size: 200% 100%; animation: rb-hair 9s linear infinite; }
@keyframes rb-hair { to { background-position: -200% 0; } }

/* ---- navigation: a gold pill that glides between tabs ------------------------------------------------- */
.rb-nav-track { position: relative; }
.rb-nav-btn { position: relative; z-index: 1; transition: color .25s var(--rb-ease), transform .25s var(--rb-spring), background .2s var(--rb-ease); }
.rb-nav-btn:active { transform: scale(.96); }
.rb-nav-btn:hover:not(.is-active) { background: rgba(251, 246, 230, .9); transform: translateY(-1px); }
.rb-nav-btn:hover .rb-i { transform: translateY(-1px) scale(1.06); } .rb-nav-btn .rb-i { transition: transform .3s var(--rb-spring); }
.rb-nav.has-ink .rb-nav-btn.is-active { background: transparent; box-shadow: none; }
.rb-nav-ink {
  position: absolute; z-index: 0; left: 0; top: 0; width: 0; height: 0; border-radius: .85rem; pointer-events: none; opacity: 0;
  background: var(--rb-gold-grad);
  box-shadow: 0 1px 0 #FFF6D8 inset, 0 -1px 0 rgba(150, 105, 30, .25) inset, 0 6px 14px -6px rgba(150, 105, 30, .65), 0 0 0 1px rgba(210, 166, 74, .35);
  transition: transform .5s var(--rb-spring), width .5s var(--rb-spring), height .3s var(--rb-ease), opacity .25s;
}
.rb-nav-ink.is-on { opacity: 1; }
.rb-nav-ink::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, .55) 50%, transparent 70%); background-size: 250% 100%; animation: rb-ink-sheen 5.5s ease-in-out infinite; }
@keyframes rb-ink-sheen { 0%, 55% { background-position: 160% 0; } 85%, 100% { background-position: -80% 0; } }

/* ---- scroll progress hairline ------------------------------------------------------------------------- */
.rb-scrollbar { position: fixed; left: 0; right: 0; top: 0; height: 3px; z-index: 1300; pointer-events: none; transform-origin: 0 50%; transform: scaleX(0); background: linear-gradient(90deg, #E1BE6F, #F6DE97 60%, #D2A64A); box-shadow: 0 0 10px rgba(225, 190, 111, .8); transition: opacity .3s; opacity: 0; }
.rb-scrollbar.is-on { opacity: 1; }

/* ---- cards: layered depth + a gold thread on the top edge ------------------------------------------------ */
.rb-card { box-shadow: var(--rb-lift); border-color: rgba(228, 214, 178, .9); transition: transform .35s var(--rb-ease), box-shadow .35s var(--rb-ease), border-color .35s; }
.rb-card::before { content: ""; position: absolute; left: 1.2rem; right: 1.2rem; top: -1px; height: 2px; border-radius: 2px; background: var(--rb-gold-hair); opacity: .85; pointer-events: none; transition: opacity .35s, left .4s var(--rb-ease), right .4s var(--rb-ease); }
.rb-card:hover { box-shadow: var(--rb-lift-hi); }
.rb-card:hover::before { left: .4rem; right: .4rem; opacity: 1; }
.rb-card--flush::before { left: 0; right: 0; border-radius: 0; }
.rb-card-head { position: relative; padding-bottom: .55rem; background: linear-gradient(90deg, rgba(225, 190, 111, .55), rgba(225, 190, 111, 0) 70%) left bottom / 100% 1px no-repeat; }
.rb-card-title .rb-i--gold, .rb-card-title > .rb-i { filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .9)); transition: transform .5s var(--rb-spring); }
.rb-card:hover .rb-card-title > .rb-i:first-child { transform: rotate(-8deg) scale(1.1); }
.rb-card--gold, .rb-callout {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='34' viewBox='0 0 34 34' fill='none' stroke='%23C79B3E' stroke-width='1.2' stroke-linecap='round'%3E%3Cpath d='M2 2 H14 C8 2 2 8 2 14 Z' opacity='.8'/%3E%3Cpath d='M2 22 C2 11 11 2 22 2' opacity='.55'/%3E%3Ccircle cx='9' cy='9' r='1.6' fill='%23D2A64A' stroke='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 6px 6px;
}
.rb-callout { background-position: 6px 6px, 0 0; }
.rb-card--gold { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='34' viewBox='0 0 34 34' fill='none' stroke='%23C79B3E' stroke-width='1.2' stroke-linecap='round'%3E%3Cpath d='M2 2 H14 C8 2 2 8 2 14 Z' opacity='.8'/%3E%3Cpath d='M2 22 C2 11 11 2 22 2' opacity='.55'/%3E%3Ccircle cx='9' cy='9' r='1.6' fill='%23D2A64A' stroke='none'/%3E%3C/svg%3E"), linear-gradient(180deg, #FFFEFB 0%, #FFFAEC 100%); background-position: 6px 6px, 0 0; }

/* ---- page titles: a gold ornament that draws itself under the heading ---------------------------------------- */
.rb-h1-sep { background: linear-gradient(180deg, #F0D58F, #B98A33); box-shadow: 0 0 8px rgba(225, 190, 111, .7); }
.rb-pagehead-title, .rb-hero-title { position: relative; }
.rb-pagehead-title::after, .rb-hero-title::after {
  content: ""; display: block; width: min(15rem, 60%); height: 12px; margin-top: .3rem;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 0 L12 6 L6 12 L0 6 Z' fill='%23D2A64A'/%3E%3Cpath d='M6 3 L9 6 L6 9 L3 6 Z' fill='%23FFF4CC'/%3E%3C/svg%3E") 0 50% / 12px 12px no-repeat,
    linear-gradient(90deg, #D2A64A, rgba(210, 166, 74, 0)) 17px 50% / calc(100% - 17px) 1.5px no-repeat;
  transform-origin: 0 50%; opacity: .9;
}
.rb-screen.is-entering .rb-pagehead-title::after, .rb-screen.is-entering .rb-hero-title::after { animation: rb-draw 1s var(--rb-ease) .25s both; }
@keyframes rb-draw { from { transform: scaleX(0); opacity: 0; } to { transform: none; opacity: .9; } }

/* ---- KPI: a light sweep on the accent bar, gentle lift, breathing icon ----------------------------------- */
.rb-kpi { box-shadow: var(--rb-lift); transition: transform .35s var(--rb-spring), box-shadow .35s var(--rb-ease); }
.rb-kpi::before { height: 3px; background: linear-gradient(90deg, var(--kpi, #E1BE6F), color-mix(in srgb, var(--kpi, #E1BE6F) 40%, #fff) 50%, var(--kpi, #E1BE6F)); background-size: 220% 100%; animation: rb-bar 6s ease-in-out infinite; }
@keyframes rb-bar { 0%, 100% { background-position: 100% 0; } 50% { background-position: 0 0; } }
.rb-kpi:hover { transform: translateY(-3px); box-shadow: var(--rb-lift-hi); }
.rb-kpi-ico { transition: transform .5s var(--rb-spring), box-shadow .3s; box-shadow: 0 0 0 0 color-mix(in srgb, var(--kpi, #E1BE6F) 30%, transparent); }
.rb-kpi:hover .rb-kpi-ico { transform: rotate(-6deg) scale(1.08); box-shadow: 0 0 0 5px color-mix(in srgb, var(--kpi, #E1BE6F) 20%, transparent); }
.rb-kpi-val { font-variant-numeric: tabular-nums; }
.rb-kpis:empty::before { content: ""; grid-column: 1 / -1; height: 5.2rem; border-radius: 14px; background: linear-gradient(100deg, #fff 30%, #FBF3DB 50%, #fff 70%) 100% 0 / 300% 100%; border: 1px solid var(--rb-line); animation: rb-skel 1.4s linear infinite; }
@keyframes rb-skel { to { background-position: -100% 0; } }

/* ---- buttons: gold you can feel ------------------------------------------------------------------------------ */
.rb-btn { transition: transform .25s var(--rb-spring), box-shadow .3s var(--rb-ease), background .2s; overflow: hidden; position: relative; }
.rb-btn:hover { transform: translateY(-1.5px); }
.rb-btn:active { transform: scale(.97); }
.rb-btn--gold { background-size: 100% 100%; box-shadow: 0 1px 0 #FBEBB8 inset, 0 -2px 0 rgba(150, 105, 30, .25) inset, 0 10px 20px -10px rgba(150, 105, 30, .9), 0 0 0 1px rgba(199, 155, 62, .4); }
.rb-btn--gold:hover { box-shadow: 0 1px 0 #FFF3CC inset, 0 -2px 0 rgba(150, 105, 30, .25) inset, 0 14px 26px -10px rgba(150, 105, 30, .95), 0 0 0 4px rgba(225, 190, 111, .25); }
.rb-ripple { position: absolute; border-radius: 50%; pointer-events: none; transform: scale(0); background: radial-gradient(circle, rgba(255, 255, 255, .75), rgba(255, 243, 200, .35) 60%, transparent 70%); animation: rb-ripple .7s ease-out forwards; }
@keyframes rb-ripple { to { transform: scale(1); opacity: 0; } }

/* ---- status: warnings breathe, "live" glints ----------------------------------------------------------------- */
.rb-status--warning { animation: rb-breathe 2.6s ease-in-out infinite; }
@keyframes rb-breathe { 0%, 100% { box-shadow: 0 0 0 0 rgba(214, 69, 80, .0); } 50% { box-shadow: 0 0 0 5px rgba(214, 69, 80, .18); } }
.rb-status--watch { position: relative; overflow: hidden; }
.rb-status--watch::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .6) 50%, transparent 65%); background-size: 250% 100%; animation: rb-ink-sheen 6s ease-in-out infinite; pointer-events: none; }
.rb-callout.is-watch .rb-callout-ico, .rb-callout.is-warning .rb-callout-ico { animation: rb-nudge 3.6s ease-in-out infinite; transform-origin: 50% 80%; }
@keyframes rb-nudge { 0%, 78%, 100% { transform: rotate(0); } 82% { transform: rotate(-7deg); } 88% { transform: rotate(6deg); } 94% { transform: rotate(-3deg); } }
.rb-callout::after { animation: rb-sunpulse 5s ease-in-out infinite; }
@keyframes rb-sunpulse { 0%, 100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.18); opacity: 1; } }

/* ---- lists and tables: a gold marker slides in on hover ------------------------------------------------------------ */
.rb-table tbody tr, .rb-alert-item, .rb-row, .rb-zcard { transition: background .25s var(--rb-ease), transform .3s var(--rb-spring), box-shadow .3s var(--rb-ease); }
.rb-table tbody tr:hover td:first-child { box-shadow: 3px 0 0 #D2A64A inset; }
.rb-alert-item:hover { transform: translateX(3px); box-shadow: 0 8px 18px -12px rgba(111, 78, 20, .45); }
.rb-thumb { transition: transform .3s var(--rb-spring), border-color .2s, box-shadow .3s; }
.rb-thumb:hover { transform: translateY(-3px) scale(1.03); }
.rb-wxcard { transition: transform .4s var(--rb-spring), box-shadow .4s; }
.rb-wxcard:hover { transform: translateY(-4px); box-shadow: var(--rb-lift-hi); }
.rb-wxcard-dot { animation: rb-dot 3s ease-in-out infinite; }
@keyframes rb-dot { 0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 25%, transparent); } 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--acc) 6%, transparent); } }

/* ---- entrance choreography: a screen opens like a curtain, cards rise one after another ---------------------------- */
.rb-screen.is-entering :is(.rb-kpi, .rb-card, .rb-wxcard, .rb-wxsum-i, .rb-callout, .rb-window, .rb-principle, .rb-altlive) {
  animation: rb-rise .75s var(--rb-ease) both; animation-delay: calc(var(--i, 0) * 70ms);
}
.rb-screen.is-entering .rb-kpi { animation-name: rb-rise-pop; }
@keyframes rb-rise { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes rb-rise-pop { 0% { opacity: 0; transform: translateY(14px) scale(.94); } 60% { opacity: 1; transform: translateY(-2px) scale(1.012); } 100% { opacity: 1; transform: none; } }
.rb-screen.is-entering .rb-zcard { animation: rb-slide-in .7s var(--rb-ease) both; animation-delay: calc(var(--i, 0) * 90ms + .35s); }
@keyframes rb-slide-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* ---- modal + toast ----------------------------------------------------------------------------------------- */
.rb-modal:not([hidden]) .rb-modal-card { animation: rb-modal-in .5s var(--rb-spring) both; }
.rb-modal:not([hidden]) .rb-modal-back { animation: rb-fade .35s ease both; }
@keyframes rb-modal-in { from { opacity: 0; transform: translateY(26px) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes rb-fade { from { opacity: 0; } to { opacity: 1; } }
.rb-modal-back { backdrop-filter: blur(5px) saturate(1.1); -webkit-backdrop-filter: blur(5px) saturate(1.1); }
.rb-modal-card { border-color: rgba(225, 190, 111, .6); box-shadow: 0 40px 90px -30px rgba(20, 30, 50, .65), 0 0 0 1px rgba(225, 190, 111, .35); }
.rb-toast { animation: rb-toast-in .5s var(--rb-spring) both; border: 1px solid rgba(225, 190, 111, .6); }
@keyframes rb-toast-in { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }

/* ---- map: the work-area ring marches, markers settle in ---------------------------------------------------------- */
.rb-area-ring--march { animation: rb-march 2.4s linear infinite; }
@keyframes rb-march { to { stroke-dashoffset: -32; } }
.rb-area-label { animation: rb-label-in .6s var(--rb-spring) both; }
@keyframes rb-label-in { from { opacity: 0; transform: translate(-50%, -100%) translateY(8px) scale(.92); } to { opacity: 1; transform: translate(-50%, -100%); } }
.rb-wxm.is-new { animation: rb-pop .6s var(--rb-spring) both; }
@keyframes rb-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
.rb-barge { position: absolute; left: 0; top: 0; pointer-events: none; transform: translate(-50%, -50%); filter: drop-shadow(0 3px 3px rgba(40, 28, 8, .45)); }
.rb-barge svg { display: block; width: 60px; height: 29px; transition: transform .4s linear; animation: rb-barge-bob 2.8s ease-in-out infinite; }
@keyframes rb-barge-bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -1.6px; } }
.rb-barge-wake { position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, .8); animation: rb-wake 2.4s ease-out infinite; }
.rb-barge-wake:nth-child(2) { animation-delay: 1.2s; }
@keyframes rb-wake { from { transform: scale(.6); opacity: .85; } to { transform: scale(4.2); opacity: 0; } }

/* ---- touch the numbers (count-up marks them) --------------------------------------------------------------------- */
.rb-counting { color: var(--rb-gold-600); transition: color .6s; }

/* ---- calm pass (UI review) ---------------------------------------------------------------------------------------
   The perpetual shimmers that stacked up on every screen are switched off; the signature motion stays: floating barge logo + glint,
   gold nav pill, entrance stagger, count-up, button ripple, the breathing warning pill, the marching work-area ring and the barge on
   the map. Delete this block to bring the removed ones back. */
.rb-kpi::before { animation: none; background-size: 100% 100%; }       /* the gold bar on a KPI card no longer sweeps */
.rb-status--watch::after { display: none; }                              /* no moving sheen on every watch pill */
.rb-callout::after { animation: none; }                                  /* no pulsing sun behind the banner */
.rb-callout.is-watch .rb-callout-ico { animation: none; }                /* only a WARNING icon nudges */
.rb-wxcard-dot { animation: none; }                                      /* the LIVE chip already pulses; the card dot stays still */
.rb-header::after { animation: none; }                                   /* the sunbeam alone moves in the masthead */
.rb-area-label { animation: none; }                                      /* the ring label no longer re-pops on every refresh */

@media (prefers-reduced-motion: reduce) {
  .rb-wxm.is-new, .rb-area-label { animation: none !important; }
  .rb-wxm-box, .rb-zmark, .rb-zlabel { transition: none !important; }
  .rb-brand-mark, .rb-brand-name, .rb-header-art, .rb-header::before, .rb-header::after, .rb-nav-ink::after, .rb-kpi::before, .rb-status--warning, .rb-status--watch::after,
  .rb-callout-ico, .rb-callout::after, .rb-wxcard-dot, .rb-area-ring--march, .rb-barge svg, .rb-barge-wake, .rb-kpis:empty::before { animation: none !important; }
  .rb-brand-name { background: none; -webkit-text-fill-color: currentColor; color: var(--rb-ink); }
  .rb-screen.is-entering :is(.rb-kpi, .rb-card, .rb-wxcard, .rb-wxsum-i, .rb-callout, .rb-window, .rb-principle, .rb-altlive, .rb-zcard) { animation: none !important; }
  .rb-nav-ink { transition: none; }
}
@media print { .rb-scrollbar, .rb-nav-ink, .rb-barge { display: none !important; } body.rb::before { display: none; } }
