/* ============================================================
   HIR Dashboard — shared styles
   Design tokens + reusable component classes.
   Page-specific layout styles stay in each page's <style> block.
   ============================================================ */

/* ---------- Fonts (Thai webfonts) ---------- */
@import url('https://fonts.googleapis.com/css2?family=Mitr:wght@200;300;400;500;600;700&family=Noto+Sans+Thai:wght@100..900&family=Prompt:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Sarabun:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800&display=swap');

/* ---------- Design tokens ---------- */
:root {
  /* Brand palette (matches the charts) */
  --brand-blue: #2d8bba;
  --brand-teal: #41b8d5;
  --brand-teal-light: #6ce5e8;

  /* Semantic accents */
  --success: #16a34a;
  --link: #2563eb;

  /* Neutral slate scale */
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --surface-hover: #f1f5f9;
  --border-muted: #eef2f6;
  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-primary: #1e293b;
  --text-body: #334155;
  --text-muted: #94a3b8;

  /* Typography */
  --font-thai: "Prompt", "Noto Sans Thai", serif;

  /* Shape & elevation */
  --radius: 10px;
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.08);
}

/* Dashboard content font (scoped so other pages are unaffected;
   the previous rule was invalid CSS and never actually applied) */
#observablehq-main {
  font-family: var(--font-thai);
}

/* ---------- Hero headings ---------- */
.hero {
  display: flex;
  flex-direction: column;
  font-family: var(--font-thai);
  text-wrap: balance;
}

.hero h1 {
  margin: 1rem 0;
  padding: 1rem 0;
  max-width: none;
  font-size: 12vw;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(30deg, var(--theme-foreground-focus), currentColor);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero h2 {
  margin: 0;
  max-width: 34em;
  font-size: 20px;
  font-style: initial;
  font-weight: 500;
  line-height: 1.5;
  color: var(--theme-foreground-muted);
}

@media (min-width: 640px) {
  .hero h1 {
    font-size: 90px;
  }
}

@media (max-width: 1024px) {
  .hero h1 {
    font-size: 32px;
  }

  .hero h2 {
    font-size: 18px;
  }
}

@media (max-width: 640px) {
  .hero h1 {
    font-size: 24px;
  }

  .hero h2 {
    font-size: 14px;
  }
}

/* ---------- Data table (HIR) ---------- */
.hir-table-wrap {
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.hir-table-class {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
  line-height: 1.45;
  table-layout: fixed;  /* Force table to respect column widths */
  box-sizing: border-box;
  color: var(--text-body);
}

.hir-table-class th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-muted);
  color: var(--text-primary);
  font-weight: 600;
  text-align: center;
  vertical-align: middle;
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--border-color);
}

.hir-table-content-class {
  padding: 0.55rem 0.75rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-muted);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.hir-table-class tbody tr:nth-child(even) {
  background: var(--surface-muted);
}

.hir-table-class tbody tr:hover {
  background: var(--surface-hover);
}

.hir-table-center { text-align: center; }

/* a[href] is needed to out-rank the framework's own `a[href]` link rule */
a.hir-icon-link  { color: var(--link); }
a.hir-icon-muted { color: var(--text-muted); pointer-events: none; }
a.hir-icon-check { color: var(--success); }
a.hir-notes-link { color: var(--link); text-decoration: none; }
a.hir-notes-link:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .hir-table-class {
    font-size: 10px;
  }

  .hir-table-content-class {
    padding: 0.25rem 0.35rem;
  }

  .hir-table-class th {
    padding: 0.35rem;
  }
}

/* ---------- PDF modal ---------- */
.modal {
  display: none; /* Hidden by default */
  position: fixed; /* Stay in place */
  z-index: 1000; /* Higher than other elements */
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7); /* Dark background with transparency */
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px); /* Adds a subtle blur effect */
}

.modal-content {
  position: relative; /* anchors the close button to this panel */
  background-color: var(--surface);
  width: 90%;
  max-width: 900px; /* Limit width on large screens */
  height: 90vh;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.2);
}

.modal iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.close {
  color: white;
  position: absolute;
  top: 15px;
  right: 25px;
  font-size: 30px;
  font-weight: bold;
  background: black;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.close:hover {
  background: red;
  color: white;
}

/* ---------- Modal — small screens ---------- */
@media (max-width: 640px) {
  .modal-content {
    width: 96%;
    height: 92vh;
    border-radius: 8px;
  }

  .close {
    top: 8px;
    right: 10px;
    font-size: 22px;
    width: 32px;
    height: 32px;
  }
}

/* ---------- Tailwind utility replacements (index.md only) ---------- */
.grid-rows-5 {
  grid-template-rows: repeat(5, minmax(0, 1fr));
}

/* ---------- Dashboard header & footer (moved from the DDC CMS page) ---------- */
.dash-title {
  font-family: var(--font-thai);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 12px 0;
}

.dash-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

/* Height-based sizing: the DDC emblem is square (2084x2084) and Picture3 is
   wide (1496x852) — width-percentage sizing made the emblem enormous */
.dash-header img {
  height: 96px;
  width: auto;
  max-width: 100%;
}

.dash-header-text {
  flex: 1;
  min-width: 240px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-body);
}

.dash-header-text p { margin: 0; }

.dash-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-body);
}

.dash-footer p { margin: 0; }
