/**
 * Bangkok GRAD — Base CSS
 * BG-008: Native HTML/CSS design system
 *
 * Contents:
 *   1. Reset and box model
 *   2. Document / root typography
 *   3. Heading hierarchy
 *   4. Body text and prose
 *   5. Links
 *   6. Lists
 *   7. Inline elements
 *   8. Images and media
 *   9. Focus and accessibility
 *   10. Utility classes
 */

/* ============================================================
   1. Reset and box model
   ============================================================*/

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

html {
  /* Prevent font scaling in landscape on iOS */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: 1rem;           /* 16px */
  line-height: 1.65;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* ============================================================
   2. Document / root typography
   ============================================================*/

/* Responsive type scale using clamp()
   BG-006 §16.3: headings 24-32px mobile, larger on desktop */

:root {
  --text-xs:   0.75rem;     /* 12px */
  --text-sm:   0.875rem;    /* 14px */
  --text-base: 1rem;        /* 16px */
  --text-lg:   1.125rem;    /* 18px */
  --text-xl:   1.25rem;     /* 20px */
  --text-2xl:  1.5rem;      /* 24px */
  --text-3xl:  clamp(1.625rem, 4vw, 2rem);       /* 26-32px */
  --text-4xl:  clamp(2rem,     4.5vw, 2.5rem);   /* 32-40px */
  --text-5xl:  clamp(2.25rem,  5vw,   3rem);     /* 36-48px */
  --text-6xl:  clamp(2.5rem,   6vw,   3.75rem);  /* 40-60px */
}

/* ============================================================
   3. Heading hierarchy
   ============================================================*/

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-navy);
  letter-spacing: -0.01em;
}

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-4xl); }
h3 { font-size: var(--text-3xl); }
h4 { font-size: var(--text-2xl); }
h5 { font-size: var(--text-xl); }
h6 { font-size: var(--text-lg); }

/* Heading spacing within content */
h1, h2, h3, h4, h5, h6 {
  margin-top: var(--space-7);
  margin-bottom: var(--space-4);
}

h1:first-child,
h2:first-child,
h3:first-child {
  margin-top: 0;
}

/* ============================================================
   4. Body text and prose
   ============================================================*/

p {
  margin-bottom: var(--space-5);
  max-width: 72ch;  /* comfortable reading line length */
}

p:last-child {
  margin-bottom: 0;
}

/* Article / report body prose */
.prose p {
  font-size: var(--text-lg);
  line-height: 1.75;
  max-width: 72ch;
}

.prose h2 {
  font-size: var(--text-3xl);
  margin-top: var(--space-9);
  margin-bottom: var(--space-5);
}

.prose h3 {
  font-size: var(--text-2xl);
  margin-top: var(--space-7);
  margin-bottom: var(--space-4);
}

.prose ul,
.prose ol {
  margin-bottom: var(--space-5);
  padding-left: var(--space-6);
}

.prose li {
  margin-bottom: var(--space-2);
  line-height: 1.65;
}

/* Lead paragraph (report intro) */
.prose-lead {
  font-size: var(--text-xl);
  line-height: 1.7;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-6);
}

/* ============================================================
   5. Links
   ============================================================*/

a {
  color: var(--color-navy);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-gold);
}

a:visited {
  color: var(--color-text-secondary);
}

/* Unstyled link (for cards, nav items) */
a.u-link-plain {
  color: inherit;
  text-decoration: none;
}

a.u-link-plain:hover {
  color: var(--color-gold);
  text-decoration: none;
}

/* ============================================================
   6. Lists
   ============================================================*/

ul, ol {
  margin-bottom: var(--space-4);
  padding-left: var(--space-6);
}

li {
  margin-bottom: var(--space-1);
}

/* Unstyled list */
.u-list-none {
  list-style: none;
  padding-left: 0;
  margin-bottom: 0;
}

/* ============================================================
   7. Inline elements
   ============================================================*/

strong, b {
  font-weight: 700;
}

em, i {
  font-style: italic;
}

small {
  font-size: var(--text-sm);
  color: var(--color-muted);
}

abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
}

/* ============================================================
   8. Images and media
   ============================================================*/

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

img {
  border-radius: var(--radius-sm);
}

/* Cover / hero image */
.u-img-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* ============================================================
   9. Focus and accessibility
   ============================================================*/

/* Visible focus ring for keyboard navigation */
:focus-visible {
  outline: 3px solid var(--color-gold);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Skip link */
.u-skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: var(--z-toast);
  padding: var(--space-3) var(--space-5);
  background: var(--color-navy);
  color: var(--color-gold);
  font-weight: 700;
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: top var(--transition-fast);
}

.u-skip-link:focus {
  top: var(--space-4);
}

/* Screen-reader only */
.u-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   10. Utility classes
   ============================================================*/

/* Text sizes */
.u-text-xs   { font-size: var(--text-xs); }
.u-text-sm   { font-size: var(--text-sm); }
.u-text-base { font-size: var(--text-base); }
.u-text-lg   { font-size: var(--text-lg); }
.u-text-xl   { font-size: var(--text-xl); }

/* Text color */
.u-text-muted     { color: var(--color-muted); }
.u-text-secondary { color: var(--color-text-secondary); }
.u-text-gold      { color: var(--color-gold); }
.u-text-navy      { color: var(--color-navy); }
.u-text-inverse   { color: var(--color-text-inverse); }

/* Font weight */
.u-font-medium  { font-weight: 500; }
.u-font-semibold { font-weight: 600; }
.u-font-bold    { font-weight: 700; }

/* Display */
.u-block        { display: block; }
.u-inline-block { display: inline-block; }
.u-hidden       { display: none; }

/* Spacing helpers */
.u-mt-0  { margin-top: 0; }
.u-mb-0  { margin-bottom: 0; }
.u-mt-2  { margin-top: var(--space-2); }
.u-mb-2  { margin-bottom: var(--space-2); }
.u-mt-4  { margin-top: var(--space-4); }
.u-mb-4  { margin-bottom: var(--space-4); }
.u-mt-6  { margin-top: var(--space-6); }
.u-mb-6  { margin-bottom: var(--space-6); }

/* Text alignment */
.u-text-center { text-align: center; }
.u-text-right  { text-align: right; }
