/* ================== Design Tokens (Dark as base) ================== */
:root {
  --bg: #0b0f17;
  --surface: #0f172a;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --line: #1f2a3b;
  --accent: #60a5fa;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(2, 6, 23, 0.35);
  --wrap: 75rem;
  --blur: 8px;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial,
    sans-serif;
  --font-display: "Space Grotesk", var(--font-body);
  --top-glow: rgba(255, 255, 255, 0.08);
  --btn-primary: #87a6f3;
  --btn-primary-ink: #0f172a;
  --btn-dark: #121827;
  --btn-dark-border: #1e2a3d;
  --btn-glow: 0 14px 38px rgba(110, 140, 255, 0.22),
    0 4px 12px rgba(110, 140, 255, 0.12);
}

/* Light theme overrides */
:root[data-theme="light"] {
  --bg: #f7f9fc;
  --surface: #ffffff;
  --text: #0b1220;
  --muted: #5b6b7f;
  --line: #e5e9f0;
  --accent: #2563eb;
  --shadow: 0 18px 50px rgba(2, 6, 23, 0.08);
  --top-glow: rgba(255, 255, 255, 0.55);
  --btn-dark: #0f1729;
  --btn-dark-border: #1f2a3b;
}

:root[data-theme="midnight"] {
  --bg: #030712;
  --surface: #0f1729;
  --text: #e5f4ff;
  --muted: #91a5c8;
  --line: #1a2540;
  --accent: #7dd3fc;
  --shadow: 0 20px 55px rgba(2, 6, 23, 0.45);
  --top-glow: rgba(125, 211, 252, 0.15);
  --btn-primary: #7dd3fc;
  --btn-primary-ink: #041426;
  --btn-dark: #0b162d;
  --btn-dark-border: #1f2d4d;
}

:root[data-theme="sand"] {
  --bg: #fef6e9;
  --surface: #fffaf1;
  --text: #2c1404;
  --muted: #885a34;
  --line: #eadcc8;
  --accent: #d97706;
  --shadow: 0 18px 45px rgba(92, 52, 20, 0.18);
  --top-glow: rgba(217, 119, 6, 0.15);
  --btn-primary: #d97706;
  --btn-primary-ink: #fff8f0;
  --btn-dark: #41230f;
  --btn-dark-border: #5a3315;
}

/* ================== Part 4 Enhancements ================== */

/* Enhancement 1: Skip to Main Content Link (Accessibility) */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border-radius: 0 0 8px 8px;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* Enhancement 2: Smooth Scroll */
html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Enhancement 3: Loading Spinner */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem;
  grid-column: 1 / -1;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid color-mix(in oklab, var(--accent) 20%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-spinner p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
    border-color: var(--accent);
    border-top-color: transparent;
    border-bottom-color: transparent;
  }
}

/* Enhancement 4: Card Entrance Animations */
@keyframes cardFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.project-cards-grid project-card {
  animation: cardFadeIn 0.4s ease-out both;
}

/* Staggered animation delays for cards */
.project-cards-grid project-card:nth-child(1) {
  animation-delay: 0.05s;
}
.project-cards-grid project-card:nth-child(2) {
  animation-delay: 0.1s;
}
.project-cards-grid project-card:nth-child(3) {
  animation-delay: 0.15s;
}
.project-cards-grid project-card:nth-child(4) {
  animation-delay: 0.2s;
}
.project-cards-grid project-card:nth-child(5) {
  animation-delay: 0.25s;
}
.project-cards-grid project-card:nth-child(6) {
  animation-delay: 0.3s;
}
.project-cards-grid project-card:nth-child(7) {
  animation-delay: 0.35s;
}
.project-cards-grid project-card:nth-child(8) {
  animation-delay: 0.4s;
}

@media (prefers-reduced-motion: reduce) {
  .project-cards-grid project-card {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* ================== Base ================== */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg, #0b0f17);
  color: var(--text, #e5e7eb);
  font: 1rem/1.6 var(--font-body, Arial);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.35s ease, color 0.25s ease;
  view-transition-name: page;
}

/* Stop the glow from widening the page */
body::before {
  content: "";
  position: fixed;
  inset: -25dvh 0 -35dvh 0; /* ← remove the -10dvw left/right */
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(
      60vw 40vw at 20% -10%,
      color-mix(in oklab, var(--accent) 28%, transparent),
      transparent 60%
    ),
    radial-gradient(
      50vw 30vw at 80% -10%,
      color-mix(in oklab, var(--accent) 16%, transparent),
      transparent 60%
    );
  filter: blur(28px);
  opacity: 0.9;

  /* keep the glow wide without affecting layout width */
  left: 50%;
  width: 120vw;
  transform: translateX(-50%);
}

body::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: 36dvh;
  z-index: 10;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    var(--top-glow),
    rgba(255, 255, 255, 0) 65%
  );
}

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

.wrap {
  max-width: var(--wrap, 1200px);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ================== Nav ================== */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(120%) blur(var(--blur, 8px));
  background: color-mix(in oklab, var(--bg) 65%, transparent);
  border-bottom: 1px solid color-mix(in oklab, var(--line) 70%, transparent);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font: 600 1rem/1 var(--font-display);
  letter-spacing: 0.2px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 24px color-mix(in oklab, var(--accent) 80%, transparent);
  animation: pulse 2.6s ease-in-out infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.12);
    opacity: 0.85;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.links {
  display: flex;
  gap: 22px;
  align-items: center;
  /* ========== Modern nesting demo ========== */
  & a {
    color: var(--muted);
  }
  & a:hover {
    color: var(--text);
  }
}

.theme-picker {
  position: relative;
  display: none;
  margin-left: 0.25rem;
}

.theme-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--line) 65%, transparent);
  background: color-mix(in oklab, var(--surface) 55%, transparent);
  color: var(--text);
  font: 600 0.7rem/1 var(--font-body);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease,
    box-shadow 0.2s ease;
}

.theme-trigger:hover {
  border-color: color-mix(in oklab, var(--accent) 40%, transparent);
  box-shadow: 0 0 10px color-mix(in oklab, var(--accent) 25%, transparent);
}

.theme-trigger:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--accent) 60%, transparent);
  outline-offset: 2px;
}

.theme-trigger-label {
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.65rem;
  color: var(--muted);
}

.theme-trigger-caret {
  font-size: 0.75rem;
  color: var(--muted);
}

.theme-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.6rem);
  width: min(18rem, 80vw);
  padding: 0.9rem;
  border-radius: 1rem;
  background: var(--surface);
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  z-index: 80;
}

.theme-panel[hidden] {
  display: none;
}

.theme-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.theme-panel-head p {
  margin: 0;
  font-weight: 600;
  font-size: 0.9rem;
}

.theme-panel-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.theme-panel-subheading {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin: 0.4rem 0 0.6rem;
}

.theme-options button,
.theme-custom-open,
.theme-custom-actions button {
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  background: color-mix(in oklab, var(--surface) 85%, transparent);
  color: var(--text);
  border-radius: 0.75rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease,
    box-shadow 0.2s ease;
}

.theme-options button[data-selected="true"],
.theme-custom-open[data-selected="true"] {
  border-color: color-mix(in oklab, var(--accent) 50%, transparent);
  background: color-mix(in oklab, var(--accent) 18%, var(--surface));
  color: var(--text);
}

.theme-options button:hover,
.theme-custom-open:hover,
.theme-custom-actions button:hover {
  border-color: color-mix(in oklab, var(--accent) 40%, transparent);
  box-shadow: 0 0 10px color-mix(in oklab, var(--accent) 25%, transparent);
}

.theme-custom-open {
  width: 100%;
  margin-top: 0.25rem;
  text-align: center;
}

.theme-custom-form {
  margin-top: 0.65rem;
  display: grid;
  gap: 0.5rem;
}

.theme-custom-form label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.8rem;
}

.theme-custom-form input[type="color"] {
  width: 100%;
  height: 2.25rem;
  border-radius: 0.5rem;
  border: 1px solid color-mix(in oklab, var(--line) 70%, transparent);
  background: transparent;
  cursor: pointer;
}

.theme-custom-form select {
  border-radius: 0.5rem;
  border: 1px solid color-mix(in oklab, var(--line) 70%, transparent);
  padding: 0.35rem 0.45rem;
  background: color-mix(in oklab, var(--surface) 90%, transparent);
  color: var(--text);
}

.theme-custom-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.theme-custom-actions button {
  flex: 1;
  font-size: 0.8rem;
}

.theme-panel hr {
  margin: 0.4rem 0;
  border: none;
  border-top: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
}

.theme-reset {
  width: 100%;
  margin-top: 0.5rem;
  border: 1px dashed color-mix(in oklab, var(--accent) 55%, transparent);
  background: color-mix(in oklab, var(--surface) 80%, transparent);
  color: var(--accent);
  border-radius: 0.9rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease,
    box-shadow 0.2s ease;
}

.theme-reset:hover {
  border-color: color-mix(in oklab, var(--accent) 80%, transparent);
  background: color-mix(in oklab, var(--accent) 18%, var(--surface));
  color: var(--text);
  box-shadow: 0 0 12px color-mix(in oklab, var(--accent) 25%, transparent);
}

.js-ready .theme-picker {
  display: block;
}

@media (max-width: 540px) {
  .theme-panel {
    position: fixed;
    left: 1rem;
    right: 1rem;
    top: auto;
    bottom: 1rem;
    width: auto;
  }
}

.no-js-note {
  margin: 0.5rem 0 0;
  padding: 0.5rem 0.75rem;
  border-radius: 0.65rem;
  background: color-mix(in oklab, var(--surface) 70%, transparent);
  border: 1px solid color-mix(in oklab, var(--line) 80%, transparent);
  font-size: 0.85rem;
  color: var(--muted);
}

/* Toggle button (disabled to satisfy "no JS") */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  cursor: not-allowed;
  border: 1px solid color-mix(in oklab, var(--line) 70%, transparent);
  background: var(--surface);
  color: var(--text);
  opacity: 0.6;
}

.toggle .icon {
  width: 18px;
  height: 18px;
  display: inline-block;
}

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

/* ================== Hero ================== */
.hero {
  padding: 6rem 0 2.25rem;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-image-pair(*) {
    animation-duration: 0.01ms !important;
    animation-delay: 0.01ms !important;
  }
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(40px, 6vw, 72px);
  line-height: 1.06;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
}

.lead {
  color: var(--muted);
  max-width: 45rem;
  font-size: clamp(16px, 2.2vw, 20px);
}

/* ================== CTA Buttons (light + dark pair) ================== */
.cta {
  margin-top: 1.375rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn {
  --pad-y: 0.875rem;
  --pad-x: 1.375rem;
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--pad-y) var(--pad-x);
  border-radius: 999px;
  border: none;
  outline: none;
  font-weight: 600;
  letter-spacing: 0.2px;
  font-size: 1.125rem;
  text-decoration: none;
  background: radial-gradient(
      140px 140px at var(--mx, 50%) var(--my, 50%),
      rgba(255, 255, 255, 0.08),
      transparent 46%
    ),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.1) 60%),
    var(--btn-dark);
  box-shadow: inset 0 0 0 1px var(--btn-dark-border);
  transition: transform 0.18s ease, box-shadow 0.22s ease, background 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:not(.primary):hover {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.btn:active {
  transform: translateY(0) scale(0.995);
}

.btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1),
    0 0 0 6px rgba(120, 150, 255, 0.35);
}

.btn.primary {
  color: var(--btn-primary-ink);
  background: radial-gradient(
      140px 140px at var(--mx, 50%) var(--my, 50%),
      rgba(255, 255, 255, 0.18),
      transparent 46%
    ),
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.22),
      rgba(255, 255, 255, 0) 55%
    ),
    var(--btn-primary);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}

.btn .shine {
  pointer-events: none;
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  overflow: hidden;
}

.btn .shine::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.14),
    rgba(255, 255, 255, 0) 42%
  );
  mix-blend-mode: screen;
}

/* ================== Hero Media with <picture> (fixed aspect + crop) ================== */
.hero-media {
  margin-top: 2.625rem;
  position: relative;
  overflow: hidden;
  border-radius: calc(var(--radius, 16px) + 8px);
  aspect-ratio: 16 / 9;
  min-height: 360px;
  box-shadow: var(--shadow, 0 18px 50px rgba(2, 6, 23, 0.35));
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
}

.hero-media picture,
.hero-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.hero-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.06),
    rgba(255, 255, 255, 0.02)
  );
  pointer-events: none;
}

/* ================== Projects v2 ================== */
#projects {
  margin-top: 0.5rem;
}

.projects-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.625rem;
}

.controls {
  display: flex;
  gap: 0.625rem;
  align-items: center;
}

.filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter {
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  background: var(--surface);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  font-size: 0.875rem;
  cursor: default;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  &[aria-pressed="true"] {
    background: color-mix(in oklab, var(--accent) 22%, transparent);
    border-color: color-mix(in oklab, var(--accent) 45%, var(--line));
  }
}

.layout {
  display: flex;
  gap: 6px;
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  border-radius: 999px;
  padding: 4px;
  background: var(--surface);
  & button {
    border: none;
    background: transparent;
    color: var(--muted);
    padding: 0.5rem 0.625rem;
    border-radius: 999px;
  }
  & button[aria-pressed="true"] {
    background: color-mix(in oklab, var(--accent) 18%, transparent);
    color: var(--text);
  }
}

.featured {
  margin-top: 1.125rem;
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 1.125rem;
}

/* Allow grid children to shrink instead of pushing the row wider */
.featured > * {
  min-width: 0;
}

@media (max-width: 900px) {
  .featured {
    grid-template-columns: 1fr;
  }
}

.featured .visual {
  min-height: 280px;
  border-radius: calc(var(--radius) + 8px);
  overflow: hidden;
  position: relative;
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  box-shadow: var(--shadow);
  aspect-ratio: 16 / 9;
}

.featured .visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.featured .panel {
  background: var(--surface);
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  border-radius: var(--radius);
  padding: 1.125rem;
  box-shadow: var(--shadow);
}

.panel h3 {
  margin: 0 0 0.375rem;
}

.kpis {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 0.625rem 0 0.375rem;
}

.kpi {
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  background: color-mix(in oklab, var(--surface) 85%, transparent);
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.875rem;
}

.kpi small {
  display: block;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.75rem;
}

.proj-grid {
  margin-top: 1.125rem;
  display: grid;
  gap: 1.125rem;
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 980px) {
  .proj-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 620px) {
  .proj-grid {
    grid-template-columns: 1fr;
  }
}

.proj {
  background: var(--surface);
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.proj figure.thumb {
  margin: 0;
  padding: 0;
  display: block;
}

.proj .thumb {
  aspect-ratio: 16 / 9;
  border-bottom: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  overflow: hidden;
}

.proj .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.proj .body {
  padding: 0.875rem;
}

.proj .title {
  font-size: 1.125rem;
  margin: 0.5rem 0 0.375rem;
}

.proj .meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.375rem 0 0.5rem;
}

.badge {
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
}

.impact {
  font-weight: 600;
  font-size: 0.875rem;
}

.proj .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.625rem;
  gap: 0.625rem;
}

.quick {
  font-size: 0.875rem;
  color: var(--text);
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.5rem 0.75rem;
  cursor: default;
}

/* ================== About (scoped demo) & Footer ================== */
section h2 {
  font-size: 1.75rem;
  margin: 0 0 0.75rem;
}

.muted {
  color: var(--muted);
}

.about {
  margin-top: 4rem;
  padding: 1.75rem;
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  position: relative;
  z-index: 1;
}

/* @scope demo */
@scope (.about) {
  h2 {
    font-size: 1.75rem;
  }
  p.muted {
    color: var(--muted);
  }
}

.contact {
  margin-top: 3rem;
}

footer {
  border-top: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  margin-top: 4rem;
  padding: 1.375rem 0;
  color: var(--muted);
}

/* Motion care */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* ================== Extra Credit: Wider-gamut color() ==================
   Uses display-p3 to override --accent when supported.
   Fallback remains the sRGB hex you already set earlier. */
@supports (color: color(display-p3 1 1 1)) {
  :root {
    /* vivid blue in display-p3 space */
    --accent: color(display-p3 0.42 0.62 1);
  }
  :root[data-theme="light"] {
    /* slightly deeper accent for light theme */
    --accent: color(display-p3 0.24 0.52 1);
  }
}

/*  Extra Credit: :has() container styling
   Highlights the filter bar when any filter is active.
   (Gracefully ignored where :has() isn’t supported.) */
@supports selector(:has(*)) {
  .filters:has(button[aria-pressed="true"]) {
    box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent) 30%, transparent);
    border-radius: 12px;
  }

  /* Bonus: give the layout switch a subtle “armed” state */
  .layout:has(button[aria-pressed="true"]) {
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.18);
  }
}

/* STYLING FOR THE ABOUT PAGE */

/* Bio split (portrait + card) */
.bio {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 1.125rem;
  margin-top: 1.25rem;
}

@media (max-width: 900px) {
  .bio {
    grid-template-columns: 1fr;
  }
}

.portrait {
  border-radius: calc(var(--radius) + 8px);
  overflow: hidden;
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  box-shadow: var(--shadow);
  aspect-ratio: 4 / 5;
  position: relative;
}

.portrait img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bio-card {
  background: var(--surface);
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  border-radius: var(--radius);
  padding: 1.125rem;
  box-shadow: var(--shadow);
}

.bio-title {
  margin: 0 0 0.5rem;
}

.stats {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 0.75rem 0 0.5rem;
  padding: 0;
  list-style: none;
}

.stat {
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  background: color-mix(in oklab, var(--surface) 85%, transparent);
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.875rem;
}

/* Skills */
.skills {
  margin-top: 2.25rem;
}

.skills-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.skills-grid {
  margin-top: 1rem;
  display: grid;
  gap: 1.125rem;
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 980px) {
  .skills-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 620px) {
  .skills-grid {
    grid-template-columns: 1fr;
  }
}

.skill {
  background: var(--surface);
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.skill h3 {
  margin: 0 0 0.375rem;
}

.chips {
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.chips li {
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
}

/* Timeline */
.timeline {
  margin-top: 2.5rem;
}

.timeline h2 {
  margin-bottom: 0.75rem;
}

.tl {
  position: relative;
  list-style: none;
  padding: 0;
  margin: 0;
}

.tl::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: color-mix(in oklab, var(--line) 70%, transparent);
}

.tl li {
  position: relative;
  padding-left: 2.25rem;
  margin: 0 0 1rem;
}

.tl .dot {
  position: absolute;
  left: 4px;
  top: 0.25rem;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 18px color-mix(in oklab, var(--accent) 70%, transparent);
}

.tl .card {
  background: var(--surface);
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  border-radius: 12px;
  padding: 0.875rem;
  box-shadow: var(--shadow);
}

/* Values */
.values {
  margin-top: 2.5rem;
}

.val-grid {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  display: grid;
  gap: 1.125rem;
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 980px) {
  .val-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 620px) {
  .val-grid {
    grid-template-columns: 1fr;
  }
}

.val {
  background: var(--surface);
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.val h3 {
  margin: 0 0 0.375rem;
}

/* CONTACT PAGE STYLE CSS */

.contact-main {
  margin-top: 0.25rem;
}

/* hero tweaks for contact */
.contact-hero {
  padding-bottom: 1.5rem;
}
.contact-hero .hero-media {
  margin-top: 1.25rem;
  min-height: 32dvh; /* dynamic viewport unit */
}

/* Reusable card (matches panels/sections on other pages) */
.card {
  background: var(--surface, #0f172a);
  border: 1px solid color-mix(in oklab, var(--line, #1f2a3b) 60%, transparent);
  border-radius: var(--radius, 16px);
  box-shadow: var(--shadow, 0 18px 50px rgba(2, 6, 23, 0.35));
  padding: 1.125rem;
}

/* Grid layout */
.contact-grid {
  display: grid;
  gap: 1.125rem;
  grid-template-columns: 1.15fr 1fr;
  margin-top: 1.125rem;
}
@media (max-width: 900px) {
  .contact-grid {
    grid-template-columns: 1fr;
  }
}

/* Info card */
.info-card h2 {
  margin: 0 0 0.5rem;
}
.contact-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: grid;
  gap: 0.5rem;
}
.contact-list li {
  display: grid;
  grid-template-columns: 7rem 1fr;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.5rem 0.625rem;
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  border-radius: 12px;
  background: color-mix(in oklab, var(--surface) 90%, transparent);
}
.contact-list .label {
  color: var(--muted);
}

/* iframe preview (accessible ratio) */
.mini-frame {
  margin-top: 0.75rem;
}
.mini-title {
  margin: 0 0 0.375rem;
}
.ratio {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  aspect-ratio: 16 / 9;
}
.ratio iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Form card */
.form-card h2 {
  margin: 0 0 0.5rem;
}

/* field styles + variables */
:root {
  --field-bg: color-mix(in oklab, var(--surface) 85%, transparent);
  --field-border: color-mix(in oklab, var(--line) 70%, transparent);
  --field-focus: color-mix(in oklab, var(--accent) 45%, transparent);
}

/* @scope keeps form styles local */
@scope (.form-card) {
  .fields {
    display: grid;
    gap: 0.875rem;
    margin: 0.75rem 0 1rem;
  }
  .field {
    display: grid;
    gap: 0.375rem;
  }
  .field label {
    font-weight: 600;
    font-size: 0.95rem;
  }
  .field input,
  .field textarea {
    background: var(--field-bg);
    color: var(--text);
    border: 1px solid var(--field-border);
    border-radius: 12px;
    padding: 0.75rem 0.875rem;
    font: inherit;
    outline: none;
    transition: border-color 0.18s ease, transform 0.12s ease,
      box-shadow 0.18s ease;
  }
  .field input:focus-visible,
  .field textarea:focus-visible {
    border-color: var(--field-focus);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 24%, transparent);
    transform: translateY(-1px);
  }
  .hint {
    color: var(--muted);
    margin: 0;
    font-size: 0.85rem;
  }
  .req {
    color: color-mix(in oklab, var(--accent) 85%, white);
  }
  .consent {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
    font-size: 0.95rem;
  }
  .form-actions {
    display: flex;
    gap: 0.625rem;
    flex-wrap: wrap;
  }
}

/* Baseline feature demo: :has() highlights invalid fields/groups */
.form-card:has(:invalid) {
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent) 26%, transparent);
}
.field:has(:invalid) input,
.field:has(:invalid) textarea {
  border-color: color(
    display-p3 0.95 0.45 0.45 / 0.85
  ); /* wider-gamut accent */
}

/* Motion care already global; buttons share existing .btn styles */

/* Extra small refinements */
.link:hover {
  color: var(--text);
}

/* Keep contrast strong in light theme */
:root[data-theme="light"] .contact-list li {
  background: color-mix(in oklab, var(--surface) 96%, white);
}

/* Mobile responsive design (≤ 420px) */
@media (max-width: 420px) {
  .wrap {
    padding-inline: 0.875rem;
  }

  /* Nav: stack and shrink */
  .nav-inner {
    height: auto;
    padding-block: 0.5rem;
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }
  .brand {
    font-size: 0.9rem;
  }
  .links {
    flex: 1 1 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
  }
  .links a {
    font-size: 0.9rem;
  }

  /* Hero */
  .hero {
    padding-top: 4.25rem;
  }
  h1 {
    font-size: clamp(28px, 8.5vw, 40px);
  }
  .hero-media {
    min-height: 210px;
    border-radius: 14px;
  }

  /* “Highlighted Projects” header row */
  .projects-head {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .controls {
    flex-wrap: wrap;
  }
  .filters {
    width: 100%;
    justify-content: flex-start;
  }
  .filter {
    padding: 0.45rem 0.6rem;
    font-size: 0.85rem;
  }

  /* Featured block spacing */
  .featured {
    gap: 0.75rem;
  }
  .panel {
    padding: 0.9rem;
  }
  .kpis {
    gap: 0.5rem;
  }
  .kpi {
    font-size: 0.8rem;
  }

  /* Project cards grid + spacing */
  .proj-grid {
    gap: 0.9rem;
  }
  .proj .body {
    padding: 0.75rem;
  }
  .proj .title {
    font-size: 1rem;
  }

  /* About + footer spacing on landing */
  .about {
    margin-top: 2.75rem;
    padding: 1.25rem;
  }
  footer {
    margin-top: 2.5rem;
  }

  /* one issue i found: image still overflows, so adding this to ensure/overrides safely that the image will not overflows*/

  /* Let grid children shrink instead of forcing the row wider */
  .featured > * {
    min-width: 0;
  }

  /* Belt & suspenders: keep the featured visual strictly inside */
  .featured .visual,
  .featured .visual picture,
  .featured .visual img {
    width: 100%;
    max-width: 100%;
  }

  /* Optional: slightly tighter radii on tiny screens prevents 1px peeking */
  @media (max-width: 420px) {
    .featured {
      gap: 0.75rem;
    }
    .featured .visual {
      border-radius: 14px;
    }
  }
}

/* ================== Small phones safety (≤ 340px) ================== */
@media (max-width: 340px) {
  .links {
    gap: 10px;
  }
  .links a {
    font-size: 0.85rem;
  }
  .filter {
    font-size: 0.8rem;
  }
  .btn {
    --pad-y: 0.7rem;
    --pad-x: 1.1rem;
    font-size: 1rem;
  }
}

/* ================== CRUD Page Styles (Part 3) ================== */
.crud-main {
  padding-bottom: 3rem;
}

.crud-hero {
  padding-bottom: 1rem;
}

.crud-hero .link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.crud-hero .link:hover {
  color: var(--text);
}

.crud-section {
  margin-top: 1.5rem;
}

.crud-card {
  background: var(--surface);
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.crud-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

.crud-card--danger {
  border-color: color-mix(in oklab, #ef4444 40%, transparent);
}

.crud-card--danger h2 {
  color: #f87171;
}

/* Projects List */
.projects-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0;
  max-height: 300px;
  overflow-y: auto;
}

.project-item {
  display: grid;
  grid-template-columns: 3rem 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 1rem;
  background: color-mix(in oklab, var(--surface) 80%, transparent);
  border: 1px solid color-mix(in oklab, var(--line) 50%, transparent);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.project-item:hover,
.project-item:focus {
  border-color: color-mix(in oklab, var(--accent) 50%, transparent);
  background: color-mix(in oklab, var(--accent) 8%, var(--surface));
  outline: none;
}

.project-item-index {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  background: color-mix(in oklab, var(--line) 40%, transparent);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  text-align: center;
}

.project-item-title {
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-item-tags {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.empty-list {
  color: var(--muted);
  text-align: center;
  padding: 2rem;
}

.refresh-btn {
  --pad-y: 0.5rem;
  --pad-x: 1rem;
  font-size: 0.875rem;
}

/* CRUD Forms */
.crud-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-group label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.form-group .req {
  color: #f87171;
}

.form-group input,
.form-group textarea,
.form-group select {
  padding: 0.75rem 1rem;
  background: color-mix(in oklab, var(--surface) 85%, transparent);
  border: 1px solid color-mix(in oklab, var(--line) 70%, transparent);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: color-mix(in oklab, var(--accent) 60%, transparent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 20%, transparent);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group select {
  cursor: pointer;
}

.form-group .hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
}

/* Form Actions */
.form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.btn-primary {
  background: color-mix(in oklab, var(--accent) 25%, var(--surface));
  border-color: color-mix(in oklab, var(--accent) 50%, transparent);
  color: var(--text);
}

.btn-primary:hover {
  background: color-mix(in oklab, var(--accent) 35%, var(--surface));
  border-color: color-mix(in oklab, var(--accent) 70%, transparent);
}

.btn-danger {
  background: color-mix(in oklab, #ef4444 20%, var(--surface));
  border-color: color-mix(in oklab, #ef4444 50%, transparent);
  color: #fca5a5;
}

.btn-danger:hover {
  background: color-mix(in oklab, #ef4444 30%, var(--surface));
  border-color: color-mix(in oklab, #ef4444 70%, transparent);
  color: #fef2f2;
}

/* Form Status Messages */
.form-status {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.form-status[hidden] {
  display: none;
}

.form-status--success {
  background: color-mix(in oklab, #22c55e 15%, transparent);
  color: #4ade80;
  border: 1px solid color-mix(in oklab, #22c55e 30%, transparent);
}

.form-status--error {
  background: color-mix(in oklab, #ef4444 15%, transparent);
  color: #f87171;
  border: 1px solid color-mix(in oklab, #ef4444 30%, transparent);
}

.form-status--warning {
  background: color-mix(in oklab, #f59e0b 15%, transparent);
  color: #fbbf24;
  border: 1px solid color-mix(in oklab, #f59e0b 30%, transparent);
}

/* Delete Preview */
.delete-preview {
  padding: 1rem;
  background: color-mix(in oklab, #ef4444 10%, transparent);
  border: 1px dashed color-mix(in oklab, #ef4444 40%, transparent);
  border-radius: 10px;
  margin: 0.5rem 0;
}

.delete-preview p {
  margin: 0;
}

.delete-preview-title {
  font-weight: 600;
  color: #fca5a5;
  margin-top: 0.25rem !important;
}

/* Example Data Section */
.example-data {
  background: color-mix(in oklab, var(--surface) 70%, transparent);
  border: 1px solid color-mix(in oklab, var(--line) 50%, transparent);
  border-radius: 10px;
  padding: 1rem;
  margin-top: 1rem;
}

.example-data dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1rem;
  margin: 0;
}

.example-data dt {
  font-weight: 600;
  color: var(--muted);
}

.example-data dd {
  margin: 0;
  color: var(--text);
  word-break: break-word;
}

/* Responsive CRUD */
@media (max-width: 620px) {
  .crud-card {
    padding: 1.25rem;
  }

  .project-item {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .project-item-index {
    display: none;
  }

  .project-item-tags {
    max-width: 100%;
  }

  .example-data dl {
    grid-template-columns: 1fr;
  }

  .example-data dt {
    margin-top: 0.5rem;
  }
}

/* ================== Data Loading Controls (Part 2) ================== */
.data-loaders {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.load-btn {
  --pad-y: 0.625rem;
  --pad-x: 1.125rem;
  font-size: 0.95rem;
  border: 1px solid color-mix(in oklab, var(--line) 70%, transparent);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.load-btn:hover {
  border-color: color-mix(in oklab, var(--accent) 50%, transparent);
  box-shadow: 0 0 12px color-mix(in oklab, var(--accent) 20%, transparent);
}

.load-btn--primary {
  background: color-mix(in oklab, var(--accent) 20%, var(--surface));
  border-color: color-mix(in oklab, var(--accent) 45%, transparent);
}

.load-btn--primary:hover {
  background: color-mix(in oklab, var(--accent) 30%, var(--surface));
}

/* Status message */
.load-status {
  margin: 0;
  padding: 0.5rem 0.875rem;
  border-radius: 8px;
  font-size: 0.875rem;
  transition: opacity 0.2s ease;
}

.load-status[hidden] {
  display: none;
}

.load-status--loading {
  background: color-mix(in oklab, var(--accent) 15%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in oklab, var(--accent) 30%, transparent);
}

.load-status--success {
  background: color-mix(in oklab, #22c55e 15%, transparent);
  color: #4ade80;
  border: 1px solid color-mix(in oklab, #22c55e 30%, transparent);
}

.load-status--error {
  background: color-mix(in oklab, #ef4444 15%, transparent);
  color: #f87171;
  border: 1px solid color-mix(in oklab, #ef4444 30%, transparent);
}

.load-status--warning {
  background: color-mix(in oklab, #f59e0b 15%, transparent);
  color: #fbbf24;
  border: 1px solid color-mix(in oklab, #f59e0b 30%, transparent);
}

/* Empty state message */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--muted);
  background: color-mix(in oklab, var(--surface) 50%, transparent);
  border: 2px dashed color-mix(in oklab, var(--line) 60%, transparent);
  border-radius: var(--radius);
}

.empty-state strong {
  color: var(--accent);
}

/* No projects found message */
.no-projects {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}

/* ================== Project Card Grid (for <project-card> custom elements) ================== */
.project-cards-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  margin-top: 1.5rem;
}

@media (max-width: 720px) {
  .project-cards-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
}

/* Ensure project-card elements fill their grid cells */
.project-cards-grid project-card {
  display: block;
  height: 100%;
}

/* Loading state for dynamically loaded cards */
.project-cards-grid.loading {
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.project-cards-grid.loading::after {
  content: "Loading projects...";
  color: var(--muted);
  font-size: 1rem;
}

/* Empty state when no cards loaded */
.project-cards-grid:empty::after {
  content: "No projects to display.";
  color: var(--muted);
  font-size: 1rem;
  text-align: center;
  grid-column: 1 / -1;
  padding: 3rem 1rem;
}
