@layer reset, base, layout, components, utilities;

@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html {
    scroll-behavior: smooth;
    scroll-padding-top: 5rem;
    text-size-adjust: 100%;
  }

  body,
  h1,
  h2,
  h3,
  h4,
  p,
  figure,
  blockquote,
  dl,
  dd {
    margin: 0;
  }

  ul[role='list'],
  ol[role='list'] {
    list-style: none;
  }

  body {
    min-height: 100vh;
    text-rendering: optimizeLegibility;
  }

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

  button,
  input,
  textarea,
  select {
    font: inherit;
  }

  button {
    border: 0;
    cursor: pointer;
  }

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

  :target {
    scroll-margin-top: 6rem;
  }

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

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

@layer base {
  :root {
    color-scheme: dark;
    --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

    --bg: #070b14;
    --bg-elevated: #0d1324;
    --surface: #111827;
    --surface-2: #172033;
    --text: #eef4ff;
    --muted: #b8c2d2;
    --muted-2: #91a0b8;
    --border: rgba(148, 163, 184, 0.24);
    --border-strong: rgba(148, 163, 184, 0.42);
    --accent: #67e8f9;
    --accent-2: #a78bfa;
    --accent-3: #34d399;
    --accent-contrast: #041016;
    --danger: #f87171;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
    --radius-sm: 0.55rem;
    --radius: 1rem;
    --radius-lg: 1.5rem;
    --radius-xl: 2rem;
    --container: 72rem;
    --header-height: 4.5rem;
  }

  @media (prefers-color-scheme: light) {
    :root:not([data-theme]) {
      color-scheme: light;
      --bg: #f6f8fc;
      --bg-elevated: #ffffff;
      --surface: #ffffff;
      --surface-2: #eef4ff;
      --text: #101828;
      --muted: #475467;
      --muted-2: #667085;
      --border: rgba(15, 23, 42, 0.14);
      --border-strong: rgba(15, 23, 42, 0.26);
      --accent: #0f766e;
      --accent-2: #6d28d9;
      --accent-3: #15803d;
      --accent-contrast: #ffffff;
      --shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
    }
  }

  :root[data-theme='light'] {
    color-scheme: light;
    --bg: #f6f8fc;
    --bg-elevated: #ffffff;
    --surface: #ffffff;
    --surface-2: #eef4ff;
    --text: #101828;
    --muted: #475467;
    --muted-2: #667085;
    --border: rgba(15, 23, 42, 0.14);
    --border-strong: rgba(15, 23, 42, 0.26);
    --accent: #0f766e;
    --accent-2: #6d28d9;
    --accent-3: #15803d;
    --accent-contrast: #ffffff;
    --shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
  }

  :root[data-theme='dark'] {
    color-scheme: dark;
    --bg: #070b14;
    --bg-elevated: #0d1324;
    --surface: #111827;
    --surface-2: #172033;
    --text: #eef4ff;
    --muted: #b8c2d2;
    --muted-2: #91a0b8;
    --border: rgba(148, 163, 184, 0.24);
    --border-strong: rgba(148, 163, 184, 0.42);
    --accent: #67e8f9;
    --accent-2: #a78bfa;
    --accent-3: #34d399;
    --accent-contrast: #041016;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  }

  body {
    background:
      radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 18%, transparent), transparent 34rem),
      radial-gradient(circle at 88% 12%, color-mix(in srgb, var(--accent-2) 20%, transparent), transparent 32rem),
      var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: clamp(1rem, 0.96rem + 0.18vw, 1.08rem);
    line-height: 1.65;
  }

  h1,
  h2,
  h3 {
    color: var(--text);
    font-weight: 780;
    letter-spacing: -0.04em;
    line-height: 1.05;
  }

  h1 {
    font-size: clamp(2.65rem, 8vw, 5.6rem);
    max-width: 11ch;
  }

  h2 {
    font-size: clamp(2rem, 4vw, 3.25rem);
    max-width: 13ch;
  }

  h3 {
    font-size: clamp(1.15rem, 2vw, 1.45rem);
  }

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

  a:focus-visible,
  button:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 4px;
  }

  ::selection {
    background: var(--accent);
    color: var(--accent-contrast);
  }
}

@layer layout {
  .container {
    width: min(var(--container), calc(100% - 2rem));
    margin-inline: auto;
  }

  .section {
    padding-block: clamp(4rem, 8vw, 7rem);
  }

  .section-lg {
    padding-block: clamp(5rem, 12vw, 9.5rem);
  }

  .section-alt {
    background:
      linear-gradient(180deg, color-mix(in srgb, var(--surface) 46%, transparent), transparent),
      color-mix(in srgb, var(--bg-elevated) 64%, transparent);
    border-block: 1px solid var(--border);
  }

  .section-heading {
    display: grid;
    gap: 1rem;
    margin-bottom: 2rem;
    max-width: 54rem;
  }

  .section-heading p:last-child {
    max-width: 56rem;
    font-size: 1.08rem;
  }

  .hero-grid,
  .project-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(18rem, 0.8fr);
    align-items: center;
    gap: clamp(2rem, 6vw, 5rem);
  }

  .hero-copy,
  .project-detail-copy {
    display: grid;
    gap: 1.25rem;
  }

  .value-grid,
  .skills-grid,
  .project-grid {
    display: grid;
    gap: 1rem;
  }

  .value-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .skills-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .content-grid,
  .two-columns,
  .impact-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(18rem, 0.72fr);
    gap: clamp(1.5rem, 5vw, 4rem);
    align-items: start;
  }

  .impact-cards {
    display: grid;
    gap: 1rem;
  }

  @media (max-width: 980px) {
    .hero-grid,
    .project-detail-grid,
    .content-grid,
    .two-columns,
    .impact-grid {
      grid-template-columns: 1fr;
    }

    .value-grid,
    .skills-grid,
    .project-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  @media (max-width: 680px) {
    .container {
      width: min(var(--container), calc(100% - 1rem));
    }

    .value-grid,
    .skills-grid,
    .project-grid {
      grid-template-columns: 1fr;
    }

    .section,
    .section-lg {
      padding-block: 3.75rem;
    }
  }
}

@layer components {
  .skip-link {
    position: fixed;
    left: 1rem;
    top: 1rem;
    z-index: 999;
    transform: translateY(-140%);
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-contrast);
    font-weight: 800;
    padding: 0.75rem 1rem;
    transition: transform 180ms ease;
  }

  .skip-link:focus {
    transform: translateY(0);
  }

  .site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: var(--header-height);
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(18px);
  }

  .header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--header-height);
    gap: 1rem;
  }

  .brand {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    font-weight: 850;
    letter-spacing: -0.03em;
  }

  .brand img {
    border-radius: 0.85rem;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  }

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

  .nav-list,
  .footer-links,
  .hero-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .nav-list a,
  .footer-links a,
  .hero-links a,
  .text-link,
  .breadcrumb {
    color: var(--muted);
    font-weight: 720;
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.25em;
  }

  .nav-list a {
    display: inline-flex;
    border-radius: 999px;
    padding: 0.55rem 0.8rem;
    font-size: 0.94rem;
  }

  .nav-list a:hover,
  .footer-links a:hover,
  .hero-links a:hover,
  .text-link:hover,
  .breadcrumb:hover {
    color: var(--text);
    text-decoration: underline;
  }

  .header-actions,
  .hero-actions,
  .contact-actions,
  .card-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
  }

  .header-actions {
    flex-wrap: nowrap;
  }

  .button,
  .filter-button,
  .theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    border-radius: 999px;
    font-weight: 800;
    line-height: 1;
    transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease;
  }

  .button:hover,
  .filter-button:hover,
  .theme-toggle:hover {
    transform: translateY(-1px);
  }

  .button {
    gap: 0.45rem;
    padding: 0.85rem 1rem;
  }

  .button-small {
    min-height: 2.25rem;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
  }

  .button-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: var(--accent-contrast);
    box-shadow: 0 18px 44px color-mix(in srgb, var(--accent) 22%, transparent);
  }

  .button-secondary {
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
  }

  .button-ghost,
  .theme-toggle,
  .filter-button {
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 68%, transparent);
    color: var(--muted);
  }

  .theme-toggle {
    width: 2.75rem;
    padding: 0;
  }

  .nav-toggle {
    display: none;
    position: relative;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
  }

  .nav-toggle-bars,
  .nav-toggle-bars::before,
  .nav-toggle-bars::after {
    position: absolute;
    left: 50%;
    width: 1.1rem;
    height: 2px;
    border-radius: 99px;
    background: var(--text);
    transform: translateX(-50%);
  }

  .nav-toggle-bars {
    top: 50%;
  }

  .nav-toggle-bars::before,
  .nav-toggle-bars::after {
    content: '';
  }

  .nav-toggle-bars::before {
    top: -0.42rem;
  }

  .nav-toggle-bars::after {
    top: 0.42rem;
  }

  .eyebrow {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.83rem;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .hero-lead {
    max-width: 47rem;
    color: var(--text);
    font-size: clamp(1.2rem, 2vw, 1.45rem);
    line-height: 1.45;
  }

  .availability {
    display: inline-flex;
    width: fit-content;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface) 76%, transparent);
    color: var(--text);
    font-weight: 730;
    padding: 0.55rem 0.8rem;
  }

  .hero-links {
    margin-top: 0.4rem;
  }

  .hero-card,
  .project-figure {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .hero-card {
    max-width: 25rem;
    margin-inline: auto;
    padding: 1rem;
  }

  .hero-card::before,
  .project-figure::before,
  .contact-card::before {
    content: '';
    position: absolute;
    inset: -1px;
    pointer-events: none;
    border-radius: inherit;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 28%, transparent), transparent 42%, color-mix(in srgb, var(--accent-2) 24%, transparent));
    mask: linear-gradient(#000, #000) content-box, linear-gradient(#000, #000);
    mask-composite: exclude;
    padding: 1px;
  }

  .hero-card picture {
    overflow: hidden;
    border-radius: 1.35rem;
    border: 1px solid var(--border);
  }

  .hero-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
  }

  .profile-panel {
    display: grid;
    gap: 0.55rem;
    padding: 1rem 0.35rem 0.25rem;
  }

  .profile-role,
  .footer-title {
    color: var(--text);
    font-weight: 850;
  }

  .status-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted);
    font-size: 0.95rem;
  }

  .status-line span {
    width: 0.7rem;
    height: 0.7rem;
    flex: 0 0 0.7rem;
    border-radius: 50%;
    background: var(--accent-3);
    box-shadow: 0 0 0 0.28rem color-mix(in srgb, var(--accent-3) 18%, transparent);
  }

  .value-card,
  .skill-card,
  .project-card,
  .content-aside,
  .content-block,
  .contact-card,
  .timeline-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.08);
  }

  .value-card,
  .skill-card,
  .content-aside,
  .content-block {
    display: grid;
    gap: 0.75rem;
    padding: 1.2rem;
  }

  .value-card h3,
  .skill-card h3,
  .content-aside h2,
  .content-block h2 {
    font-size: 1.18rem;
    letter-spacing: -0.02em;
  }

  .project-card {
    overflow: hidden;
    display: grid;
    grid-template-rows: auto 1fr;
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
  }

  .project-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-strong);
  }

  .project-card[hidden] {
    display: none;
  }

  .project-media {
    overflow: hidden;
    border-bottom: 1px solid var(--border);
  }

  .project-media img,
  .project-figure img {
    width: 100%;
    height: auto;
    transition: transform 260ms ease;
  }

  .project-card:hover .project-media img {
    transform: scale(1.025);
  }

  .project-body {
    display: grid;
    align-content: start;
    gap: 0.9rem;
    padding: 1.2rem;
  }

  .project-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 830;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .project-body h3 a:hover {
    text-decoration: underline;
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.18em;
  }

  .tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .tag {
    display: inline-flex;
    align-items: center;
    min-height: 1.75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface-2) 78%, transparent);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.76rem;
    font-weight: 760;
    padding: 0.25rem 0.55rem;
  }

  .filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
  }

  .filter-button {
    min-height: 2.35rem;
    padding: 0.55rem 0.8rem;
    font-size: 0.92rem;
  }

  .filter-button[aria-pressed='true'] {
    background: var(--accent);
    color: var(--accent-contrast);
    border-color: transparent;
  }

  .timeline {
    display: grid;
    gap: 1rem;
    max-width: 58rem;
  }

  .timeline-item {
    display: grid;
    grid-template-columns: 8.5rem minmax(0, 1fr);
    gap: 1rem;
    padding: 1rem;
  }

  .timeline-item > span {
    color: var(--accent);
    font-family: var(--font-mono);
    font-weight: 850;
  }

  .timeline-item h3 {
    margin-bottom: 0.35rem;
    font-size: 1.14rem;
    letter-spacing: -0.02em;
  }

  .contact-card {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 1.25rem;
    overflow: hidden;
    padding: clamp(1.3rem, 4vw, 2rem);
  }

  .contact-card h2 {
    max-width: 18ch;
    margin-block: 0.2rem 0.7rem;
  }

  .site-footer {
    padding-block: 2.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
  }

  .footer-grid {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }

  .footer-links {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.8rem;
  }

  .project-detail {
    background:
      radial-gradient(circle at 68% 12%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 28rem),
      transparent;
  }

  .project-detail h1 {
    max-width: 12ch;
  }

  .project-figure {
    padding: 0.5rem;
  }

  .project-figure img {
    border-radius: 1.4rem;
  }

  .check-list {
    display: grid;
    gap: 0.75rem;
    list-style: none;
    margin: 1.2rem 0 0;
    padding: 0;
  }

  .check-list li {
    position: relative;
    color: var(--muted);
    padding-left: 1.8rem;
  }

  .check-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    top: 0.05rem;
    display: grid;
    place-items: center;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    background: color-mix(in srgb, var(--accent-3) 25%, transparent);
    color: var(--accent-3);
    font-size: 0.78rem;
    font-weight: 900;
  }

  [data-reveal] {
    transform: translateY(0.75rem);
    opacity: 0;
    transition: opacity 520ms ease, transform 520ms ease;
  }

  [data-reveal].is-visible,
  :root:not([data-js='true']) [data-reveal] {
    transform: none;
    opacity: 1;
  }

  @media (prefers-reduced-motion: reduce) {
    [data-reveal] {
      transform: none;
      opacity: 1;
    }

    .project-media img,
    .button,
    .filter-button,
    .theme-toggle,
    .project-card {
      transition: none;
    }
  }

  @media (max-width: 920px) {
    .header-actions .button-small {
      display: none;
    }
  }

  @media (max-width: 780px) {
    :root[data-js='true'] .nav-toggle {
      display: inline-flex;
    }

    :root[data-js='true'] .site-nav {
      position: absolute;
      left: 0.5rem;
      right: 0.5rem;
      top: calc(var(--header-height) + 0.4rem);
      display: none;
      padding: 0.7rem;
      border: 1px solid var(--border);
      border-radius: 1rem;
      background: var(--bg-elevated);
      box-shadow: var(--shadow);
    }

    :root[data-js='true'] .site-nav.is-open {
      display: block;
    }

    :root[data-js='true'] .nav-list {
      display: grid;
      align-items: stretch;
      gap: 0.2rem;
    }

    :root[data-js='true'] .nav-list a {
      display: flex;
      justify-content: space-between;
      border-radius: 0.75rem;
      padding: 0.85rem 0.9rem;
    }

    .header-inner {
      gap: 0.6rem;
    }

    .brand span {
      display: none;
    }

    .timeline-item {
      grid-template-columns: 1fr;
    }

    .contact-card,
    .footer-grid {
      grid-template-columns: 1fr;
      align-items: start;
    }

    .footer-grid {
      display: grid;
    }

    .footer-links {
      justify-content: start;
    }
  }
}

@layer 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: 0;
  }
}
