/* ============================================
   CodeCraftedApps - Global Stylesheet
   Dark theme, modern, minimal
   ============================================ */

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

:root {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d27;
  --bg-card: #1e2130;
  --bg-card-hover: #252839;
  --text-primary: #e8e9ed;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.15);
  --border: #2a2d3a;
  --border-hover: #3b82f6;
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 1100px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', monospace;
  /* Spacing scale */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
}

html {
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--bg-primary);
}

/* --- Scrollbar (Webkit) --- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

/* Focus styles for keyboard navigation */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

img {
  max-width: 100%;
  display: block;
}

/* --- Layout --- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

main {
  flex: 1;
}

/* --- Header / Nav --- */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  background: rgba(15, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.site-logo span {
  color: var(--accent);
}

.site-nav {
  display: flex;
  gap: 28px;
  align-items: center;
}

.site-nav a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  position: relative;
  transition: color 0.2s ease;
}

.site-nav a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.site-nav a:hover::after,
.site-nav a.active::after {
  width: 100%;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--text-primary);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
}

/* --- Hero Section --- */
.hero {
  padding: 80px 0 60px;
  text-align: center;
  background: linear-gradient(to bottom, var(--accent-glow), transparent);
  /* To swap in a real banner image:
     background: linear-gradient(to bottom, rgba(15,17,23,0.55), var(--bg-primary)),
                 url('../images/hero-banner.jpg') center/cover no-repeat; */
}

.hero h1 {
  font-size: 2.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 16px;
}

.hero h1 span {
  color: var(--accent);
}

.hero .tagline {
  font-size: 1.2rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 12px;
  line-height: 1.5;
}

.hero .sub-tagline {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* --- Section --- */
.section {
  padding: 60px 0;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.section-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 36px;
}

/* --- Project Cards Grid --- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.project-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  box-shadow: 0 0 20px var(--accent-glow);
  transform: translateY(-2px);
}

.project-card .card-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 20px;
  width: fit-content;
}

.badge-app {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.badge-tool {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.badge-coming-soon {
  background: rgba(156, 163, 175, 0.15);
  color: #9ca3af;
}

.project-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.project-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.55;
  flex-grow: 1;
}

.project-card .card-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 4px;
}

.project-card .card-link::after {
  content: '\2192';
  transition: transform 0.2s ease;
}

.project-card:hover .card-link::after {
  transform: translateX(4px);
}

/* --- About Section --- */
.about-content {
  max-width: 700px;
}

.about-content p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 16px;
}

/* --- Page Header (for sub-pages) --- */
.page-header {
  padding: 60px 0 40px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, var(--accent-glow), transparent);
  /* To swap in a real banner image:
     background: linear-gradient(to bottom, rgba(15,17,23,0.6), var(--bg-primary)),
                 url('../images/page-banner.jpg') center/cover no-repeat; */
}

.page-header h1 {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* --- Legal / Content Pages --- */
.content-section {
  padding: 48px 0;
}

.content-body {
  max-width: 750px;
}

.content-body h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: 36px;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

.content-body h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 28px;
  margin-bottom: 10px;
}

.content-body p {
  color: var(--text-secondary);
  font-size: 0.93rem;
  line-height: 1.75;
  margin-bottom: 14px;
}

.content-body ul,
.content-body ol {
  color: var(--text-secondary);
  font-size: 0.93rem;
  line-height: 1.75;
  margin-bottom: 14px;
  padding-left: 24px;
}

.content-body li {
  margin-bottom: 6px;
}

.content-body a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* --- Contact Page --- */
.contact-methods {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 8px;
}

.contact-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

.contact-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.contact-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 12px;
}

.contact-card a {
  font-weight: 600;
  font-size: 0.9rem;
}

/* --- Footer --- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: 40px;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-copyright {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer-links a {
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: color 0.2s ease;
}

.footer-links a:hover {
  color: var(--text-secondary);
}

/* --- Skip Link --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  background: var(--accent);
  color: var(--bg-primary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  z-index: 200;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 8px;
}

/* --- Back to Top --- */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease, background 0.2s ease, border-color 0.2s ease;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Breadcrumbs --- */
.breadcrumbs {
  padding: 12px 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.breadcrumbs a {
  color: var(--text-muted);
  transition: color 0.2s ease;
}

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

.breadcrumbs .separator {
  margin: 0 8px;
  opacity: 0.5;
}

/* --- Scroll Reveal --- */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

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

/* --- Tiled Background Watermark --- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: url('codecraftedbackground.png') repeat center center;
  background-size: 400px;
  opacity: 0.03;
  filter: invert(1);
  pointer-events: none;
}

/* --- Noise Texture Overlay --- */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.02;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* --- Richer Footer --- */
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}

.footer-brand .site-logo {
  margin-bottom: 8px;
}

.footer-brand .footer-tagline {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.6;
  max-width: 280px;
}

.footer-column h4 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.footer-column a {
  display: block;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 3px 0;
  transition: color 0.2s ease;
}

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

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.footer-bottom p {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .hero {
    padding: 50px 0 40px;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .hero .tagline {
    font-size: 1.05rem;
  }

  .section {
    padding: 40px 0;
  }

  .projects-grid {
    grid-template-columns: 1fr;
  }

  .page-header {
    padding: 40px 0 28px;
  }

  .page-header h1 {
    font-size: 1.75rem;
  }

  .site-nav a::after {
    display: none;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 24px;
    text-align: center;
  }

  .footer-brand .footer-tagline {
    max-width: 100%;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
  }

  /* Mobile nav */
  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 16px 24px;
    gap: 16px;
  }

  .site-nav.open {
    display: flex;
  }

  .nav-toggle {
    display: block;
  }

  .footer-content {
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .hero h1 {
    font-size: 1.65rem;
  }

  .container {
    padding: 0 16px;
  }

  .project-card {
    padding: 22px;
  }
}

/* --- Print Stylesheet --- */
@media print {
  .site-header,
  .site-footer,
  .nav-toggle,
  .back-to-top,
  .skip-link,
  body::before,
  body::after {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  a {
    color: black;
    text-decoration: underline;
  }

  .content-body {
    max-width: 100%;
  }

  .hero,
  .page-header {
    background: none !important;
  }

  .page-header {
    border-bottom: 1px solid #ccc;
  }
}

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

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

  html {
    scroll-behavior: auto;
  }
}
