/* Pejabat Sultan Kelantan
   One bold element: the royal-yellow hero with the Jawi name.
   Everything else stays quiet: white paper, red ink, thin yellow rules. */

:root {
  --kuning: #F2B807;        /* kuning diraja, royal yellow */
  --kuning-muda: #FDF3D0;   /* pale yellow wash */
  --garis: #EAD9A2;         /* yellow rule */
  --merah: #8C1325;         /* Kelantan red */
  --merah-gelap: #5E0C19;   /* deep red for type on yellow and the footer */
  --dakwat: #2B1216;        /* red-ink body text */
  --dakwat-2: #5F4C47;      /* secondary text */
  --kertas: #FFFFFF;
  --krim-teks: #F7E9C6;     /* light text on deep red */

  --f-jawi: "Amiri", "Noto Naskh Arabic", "Traditional Arabic", serif;
  --f-head: "Amiri", Georgia, "Times New Roman", serif;
  --f-body: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --t-sm: 0.875rem;
  --t-base: 1.0625rem;
  --t-md: 1.25rem;
  --t-lg: 1.5625rem;
  --t-xl: 1.953rem;

  --wrap: 74rem;
  --gutter: clamp(1rem, 4vw, 2rem);
  --radius: 6px;

  /* Pucuk rebung (bamboo shoot) songket border, red on yellow. */
  --rebung-hero: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='22' viewBox='0 0 28 22'%3E%3Cpath d='M0 22 14 0l14 22z' fill='%235E0C19'/%3E%3Cpath d='M7 22l7-12 7 12z' fill='%23F2B807'/%3E%3Cpath d='M11.5 22 14 17.5 16.5 22z' fill='%238C1325'/%3E%3C/svg%3E");
  --rebung-foot: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='22' viewBox='0 0 28 22'%3E%3Cpath d='M0 22 14 0l14 22z' fill='%235E0C19'/%3E%3Cpath d='M7 22l7-12 7 12z' fill='%23F2B807'/%3E%3Cpath d='M11.5 22 14 17.5 16.5 22z' fill='%235E0C19'/%3E%3C/svg%3E");
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
/* Keep in-page jumps (e.g. /fungsi#kewangan) clear of the sticky header.
   site.js keeps --masthead-h equal to the header's real height. */
html { scroll-padding-top: calc(var(--masthead-h, 8.5rem) + 0.75rem); }

body {
  margin: 0;
  background: var(--kertas);
  color: var(--dakwat);
  font-family: var(--f-body);
  font-size: var(--t-base);
  line-height: 1.65;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--merah); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
a[href^="tel:"], a[href^="mailto:"] { white-space: nowrap; }

:focus-visible { outline: 3px solid var(--merah); outline-offset: 2px; }

h1, h2, h3 { font-family: var(--f-head); font-weight: 700; line-height: 1.15; color: var(--merah-gelap); }

[lang="ms-Arab"] { font-family: var(--f-jawi); }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }

.skip {
  position: absolute; left: -999px; top: 0.75rem; z-index: 50;
  background: var(--kuning); color: var(--merah-gelap); padding: 0.6rem 1rem; font-weight: 600;
}
.skip:focus { left: 0.75rem; }

/* ---------- Top bar ---------- */

.topbar { background: var(--merah-gelap); color: var(--krim-teks); font-size: 0.8125rem; }
.topbar-in { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 1.5rem; padding-block: 0.45rem; }
.topbar p { margin: 0; }
.topbar a { color: var(--krim-teks); text-decoration: none; }
.topbar a:hover { text-decoration: underline; }
.topbar-contact { display: flex; gap: 1.25rem; }
.hijri:not(:empty) { margin-left: 0.75rem; padding-left: 0.75rem; border-left: 1px solid rgba(247, 233, 198, 0.35); }

/* ---------- Masthead and navigation ---------- */

/* Sticky header: stays at the top on every screen size. Once the page has
   scrolled past the top bar it gets the is-stuck class: it shrinks and casts
   a soft shadow so it takes little room while reading. */
.masthead {
  position: sticky; top: 0; z-index: 40;
  background: var(--kertas); border-bottom: 1px solid var(--garis);
  transition: box-shadow 0.2s ease;
}
.masthead.is-stuck { box-shadow: 0 8px 24px -16px rgba(94, 12, 25, 0.45); }
.masthead .wordmark, .masthead .crest, .masthead .wordmark-rumi, .masthead .wordmark-jawi, .masthead .nav-top {
  transition: padding 0.2s ease, height 0.2s ease, font-size 0.2s ease;
}
.masthead.is-stuck .wordmark { padding-block: 0.45rem 0.4rem; }
/* Shrunk sizes per screen size, always smaller than the normal ones. */
@media (min-width: 60.0625rem) {
  .masthead.is-stuck .crest { height: 2.6rem; }
  .masthead.is-stuck .wordmark-rumi { font-size: 1.35rem; }
  .masthead.is-stuck .wordmark-jawi { font-size: 1.15rem; }
  .masthead.is-stuck .nav-top { padding-block: 0.55rem; }
}
@media (max-width: 60rem) {
  .masthead.is-stuck .crest { height: 2.4rem; }
  .masthead.is-stuck .wordmark-rumi { font-size: 1.3rem; }
  .masthead.is-stuck .wordmark-jawi { font-size: 1.1rem; }
}
@media (max-width: 30rem) {
  .masthead.is-stuck .crest { height: 2.1rem; }
  .masthead.is-stuck .wordmark-rumi { font-size: 1.1rem; }
  .masthead.is-stuck .wordmark-jawi { font-size: 1rem; }
}
.masthead-in { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; column-gap: 1.5rem; }

.wordmark { display: flex; align-items: center; gap: 0.9rem; padding-block: 0.85rem 0.75rem; text-decoration: none; min-width: 0; }
.crest { height: 3.6rem; width: auto; flex: none; }
.wordmark-text { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.2rem 1rem; min-width: 0; }
.wordmark-rumi { font-family: var(--f-head); font-weight: 700; font-size: 1.7rem; line-height: 1; color: var(--merah-gelap); }
.wordmark-jawi { font-size: 1.45rem; line-height: 1; color: var(--merah); }

.menu-toggle {
  display: none;
  font: 600 var(--t-sm) var(--f-body); color: var(--merah-gelap);
  background: var(--kuning-muda); border: 1px solid var(--garis); border-radius: var(--radius);
  padding: 0.55rem 0.9rem; cursor: pointer;
}

.nav { flex-basis: 100%; border-top: 1px solid var(--garis); }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; }
.nav-item { position: relative; }
.nav-top {
  display: block; padding: 0.8rem 0.85rem; text-decoration: none;
  color: var(--dakwat); font-weight: 600; font-size: 0.9375rem;
}
.nav-item:first-child .nav-top { padding-left: 0; }
.nav-top:hover, .nav-item:focus-within > .nav-top { color: var(--merah); }
.nav-item.is-current > .nav-top { box-shadow: inset 0 -3px 0 var(--kuning); color: var(--merah-gelap); }

.nav-sub {
  display: none; position: absolute; left: 0; top: 100%; min-width: 17rem;
  list-style: none; margin: 0; padding: 0.4rem 0;
  background: var(--kertas); border: 1px solid var(--garis); border-top: 3px solid var(--kuning);
  box-shadow: 0 12px 24px -12px rgba(94, 12, 25, 0.25);
}
.nav-sub:empty { display: none !important; }
.nav-item:hover > .nav-sub, .nav-item:focus-within > .nav-sub { display: block; }
.nav-sub a { display: block; padding: 0.5rem 1rem; color: var(--dakwat); text-decoration: none; font-size: 0.9375rem; }
.nav-sub a:hover, .nav-sub a[aria-current="page"] { background: var(--kuning-muda); color: var(--merah-gelap); }

@media (max-width: 60rem) {
  /* Stack the Rumi and Jawi names so the Menu button fits beside them. */
  /* Logo left, Menu button pinned right, menu panel below. */
  .masthead-in { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 0.75rem; }
  .masthead-in > .nav { grid-column: 1 / -1; }
  .wordmark-text { flex-direction: column; align-items: flex-start; gap: 0.3rem; }
  .menu-toggle { flex: none; min-height: 44px; padding-inline: 1.1rem; }
  .menu-toggle:not([hidden]) { display: inline-block; }
  .js .nav:not(.is-open) { display: none; }
  /* The open menu scrolls by itself, so its end is always reachable even
     though the header is pinned to the top. */
  .js .nav.is-open {
    max-height: calc(100vh - var(--masthead-bar, 4.5rem));
    max-height: calc(100dvh - var(--masthead-bar, 4.5rem));
    overflow-y: auto; overscroll-behavior: contain;
  }
  .masthead.is-stuck .nav-top, .masthead.is-stuck .nav-item:first-child .nav-top { padding-block: 0.65rem; }
  .nav-list { flex-direction: column; padding-block: 0.5rem 1rem; }
  .nav-top, .nav-item:first-child .nav-top { padding: 0.65rem 0; }
  .nav-item.is-current > .nav-top { box-shadow: inset 3px 0 0 var(--kuning); padding-left: 0.75rem; }
  .nav-sub, .nav-item:hover > .nav-sub { display: block; position: static; border: 0; box-shadow: none; padding: 0 0 0.4rem 0.9rem; min-width: 0; }
  .nav-sub a { padding: 0.6rem 0.6rem; font-size: 0.9375rem; color: var(--dakwat-2); }
  .nav-top, .nav-item:first-child .nav-top { padding-block: 0.75rem; }
}

/* ---------- Hero ---------- */

.hero { background: var(--kuning); color: var(--merah-gelap); position: relative; overflow: hidden; isolation: isolate; }
.hero-in {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  align-items: center; gap: 2rem 3rem;
  padding-block: clamp(2.75rem, 6.5vw, 5rem) clamp(2.5rem, 5.5vw, 4rem);
}
.hero-crest { height: clamp(3.75rem, 6vw, 5.25rem); width: auto; margin-bottom: 1rem; }
.hero h1 { font-size: clamp(2.5rem, 5.2vw, 4rem); line-height: 1.02; margin: 0 0 1.1rem; max-width: 12ch; }
.hero-motto { font-family: var(--f-head); font-size: clamp(1.2rem, 2vw, 1.45rem); line-height: 1.35; margin: 0 0 1rem; max-width: 30ch; }
.hero-intro { margin: 0 0 1.75rem; max-width: 42ch; color: var(--dakwat); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 0; }
.hero-jawi {
  margin: 0; text-align: right; color: var(--merah);
  font-size: clamp(3rem, 6vw, 5.75rem); line-height: 1.45;
  animation: tulis 1.5s cubic-bezier(0.2, 0.7, 0.2, 1) 0.15s both;
}
/* Reveal right to left, the direction Jawi is written. */
@keyframes tulis { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0 0 0 0); } }

/* With a background video: footage of Istana Balai Besar under a deep-red
   shade, so the crest, gold title and Jawi stay readable. */
.hero-has-media { background: var(--merah-gelap); color: var(--krim-teks); min-height: clamp(24rem, 58vh, 34rem); display: flex; flex-direction: column; }
.hero-has-media .hero-in { padding-block: clamp(2rem, 4.5vw, 3.25rem) clamp(2rem, 4vw, 3rem); }
.hero-has-media .hero-in { flex: 1; }
.hero-media { position: absolute; inset: 0; z-index: 0; overflow: hidden; container-type: size; }
.hero-poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* Photo only: a slow pan and zoom across the palace. */
.hero-motion .hero-poster { transform-origin: 60% 45%; animation: hanyut 28s ease-in-out infinite alternate; }
.hero-motion.is-paused .hero-poster { animation-play-state: paused; }
@keyframes hanyut {
  from { transform: scale(1.04) translate3d(0, 0, 0); }
  to { transform: scale(1.18) translate3d(-2.5%, -1.5%, 0); }
}
/* Cover the box at 16:9 and crop YouTube's edges; clicks go to the page. */
.hero-media iframe {
  position: absolute; top: 50%; left: 50%; border: 0; pointer-events: none;
  width: max(120cqw, 213.4cqh); height: max(120cqh, 67.5cqw);
  transform: translate(-50%, -50%);
  opacity: 0; transition: opacity 1.2s ease;
}
.hero-media iframe.is-playing { opacity: 1; }
/* ---------- Hero with a framed video ----------
   A small self-hosted clip plays in a gold-edged frame beside the text, at
   or below its own size, so it stays sharp. */
.hero-framed {
  background-color: var(--merah-gelap); color: var(--krim-teks);
  background-image: radial-gradient(ellipse 55% 70% at 78% 45%, rgba(242, 184, 7, 0.16), transparent 70%);
}
.hero-framed .hero-in {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: center;
  padding-block: clamp(2.25rem, 5vw, 3.5rem) clamp(2.25rem, 4.5vw, 3.25rem);
}
.hero-framed h1 { color: var(--kuning); }
.hero-framed .hero-motto { color: var(--krim-teks); }
.hero-framed .hero-intro { color: rgba(247, 233, 198, 0.9); }
.hero-framed .btn-line { border-color: var(--krim-teks); color: var(--krim-teks); }
.hero-framed .btn-line:hover { background: rgba(247, 233, 198, 0.12); }
.hero-framed :focus-visible { outline-color: var(--kuning); }
.hero-framed .hero-jawi {
  text-align: left; color: var(--kuning); margin: 0 0 0.35rem;
  font-size: clamp(1.9rem, 3.2vw, 2.75rem); line-height: 1.5;
}
.hero-frame { margin: 0; width: 100%; max-width: 640px; justify-self: end; }
.hero-frame-media {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 10px;
  background: #2A060C; border: 2px solid var(--kuning);
  box-shadow: 0 0 0 6px rgba(242, 184, 7, 0.14), 0 28px 60px -24px rgba(0, 0, 0, 0.7);
}
.hero-frame-media .hero-poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 0.8s ease;
}
.hero-video.is-playing { opacity: 1; }
.hero-frame-cap {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 0.85rem;
  font-family: var(--f-head); font-size: 1.1rem; color: var(--krim-teks);
}
.hero-framed .hero-toggle { position: static; margin: 0; align-self: auto; flex: none; }
.hero-shade {
  position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(100deg, rgba(58, 8, 16, 0.94) 0%, rgba(58, 8, 16, 0.82) 42%, rgba(58, 8, 16, 0.5) 100%);
}
.hero-has-media h1 { color: var(--kuning); }
.hero-has-media .hero-motto { color: var(--krim-teks); }
.hero-has-media .hero-intro { color: rgba(247, 233, 198, 0.9); }
.hero-has-media .hero-jawi { color: var(--kuning); text-shadow: 0 2px 24px rgba(0, 0, 0, 0.35); }
.hero-has-media .btn-line { border-color: var(--krim-teks); color: var(--krim-teks); }
.hero-has-media .btn-line:hover { background: rgba(247, 233, 198, 0.12); }
.hero-has-media :focus-visible { outline-color: var(--kuning); }
.hero-toggle {
  position: absolute; z-index: 3; right: var(--gutter); bottom: calc(22px + 1rem);
  font: 600 0.8125rem var(--f-body); color: var(--krim-teks); cursor: pointer;
  background: rgba(58, 8, 16, 0.6); border: 1px solid rgba(247, 233, 198, 0.45); border-radius: 999px;
  padding: 0.5rem 0.95rem; min-height: 40px;
}
.hero-toggle:hover { background: rgba(58, 8, 16, 0.85); }

.rebung { height: 22px; background: var(--rebung-hero) repeat-x left bottom / 28px 22px; }
.hero .rebung { background-color: var(--kuning); position: relative; z-index: 2; }
.rebung-footer { background-image: var(--rebung-foot); background-color: var(--kertas); }

.btn {
  display: inline-flex; align-items: center; padding: 0.8rem 1.35rem; border-radius: 4px;
  font-weight: 600; font-size: 0.9375rem; text-decoration: none; line-height: 1.2;
}
.btn-ink { background: var(--merah-gelap); color: var(--kertas); }
.btn-ink:hover { background: var(--merah); }
.btn-gold { background: var(--kuning); color: var(--merah-gelap); }
.btn-gold:hover { background: #FFCB2E; }
.btn-line { border: 1.5px solid var(--merah-gelap); color: var(--merah-gelap); }
.btn-line:hover { background: rgba(255, 255, 255, 0.35); }

/* ---------- Home blocks ---------- */

.block { padding-block: clamp(3rem, 7vw, 5rem); }
.block + .block { border-top: 1px solid var(--garis); }
.block h2 { font-size: clamp(1.75rem, 3vw, 2.35rem); margin: 0; }
.block-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem 2rem; margin-bottom: 2rem; }
.block-note { margin: 0; color: var(--dakwat-2); font-size: var(--t-sm); }
.more { font-weight: 600; font-size: 0.9375rem; }

.dateline { margin: 0 0 0.4rem; font-size: var(--t-sm); color: var(--dakwat-2); }

.index-list a, .topic-list a { color: inherit; text-decoration: none; }

.since { background: var(--kuning-muda); }
.since-in { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2rem 4rem; align-items: start; }
.since h2 { font-size: clamp(1.9rem, 3.6vw, 2.8rem); max-width: 18ch; }
.since-text p { margin: 0 0 1rem; font-size: 1.125rem; max-width: 58ch; }

.topic-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); column-gap: 2.5rem; }
.topic-list li { border-top: 1px solid var(--garis); }
.topic-list a { display: block; padding-block: 1.15rem 1.3rem; }
.topic-title { display: block; font-family: var(--f-head); font-weight: 700; font-size: 1.35rem; line-height: 1.2; color: var(--merah-gelap); margin-bottom: 0.35rem; }
.topic-sum { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: 0.9375rem; color: var(--dakwat-2); }
.topic-list a:hover .topic-title { color: var(--merah); text-decoration: underline; text-decoration-thickness: 1px; }
.is-empty .topic-title, .is-empty .index-title { color: var(--dakwat-2); }
.is-empty .topic-sum, .is-empty .index-sum { font-style: italic; }

.palaces h2 { margin-bottom: 1.5rem; }
.palace-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.palace-list a {
  display: inline-block; padding: 0.55rem 1.1rem; border: 1px solid var(--garis); border-radius: 999px;
  font-family: var(--f-head); font-size: 1.15rem; color: var(--merah-gelap); text-decoration: none;
}
.palace-list a:hover { background: var(--kuning-muda); border-color: var(--kuning); }

/* Berita terkini: the office's Facebook and TikTok feeds as two equal cards. */
.news-social { background: var(--kuning-muda); }
/* Facebook's feed is at most 500px wide, so its card fits it exactly and
   TikTok takes the rest, enough room for its row of video thumbnails. */
.feed-grid { display: grid; grid-template-columns: minmax(0, 502px) minmax(0, 1fr); gap: clamp(1.25rem, 2.5vw, 2rem); align-items: stretch; }
.feed-card {
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  background: var(--kertas); border: 1px solid var(--garis); border-radius: 10px;
  box-shadow: 0 1px 0 var(--garis), 0 18px 40px -28px rgba(94, 12, 25, 0.35);
}
.feed-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem 1rem;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--garis);
}
.feed-id { min-width: 0; }
.feed-platform { margin: 0; font-size: 0.8125rem; font-weight: 600; color: var(--dakwat-2); }
.feed-name { margin: 0; font-family: var(--f-head); font-weight: 700; font-size: 1.2rem; line-height: 1.25; color: var(--merah-gelap); }
.btn-small { padding: 0.55rem 0.95rem; font-size: 0.875rem; background: var(--merah-gelap); color: var(--kertas); flex: none; }
.btn-small:hover { background: var(--merah); }
.feed-body { flex: 1; display: flex; justify-content: center; align-items: center; padding: 1rem; }
.feed-body.feed-fb { padding: 0; align-items: flex-start; }
/* TikTok switches to its wide layout (a full row of videos) above ~580px. */
.feed-body.feed-tt { padding: 0; }
/* Facebook draws the plugin at the width in its URL (max 500px). */
.feed-fb iframe { display: block; width: 100%; max-width: 500px; height: 540px; border: 0; }
.feed-tt .tiktok-embed { margin: 0; width: 100%; max-width: 780px; min-width: 288px; }
.feed-tt .tiktok-embed > section { padding: 1.25rem; text-align: center; }

.apps-in { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.2fr); gap: 1.5rem 3rem; align-items: start; }
.apps-in p { color: var(--dakwat-2); margin: 0.5rem 0 0; }
.app-list {
  list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap;
  gap: 1px; background: var(--garis); border: 1px solid var(--garis); border-radius: var(--radius); overflow: hidden;
}
.app-list li { flex: 1 1 12rem; }
.app-list a { display: flex; flex-direction: column; height: 100%; padding: 1rem 1.1rem; background: var(--kertas); text-decoration: none; color: var(--dakwat); }
.app-list a:hover { background: var(--kuning-muda); }
.app-name { font-weight: 700; color: var(--merah-gelap); }
.app-note { font-size: 0.8125rem; color: var(--dakwat-2); }

/* ---------- Inner pages ---------- */

.titleband { background: var(--kuning-muda); border-bottom: 1px solid var(--garis); padding-block: clamp(2rem, 5vw, 3.25rem) clamp(1.75rem, 4vw, 2.5rem); }
.titleband h1 { font-size: clamp(2.1rem, 4.6vw, 3.3rem); margin: 0; max-width: 24ch; }
.titleband .post-title { font-size: clamp(1.75rem, 3.4vw, 2.6rem); max-width: 32ch; }
.crumb { margin: 0 0 0.5rem; font-size: var(--t-sm); font-weight: 600; }
.crumb a { text-decoration: none; }
.crumb a:hover { text-decoration: underline; }
.lede { margin: 0.9rem 0 0; font-size: 1.125rem; color: var(--dakwat-2); max-width: 60ch; }
.post-meta { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; margin: 1rem 0 0; font-size: var(--t-sm); color: var(--dakwat-2); }
.post-dateline { font-weight: 600; color: var(--merah-gelap); }

.with-aside { display: grid; grid-template-columns: minmax(0, 1fr) 16rem; gap: 2rem 4.5rem; align-items: start; }
.wrap > .prose, .with-aside > .prose { padding-block: 2.5rem 4rem; }

.aside { position: sticky; top: calc(var(--masthead-h, 8.5rem) + 1.25rem); margin-top: 2.5rem; padding-left: 1.25rem; border-left: 1px solid var(--garis); }
.aside-h { margin: 0 0 0.6rem; font-family: var(--f-head); font-weight: 700; font-size: 1.2rem; }
.aside-h a { color: var(--merah-gelap); text-decoration: none; }
.aside ul { list-style: none; margin: 0; padding: 0; }
.aside li a { display: block; padding: 0.4rem 0.7rem; margin-left: -0.7rem; border-radius: 4px; color: var(--dakwat); text-decoration: none; font-size: 0.9375rem; line-height: 1.35; }
.aside li a:hover { background: var(--kuning-muda); }
.aside li a[aria-current="page"] { background: var(--kuning-muda); color: var(--merah-gelap); font-weight: 600; box-shadow: inset 3px 0 0 var(--kuning); }

.prose { max-width: 40rem; }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.1rem; }
.prose h2 { font-size: var(--t-xl); margin: 2.5rem 0 0.9rem; }
.prose h3 { font-size: var(--t-lg); margin: 2rem 0 0.6rem; color: var(--merah); }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin-block: 0.35rem; }
.prose li::marker { color: var(--merah); }
.prose strong { color: var(--merah-gelap); }
.prose blockquote {
  margin: 2.5rem 0 0; padding: 1.25rem 1.5rem; border-radius: var(--radius);
  background: var(--kuning-muda); font-family: var(--f-head); font-size: 1.2rem; line-height: 1.5; color: var(--merah-gelap);
}
.prose blockquote p { margin: 0; white-space: pre-line; }
/* Justified body text. The server inserts soft hyphens at Malay syllable
   breaks, so lines fill evenly instead of opening wide gaps. Phones stay
   left-aligned: their lines are too short for justification to look even. */
@media (min-width: 48rem) {
  .prose p, .prose li, .since-text p {
    text-align: justify; text-justify: inter-word; hyphens: manual;
  }
}
.prose p, .since-text p { text-wrap: pretty; }
.page-img { width: 100%; border-radius: var(--radius); margin-bottom: 1.75rem; }

/* Reign list on the Sejarah page is a real sequence, so it reads as a timeline. */
.page-sejarah-kesultanan ul { list-style: none; padding: 0; margin-left: 0.35rem; border-left: 2px solid var(--garis); }
.page-sejarah-kesultanan li { position: relative; padding: 0.35rem 0 0.35rem 1.4rem; margin: 0; }
.page-sejarah-kesultanan li::before {
  content: ""; position: absolute; left: -7px; top: 0.85rem; width: 12px; height: 12px; border-radius: 50%;
  background: var(--kuning); border: 2px solid var(--merah-gelap);
}
.page-sejarah-kesultanan li > strong:first-child { display: block; font-family: var(--f-head); font-size: 1.1rem; color: var(--merah); font-variant-numeric: tabular-nums; }

.gallery { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.6rem; }
.gallery a { display: block; border-radius: 6px; overflow: hidden; cursor: zoom-in; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; transition: transform 0.35s ease; }
.gallery a:hover img, .gallery a:focus-visible img { transform: scale(1.04); }
.page-img-link { display: block; cursor: zoom-in; }
.prose .gallery { padding: 0; }
.prose .gallery li { margin: 0; }

/* Flags: show each flag whole on a white card, never cropped. */
.page-bendera .gallery { grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; }
.page-bendera .gallery a {
  background: var(--kertas); border: 1px solid var(--garis); padding: 0.6rem;
  box-shadow: 0 1px 0 var(--garis); transition: border-color 0.2s ease, transform 0.2s ease;
}
.page-bendera .gallery a:hover, .page-bendera .gallery a:focus-visible { border-color: var(--kuning); transform: translateY(-2px); }
.page-bendera .gallery img { aspect-ratio: 1024 / 588; object-fit: contain; border-radius: 3px; background: var(--kuning-muda); }
.page-bendera .gallery a:hover img { transform: none; }
.page-bendera.prose { max-width: none; }

/* ---------- Photo viewer ---------- */

html.lb-open { overflow: hidden; }
.lightbox {
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; background: #1C050A; color: var(--krim-teks);
}
.lightbox::backdrop { background: #1C050A; }
.lightbox[open] { display: grid; place-items: center; animation: lb-in 0.2s ease; }
@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }
.lb-figure { margin: 0; width: 100%; height: 100%; display: grid; place-items: center; align-content: center; gap: 0.75rem; padding: 4.5rem 4.5rem 2.5rem; }
.lb-img {
  max-width: min(100%, 1400px); max-height: calc(100dvh - 8rem); width: auto; height: auto;
  object-fit: contain; border-radius: 4px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  opacity: 0; transition: opacity 0.25s ease;
}
.lb-img.is-loaded { opacity: 1; }
.lb-count { font-size: var(--t-sm); color: rgba(247, 233, 198, 0.8); font-variant-numeric: tabular-nums; }
.lb-btn {
  position: fixed; display: grid; place-items: center; width: 48px; height: 48px; padding: 0;
  border-radius: 50%; border: 1px solid rgba(247, 233, 198, 0.35); background: rgba(58, 8, 16, 0.75);
  color: var(--krim-teks); font: 400 1.6rem/1 var(--f-body); cursor: pointer;
}
.lb-btn:hover { background: var(--merah); border-color: var(--kuning); }
.lb-btn:focus-visible { outline: 3px solid var(--kuning); outline-offset: 2px; }
.lb-close { top: 1rem; right: 1rem; font-size: 1.2rem; }
.lb-prev { left: 1rem; top: 50%; transform: translateY(-50%); font-size: 2rem; }
.lb-next { right: 1rem; top: 50%; transform: translateY(-50%); font-size: 2rem; }
.lb-btn[hidden] { display: none; }
@media (max-width: 48rem) {
  .lb-figure { padding: 4rem 0.75rem 5.5rem; }
  .lb-img { max-height: calc(100dvh - 10rem); }
  .lb-prev, .lb-next { top: auto; bottom: 1.25rem; transform: none; }
  .lb-prev { left: calc(50% - 64px); }
  .lb-next { right: calc(50% - 64px); }
}

.videos { display: grid; gap: 2rem; margin-top: 0.5rem; }
.video { margin: 0; }
.video-frame { aspect-ratio: 16 / 9; background: var(--merah-gelap); border-radius: var(--radius); overflow: hidden; }
.video-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.video figcaption { margin-top: 0.6rem; font-family: var(--f-head); font-size: 1.15rem; line-height: 1.3; color: var(--merah-gelap); }
.video-source { display: block; margin-top: 0.2rem; font-family: var(--f-body); font-size: var(--t-sm); color: var(--dakwat-2); }

.map-frame { aspect-ratio: 4 / 3; margin-top: 2rem; border: 1px solid var(--garis); border-radius: var(--radius); overflow: hidden; background: var(--kuning-muda); }
.map-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
/* ---------- Organisation chart ----------
   Drawn in HTML so text stays sharp and the chart fits any width: a tree
   across the column when there is room, a vertical list when narrow. */
.page-carta-organisasi.prose { max-width: none; }
.orgchart { margin: 0 0 2rem; container-type: inline-size; }
.org-head {
  position: relative; width: fit-content; max-width: 100%; margin: 0 auto; padding: 0.9rem 1.6rem;
  text-align: center; font-family: var(--f-head); font-weight: 700; font-size: 1.3rem; line-height: 1.25;
  color: var(--kuning); background: var(--merah-gelap); border-radius: 8px;
  box-shadow: inset 0 -3px 0 var(--kuning);
}
.org-head::after { content: ""; position: absolute; left: 50%; top: 100%; width: 2px; height: 1.5rem; background: var(--merah-gelap); }
.prose .org-units {
  list-style: none; margin: 3rem 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.6rem;
}
.prose .org-units li { position: relative; margin: 0; }
/* Each unit draws its own drop line and its piece of the bar above. */
.org-units li::before { content: ""; position: absolute; left: 50%; top: -1.5rem; width: 2px; height: 1.5rem; background: var(--merah-gelap); }
.org-units li::after { content: ""; position: absolute; top: -1.5rem; left: -0.3rem; right: -0.3rem; height: 2px; background: var(--merah-gelap); }
.org-units li:first-child::after { left: 50%; }
.org-units li:last-child::after { right: 50%; }
.org-unit {
  display: flex; align-items: center; justify-content: center; height: 100%; min-height: 6.5rem;
  padding: 0.75rem 0.5rem; text-align: center; font-size: 0.875rem; font-weight: 600; line-height: 1.3;
  color: var(--merah-gelap); background: var(--kuning-muda); border: 1px solid var(--garis); border-radius: 8px;
  text-decoration: none; hyphens: auto;
}
a.org-unit:hover, a.org-unit:focus-visible { background: #FCEBB4; border-color: var(--kuning); }
.org-cap { margin-top: 1.25rem; font-size: var(--t-sm); text-align: center; }
@container (max-width: 44rem) {
  .org-head { margin: 0; text-align: left; }
  .org-head::after { left: 1.25rem; }
  .prose .org-units { display: flex; flex-direction: column; gap: 0.5rem; margin: 1.5rem 0 0 1.25rem; padding-left: 1.5rem; border-left: 2px solid var(--merah-gelap); }
  .org-units li::before { left: -1.5rem; top: 50%; width: 1.5rem; height: 2px; }
  .org-units li::after { display: none; }
  .org-unit { justify-content: flex-start; text-align: left; min-height: 0; padding: 0.8rem 1rem; font-size: 0.9375rem; }
  .org-cap { text-align: left; }
}

.contact { display: grid; grid-template-columns: 10rem minmax(0, 1fr); margin: 2rem 0 0; border-top: 1px solid var(--garis); }
.contact dt, .contact dd { margin: 0; padding: 0.85rem 0; border-bottom: 1px solid var(--garis); }
.contact dt { font-weight: 600; color: var(--merah-gelap); }

.index-list { list-style: none; margin: 0; padding: 2rem 0 4rem; max-width: 60rem; }
.index-list li { border-bottom: 1px solid var(--garis); }
.index-list a { display: grid; grid-template-columns: 18rem minmax(0, 1fr); gap: 0.25rem 2rem; padding-block: 1.25rem; }
.index-title { font-family: var(--f-head); font-weight: 700; font-size: 1.35rem; line-height: 1.25; color: var(--merah-gelap); }
.index-sum { color: var(--dakwat-2); font-size: 0.9375rem; }
.index-list a:hover .index-title { color: var(--merah); text-decoration: underline; text-decoration-thickness: 1px; }
.news-index a { grid-template-columns: 9rem minmax(0, 1fr); }
.news-index .dateline { grid-row: span 2; margin: 0.3rem 0 0; }
.news-index .index-sum { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.more-news { border-top: 1px solid var(--garis); padding-block: 2rem 4rem; max-width: 40rem; }
.more-news h2 { font-size: var(--t-lg); margin: 0 0 0.75rem; }
.more-news ul { list-style: none; margin: 0; padding: 0; }
.more-news li { padding-block: 0.45rem; }
.more-news a { color: var(--dakwat); text-decoration: none; }
.more-news a:hover { color: var(--merah); text-decoration: underline; }
.more-news .dateline { display: inline; margin-right: 0.6rem; }

/* ---------- Empty state ---------- */

.empty {
  position: relative; overflow: hidden; margin: 0 0 1rem;
  padding: calc(clamp(1.5rem, 4vw, 2.75rem) + 12px) clamp(1.5rem, 4vw, 2.75rem) clamp(1.5rem, 4vw, 2.5rem);
  background: var(--kuning-muda); border-radius: 8px;
}
.empty-mark { position: absolute; inset: 0 0 auto 0; height: 12px; background: var(--rebung-hero) repeat-x left bottom / 16px 12px; background-color: var(--kuning); transform: scaleY(-1); }
.empty .empty-h { font-size: clamp(1.5rem, 2.6vw, 1.9rem); margin: 0 0 0.6rem; }
.empty .empty-lede { margin: 0; color: var(--dakwat-2); max-width: 52ch; }
.empty .empty-next { margin-top: 1.75rem; }
.empty .empty-next-h { margin: 0 0 0.6rem; font-size: var(--t-sm); font-weight: 600; color: var(--dakwat-2); }
.empty .empty-next ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.empty .empty-next li { margin: 0; }
.empty .empty-next a {
  display: grid; gap: 0.15rem; padding: 0.85rem 1.1rem; text-decoration: none;
  background: var(--kertas); border: 1px solid var(--garis); border-radius: var(--radius);
}
.empty .empty-next a:hover { border-color: var(--kuning); }
.empty-next-title { font-family: var(--f-head); font-weight: 700; font-size: 1.2rem; line-height: 1.25; color: var(--merah-gelap); }
.empty-next-sum { font-size: var(--t-sm); color: var(--dakwat-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty .empty-contact { margin: 1.5rem 0 0; font-size: 0.9375rem; }
.wrap > .empty { margin-block: 2.5rem 4rem; }

/* ---------- Footer ---------- */

.footer { background: var(--merah-gelap); color: var(--krim-teks); margin-top: 0; }
.footer a { color: var(--krim-teks); }
.footer :focus-visible { outline-color: var(--kuning); }
.footer-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) repeat(3, minmax(0, 1fr)); gap: 2.5rem; padding-block: 3.5rem 2.5rem; }
.footer-crest { height: 5.5rem; width: auto; margin-bottom: 1rem; }
.footer-name { margin: 0; font-family: var(--f-head); font-weight: 700; font-size: 1.6rem; color: var(--kuning); line-height: 1.2; }
.footer-jawi { margin: 0.25rem 0 1rem; font-size: 1.5rem; color: var(--kuning); text-align: left; }
.footer address { font-style: normal; font-size: 0.9375rem; line-height: 1.7; }
.footer-h { margin: 0 0 0.6rem; font-size: 1.15rem; color: var(--kuning); }
.footer-h:not(:first-child) { margin-top: 1.5rem; }
.footer-list { list-style: none; margin: 0; padding: 0; font-size: 0.9375rem; }
.footer-list li { margin-block: 0.3rem; line-height: 1.45; }
.footer-list a { text-decoration: none; }
.footer-list a:hover { text-decoration: underline; }
.footer-base { border-top: 1px solid rgba(247, 233, 198, 0.18); padding-block: 1.25rem 2rem; font-size: 0.8125rem; color: rgba(247, 233, 198, 0.8); }
.footer-base p { margin: 0.25rem 0; }
.footer-base p:first-child { font-family: var(--f-head); font-size: 1.05rem; color: var(--krim-teks); }

/* ---------- Narrow screens ---------- */

@media (max-width: 60rem) {
  .with-aside { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .aside { position: static; margin: 0 0 3rem; }
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feed-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 48rem) {
  .hero-in, .since-in, .apps-in { grid-template-columns: minmax(0, 1fr); }
  .hero-jawi { order: -1; text-align: right; }
  .hero-shade { background: rgba(58, 8, 16, 0.84); }
  .hero-framed .hero-in { grid-template-columns: minmax(0, 1fr); }
  .hero-frame { justify-self: stretch; max-width: none; }
  /* On phones the button gets its own row under the banner text. */
  .hero-toggle { position: relative; right: auto; bottom: auto; align-self: flex-end; margin: -0.75rem var(--gutter) 1rem; }
  .index-list a, .news-index a { grid-template-columns: minmax(0, 1fr); }
  .news-index .dateline { grid-row: auto; }
  .contact { grid-template-columns: minmax(0, 1fr); }
  .contact dt { border-bottom: 0; padding-bottom: 0; }
  .feed-body, .feed-body.feed-tt { padding: 0.75rem; }
  .feed-head { padding: 0.85rem 1rem; }
  .feed-name { font-size: 1.05rem; }
  .wordmark-rumi { font-size: 1.45rem; }
  .crest { height: 2.9rem; }
  .wordmark-jawi { font-size: 1.25rem; }
}

@media (max-width: 48rem) {
  .more { display: inline-block; padding-block: 0.65rem; }
  .since-text .more { margin-top: -0.4rem; }
  .footer-list li { margin: 0; }
  .footer-list a { display: block; padding-block: 0.6rem; }
  .footer address a, .contact dd a { display: inline-block; padding-block: 0.6rem; margin-block: -0.6rem; }
  .more-news li { padding: 0; }
  .more-news a { display: block; padding-block: 0.7rem; }
  .topbar a { display: inline-block; padding-block: 0.35rem; }
  .topbar-in { padding-block: 0.2rem; }
}

@media (max-width: 30rem) {
  .footer-grid { grid-template-columns: minmax(0, 1fr); }
  .crest { height: 2.5rem; }
  .wordmark { gap: 0.65rem; }
  .wordmark-rumi { font-size: 1.2rem; line-height: 1.15; }
  .wordmark-jawi { font-size: 1.1rem; }
  .topbar-contact { gap: 0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-jawi { animation: none; }
  .hero-media iframe, .hero-video { transition: none; }
  .hero-motion .hero-poster { animation: none; }
  .hero-motion .hero-toggle { display: none; }
  .gallery img, .page-bendera .gallery a, .lightbox[open], .lb-img { transition: none; animation: none; }
  * { scroll-behavior: auto !important; }
}
