/* ============================================================
   RIIF — Global Styles
   ============================================================ */

@import url('./variables.css');

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

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  tab-size: 4;
  height: 100%;
}

body {
  min-height: 100%;
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-white);
  overflow-x: hidden;
}

/* Block-level reset */
blockquote,
dl,
dd,
h1, h2, h3, h4, h5, h6,
hr,
figure,
p,
pre {
  margin: 0;
}

/* List reset */
ol, ul, menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Media reset */
img,
svg,
video,
canvas,
audio,
iframe,
embed,
object {
  display: block;
  vertical-align: middle;
  max-width: 100%;
}

img,
video {
  height: auto;
}

/* Form reset */
input,
button,
textarea,
select,
optgroup {
  font: inherit;
  color: inherit;
  margin: 0;
}

button,
[role="button"] {
  cursor: pointer;
  background: transparent;
  border: none;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Table */
table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* Typography baseline */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text-primary);
}

p {
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
}

strong, b {
  font-weight: var(--font-semibold);
}

/* Focus visible (accessibility) */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Remove focus outline for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================================
   2. SELECTION STYLING
   ============================================================ */

::selection {
  background-color: rgba(79, 70, 229, 0.15);
  color: var(--color-primary-700);
}

::-moz-selection {
  background-color: rgba(79, 70, 229, 0.15);
  color: var(--color-primary-700);
}

/* ============================================================
   3. SCROLLBAR STYLING (WebKit)
   ============================================================ */

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

::-webkit-scrollbar-track {
  background: var(--color-bg-light);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--color-primary-400), var(--color-purple-500));
  border-radius: var(--radius-full);
  border: 2px solid var(--color-bg-light);
  transition: background var(--duration-200) var(--ease-in-out);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--color-primary-600), var(--color-purple-700));
}

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

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-primary-400) var(--color-bg-light);
}

/* ============================================================
   4. LAYOUT UTILITIES
   ============================================================ */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-px);
}

.container--wide {
  max-width: var(--container-wide);
}

.container--narrow {
  max-width: var(--container-narrow);
}

.section {
  padding-block: var(--section-padding-y);
}

.section--sm {
  padding-block: var(--section-padding-y-md);
}

.section--lg {
  padding-block: calc(var(--section-padding-y) * 1.25);
}

/* Background alternating */
.section--white {
  background-color: var(--color-bg-white);
}

.section--light {
  background-color: var(--color-bg-light);
}

.section--blue {
  background-color: var(--color-bg-blue);
}

.section--dark {
  background: var(--gradient-dark);
  color: var(--color-text-inverse);
}

.section--hero {
  background: var(--gradient-hero);
  color: var(--color-text-inverse);
}

/* ============================================================
   5. GRID UTILITIES
   ============================================================ */

.grid {
  display: grid;
  gap: var(--grid-gap);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-auto-sm { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { display: flex; flex-direction: column; }
.flex-wrap { display: flex; flex-wrap: wrap; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* ============================================================
   6. TYPOGRAPHY UTILITIES
   ============================================================ */

.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-2xl    { font-size: var(--text-2xl); }
.text-3xl    { font-size: var(--text-3xl); }
.text-4xl    { font-size: var(--text-4xl); }
.text-5xl    { font-size: var(--text-5xl); }

.font-medium   { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold     { font-weight: var(--font-bold); }

.text-center { text-align: center; }
.text-left   { text-align: left; }
.text-right  { text-align: right; }

.text-primary   { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-muted     { color: var(--color-text-muted); }
.text-inverse   { color: var(--color-text-inverse); }
.text-brand     { color: var(--color-primary); }

/* Text Gradient */
.text-gradient {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}

.text-gradient-sky {
  background: var(--gradient-text-sky);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}

.text-gradient-aurora {
  background: var(--gradient-aurora);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}

/* ============================================================
   7. BUTTON SYSTEM
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.6875rem 1.5rem;       /* 11px 24px */
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  line-height: 1;
  letter-spacing: var(--tracking-wide);
  border-radius: var(--radius-btn);
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
  user-select: none;
  vertical-align: middle;
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}

/* Size variants */
.btn--sm {
  padding: 0.4375rem 1rem;  /* 7px 16px */
  font-size: var(--text-xs);
}

.btn--lg {
  padding: 0.875rem 2rem;   /* 14px 32px */
  font-size: var(--text-base);
  border-radius: var(--radius-lg);
}

.btn--xl {
  padding: 1.0625rem 2.5rem; /* 17px 40px */
  font-size: var(--text-lg);
  border-radius: var(--radius-lg);
}

.btn--pill {
  border-radius: var(--radius-btn-pill);
}

.btn--full {
  width: 100%;
}

/* --- Primary: Gradient Fill --- */
.btn-primary {
  background: var(--gradient-primary);
  color: var(--color-text-inverse);
  border-color: transparent;
  box-shadow: var(--shadow-primary-sm);
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-primary-vivid);
  opacity: 0;
  transition: opacity var(--duration-200) var(--ease-in-out);
  border-radius: inherit;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-primary);
}

.btn-primary:hover::before {
  opacity: 1;
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-primary-sm);
}

.btn-primary span {
  position: relative;
  z-index: 1;
}

.btn-primary > * {
  position: relative;
  z-index: 1;
}

/* --- Secondary: Dark Navy Fill --- */
.btn-secondary {
  background: var(--color-secondary);
  color: var(--color-text-inverse);
  border-color: var(--color-secondary);
}

.btn-secondary:hover {
  background: var(--color-navy-700);
  border-color: var(--color-navy-700);
  transform: translateY(-2px);
  box-shadow: var(--shadow-dark);
}

.btn-secondary:active {
  transform: translateY(0);
}

/* --- Outline: Bordered --- */
.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-outline:hover {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  transform: translateY(-2px);
  box-shadow: var(--shadow-primary-sm);
}

.btn-outline:active {
  transform: translateY(0);
}

.btn-outline--white {
  color: var(--color-text-inverse);
  border-color: rgba(255, 255, 255, 0.5);
}

.btn-outline--white:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--color-text-inverse);
  color: var(--color-text-inverse);
}

/* --- Ghost: Text Only --- */
.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--color-bg-light);
  color: var(--color-text-primary);
}

/* --- CTA: Animated Gradient --- */
.btn-cta {
  background-size: 200% auto;
  background-image: linear-gradient(135deg, #4F46E5 0%, #7C3AED 40%, #38BDF8 80%, #4F46E5 100%);
  color: var(--color-text-inverse);
  border-color: transparent;
  box-shadow: var(--shadow-primary-sm);
  animation: gradientShift 4s ease infinite;
}

.btn-cta:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: var(--shadow-primary);
}

/* ============================================================
   8. BADGE / TAG / CHIP
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.25rem 0.75rem;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  line-height: 1;
  border-radius: var(--radius-badge);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  white-space: nowrap;
}

.badge--primary {
  background: rgba(79, 70, 229, 0.1);
  color: var(--color-primary-600);
  border: 1px solid rgba(79, 70, 229, 0.2);
}

.badge--secondary {
  background: rgba(30, 27, 75, 0.08);
  color: var(--color-navy-700);
  border: 1px solid rgba(30, 27, 75, 0.15);
}

.badge--sky {
  background: rgba(56, 189, 248, 0.12);
  color: var(--color-sky-600);
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.badge--purple {
  background: rgba(167, 139, 250, 0.12);
  color: var(--color-violet-600);
  border: 1px solid rgba(167, 139, 250, 0.25);
}

.badge--success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge--warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge--error {
  background: var(--color-error-bg);
  color: var(--color-error);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Dot badge */
.badge::before {
  content: '';
  display: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge--dot::before {
  display: block;
}

/* Tag (no uppercase) */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.3125rem 0.75rem;
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  border-radius: var(--radius-md);
  background: var(--color-bg-light);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  transition: var(--transition-base);
  cursor: default;
}

.tag:hover {
  background: var(--gradient-primary-soft);
  color: var(--color-primary-700);
  border-color: rgba(79, 70, 229, 0.25);
}

/* ============================================================
   9. DIVIDER
   ============================================================ */

.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin-block: var(--space-6);
}

.divider--gradient {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-border-medium), transparent);
  margin-block: var(--space-8);
}

/* ============================================================
   10. HELPER UTILITIES
   ============================================================ */

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

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overflow-hidden { overflow: hidden; }
.relative        { position: relative; }
.absolute        { position: absolute; }

.rounded-sm   { border-radius: var(--radius-sm); }
.rounded-md   { border-radius: var(--radius-md); }
.rounded-lg   { border-radius: var(--radius-lg); }
.rounded-xl   { border-radius: var(--radius-xl); }
.rounded-2xl  { border-radius: var(--radius-2xl); }
.rounded-full { border-radius: var(--radius-full); }

/* Spacing helpers */
.mt-auto { margin-top: auto; }
.mb-4    { margin-bottom: var(--space-4); }
.mb-6    { margin-bottom: var(--space-6); }
.mb-8    { margin-bottom: var(--space-8); }
.mb-12   { margin-bottom: var(--space-12); }

.py-2    { padding-block: var(--space-2); }
.py-4    { padding-block: var(--space-4); }
.py-6    { padding-block: var(--space-6); }
.py-8    { padding-block: var(--space-8); }

/* ============================================================
   11. LINK STYLES
   ============================================================ */

.link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: var(--font-medium);
  transition: color var(--duration-200) var(--ease-in-out);
  position: relative;
}

.link::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform var(--duration-300) var(--ease-out);
}

.link:hover {
  color: var(--color-primary-700);
}

.link:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* ============================================================
   12. ICON WRAPPER
   ============================================================ */

.icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: var(--gradient-primary-soft);
  color: var(--color-primary);
  flex-shrink: 0;
  transition: var(--transition-smooth);
}

.icon-wrap--sm {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
}

.icon-wrap--lg {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-xl);
}

.icon-wrap--xl {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-2xl);
}

.icon-wrap--gradient {
  background: var(--gradient-primary);
  color: white;
}

.icon-wrap--sky {
  background: rgba(56, 189, 248, 0.12);
  color: var(--color-sky-500);
}

.icon-wrap--purple {
  background: rgba(167, 139, 250, 0.12);
  color: var(--color-violet-500);
}

/* ============================================================
   13. GLASS CARD UTILITY
   ============================================================ */

.glass {
  background: var(--glass-bg-light);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
}

.glass--dark {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border-dark);
  color: var(--color-text-inverse);
}

/* ============================================================
   14. HIGHLIGHT / MARK
   ============================================================ */

mark,
.highlight {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.12), rgba(124, 58, 237, 0.12));
  color: var(--color-primary-700);
  padding: 0.1em 0.3em;
  border-radius: var(--radius-sm);
}

/* ============================================================
   15. GRADIENT BORDER UTILITY
   ============================================================ */

.gradient-border {
  position: relative;
  background: var(--color-bg-white);
  border-radius: var(--radius-card);
}

.gradient-border::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: var(--gradient-primary);
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* ============================================================
   16. SKIP LINK (Accessibility)
   ============================================================ */

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: var(--z-toast);
  padding: var(--space-3) var(--space-6);
  background: var(--color-primary);
  color: white;
  border-radius: var(--radius-md);
  font-weight: var(--font-semibold);
  text-decoration: none;
  transition: top var(--duration-150) var(--ease-out);
}

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