/* ==========================================================================
   TGSIMS  -  Base: reset, typography, helpers
   ========================================================================== */

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

* { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  font-size: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

img, picture, svg, video { display: block; max-width: 100%; }
svg { flex-shrink: 0; }

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button { background: none; border: none; cursor: pointer; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: none; }

ul, ol { list-style: none; }

h1, h2, h3, h4, h5 {
  line-height: var(--lh-tight);
  font-weight: var(--fw-bold);
  color: var(--text);
  letter-spacing: -0.02em;
}

/* Headings scale */
.h1 { font-size: var(--fs-3xl); font-weight: var(--fw-extra); }
.h2 { font-size: var(--fs-2xl); font-weight: var(--fw-extra); }
.h3 { font-size: var(--fs-xl); }
.h4 { font-size: var(--fs-lg); }

::selection { background: var(--brand-500); color: #fff; }

/* Focus visibility */
:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* Scrollbar (WebKit) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-full);
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ---- Text / color utilities ---- */
.text-muted { color: var(--text-muted); }
.text-dim   { color: var(--text-dim); }
.text-brand { color: var(--brand); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-nowrap { white-space: nowrap; }
.font-mono { font-family: var(--font-mono); }
.fw-semi { font-weight: var(--fw-semi); }
.fw-bold { font-weight: var(--fw-bold); }
.uppercase { text-transform: uppercase; letter-spacing: 0.06em; }

/* Inline icon sized to the surrounding text (for icons inside sentences/links) */
.i-inline { display: inline-block; width: 1em; height: 1em; vertical-align: -0.14em; }

/* ---- Layout utilities ---- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--sp-6);
}
.flex   { display: flex; }
.inline-flex { display: inline-flex; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }
.grid { display: grid; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }

/* ---- Visibility helpers ---- */
.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;
}

/* ---- Motion ---- */
.fade-in { animation: fadeIn var(--dur-slow) var(--ease-out) both; }
.rise-in { animation: riseIn var(--dur-slow) var(--ease-out) both; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes riseIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@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;
  }
}

/* Theme transition guard  -  prevents flash when toggling */
.theme-transition,
.theme-transition * {
  transition: background-color var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              color var(--dur) var(--ease) !important;
}
