/* ==========================================================================
   Malaysia Boleh - base design system
   Glassmorphism, static theme colours (no gradients/orbs/blobs)
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/*
  Any element carrying the `hidden` attribute must stay hidden even if a
  class on it also sets `display` (e.g. .state-banner/.fa-loading use
  `display: flex`, which ties [hidden]'s specificity and would otherwise
  win the cascade by appearing later in this stylesheet).
*/
[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
}

body {
  font-family: "Jua", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.glass,
.btn,
.page-card,
a {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease,
    box-shadow 0.15s ease, transform 0.15s ease;
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

img, svg {
  display: block;
  max-width: 100%;
}

input, select, textarea, button {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

a {
  color: var(--brand-strong);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

::selection {
  background: var(--brand);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--brand-strong);
  outline-offset: 2px;
}

.icon {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
  stroke: currentColor;
}

/* -- Layout -- */

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 48px;
}

img {
  max-width: 100%;
}

table {
  max-width: 100%;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* -- Topbar -- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  color: var(--ink);
  min-width: 0;
}

.brand-mark img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
}

.brand-mark span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-spacer {
  flex: 1;
  min-width: 8px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* -- Buttons -- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:hover {
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn:disabled:hover {
  box-shadow: none;
  transform: none;
}

.btn-primary {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  color: #fff;
}

.btn-coffee {
  background: var(--surface);
  color: var(--ink);
}

.btn-coffee .icon {
  color: var(--brand-strong);
}

/* -- Glass card -- */

.glass {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

/* -- Hero -- */

.hero {
  padding: 40px 0 24px;
  text-align: left;
}

.hero h1 {
  font-size: 2.1rem;
  margin-bottom: 10px;
  color: var(--ink);
}

.hero p {
  color: var(--muted);
  max-width: 560px;
  margin: 0;
}

/* Homepage hero only - other pages keep the left-aligned .hero default. */
.home-hero {
  text-align: center;
}

.home-hero p {
  margin: 0 auto;
}

/* -- Page grid (directory cards) -- */

.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 28px;
}

.page-card {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.page-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.1);
  text-decoration: none;
}

.page-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--brand);
  color: var(--brand-strong);
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-card-icon .icon {
  width: 22px;
  height: 22px;
}

.page-card h3 {
  color: var(--ink);
  font-size: 1.1rem;
}

.page-card p {
  color: var(--muted);
  font-size: 0.92rem;
}

/* -- Modal -- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 25, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.2s ease, visibility 0s linear;
}

.modal-panel {
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 24px;
  background: var(--surface-solid);
  transform: translateY(12px) scale(0.98);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.modal-overlay.open .modal-panel {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.modal-header h2 {
  font-size: 1.2rem;
  color: var(--ink);
}

.modal-close {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 6px;
  border-radius: 8px;
}

.modal-close:hover {
  background: var(--brand);
}

.modal-sub {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 18px;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.4);
  text-align: left;
}

.theme-option[aria-pressed="true"] {
  border-color: var(--brand-strong);
  box-shadow: 0 0 0 2px var(--brand-strong) inset;
}

.theme-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.theme-option span {
  font-size: 0.85rem;
  color: var(--ink);
}

.theme-check {
  margin-left: auto;
  width: 16px;
  height: 16px;
  color: var(--brand-strong);
  visibility: hidden;
}

.theme-option[aria-pressed="true"] .theme-check {
  visibility: visible;
}

/* -- Status banners / data states -- */

@keyframes panelFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.state-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 14px;
  margin: 18px 0;
  font-size: 0.92rem;
  animation: panelFadeIn 0.2s ease;
}

.state-banner.info {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}

.state-banner.warn {
  background: rgba(234, 88, 12, 0.1);
  border: 1px solid rgba(234, 88, 12, 0.3);
  color: #9a3412;
}

.state-banner.danger {
  background: rgba(185, 28, 28, 0.1);
  border: 1px solid rgba(185, 28, 28, 0.3);
  color: #991b1b;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--brand-strong);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* -- Footer -- */

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 24px 0 40px;
}

.site-footer a {
  color: var(--muted);
  text-decoration: underline;
}

.footer-sources {
  margin-top: 4px;
  font-size: 0.78rem;
  opacity: 0.8;
}

.footer-heart {
  /* Intentionally a fixed green, independent of the active accent theme. */
  display: inline-block;
  color: #2f9e44;
  vertical-align: -2px;
  margin: 0 1px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.92rem;
}

@media (max-width: 560px) {
  .hero {
    padding: 32px 0 18px;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .hero p {
    font-size: 0.92rem;
  }

  .topbar-inner {
    padding: 12px 14px;
  }

  .btn span.btn-label {
    display: none;
  }

  .btn {
    padding: 9px 12px;
  }

  .container {
    padding: 0 14px 36px;
  }

  .modal-panel {
    padding: 18px;
  }

  .theme-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 380px) {
  .brand-mark span {
    display: none;
  }
}
