/* ==========================================================================
   Design Tokens — petermark.dev
   ========================================================================== */

/* Dark theme (default) */
:root {
  /* Colors */
  --color-bg: #0f0f0f;
  --color-surface: #1a1a1a;
  --color-text: #e5e5e5;
  --color-text-muted: #888888;
  --color-accent: #a78bfa;
  --color-border: #2a2a2a;

  /* Typography */
  --font-family-base: 'Inter', system-ui, -apple-system, sans-serif;
  --font-size-base: 16px;
  --line-height-base: 1.6;

  --font-size-heading-section: 1.75rem;
  --font-weight-heading-section: 600;
  --letter-spacing-heading: -0.02em;

  --font-size-hero-name: 3rem;
  --font-weight-hero-name: 700;

  /* Spacing */
  --spacing-section-vertical: 80px;
  --spacing-page-horizontal: 24px;
  --spacing-container-max: 860px;

  /* Status */
  --color-status-green: #22c55e;

  /* Transitions */
  --transition-default: 200ms ease;

  /* Navigation */
  --nav-height: 64px;
  --color-nav-bg: rgba(26, 26, 26, 0.85);
}

/* Light theme override */
[data-theme="light"] {
  --color-bg: #fafafa;
  --color-surface: #ffffff;
  --color-text: #111111;
  --color-text-muted: #555555;
  --color-accent: #7c3aed;
  --color-border: #e5e5e5;
  --color-nav-bg: rgba(255, 255, 255, 0.85);
}

/* ==========================================================================
   Base Reset & Global Styles
   ========================================================================== */

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

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

body {
  font-family: var(--font-family-base);
  font-size: 1rem;
  line-height: var(--line-height-base);
  background-color: var(--color-bg);
  color: var(--color-text);
  margin: 0;
  padding: 0;
  padding-top: var(--nav-height);
  overflow-wrap: break-word;
  transition: background-color var(--transition-default), color var(--transition-default);
}

/* ==========================================================================
   Selection
   ========================================================================== */

::-moz-selection {
  background: var(--color-accent);
  color: var(--color-bg);
  text-shadow: none;
}

::selection {
  background: var(--color-accent);
  color: var(--color-bg);
  text-shadow: none;
}

/* ==========================================================================
   Media Elements
   ========================================================================== */

audio,
canvas,
iframe,
img,
svg,
video {
  vertical-align: middle;
}

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

/* ==========================================================================
   Typography Reset
   ========================================================================== */

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  font-weight: 600;
  line-height: 1.2;
}

p {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-default);
}

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

/* ==========================================================================
   Form Elements
   ========================================================================== */

button {
  font-family: inherit;
  cursor: pointer;
}

/* ==========================================================================
   Focus Styles (keyboard navigation)
   ========================================================================== */

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ==========================================================================
   Skip Link (keyboard accessibility)
   ========================================================================== */

.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  z-index: 200;
  padding: 0.75rem 1.5rem;
  background-color: var(--color-accent);
  color: var(--color-bg);
  font-weight: 600;
  font-size: 0.9375rem;
  border-radius: 0 0 0.375rem 0;
  transition: top var(--transition-default);
}

.skip-link:focus {
  top: 0;
  color: var(--color-bg);
}

/* ==========================================================================
   Layout Utilities
   ========================================================================== */

.container {
  max-width: var(--spacing-container-max);
  margin-inline: auto;
  padding-inline: var(--spacing-page-horizontal);
}

.section {
  padding-block: var(--spacing-section-vertical);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.section.is-visible {
  opacity: 1;
  transform: none;
}

.section__heading {
  font-size: var(--font-size-heading-section);
  font-weight: var(--font-weight-heading-section);
  letter-spacing: var(--letter-spacing-heading);
  color: var(--color-text);
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  :root {
    --spacing-page-horizontal: 48px;
  }

  /* Desktop: links always visible inline; hamburger hidden */
  .nav__links {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1.5rem;
    position: static;
    background-color: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: none;
    padding: 0;
  }

  .nav__hamburger {
    display: none;
  }
}

/* ==========================================================================
   Navigation
   ========================================================================== */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--nav-height);
  background-color: var(--color-nav-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  transition:
    border-color var(--transition-default),
    background-color var(--transition-default);
}

.nav--scrolled {
  border-bottom-color: var(--color-border);
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: var(--spacing-container-max);
  margin-inline: auto;
  padding-inline: var(--spacing-page-horizontal);
}

.nav__wordmark {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-accent);
  letter-spacing: -0.01em;
  transition: opacity var(--transition-default);
}

.nav__wordmark:hover {
  opacity: 0.75;
}

.nav__right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Mobile: links hidden by default; shown as dropdown when .nav--open */
.nav__links {
  display: none;
}

.nav--open .nav__links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.25rem;
  position: absolute;
  top: var(--nav-height);
  left: 0;
  right: 0;
  background-color: var(--color-nav-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
  padding: 1.25rem var(--spacing-page-horizontal);
  z-index: 99;
}

.nav__hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0.25rem;
  color: var(--color-text-muted);
  transition: color var(--transition-default);
  line-height: 1;
}

.nav__hamburger:hover {
  color: var(--color-text);
}

.nav__hamburger-icon--close {
  display: none;
}

.nav--open .nav__hamburger-icon--menu {
  display: none;
}

.nav--open .nav__hamburger-icon--close {
  display: block;
}

.nav__link {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.nav__link--active {
  color: var(--color-accent);
}

.nav__link--active:hover {
  color: var(--color-accent);
}

.nav__theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0.25rem;
  color: var(--color-text-muted);
  transition: color var(--transition-default);
  line-height: 1;
}

.nav__theme-toggle:hover {
  color: var(--color-text);
}

/* Dark mode: show sun; light mode: show moon */
.nav__icon--moon {
  display: none;
}

[data-theme="light"] .nav__icon--sun {
  display: none;
}

[data-theme="light"] .nav__icon--moon {
  display: block;
}

/* ==========================================================================
   Hero Section
   ========================================================================== */

.hero {
  min-height: calc(100vh - var(--nav-height));
  display: flex;
  align-items: center;
  opacity: 1;
  transform: none;
}

.hero__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
  text-align: center;
  width: 100%;
}

.hero__text {
  display: flex;
  flex-direction: column;
}

.hero__greeting {
  font-size: 1rem;
  color: var(--color-text-muted);
  margin-bottom: 0.375rem;
}

.hero__name {
  font-size: var(--font-size-hero-name);
  font-weight: var(--font-weight-hero-name);
  color: var(--color-accent);
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.hero__title {
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.hero__tagline {
  font-size: 1rem;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

.hero__status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  align-self: center;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.3125rem 0.875rem;
  margin-bottom: 1.75rem;
}

.hero__status-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background-color: var(--color-status-green);
  flex-shrink: 0;
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes status-pulse {
    0% {
      box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
    }
    70% {
      box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
    }
    100% {
      box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
  }

  .hero__status-dot {
    animation: status-pulse 2s ease infinite;
  }
}

.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.875rem;
  justify-content: center;
  margin-bottom: 1.75rem;
}

.hero__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.5rem;
  border-radius: 0.375rem;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  transition:
    background-color var(--transition-default),
    color var(--transition-default),
    border-color var(--transition-default),
    opacity var(--transition-default);
}

.hero__btn--primary {
  background-color: var(--color-accent);
  color: var(--color-bg);
  border: 2px solid var(--color-accent);
}

.hero__btn--primary:hover {
  color: var(--color-bg);
  opacity: 0.85;
}

.hero__btn--secondary {
  background-color: transparent;
  color: var(--color-accent);
  border: 2px solid var(--color-accent);
}

.hero__btn--secondary:hover {
  background-color: var(--color-accent);
  color: var(--color-bg);
}

.hero__social {
  display: flex;
  gap: 1.25rem;
  justify-content: center;
}

.hero__social-link {
  display: flex;
  align-items: center;
  color: var(--color-text-muted);
}

.hero__photo-wrap {
  flex-shrink: 0;
}

.hero__photo {
  display: block;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 20%;
  border: 3px solid var(--color-border);
}

@media (min-width: 768px) {
  .hero__inner {
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 4rem;
  }

  .hero__text {
    flex: 1;
  }

  .hero__status {
    align-self: flex-start;
  }

  .hero__cta {
    justify-content: flex-start;
  }

  .hero__social {
    justify-content: flex-start;
  }

  .hero__photo {
    width: 300px;
    height: 300px;
  }
}

@media (min-width: 1024px) {
  :root {
    --font-size-hero-name: 4rem;
  }

  .hero__tagline {
    font-size: 1.125rem;
  }
}

/* ==========================================================================
   Experience Section
   ========================================================================== */

.timeline {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.timeline__entry {
  border-left: 2px solid var(--color-accent);
  padding-left: 1.5rem;
}

.timeline__header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.timeline__role {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.timeline__date {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.timeline__bullets {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  list-style-type: disc;
  padding-left: 1.25rem;
}

.timeline__bullet {
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  line-height: var(--line-height-base);
}

@media (min-width: 768px) {
  .timeline__header {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
  }

  .timeline__date {
    flex-shrink: 0;
    text-align: right;
  }
}

/* ==========================================================================
   Education Section
   ========================================================================== */

.education__entry {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  padding: 1.5rem;
}

.education__header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.375rem;
}

.education__degree {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.education__date {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.education__institution {
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

.education__details {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  list-style-type: disc;
  padding-left: 1.25rem;
}

.education__detail {
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  line-height: var(--line-height-base);
}

@media (min-width: 768px) {
  .education__header {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
  }

  .education__date {
    flex-shrink: 0;
    text-align: right;
  }
}

/* ==========================================================================
   Skills Section
   ========================================================================== */

.skills__categories {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
}

.skills__category {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.skills__category-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.skills__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
}

.skills__tag {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  padding: 0.25rem 0.75rem;
}

@media (min-width: 768px) {
  .skills__category {
    flex-direction: row;
    align-items: flex-start;
    gap: 1.5rem;
  }

  .skills__category-name {
    min-width: 180px;
    flex-shrink: 0;
    padding-top: 0.3125rem;
  }
}

/* ==========================================================================
   Projects Section
   ========================================================================== */

.projects__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.projects__card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  overflow: hidden;
  transition:
    box-shadow var(--transition-default),
    transform var(--transition-default);
}

.projects__card:hover {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.24);
  transform: translateY(-4px);
}

.projects__card-thumb {
  overflow: hidden;
}

.projects__card-img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.projects__card-body {
  padding: 1.25rem;
}

.projects__card-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.projects__card-desc {
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  line-height: var(--line-height-base);
  margin-bottom: 1rem;
}

.projects__card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 1rem;
}

.projects__card-tag {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-accent);
  background-color: rgba(167, 139, 250, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.25);
  border-radius: 999px;
  padding: 0.1875rem 0.625rem;
}

[data-theme="light"] .projects__card-tag {
  background-color: rgba(124, 58, 237, 0.1);
  border-color: rgba(124, 58, 237, 0.2);
}

.projects__card-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.projects__card-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.projects__card-link:hover {
  color: var(--color-accent);
}

@media (min-width: 768px) {
  .projects__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================================================
   Hobbies Section
   ========================================================================== */

.hobbies__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.hobbies__chip {
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.5rem 1rem;
}

/* ==========================================================================
   Leadership Section
   ========================================================================== */

.leadership__list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  list-style-type: disc;
  padding-left: 1.25rem;
}

.leadership__item {
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  line-height: var(--line-height-base);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  border-top: 1px solid var(--color-border);
  padding-block: 2.5rem;
}

.footer__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.footer__name {
  font-size: 0.9375rem;
  color: var(--color-text-muted);
}

.footer__social {
  display: flex;
  gap: 1.25rem;
  justify-content: center;
}

.footer__social-link {
  display: flex;
  align-items: center;
  color: var(--color-text-muted);
}

.footer__meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.footer__built-link {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.footer__built-link:hover {
  color: var(--color-accent);
}

.footer__built {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* ==========================================================================
   Back to Top Button
   ========================================================================== */

.back-to-top {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--transition-default),
    color var(--transition-default),
    border-color var(--transition-default);
}

.back-to-top--visible {
  opacity: 1;
  pointer-events: auto;
}

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

/* ==========================================================================
   Helper Classes
   ========================================================================== */

.hidden,
[hidden] {
  display: none;
}

/* Pages without a fixed nav (e.g. 404) don't need the nav offset */
.body--no-nav {
  padding-top: 0;
}

/* ==========================================================================
   404 Error Page
   ========================================================================== */

.not-found {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: 48px 24px;
}

.not-found__code {
  font-size: clamp(5rem, 20vw, 9rem);
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1;
  margin: 0 0 1rem;
  letter-spacing: -0.04em;
}

.not-found__heading {
  font-size: var(--font-size-heading-section);
  font-weight: var(--font-weight-heading-section);
  letter-spacing: var(--letter-spacing-heading);
  color: var(--color-text);
  margin: 0 0 0.75rem;
}

.not-found__message {
  color: var(--color-text-muted);
  margin: 0 0 2rem;
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

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

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

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

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
  *,
  *::before,
  *::after {
    background: #fff !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  a,
  a:visited {
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
  }

  a[href^="#"]::after,
  a[href^="javascript:"]::after {
    content: "";
  }

  pre,
  blockquote {
    border: 1px solid #999;
    page-break-inside: avoid;
  }

  tr,
  img {
    page-break-inside: avoid;
  }

  p,
  h2,
  h3 {
    orphans: 3;
    widows: 3;
  }

  h2,
  h3 {
    page-break-after: avoid;
  }

  /* Portfolio-specific print rules */

  /* Nav is hidden so body no longer needs top padding */
  body {
    padding-top: 0;
  }

  /* Sections start at opacity: 0 via scroll animation — force visible for print */
  .section {
    opacity: 1;
    transform: none;
    padding-block: 1.5rem;
  }

  /* Hide non-content chrome */
  .nav,
  .back-to-top,
  .skip-link {
    display: none;
  }

  /* Compact hero — no interaction elements needed in print */
  .hero {
    min-height: auto;
  }

  .hero__cta,
  .hero__social,
  .hero__photo-wrap {
    display: none;
  }

  .hero__inner {
    flex-direction: column;
  }

  /* Avoid breaking inside content blocks */
  .timeline__entry,
  .education__entry,
  .projects__card {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* Avoid splitting immediately after key headings */
  .section__heading,
  .timeline__role,
  .education__degree {
    page-break-after: avoid;
    break-after: avoid;
  }

  /* Print projects in a single column */
  .projects__grid {
    grid-template-columns: 1fr;
  }

  /* Hide footer chrome; keep name/location text */
  .footer__social,
  .footer__meta {
    display: none;
  }
}
