/* ==========================================================================
   styles.css — Design Tokens, Typography, Utilities & Global Styles
   Justin Psaila Portfolio
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Custom Properties (Design Tokens)
   -------------------------------------------------------------------------- */
:root {
  /* Colours */
  --background:         #ffffff;
  --foreground:         #1a1a1a;
  --secondary:          #f6f6f6;
  --muted:              #eaeaea;
  --muted-foreground:   #666666;
  --accent:             #c84030; /* Darkened from #f06040 — passes WCAG AA 4.5:1 on white */
  --accent-foreground:  #ffffff;
  --border:             rgba(0, 0, 0, 0.08);
  --input-background:   #f6f6f6;
  --destructive:        #d4183d;
  --text-body-dark:     #364153;
  --text-secondary-dark:#4a5565;
  --divider:            #e5e7eb;
  --chapter-grey:       #5a6474; /* Darkened from #99a1af — passes WCAG AA 4.5:1 on white */

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
               Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
               sans-serif;
  --font-serif: Georgia, 'Times New Roman', serif;
  --font-size-base: 16px;

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Border radius */
  --radius-sm: 0.25rem;
  --radius:    0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 0.625rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast:   all 0.2s ease;
  --transition-base:   all 0.3s ease;
  --transition-slow:   all 0.7s ease;
}

/* --------------------------------------------------------------------------
   2. Base / Reset
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--foreground);
  background-color: var(--background);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --------------------------------------------------------------------------
   3. Typography Scale
   -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 500;
  line-height: 1.5;
  color: var(--foreground);
  margin-top: 0;
}

h1 { font-size: 1.5rem;   }
h2 { font-size: 1.25rem;  }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem;     }

p {
  font-size: 1rem;
  line-height: 1.5;
  margin-top: 0;
  margin-bottom: 1rem;
}

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

/* Display type — fluid, clamped */
.text-display-xl {
  font-size: clamp(3.5rem, 8vw, 7rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 400;
  margin: 0;
}

.text-display-lg {
  font-size: clamp(2.5rem, 5vw, 4.5rem);
  line-height: 1.15;
  letter-spacing: -0.015em;
  font-weight: 400;
  margin: 0;
}

.text-display-md {
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  font-weight: 400;
  margin: 0;
}

/* Serif italic for emphasis */
.serif-italic {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
}

/* Body utility classes */
.text-sm   { font-size: 0.875rem; }
.text-xs   { font-size: 0.75rem;  }
.text-lg   { font-size: 1.125rem; }

.leading-relaxed { line-height: 1.625; }

.tracking-wider { letter-spacing: 0.05em; }

.text-uppercase { text-transform: uppercase; }

.text-foreground        { color: var(--foreground) !important; }
.text-muted-foreground  { color: var(--muted-foreground) !important; }
.text-accent            { color: var(--accent) !important; }

/* --------------------------------------------------------------------------
   4. Responsive base font
   -------------------------------------------------------------------------- */
@media (max-width: 575.98px) {
  :root { --font-size-base: 15px; }
}

/* --------------------------------------------------------------------------
   5. Spacing utilities (supplement Bootstrap)
   -------------------------------------------------------------------------- */
.py-12 { padding-top: var(--space-12) !important; padding-bottom: var(--space-12) !important; }
.py-16 { padding-top: var(--space-16) !important; padding-bottom: var(--space-16) !important; }
.py-20 { padding-top: var(--space-20) !important; padding-bottom: var(--space-20) !important; }
.py-24 { padding-top: var(--space-24) !important; padding-bottom: var(--space-24) !important; }
.py-32 { padding-top: var(--space-32) !important; padding-bottom: var(--space-32) !important; }

.pt-12 { padding-top: var(--space-12) !important; }
.pb-12 { padding-bottom: var(--space-12) !important; }

@media (min-width: 768px) {
  .py-md-20 { padding-top: var(--space-20) !important; padding-bottom: var(--space-20) !important; }
  .py-md-24 { padding-top: var(--space-24) !important; padding-bottom: var(--space-24) !important; }
}

/* --------------------------------------------------------------------------
   6. Button Variants
   -------------------------------------------------------------------------- */

/* Shared button base */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
  padding: 0.625rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition-base);
  white-space: nowrap;
}

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

/* Primary: coral fill */
.btn-accent {
  background-color: var(--accent);
  color: var(--accent-foreground);
  border-color: var(--accent);
}

.btn-accent:hover,
.btn-accent:focus {
  background-color: rgba(240, 96, 64, 0.88);
  color: var(--accent-foreground);
  border-color: rgba(240, 96, 64, 0.88);
  text-decoration: none;
}

/* Outline: subtle border */
.btn-outline-secondary {
  background-color: transparent;
  color: var(--foreground);
  border-color: var(--border);
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
  background-color: var(--secondary);
  color: var(--foreground);
  border-color: var(--border);
  text-decoration: none;
}

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

.btn-outline-accent:hover,
.btn-outline-accent:focus {
  background-color: var(--accent);
  color: var(--accent-foreground);
  text-decoration: none;
}

/* Ghost / link */
.btn-ghost {
  background-color: transparent;
  color: var(--foreground);
  border-color: transparent;
  padding-left: 0;
  padding-right: 0;
}

.btn-ghost:hover,
.btn-ghost:focus {
  color: var(--accent);
  background-color: transparent;
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   7. Links & Hover Accent
   -------------------------------------------------------------------------- */
a {
  color: inherit;
  text-decoration: none;
  transition: color 0.25s ease;
}

a:hover { color: var(--accent); }

.hover-accent:hover { color: var(--accent) !important; }

/* --------------------------------------------------------------------------
   8. Focus States (WCAG AAA)
   -------------------------------------------------------------------------- */
*:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

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

/* --------------------------------------------------------------------------
   9. Skip Navigation (screen readers)
   -------------------------------------------------------------------------- */
.skip-nav {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 9999;
}

.skip-nav:focus {
  position: fixed;
  left: 1rem;
  top: 1rem;
  width: auto;
  height: auto;
  padding: 0.75rem 1.25rem;
  background-color: var(--accent);
  color: var(--accent-foreground);
  font-weight: 600;
  border-radius: var(--radius);
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Screen reader only */
.sr-only {
  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;
  white-space: nowrap !important;
  border: 0 !important;
}

/* --------------------------------------------------------------------------
   10. Transitions & Micro-interactions
   -------------------------------------------------------------------------- */
.transition-all    { transition: var(--transition-base); }
.transition-colors { transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease; }
.transition-transform { transition: transform 0.7s ease; }

/* --------------------------------------------------------------------------
   11. Images
   -------------------------------------------------------------------------- */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

img[loading="lazy"] {
  background-color: var(--muted);
}

/* --------------------------------------------------------------------------
   12. Scrollbar hide
   -------------------------------------------------------------------------- */
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.scrollbar-hide::-webkit-scrollbar { display: none; }

/* --------------------------------------------------------------------------
   13. Utility: line clamp
   -------------------------------------------------------------------------- */
.line-clamp-2 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.line-clamp-3 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

/* --------------------------------------------------------------------------
   14. Scroll-reveal animation base
   -------------------------------------------------------------------------- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

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

/* --------------------------------------------------------------------------
   15. Divider
   -------------------------------------------------------------------------- */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0;
}

/* --------------------------------------------------------------------------
   16. Badge / Tag
   -------------------------------------------------------------------------- */
.badge-tool {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.3125rem 0.625rem;
  border-radius: var(--radius-full);
  background-color: var(--secondary);
  color: var(--muted-foreground);
  border: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   17. Accessibility: high contrast & reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

@media (prefers-contrast: high) {
  :root {
    --foreground:       #000000;
    --background:       #ffffff;
    --border:           rgba(0, 0, 0, 0.4);
    --muted-foreground: #444444;
  }
}

/* --------------------------------------------------------------------------
   18. WCAG 2.2 AA — Touch Target Size (2.5.8)
   All interactive elements must have a clickable area of at least 24×24 CSS px.
   Inline links within body text are exempt.
   -------------------------------------------------------------------------- */

/* Buttons and anchor-buttons: enforce minimum target size */
.btn,
button {
  min-height: 44px; /* 44px provides comfortable touch; satisfies 2.5.8 and 2.5.5 */
  min-width: 44px;
}

/* Nav links */
.site-nav__link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

/* Footer icon links */
.site-footer__link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Back button */
.btn-back {
  min-height: 44px;
}

/* Gallery trigger buttons */
.gallery-item {
  min-height: 44px;
  min-width: 44px;
}

/* Lightbox close button */
.lightbox__close {
  min-height: 44px;
  min-width: 44px;
}

/* --------------------------------------------------------------------------
   19. Print
   -------------------------------------------------------------------------- */
@media print {
  .btn,
  nav,
  .skip-nav {
    display: none !important;
  }

  body {
    color: #000;
    background: #fff;
  }
}

/* --------------------------------------------------------------------------
   20. Back-to-top button
   -------------------------------------------------------------------------- */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 44px;
  height: 44px;
  min-height: 44px;
  min-width: 44px;
  background-color: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.22s ease, visibility 0.22s ease, transform 0.22s ease, background-color 0.15s ease;
  z-index: 89;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background-color: rgba(200, 64, 48, 0.88);
}

.back-to-top:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .back-to-top { transition: none; }
}

/* --------------------------------------------------------------------------
   21. Mobile nav toggle (base styles — responsive overrides live in
       components.css after the .site-nav__links flex declaration so the
       cascade works correctly)
   -------------------------------------------------------------------------- */
.site-nav__toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--foreground);
  cursor: pointer;
  padding: 0.25rem;
  min-height: 44px;
  min-width: 44px;
  border-radius: var(--radius);
  transition: color 0.15s ease;
}

.site-nav__toggle:hover { color: var(--accent); }

.site-nav__toggle:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* Required for mobile dropdown positioning */
.site-nav {
  position: relative;
}

/* --------------------------------------------------------------------------
   22. Active nav link
   -------------------------------------------------------------------------- */
.site-nav__link.is-active {
  color: var(--accent);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   23. Image skeleton shimmer (loading state)
   -------------------------------------------------------------------------- */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.img-skeleton {
  background: linear-gradient(
    90deg,
    var(--secondary) 25%,
    var(--muted)     50%,
    var(--secondary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius);
}

.project-card__img-wrap {
  position: relative;
  overflow: hidden;
  background-color: var(--secondary);
}

.project-card__img-wrap::before {
  content: '';
  display: block;
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    var(--secondary) 25%,
    color-mix(in srgb, var(--secondary) 60%, var(--muted)) 50%,
    var(--secondary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
  transition: opacity 0.3s ease;
  z-index: 1;
}

.project-card__img-wrap.img-loaded::before {
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .project-card__img-wrap::before { animation: none; }
}

/* --------------------------------------------------------------------------
   24. Work page filter bar
   -------------------------------------------------------------------------- */
/* Filter pill wrapper */
.work-filter {
  margin-top: 2.5rem;
  margin-bottom: 2rem;
}

/* Pill group */
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Individual pill */
.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 1.1rem;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--background);
  color: var(--muted-foreground);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  min-height: 36px;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.filter-pill:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.filter-pill.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.filter-pill:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.work-filter__empty {
  padding: 4rem 0;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 1rem;
}

/* --------------------------------------------------------------------------
   Animations (animations.js support)
   -------------------------------------------------------------------------- */

/* Cursor spotlight — ambient accent radial glow that follows the cursor.
   Positioned via JS (left/top). Desktop / fine-pointer only. */
.cursor-spotlight {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(200, 64, 48, 0.055) 0%,
    rgba(200, 64, 48, 0.02)  35%,
    transparent              70%
  );
  transform: translate(-50%, -50%);
  z-index: 0;
  opacity: 0;
  transition: opacity 0.5s ease;
  will-change: left, top;
}

/* Ensure sections and cards sit above the spotlight */
.hero,
.site-nav,
section,
.project-card,
.case-study-container {
  position: relative;
  z-index: 1;
}

/* Card tilt — enable 3D rendering context on the card grid item */
.project-card {
  transform-style: preserve-3d;
}

/* Reduced-motion overrides — belt-and-braces in addition to the JS gate */
@media (prefers-reduced-motion: reduce) {
  .cursor-spotlight { display: none; }
  .project-card     { transform: none !important; }
  .cs-chapter__accent-bar { width: 4rem !important; transition: none !important; }
}
