
/* ============================================================
   CAT ACADEMY IMIPAS — css/base.css
   v3.1 — STABLE FOUNDATION

   TANGGUNG JAWAB:
   - Modern CSS reset
   - HTML & body baseline
   - Root SPA
   - Media elements
   - Form reset
   - Link & typography
   - Lists, code, tables
   - Native details & dialog
   - Focus accessibility
   - Selection & scrollbar
   - Screen reader utilities
   - Reduced motion
   - High contrast
   - Print

   KOMPATIBILITAS:
   - css/variables.css
   - css/layout.css
   - css/components.css
   - css/utilities.css
   - SPA hash router
   - Firebase authentication pages
   - CAT simulator

   ATURAN:
   Tidak mengatur komponen khusus, layout,
   atau halaman tertentu.

   ============================================================ */


/* ============================================================
   1. MODERN CSS RESET
   ============================================================ */

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

html,
body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
figure,
blockquote,
dl,
dd,
ol,
ul,
fieldset,
legend,
pre,
hr {
  margin: 0;
  padding: 0;
}


/* ============================================================
   2. HTML BASELINE
   ============================================================ */

html {
  min-height: 100%;

  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;

  -webkit-tap-highlight-color:
    var(--tap-highlight, transparent);

  scroll-behavior: smooth;

  scroll-padding-top:
    calc(
      var(--topbar-height, 60px) +
      var(--safe-top, 0px) +
      16px
    );

  overflow-wrap: break-word;
}


/* ============================================================
   3. BODY BASELINE
   ============================================================ */

body {
  min-width: 0;

  min-height: 100vh;
  min-height: 100dvh;

  margin: 0;

  background:
    var(--bg-app, #0a1929);

  color:
    var(--text-primary, #ffffff);

  font-family:
    var(--font-sans, system-ui, sans-serif);

  font-size:
    var(--fs-base, 0.9375rem);

  font-weight:
    var(--fw-regular, 400);

  line-height:
    var(--lh-normal, 1.5);

  letter-spacing:
    var(--ls-normal, 0);

  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  text-rendering: optimizeLegibility;

  overflow-x: hidden;

  transition:
    background-color
      var(--duration-slow, 320ms)
      var(--ease-out, ease),
    color
      var(--duration-slow, 320ms)
      var(--ease-out, ease);
}


/* ============================================================
   4. SPLASH SCREEN SCROLL LOCK
   ============================================================ */

body.cat-splash-lock {
  overflow: hidden;
  overscroll-behavior: none;
}


/* ============================================================
   5. SPA ROOT
   ============================================================ */

#app {
  display: flex;
  flex-direction: column;

  position: relative;

  width: 100%;
  min-width: 0;

  min-height: 100vh;
  min-height: 100dvh;

  isolation: isolate;
}


/* ============================================================
   6. MEDIA ELEMENTS
   ============================================================ */

img,
picture,
video,
canvas {
  display: block;

  max-width: 100%;

  height: auto;
}

img,
video {
  border-style: none;
}

audio {
  max-width: 100%;
}

svg {
  display: block;

  max-width: 100%;

  vertical-align: middle;

  /*
   * Jangan set fill: currentColor.
   * Ikon Lucide/Feather menggunakan stroke.
   */
}

iframe,
embed,
object {
  max-width: 100%;
}

iframe {
  border: 0;
}

figure {
  max-width: 100%;
}

figcaption {
  margin-top:
    var(--space-2, 8px);

  color:
    var(--text-tertiary, #8ba3b8);

  font-size:
    var(--fs-xs, 12px);
}


/* ============================================================
   7. FORM RESET
   ============================================================ */

button,
input,
optgroup,
select,
textarea {
  font: inherit;

  color: inherit;

  letter-spacing: inherit;

  margin: 0;
}

button {
  cursor: pointer;

  text-transform: none;

  -webkit-tap-highlight-color:
    var(--tap-highlight, transparent);
}

button,
input[type="button"],
input[type="reset"],
input[type="submit"] {
  font-family: inherit;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
}

button:disabled {
  opacity: 0.55;
}

input::-ms-clear,
input::-ms-reveal {
  display: none;
}

input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
}

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 {
  -webkit-appearance: none;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

::-webkit-file-upload-button {
  -webkit-appearance: button;
  font: inherit;
}

textarea {
  resize: vertical;

  min-height: 120px;
}

fieldset {
  min-width: 0;
  border: 0;
}

legend {
  padding: 0;
}

label {
  display: inline-block;
  cursor: pointer;
}

output {
  display: inline-block;
}

::placeholder {
  color:
    var(--text-muted, #5b7893);

  opacity: 1;
}


/* ============================================================
   8. AUTOFILL THEME SUPPORT
   ============================================================ */

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color:
    var(--text-primary);

  -webkit-box-shadow:
    0 0 0 1000px
    var(--bg-surface-2)
    inset;

  caret-color:
    var(--text-primary);

  transition:
    background-color 5000s ease-in-out 0s;
}


/* ============================================================
   9. LINKS
   ============================================================ */

a {
  color:
    var(--text-link, #a0c1eb);

  text-decoration: none;

  text-underline-offset: 3px;

  transition:
    color
    var(--duration-fast, 120ms)
    var(--ease-out, ease);
}

a:hover {
  color:
    var(--accent-primary-hover, #a0c1eb);

  text-decoration: underline;
}

a:active {
  color:
    var(--accent-primary-active, #3884e6);
}

a:not([href]):not([class]) {
  color: inherit;
  text-decoration: none;
  cursor: default;
}


/* ============================================================
   10. HEADINGS
   ============================================================ */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family:
    var(--font-display, system-ui, sans-serif);

  font-weight:
    var(--fw-bold, 700);

  line-height:
    var(--lh-heading, 1.25);

  letter-spacing:
    var(--ls-tight, -0.02em);

  color:
    var(--text-primary);

  margin-bottom:
    var(--space-3, 12px);

  overflow-wrap: break-word;
}

@supports (text-wrap: balance) {
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    text-wrap: balance;
  }
}

h1 {
  font-size:
    var(--fs-3xl, 2rem);

  font-weight:
    var(--fw-extrabold, 800);

  line-height:
    var(--lh-tight, 1.2);
}

h2 {
  font-size:
    var(--fs-2xl, 1.625rem);
}

h3 {
  font-size:
    var(--fs-xl, 1.3125rem);
}

h4 {
  font-size:
    var(--fs-lg, 1.125rem);
}

h5 {
  font-size:
    var(--fs-md, 1rem);

  font-weight:
    var(--fw-semibold, 600);
}

h6 {
  font-size:
    var(--fs-base, 0.9375rem);

  font-weight:
    var(--fw-semibold, 600);

  text-transform: uppercase;

  letter-spacing:
    var(--ls-wider, 0.05em);

  color:
    var(--text-tertiary);
}


/* ============================================================
   11. PARAGRAPHS & INLINE TEXT
   ============================================================ */

p {
  margin-bottom:
    var(--space-4, 16px);

  line-height:
    var(--lh-relaxed, 1.65);

  overflow-wrap: break-word;
}

@supports (text-wrap: pretty) {
  p {
    text-wrap: pretty;
  }
}

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

small {
  font-size:
    var(--fs-sm, 0.8125rem);
}

strong,
b {
  font-weight:
    var(--fw-bold, 700);
}

em,
i {
  font-style: italic;
}

mark {
  background:
    var(--color-warning-100, #fef3c7);

  color:
    var(--color-navy-900, #0a1929);

  padding:
    0 var(--space-1, 4px);

  border-radius:
    var(--radius-xs, 4px);
}

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

  text-underline-offset: 3px;

  cursor: help;
}

sub,
sup {
  position: relative;

  font-size: 0.75em;

  line-height: 0;

  vertical-align: baseline;
}

sup {
  top: -0.5em;
}

sub {
  bottom: -0.25em;
}

hr {
  height: 1px;

  margin:
    var(--space-6, 24px) 0;

  border: 0;

  background:
    var(--border-default);
}


/* ============================================================
   12. BLOCKQUOTE
   ============================================================ */

blockquote {
  margin:
    var(--space-5, 20px) 0;

  padding:
    var(--space-3, 12px)
    var(--space-5, 20px);

  border-left:
    4px solid
    var(--accent-primary);

  background:
    var(--bg-muted);

  border-radius:
    0
    var(--radius-md, 12px)
    var(--radius-md, 12px)
    0;

  color:
    var(--text-secondary);

  font-style: italic;
}

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

blockquote cite {
  display: block;

  margin-top:
    var(--space-2, 8px);

  font-style: normal;

  font-size:
    var(--fs-sm, 0.8125rem);

  color:
    var(--text-tertiary);
}


/* ============================================================
   13. LISTS
   ============================================================ */

ul,
ol {
  padding-left:
    var(--space-5, 20px);

  margin-bottom:
    var(--space-4, 16px);
}

ul {
  list-style: disc;
}

ol {
  list-style: decimal;
}

li {
  margin-bottom:
    var(--space-2, 8px);

  line-height:
    var(--lh-relaxed, 1.65);
}

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

ul ul,
ol ol,
ul ol,
ol ul {
  margin-top:
    var(--space-2, 8px);

  margin-bottom: 0;
}

ul[role="list"],
ol[role="list"],
.list-unstyled {
  list-style: none;
  padding-left: 0;
}

dl {
  margin-bottom:
    var(--space-4, 16px);
}

dt {
  margin-top:
    var(--space-3, 12px);

  font-weight:
    var(--fw-semibold, 600);

  color:
    var(--text-primary);
}

dd {
  margin-top:
    var(--space-1, 4px);

  margin-left: 0;

  padding-left:
    var(--space-4, 16px);

  border-left:
    2px solid
    var(--border-subtle);

  color:
    var(--text-secondary);
}


/* ============================================================
   14. CODE / PRE / KBD
   ============================================================ */

code,
kbd,
samp,
pre {
  font-family:
    var(--font-mono, monospace);

  font-size: 0.9em;
}

code {
  padding: 2px 6px;

  background:
    var(--bg-code);

  border:
    1px solid
    var(--border-subtle);

  border-radius:
    var(--radius-xs, 4px);

  color:
    var(--text-brand);

  overflow-wrap: anywhere;
}

pre {
  display: block;

  max-width: 100%;

  margin-bottom:
    var(--space-4, 16px);

  padding:
    var(--space-4, 16px);

  background:
    var(--bg-surface-2);

  border:
    1px solid
    var(--border-subtle);

  border-radius:
    var(--radius-md, 12px);

  overflow-x: auto;

  line-height:
    var(--lh-normal, 1.5);

  tab-size: 2;

  -webkit-overflow-scrolling: touch;
}

pre code {
  display: block;

  padding: 0;

  border: 0;

  background: transparent;

  color:
    var(--text-primary);

  font-size: inherit;

  overflow-wrap: normal;

  white-space: pre;
}

kbd {
  display: inline-block;

  padding: 2px 6px;

  background:
    var(--bg-surface-3);

  border:
    1px solid
    var(--border-strong);

  border-bottom-width: 2px;

  border-radius:
    var(--radius-xs, 4px);

  color:
    var(--text-primary);

  font-size: 0.85em;

  font-weight:
    var(--fw-semibold, 600);

  line-height: 1.2;
}


/* ============================================================
   15. TABLE BASELINE
   ============================================================ */

table {
  width: 100%;

  border-collapse: collapse;

  border-spacing: 0;

  font-size:
    var(--fs-sm, 0.8125rem);
}

caption {
  caption-side: bottom;

  padding:
    var(--space-2, 8px) 0;

  font-size:
    var(--fs-xs, 0.75rem);

  color:
    var(--text-tertiary);

  text-align: left;
}

th,
td {
  text-align: left;

  vertical-align: top;
}


/* ============================================================
   16. NATIVE DETAILS & SUMMARY
   ============================================================ */

details > summary {
  cursor: pointer;
}

/*
 * Marker native dipertahankan.
 * Komponen accordion custom menggunakan
 * .accordion-trigger pada components.css.
 */


/* ============================================================
   17. FOCUS ACCESSIBILITY
   ============================================================ */

/*
 * Jangan menghapus outline global.
 * Browser tetap menyediakan fallback
 * untuk pengguna keyboard.
 */

:focus-visible {
  outline:
    2px solid
    var(--border-focus, #bed7f7);

  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline:
    2px solid
    var(--border-focus, #bed7f7);

  outline-offset: 3px;
}

/*
 * Untuk komponen tertentu, shadow fokus
 * dapat ditambahkan pada components.css.
 */


/* ============================================================
   18. TEXT SELECTION
   ============================================================ */

::selection {
  background:
    var(--selection-bg, #70a6ed);

  color:
    var(--selection-fg, #050d17);

  text-shadow: none;
}

::-moz-selection {
  background:
    var(--selection-bg, #70a6ed);

  color:
    var(--selection-fg, #050d17);
}


/* ============================================================
   19. SCROLLBAR
   ============================================================ */

* {
  scrollbar-width: thin;

  scrollbar-color:
    var(--border-default)
    transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background:
    var(--border-default);

  border-radius:
    var(--radius-pill, 999px);

  border: 2px solid transparent;

  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background:
    var(--border-strong);

  background-clip: padding-box;
}

::-webkit-scrollbar-corner {
  background: transparent;
}


/* ============================================================
   20. HIDDEN
   ============================================================ */

[hidden] {
  display: none !important;
}


/* ============================================================
   21. NATIVE DIALOG
   ============================================================ */

dialog {
  max-width: 100vw;

  max-height: 100vh;
  max-height: 100dvh;

  padding: 0;

  border: 0;

  background: transparent;

  color: inherit;
}

dialog:not([open]) {
  display: none;
}

dialog::backdrop {
  background:
    var(--bg-scrim, rgba(5,13,23,.72));

  backdrop-filter: blur(4px);

  -webkit-backdrop-filter: blur(4px);
}


/* ============================================================
   22. SCREEN READER UTILITIES
   ============================================================ */

.sr-only,
.visually-hidden {
  position: absolute !important;

  width: 1px !important;
  height: 1px !important;

  padding: 0 !important;

  margin: -1px !important;

  overflow: hidden !important;

  clip: rect(0, 0, 0, 0) !important;

  clip-path: inset(50%) !important;

  white-space: nowrap !important;

  border: 0 !important;
}


/* ============================================================
   23. SCREEN READER FOCUSABLE
   ============================================================ */

.sr-only-focusable:focus,
.sr-only-focusable:focus-visible,
.sr-only-focusable:active {
  position: static !important;

  width: auto !important;
  height: auto !important;

  padding:
    var(--space-2, 8px)
    var(--space-4, 16px) !important;

  margin: 0 !important;

  overflow: visible !important;

  clip: auto !important;

  clip-path: none !important;

  white-space: normal !important;
}


/* ============================================================
   24. SKIP LINKS
   ============================================================ */

/*
 * .skip-to-content utama dikelola
 * oleh layout.css.
 *
 * Alias .skip-link tetap disediakan.
 */

.skip-link {
  position: fixed;

  top: -120px;
  left:
    var(--space-4, 16px);

  z-index:
    var(--z-tooltip, 700);

  padding:
    var(--space-2, 8px)
    var(--space-4, 16px);

  background:
    var(--accent-primary);

  color:
    var(--text-on-accent);

  font-weight:
    var(--fw-semibold, 600);

  border-radius:
    var(--radius-md, 12px);

  box-shadow:
    var(--shadow-lg);

  text-decoration: none;

  transition:
    top
    var(--duration-base, 200ms)
    var(--ease-out, ease);
}

.skip-link:focus,
.skip-link:focus-visible {
  top:
    calc(
      var(--space-4, 16px) +
      var(--safe-top, 0px)
    );

  color:
    var(--text-on-accent);

  text-decoration: none;

  outline:
    2px solid currentColor;

  outline-offset: 2px;
}


/* ============================================================
   25. MOBILE SCROLLBAR
   ============================================================ */

@media (max-width: 768px) {
  ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }

  ::-webkit-scrollbar-thumb {
    border-width: 1px;
  }
}


/* ============================================================
   26. HIGH CONTRAST
   ============================================================ */

@media (prefers-contrast: more) {
  a:hover {
    text-decoration-thickness: 2px;
  }

  :focus-visible {
    outline-width: 3px;
  }
}


/* ============================================================
   27. REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;

    animation-iteration-count: 1 !important;

    transition-duration: 0.001ms !important;

    scroll-behavior: auto !important;
  }
}


/* ============================================================
   28. PRINT
   ============================================================ */

@media print {
  html,
  body {
    min-height: auto !important;

    background: #ffffff !important;

    color: #000000 !important;

    scroll-behavior: auto;
  }

  a {
    color: #000000 !important;

    text-decoration: underline !important;
  }

  img,
  svg {
    max-width: 100% !important;
  }

  pre {
    white-space: pre-wrap;

    overflow: visible;

    overflow-wrap: anywhere;
  }

  code,
  pre,
  kbd {
    background: #f5f5f5 !important;

    color: #000000 !important;

    border-color: #cccccc;
  }

  ::-webkit-scrollbar {
    display: none;
  }

  .skip-link {
    display: none !important;
  }

  body {
    transition: none !important;
  }
}
