/* ============================================================
   Улсын бүртгэлийн ерөнхий газар — landing
   Follows the УБЕГ brandbook (brando, 2025):
     color 1  #005b89   color 2  #24aae2   color 3  #25408f
     color 4  #fdc682   color 5  #e4994c
     gradients: 2→3 (blue), 4→5 (gold)
     type: Arimo — the brandbook's Cyrillic font (4 Фонт/крилл), and
           metric-identical to the Arial Bold used in the logo wordmark
     device: ornamental line band with the seal centred beneath it
   ============================================================ */

/* ---------- brand font (self-hosted, subset to Latin + Cyrillic) ---------- */
@font-face { font-family: "Arimo"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/Arimo-Regular.woff2") format("woff2"); }
@font-face { font-family: "Arimo"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("../fonts/Arimo-Medium.woff2") format("woff2"); }
@font-face { font-family: "Arimo"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("../fonts/Arimo-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "Arimo"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("../fonts/Arimo-Bold.woff2") format("woff2"); }

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

/* ---------- brand tokens ---------- */
:root {
  --c1: #005b89;   /* deep teal blue */
  --c2: #24aae2;   /* bright blue    */
  --c3: #25408f;   /* royal navy     */
  --c4: #fdc682;   /* light gold     */
  --c5: #e4994c;   /* gold           */

  --text: "Arimo", Arial, "Helvetica Neue", system-ui, sans-serif;
  --display: var(--text);

  --maxw: 1200px;
  --gutter: clamp(18px, 4vw, 40px);
  --ease: cubic-bezier(.22, .61, .36, 1);
  --r: 14px;
}

[data-theme="light"] {
  --page: #f4f7fb;
  --page-2: #ffffff;
  --ink: #16224a;
  --ink-2: #5b6782;
  --ink-3: #5f6a85;   /* 5.0:1 on --page; gold/lighter greys fail WCAG here */
  --head: var(--c3);
  --surface: #ffffff;
  --line: rgba(37, 64, 143, .13);
  --line-soft: rgba(37, 64, 143, .07);
  --ornament: var(--c3);
  --ornament-opacity: .16;
  --shadow: 0 2px 4px rgba(21, 40, 100, .04), 0 14px 30px -18px rgba(21, 40, 100, .30);
  --shadow-hi: 0 4px 10px rgba(21, 40, 100, .06), 0 26px 48px -22px rgba(21, 40, 100, .38);
  --chip: rgba(37, 64, 143, .06);
  --seal-rest: var(--c3);   /* resting colour of the four service gereges */
}

[data-theme="dark"] {
  --page: #14286b;
  --page-2: #0d2b52;
  --ink: #ffffff;
  --ink-2: rgba(255, 255, 255, .76);
  --ink-3: rgba(255, 255, 255, .52);
  --head: #ffffff;
  --surface: rgba(255, 255, 255, .07);
  --line: rgba(255, 255, 255, .16);
  --line-soft: rgba(255, 255, 255, .10);
  --ornament: #ffffff;
  --ornament-opacity: .16;
  --shadow: 0 18px 36px -24px rgba(0, 0, 0, .7);
  --shadow-hi: 0 30px 56px -26px rgba(0, 0, 0, .8);
  --chip: rgba(255, 255, 255, .10);
  --seal-rest: rgba(255, 255, 255, .82);
}

/* ---------- base ---------- */
body {
  min-height: 100vh;
  font-family: var(--text);
  font-size: 16px;
  color: var(--ink);
  background: var(--page);
}
[data-theme="light"] body,
body[data-theme="light"] { background: var(--page); }
[data-theme="dark"] body {
  background:
    radial-gradient(120% 80% at 50% 0%, #2c53b4 0%, transparent 58%),
    linear-gradient(168deg, var(--c3) 0%, var(--c1) 100%);
  background-attachment: fixed;
}

.skip-link {
  position: absolute; left: -9999px; top: 12px; z-index: 60;
  padding: 10px 16px; border-radius: 8px; background: var(--c3); color: #fff; font-weight: 700;
}
.skip-link:focus { left: 12px; }

.u-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- ornament band (the brand's signature device) ----------
   Direct child of <body> so it spans the full viewport, exactly like
   the band across the top of the official letterhead. */
.ornament {
  position: absolute; top: 0; left: 0; right: 0; z-index: 0;
  height: clamp(66px, 8.5vw, 124px);
  pointer-events: none;
}
/* The mask lives on ::before so the closing rule below isn't masked away too. */
.ornament::before {
  content: ""; position: absolute; inset: 0;
  background-color: var(--ornament);
  opacity: var(--ornament-opacity);
  -webkit-mask-image: url("../img/ornament.png");
  mask-image: url("../img/ornament.png");
  -webkit-mask-size: auto 100%;
  mask-size: auto 100%;
  -webkit-mask-position: center bottom;
  mask-position: center bottom;
  -webkit-mask-repeat: repeat-x;
  mask-repeat: repeat-x;
}
.ornament::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: var(--ornament);
  opacity: calc(var(--ornament-opacity) * 1.7);
}

/* ---------- shell ----------
   The landing is meant to sit in a single desktop viewport, so the vertical
   rhythm is driven by vh and the footer is pinned by the flex column. */
.page {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  min-height: 100vh; min-height: 100svh;
  max-width: var(--maxw); margin-inline: auto;
  padding: 0 var(--gutter) clamp(18px, 3vh, 36px);
}
/* Centre the services in whatever room is left so the spare space is shared
   above and below them rather than dumped above the footer. */
.page > main { flex: 1 0 auto; display: flex; flex-direction: column; justify-content: center; }

/* ---------- masthead ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: clamp(10px, 1.4vh, 16px) 0;
}
.topbar__links { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar__link {
  padding: 7px 12px; border-radius: 7px;
  font-size: .84rem; font-weight: 600; color: var(--ink-2);
  transition: background .2s var(--ease), color .2s var(--ease);
}
.topbar__link:hover { background: var(--chip); color: var(--head); }

.langs { display: flex; gap: 2px; padding: 3px; border-radius: 8px; background: var(--chip); }
.lang {
  padding: 6px 12px; border-radius: 6px;
  font-family: var(--display);
  font-size: .74rem; font-weight: 700; letter-spacing: .06em; color: var(--ink-2);
  transition: background .2s var(--ease), color .2s var(--ease);
}
.lang:hover { color: var(--head); }
.lang.is-active { background: var(--c3); color: #fff; }
[data-theme="dark"] .lang.is-active { background: #fff; color: var(--c3); }

/* Letterhead order: seal → agency line → organisation name → lead. */
.masthead__id {
  text-align: center;
  padding-top: clamp(6px, 1.2vh, 18px);
  padding-bottom: clamp(22px, 4.4vh, 52px);
}
.mark { width: clamp(38px, 5vh, 54px); margin: 0 auto; }
.mark img { width: 100%; height: auto; }

.logo { display: inline-block; width: clamp(190px, 23vw, 250px); margin: 0 auto; }
.logo img { width: 100%; height: auto; }

.kicker {
  margin: clamp(10px, 1.6vh, 18px) 0 0;
  font-family: var(--display);
  font-size: clamp(.58rem, .88vw, .68rem); font-weight: 700;
  letter-spacing: .17em; color: var(--ink-3);
}
.headline {
  margin: 6px auto 0; max-width: 22ch; text-wrap: balance;   /* 2 lines, like the lockup */
  font-family: var(--display);
  font-size: clamp(1.05rem, 2.2vw, 1.62rem); font-weight: 700;
  letter-spacing: .015em; line-height: 1.24; color: var(--head);
}
.lead {
  margin: clamp(10px, 1.8vh, 20px) auto 0; max-width: 54ch;
  font-size: clamp(.88rem, 1.15vw, .97rem); color: var(--ink-2); line-height: 1.6;
}

/* ---------- sections ---------- */
.section + .section { margin-top: clamp(28px, 4.5vh, 56px); }
.section__head {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  margin-bottom: clamp(12px, 2vh, 22px);
  padding-bottom: 10px; border-bottom: 1px solid var(--line-soft);
}
.section__title {
  margin: 0; font-family: var(--display);
  font-size: clamp(.98rem, 1.6vw, 1.12rem); font-weight: 700; letter-spacing: .01em;
  color: var(--head);
}
.section__title::before {
  content: ""; display: inline-block; vertical-align: middle;
  width: 3px; height: 1em; margin-right: 10px; border-radius: 2px;
  background: linear-gradient(180deg, var(--c4), var(--c5));
}
.section__subtitle { margin: 0; font-size: .87rem; color: var(--ink-3); }

/* ---------- grids ---------- */
.grid { display: grid; gap: clamp(12px, 1.4vw, 18px); }
.grid--seal { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid--tile { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
@media (min-width: 880px) { .grid--tile { grid-template-columns: repeat(3, 1fr); } }

/* ---------- seal card ---------- */
.card {
  position: relative; display: flex; flex-direction: column;
  min-height: 100%; padding: clamp(16px, 2.2vh, 24px);
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .35s var(--ease);
}
/* gold hairline that sweeps in on hover — the brand's accent gradient */
.card::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, var(--c4), var(--c5));
  transform: scaleX(0); transform-origin: left;
  transition: transform .45s var(--ease);
}
.card:hover, .card:focus-visible { transform: translateY(-3px); box-shadow: var(--shadow-hi); border-color: var(--line); }
.card:hover::after, .card:focus-visible::after { transform: scaleX(1); }
.card:focus-visible { outline: 2px solid var(--c2); outline-offset: 3px; }

/* ---------- gerege badge: logo at rest, icon on hover ---------- */
.card__seal { display: block; width: clamp(32px, 4.4vh, 42px); margin-bottom: clamp(12px, 1.8vh, 20px); }
.tile__seal { display: block; width: 30px; }

.seal {
  position: relative; display: block;
  transform-style: preserve-3d;
  transition: transform .62s cubic-bezier(.45, .05, .2, 1);
}
.seal__face {
  display: block;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.seal__face svg { width: 100%; height: auto; }
/* Tinted silhouette of the real gerege — navy here, so the four service
   marks read as a set and never compete with the gold masthead mark. */
.seal__face--mark {
  aspect-ratio: 220 / 538;
  background-color: var(--seal-rest);
  -webkit-mask: url("../img/mark-mask.png") center / contain no-repeat;
  mask: url("../img/mark-mask.png") center / contain no-repeat;
}
.seal__face--icon {
  position: absolute; inset: 0;
  transform: rotateY(180deg);
}
.seal__face--icon svg { filter: drop-shadow(0 7px 12px rgba(18, 38, 96, .30)); }
.seal--static svg { width: 100%; height: auto; }

@media (hover: hover) {
  .card:hover .seal, .card:focus-visible .seal,
  .tile:hover .seal, .tile:focus-visible .seal { transform: rotateY(180deg); }
}
/* Touch devices never hover, so show the informative face instead. */
@media (hover: none) {
  .seal { transform: rotateY(180deg); }
}
@media (prefers-reduced-motion: reduce) {
  .seal { transform: rotateY(180deg); }
}

.card__title {
  margin: 0; font-family: var(--display);
  font-size: clamp(.96rem, 1.3vw, 1.06rem); font-weight: 700; line-height: 1.3;
  color: var(--head); letter-spacing: .005em;
}
.card__desc {
  margin: 8px 0 0; font-size: .855rem; line-height: 1.5; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* Gold is a fill colour in the brandbook — as small text on white it only
   reaches 2.3:1, so the label is navy and gold stays on the arrow. */
.card__go {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: auto; padding-top: clamp(10px, 1.8vh, 18px);
  font-family: var(--display); font-size: .76rem; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase; color: var(--head);
}
.card__go svg { width: 14px; height: 14px; color: var(--c5); transition: transform .35s var(--ease); }
.card:hover .card__go svg { transform: translateX(4px); }

.card__badge {
  position: absolute; top: 16px; right: 16px;
  padding: 4px 9px; border-radius: 5px;
  font-family: var(--display); font-size: .62rem; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase;
  background: linear-gradient(90deg, var(--c4), var(--c5)); color: #46280a;
}

/* ---------- compact tile ---------- */
.tile {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 20px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.tile:hover, .tile:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow-hi); }
.tile:focus-visible { outline: 2px solid var(--c2); outline-offset: 3px; }
.tile__seal { flex: 0 0 auto; }
.tile__seal svg { width: 30px; height: auto; }
.tile__body { min-width: 0; }
.tile__label {
  display: block; font-family: var(--display); font-weight: 700;
  font-size: .9rem; line-height: 1.32; color: var(--head);
}
.tile__desc { display: block; margin-top: 3px; font-size: .78rem; color: var(--ink-3); line-height: 1.45; }

/* ---------- footer ---------- */
.footer {
  margin-top: clamp(18px, 3vh, 40px); padding-top: clamp(13px, 2vh, 22px);
  border-top: 1px solid var(--line-soft);
  display: flex; flex-wrap: wrap; gap: 12px 26px;
  align-items: center; justify-content: space-between;
  font-size: .82rem; color: var(--ink-3);
}
.footer__meta, .footer__links { display: flex; flex-wrap: wrap; gap: 6px 22px; }
.footer__links a { transition: color .2s var(--ease); }
.footer__links a:hover { color: var(--c5); }
.footer__contact b { font-weight: 700; color: var(--ink-2); }

/* ---------- states ---------- */
.notice {
  max-width: 620px; margin: clamp(50px, 10vh, 120px) auto; padding: 26px 28px;
  border-radius: var(--r); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.notice h2 { margin: 0 0 8px; font-family: var(--display); font-size: 1rem; color: var(--head); }
.notice p { margin: 0 0 10px; color: var(--ink-2); font-size: .88rem; line-height: 1.6; }
.notice code {
  display: inline-block; padding: 3px 8px; border-radius: 6px; background: var(--chip);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .84em;
}
.fallback { padding: 40px; text-align: center; }

/* ---------- entrance ---------- */
@media (prefers-reduced-motion: no-preference) {
  .reveal { opacity: 0; transform: translateY(10px); animation: rise .55s var(--ease) forwards; }
  @keyframes rise { to { opacity: 1; transform: none; } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
