/**
 * ============================================================
 * EduLab Interaktif
 * File        : assets/css/base.css
 * Deskripsi   : Fondasi CSS global, reset, aksesibilitas, dan elemen dasar.
 * Versi       : 1.0.0
 * Author      : EduLab Interaktif
 * ============================================================
 *
 * Fungsi file:
 * - Menetapkan reset CSS modern.
 * - Mengatur elemen dasar HTML dan body.
 * - Menyediakan fondasi tipografi.
 * - Menyediakan aksesibilitas dasar.
 * - Menyediakan scrollbar, selection, focus ring, dan utilitas global.
 *
 * Catatan:
 * - Variabel warna dan design token utama berasal dari:
 *   assets/css/themes.css
 * - Layout besar halaman diletakkan di:
 *   assets/css/layout.css
 * - Komponen UI diletakkan di:
 *   assets/css/components.css
 */

/* ============================================================
   1. Modern CSS Reset
============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  min-width: 320px;
  min-height: 100%;
  font-size: 16px;
  line-height: var(--leading-normal);
  scroll-behavior: smooth;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  background: var(--color-background);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  font-family: var(--font-primary);
  font-size: var(--text-base);
  font-weight: var(--font-regular);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background:
    var(--gradient-hero),
    var(--color-background);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition:
    background-color var(--transition-normal),
    color var(--transition-normal);
}

body.is-locked,
body[data-scroll-lock="true"] {
  overflow: hidden;
}

/* ============================================================
   2. Document Defaults
============================================================ */

:where(main, section, article, aside, header, footer, nav, figure, figcaption) {
  display: block;
}

:where(img, picture, video, canvas, svg) {
  display: block;
  max-width: 100%;
}

:where(img, video) {
  height: auto;
}

:where(svg) {
  flex-shrink: 0;
}

:where(iframe) {
  max-width: 100%;
  border: 0;
}

:where(hr) {
  height: 1px;
  border: 0;
  background: var(--color-border);
}

:where(table) {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
}

:where(th, td) {
  text-align: left;
  vertical-align: top;
}

:where(dialog) {
  border: 0;
}

:where(summary) {
  cursor: pointer;
}

:where(template) {
  display: none;
}

/* ============================================================
   3. Typography Base
============================================================ */

:where(h1, h2, h3, h4, h5, h6) {
  font-family: var(--font-display);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text-strong);
  text-wrap: balance;
}

h1 {
  font-size: clamp(var(--text-4xl), 6vw, var(--text-6xl));
}

h2 {
  font-size: clamp(var(--text-3xl), 4vw, var(--text-5xl));
}

h3 {
  font-size: clamp(var(--text-2xl), 3vw, var(--text-4xl));
}

h4 {
  font-size: clamp(var(--text-xl), 2.4vw, var(--text-3xl));
}

h5 {
  font-size: clamp(var(--text-lg), 2vw, var(--text-2xl));
}

h6 {
  font-size: var(--text-lg);
}

:where(p) {
  max-width: 72ch;
  color: var(--color-text-muted);
  text-wrap: pretty;
}

:where(strong, b) {
  font-weight: var(--font-bold);
  color: var(--color-text-strong);
}

:where(em, i) {
  font-style: italic;
}

:where(small) {
  font-size: var(--text-sm);
}

:where(mark) {
  padding: 0.08em 0.28em;
  border-radius: var(--radius-xs);
  color: var(--color-text-strong);
  background: var(--color-warning-soft);
}

:where(code, kbd, samp, pre) {
  font-family: var(--font-mono);
}

:where(code) {
  padding: 0.14em 0.34em;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-xs);
  font-size: 0.92em;
  color: var(--color-text-brand);
  background: var(--color-surface-muted);
}

:where(pre) {
  overflow-x: auto;
  padding: var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  color: var(--color-text);
  background: var(--color-surface-muted);
}

:where(pre code) {
  padding: 0;
  border: 0;
  border-radius: 0;
  color: inherit;
  background: transparent;
}

:where(kbd) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75em;
  min-height: 1.75em;
  padding: 0.1em 0.45em;
  border: 1px solid var(--color-border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
  font-size: 0.84em;
  font-weight: var(--font-semibold);
  color: var(--color-text);
  background: var(--color-surface-solid);
  box-shadow: var(--shadow-xs);
}

:where(blockquote) {
  padding: var(--space-5) var(--space-6);
  border-left: 4px solid var(--color-brand-500);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  color: var(--color-text-muted);
  background: var(--color-surface-muted);
}

:where(blockquote p) {
  color: inherit;
}

/* ============================================================
   4. Links
============================================================ */

:where(a) {
  color: var(--color-link);
  text-decoration: none;
  text-underline-offset: 0.18em;
  transition:
    color var(--transition-fast),
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    opacity var(--transition-fast);
}

:where(a:hover) {
  color: var(--color-link-hover);
}

:where(a:active) {
  color: var(--color-link-active);
}

:where(a[href^="tel:"],
a[href^="mailto:"]) {
  word-break: break-word;
}

/* ============================================================
   5. Lists
============================================================ */

:where(ul, ol) {
  padding-left: 1.25rem;
}

:where(li) {
  margin-block: 0.25rem;
}

:where(nav ul, nav ol, [role="list"]) {
  padding-left: 0;
  list-style: none;
}

/* ============================================================
   6. Forms, Buttons, Inputs
============================================================ */

:where(button, input, textarea, select, option) {
  font: inherit;
}

:where(button) {
  appearance: none;
  border: 0;
  cursor: pointer;
  color: inherit;
  background: transparent;
}

:where(button:disabled, input:disabled, textarea:disabled, select:disabled) {
  cursor: not-allowed;
  opacity: 0.58;
}

:where(input, textarea, select) {
  width: 100%;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-input);
  color: var(--input-text);
  background: var(--input-bg);
  transition:
    border-color var(--transition-fast),
    background-color var(--transition-fast),
    box-shadow var(--transition-fast),
    color var(--transition-fast);
}

:where(input, select) {
  min-height: 44px;
  padding: 0.75rem 1rem;
}

:where(textarea) {
  min-height: 120px;
  padding: 0.9rem 1rem;
  resize: vertical;
}

:where(input::placeholder, textarea::placeholder) {
  color: var(--input-placeholder);
  opacity: 1;
}

:where(select) {
  cursor: pointer;
}

:where(label) {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--color-text);
}

:where(fieldset) {
  min-width: 0;
  padding: var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
}

:where(legend) {
  padding-inline: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  color: var(--color-text-strong);
}

:where(input[type="checkbox"],
input[type="radio"]) {
  width: 1rem;
  height: 1rem;
  min-height: auto;
  padding: 0;
  accent-color: var(--color-brand-600);
}

:where(input[type="range"]) {
  padding: 0;
  border: 0;
  accent-color: var(--color-brand-600);
  background: transparent;
}

:where(input[type="file"]) {
  cursor: pointer;
}

:where(input[type="search"]) {
  appearance: textfield;
}

:where(input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration) {
  appearance: none;
}

/* ============================================================
   7. Focus Accessibility
============================================================ */

:where(a, button, input, textarea, select, summary, [tabindex]):focus {
  outline: none;
}

:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

:where(input, textarea, select):focus-visible {
  border-color: var(--input-border-focus);
  background: var(--input-bg-focus);
  box-shadow: var(--shadow-focus);
}

/* ============================================================
   8. Accessibility Helpers
============================================================ */

.skip-link {
  position: fixed;
  top: var(--space-4);
  left: var(--space-4);
  z-index: var(--z-tooltip);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border-focus);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  color: var(--button-primary-text);
  background: var(--button-primary-bg);
  box-shadow: var(--shadow-button);
  transform: translateY(calc(-100% - var(--space-8)));
  transition:
    transform var(--transition-normal),
    box-shadow var(--transition-normal);
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
}

.visually-hidden,
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  clip-path: inset(50%) !important;
  border: 0 !important;
  padding: 0 !important;
  margin: -1px !important;
}

.not-sr-only {
  position: static !important;
  width: auto !important;
  height: auto !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
  clip-path: none !important;
  margin: 0 !important;
}

[hidden] {
  display: none !important;
}

[aria-hidden="true"] {
  speak: none;
}

/* ============================================================
   9. Selection
============================================================ */

::selection {
  color: var(--selection-text);
  background: var(--selection-bg);
}

/* ============================================================
   10. Scrollbar
============================================================ */

html {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  border: 3px solid var(--scrollbar-track);
  border-radius: var(--radius-full);
  background: var(--scrollbar-thumb);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* ============================================================
   11. Media Defaults
============================================================ */

img {
  border-style: none;
}

img[width],
img[height] {
  height: auto;
}

svg {
  fill: currentColor;
}

video,
audio {
  width: 100%;
}

audio {
  min-height: 44px;
}

canvas {
  touch-action: none;
}

figure {
  margin: 0;
}

figcaption {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-soft);
}

/* ============================================================
   12. App-Level Base Classes
============================================================ */

.app-shell {
  position: relative;
  z-index: var(--z-base);
  min-height: 100vh;
  min-height: 100dvh;
}

.app-root {
  width: 100%;
}

.container {
  width: min(100% - calc(var(--container-padding) * 2), var(--container-max));
  margin-inline: auto;
}

.page-section {
  padding-block: clamp(var(--space-12), 8vw, var(--space-20));
}

.section-header {
  display: grid;
  gap: var(--space-3);
  max-width: 760px;
  margin-bottom: var(--space-8);
}

.section-eyebrow,
.eyebrow {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  gap: var(--space-2);
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--badge-border);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  line-height: 1;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--badge-text);
  background: var(--badge-bg);
}

.section-title {
  color: var(--color-text-strong);
}

.section-description {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
}

/* ============================================================
   13. Utility Classes: Display
============================================================ */

.block {
  display: block;
}

.inline-block {
  display: inline-block;
}

.inline-flex {
  display: inline-flex;
}

.flex {
  display: flex;
}

.grid {
  display: grid;
}

.contents {
  display: contents;
}

/* ============================================================
   14. Utility Classes: Alignment
============================================================ */

.items-center {
  align-items: center;
}

.items-start {
  align-items: flex-start;
}

.items-end {
  align-items: flex-end;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

/* ============================================================
   15. Utility Classes: Spacing
============================================================ */

.gap-1 {
  gap: var(--space-1);
}

.gap-2 {
  gap: var(--space-2);
}

.gap-3 {
  gap: var(--space-3);
}

.gap-4 {
  gap: var(--space-4);
}

.gap-5 {
  gap: var(--space-5);
}

.gap-6 {
  gap: var(--space-6);
}

.gap-8 {
  gap: var(--space-8);
}

.mt-2 {
  margin-top: var(--space-2);
}

.mt-4 {
  margin-top: var(--space-4);
}

.mt-6 {
  margin-top: var(--space-6);
}

.mt-8 {
  margin-top: var(--space-8);
}

.mb-2 {
  margin-bottom: var(--space-2);
}

.mb-4 {
  margin-bottom: var(--space-4);
}

.mb-6 {
  margin-bottom: var(--space-6);
}

.mb-8 {
  margin-bottom: var(--space-8);
}

/* ============================================================
   16. Utility Classes: Text
============================================================ */

.text-xs {
  font-size: var(--text-xs);
}

.text-sm {
  font-size: var(--text-sm);
}

.text-base {
  font-size: var(--text-base);
}

.text-lg {
  font-size: var(--text-lg);
}

.text-xl {
  font-size: var(--text-xl);
}

.text-muted {
  color: var(--color-text-muted);
}

.text-soft {
  color: var(--color-text-soft);
}

.text-strong {
  color: var(--color-text-strong);
}

.text-brand {
  color: var(--color-text-brand);
}

.font-medium {
  font-weight: var(--font-medium);
}

.font-semibold {
  font-weight: var(--font-semibold);
}

.font-bold {
  font-weight: var(--font-bold);
}

/* ============================================================
   17. Utility Classes: Surface
============================================================ */

.surface {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
}

.surface-solid {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  background: var(--color-surface-solid);
  box-shadow: var(--shadow-card);
}

.glass {
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
}

/* ============================================================
   18. Loading State Base
============================================================ */

.loading-state {
  display: grid;
  min-height: 240px;
  place-items: center;
  gap: var(--space-4);
  padding: var(--space-10);
  text-align: center;
  color: var(--color-text-muted);
}

.loading-state__spinner {
  width: 42px;
  height: 42px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-brand-600);
  border-radius: var(--radius-full);
  animation: edulab-spin 850ms linear infinite;
}

.loading-state__text {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--color-text-muted);
}

/* ============================================================
   19. Noscript Warning
============================================================ */

.noscript-warning {
  position: fixed;
  inset: 0;
  z-index: var(--z-toast);
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background: var(--overlay-bg-strong);
}

.noscript-warning__box {
  width: min(100%, 520px);
  padding: var(--space-8);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  color: var(--color-text);
  background: var(--color-surface-solid);
  box-shadow: var(--shadow-xl);
}

.noscript-warning__box h2 {
  margin-bottom: var(--space-3);
  font-size: var(--text-2xl);
}

.noscript-warning__box p {
  color: var(--color-text-muted);
}

/* ============================================================
   20. Print Base
============================================================ */

@media print {
  html {
    scroll-behavior: auto;
  }

  body {
    color: #000000;
    background: #ffffff !important;
  }

  *,
  *::before,
  *::after {
    box-shadow: none !important;
    text-shadow: none !important;
    background-image: none !important;
  }

  a {
    color: #000000;
    text-decoration: underline;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
  }

  img,
  svg,
  video,
  canvas {
    break-inside: avoid;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    break-after: avoid;
  }

  p,
  blockquote,
  table,
  pre {
    orphans: 3;
    widows: 3;
  }

  .skip-link,
  .site-nav,
  .hero-actions,
  .app-background,
  .loading-state,
  .noscript-warning {
    display: none !important;
  }
}

/* ============================================================
   21. Reduced Motion Safety
============================================================ */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

/* ============================================================
   22. Base Keyframes
============================================================ */

@keyframes edulab-spin {
  to {
    transform: rotate(360deg);
  }
}