/* ==========================================================================
   ReCyF Tool - Base Styles (Reset, Typography, Global)
   ========================================================================== */

/* --- Font Faces --- */
@font-face {
  font-family: 'Montserrat';
  src: url('../fonts/montserrat-400-latin.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Montserrat';
  src: url('../fonts/montserrat-600-latin.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Montserrat';
  src: url('../fonts/montserrat-700-latin.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Mulish';
  src: url('../fonts/mulish-400-latin.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Mulish';
  src: url('../fonts/mulish-700-latin.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

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

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

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: var(--line-height);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden; /* app manages its own scrolling */
  height: 100vh;
  height: 100dvh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--color-dark);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }

a {
  color: var(--color-primary);
  text-decoration: none;
}
a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  background: none;
  font-size: inherit;
}

input, select, textarea {
  font-family: var(--font-body);
  font-size: var(--text-base);
}

/* --- V18: Form Input Focus Glow --- */
input[type="text"],
input[type="search"],
textarea,
select {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
  border-color: var(--color-primary);
  box-shadow: var(--focus-ring, 0 0 0 3px rgba(43, 122, 15, 0.15));
  outline: none;
}

table {
  border-collapse: collapse;
  width: 100%;
}

img {
  max-width: 100%;
  height: auto;
}

/* --- Skip Link (Accessibility) --- */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-primary);
  color: var(--color-bg);
  padding: var(--space-sm) var(--space-lg);
  z-index: var(--z-skip-link);
  transition: top 0.2s;
}
.skip-link:focus {
  top: 0;
}

/* --- Utility Classes --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.text-muted { color: var(--color-text-muted); }
.text-primary { color: var(--color-primary); }
.text-danger { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.text-success { color: var(--color-success); }
.text-info { color: var(--color-info); }

.font-semibold { font-weight: var(--weight-semibold); }
.font-bold { font-weight: var(--weight-bold); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }

.hidden:not(.skeleton-loading):not(.app) { display: none !important; }
.app.hidden { display: flex !important; opacity: 0; pointer-events: none; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* --- Focus Styles (Keyboard Navigation) --- */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}

/* Enhanced focus for small or dark-background interactive elements */
.score-dots__dot:focus-visible {
  outline-offset: 3px;
  box-shadow: 0 0 0 2px var(--color-primary-bg);
}
.accordion__header:focus-visible,
.ref-tabs__tab:focus-visible {
  outline-offset: -2px;
}
.sidebar__item:focus-visible {
  outline-color: #fff;
  outline-offset: -2px;
}
.card--clickable:focus-visible {
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

/* --- Noscript Notice --- */
.noscript-notice {
  padding: 2rem;
  text-align: center;
  font-family: sans-serif;
}

/* --- Loading Skeleton --- */
.skeleton-loading {
  height: 100vh;
  background: var(--color-header-bg, #111);
  overflow: hidden;
  transition: opacity 0.3s ease;
}
.skeleton-loading.hidden {
  display: block !important;  /* override .hidden to use opacity fade */
  opacity: 0;
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: -1;
}
.skeleton-header { height: 72px; background: var(--color-header-bg); }
.skeleton-body { display: flex; height: calc(100vh - 72px); }
.skeleton-sidebar { width: 240px; background: var(--color-sidebar-bg); flex-shrink: 0; }
.skeleton-main { flex: 1; padding: 24px; background: var(--color-bg); }
.skeleton-line { height: 16px; background: var(--color-bg-alt); border-radius: 4px; margin-bottom: 12px; }
.skeleton-line--lg { width: 60%; height: 24px; }
.skeleton-line--md { width: 45%; }
.skeleton-line--sm { width: 30%; }
.skeleton-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 24px; }
.skeleton-cards--spaced { margin-top: 24px; }
.skeleton-line--spaced { margin-top: 24px; }
.skeleton-card { height: 120px; background: var(--color-bg-alt); border-radius: 8px; }

@keyframes skeleton-pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.7; } }
.skeleton-line, .skeleton-card { animation: skeleton-pulse 1.5s ease-in-out infinite; }

/* --- Skeleton Utility Classes --- */
.skeleton-bar {
  width: 100%;
  height: 16px;
  background: var(--color-bg-alt);
  border-radius: 4px;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-circle {
  width: 40px;
  height: 40px;
  background: var(--color-bg-alt);
  border-radius: 50%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-text {
  width: 60%;
  height: 12px;
  background: var(--color-bg-alt);
  border-radius: 4px;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* --- V20: Staggered Scroll Reveal Delays --- */
.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  .skeleton-line, .skeleton-card, .skeleton-header, .skeleton-sidebar {
    animation: none;
  }

  /* Disable micro-interaction transforms */
  .btn:hover,
  .btn:active,
  .card:hover,
  .btn--primary:hover::after {
    transform: none !important;
  }

  .reveal-delay-1,
  .reveal-delay-2,
  .reveal-delay-3,
  .reveal-delay-4 {
    transition-delay: 0s !important;
  }
}

/* --- Page Transitions --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.main__content > *:first-child {
  animation: fadeIn 0.2s ease-out;
}

/* --- Mobile Notice Overlay --- */
.mobile-notice {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, 0.97);
  color: #fff;
  z-index: var(--z-notice);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  font-family: var(--font-body);
}

@media (max-width: 600px) {
  .mobile-notice:not(.mobile-notice--dismissed) {
    display: flex;
  }
}

.mobile-notice--dismissed {
  display: none !important;
}

.mobile-notice__title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
}

.mobile-notice__text {
  font-size: 14px;
  color: rgba(255,255,255,0.6);
  max-width: 400px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.mobile-notice__link {
  color: var(--color-primary);
  text-decoration: underline;
}

.mobile-notice__dismiss {
  margin-top: 20px;
  padding: 8px 20px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  cursor: pointer;
}

.mobile-notice__dismiss:hover {
  border-color: rgba(255,255,255,0.6);
  color: #fff;
}
