/* ==========================================================================
   Design tokens
   ========================================================================== */

:root,
[data-theme="light"] {
  --c-bg: #ffffff;
  --c-bg-alt: #f7f5f5;
  --c-text: #111111;
  --c-text-dim: #5a5654;
  --c-accent: #7a1620;
  --c-accent-contrast: #ffffff;
  --c-border: #e3e0df;
  --c-card-bg: #ffffff;
}

[data-theme="dark"] {
  --c-bg: #0b0b0c;
  --c-bg-alt: #161616;
  --c-text: #f2f0ee;
  --c-text-dim: #a8a4a2;
  --c-accent: #c23b3b;
  --c-accent-contrast: #ffffff;
  --c-border: #2a2a2c;
  --c-card-bg: #141414;
}

:root {
  --font-display: "Charis SIL", serif; /* Added "Charis SIL" to the front of the variable stack */
  --font-body: "Inter", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-body);
  line-height: 1.6;
  transition: background 0.2s ease, color 0.2s ease;
}

a { color: inherit; }

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

body h1, body h2, body h3, 
main h1, main h2, main h3, 
.hero h1, .site-title {
  /* Listing Charis SIL first forces Chrome to map to the remote Google Font file instead of your corrupt system file */
  font-family: "Charis SIL", serif !important; 
  font-weight: 700 !important;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c-accent);
  margin: 0 0 0.75rem;
}

/* ==========================================================================
   Nav
   ========================================================================== */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--c-bg);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1.5rem;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--c-border);
  transition: padding 0.25s ease, box-shadow 0.25s ease;
}

.site-nav.is-compact {
  padding: 0.55rem 2rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .site-nav.is-compact {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.site-nav__brand {
  font-family: var(--font-display);
  font-weight: 700;
  text-decoration: none;
  font-size: 1.1rem;
  transition: font-size 0.25s ease;
  justify-self: start;
}

.site-nav.is-compact .site-nav__brand {
  font-size: 0.8rem;
}

.site-nav__links {
  display: flex;
  gap: 1.75rem;
  list-style: none;
  margin: 0;
  padding: 0;
  justify-self: center;
}

.site-nav__links a {
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-text-dim);
  padding-bottom: 0.25rem;
  border-bottom: 2px solid transparent;
  transition: font-size 0.25s ease, color 0.15s ease;
}

.site-nav.is-compact .site-nav__links a {
  font-size: 0.65rem;
}

.site-nav__links a:hover,
.site-nav__links a.is-active {
  color: var(--c-text);
  border-bottom-color: var(--c-accent);
}

.theme-toggle {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  background: none;
  border: 1px solid var(--c-border);
  color: var(--c-text-dim);
  padding: 0.4rem 0.7rem;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  gap: 0.4em;
  justify-self: end;
}

.theme-toggle:hover {
  border-color: var(--c-accent);
  color: var(--c-text);
}

.theme-toggle {
  transition: font-size 0.25s ease, padding 0.25s ease, border-color 0.15s ease, color 0.15s ease;
}

.site-nav.is-compact .theme-toggle {
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
}

/* ==========================================================================
   Layout shell
   ========================================================================== */

.site-content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 3rem 2rem 5rem;
}

.site-footer {
  border-top: 1px solid var(--c-border);
  padding: 2rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--c-text-dim);
}

.site-footer a {
  color: var(--c-text-dim);
}

/* ==========================================================================
   Signature element: corner-bracket frames
   Nod to oscilloscope / schematic calibration marks — reads as
   engineering/test-equipment UI without being literal about it.
   ========================================================================== */

.bracket-frame {
  position: relative;
  padding: 2rem;
}

.bracket-frame::before,
.bracket-frame::after,
.project-card::before,
.project-card::after,
.article-card::before,
.article-card::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-color: var(--c-border);
  border-style: solid;
  border-width: 0;
  transition: border-color 0.15s ease;
}

.bracket-frame::before { top: 0; left: 0; border-top-width: 2px; border-left-width: 2px; }
.bracket-frame::after { bottom: 0; right: 0; border-bottom-width: 2px; border-right-width: 2px; }

.project-card::before,
.article-card::before { top: -1px; left: -1px; border-top-width: 2px; border-left-width: 2px; }
.project-card::after,
.article-card::after { bottom: -1px; right: -1px; border-bottom-width: 2px; border-right-width: 2px; }

.project-card:hover::before,
.project-card:hover::after,
.article-card:hover::before,
.article-card:hover::after {
  border-color: var(--c-accent);
}

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

.hero {
  margin-bottom: 4rem;
  display: flex;
  align-items: center;
  gap: 3rem;
  position: relative;
  isolation: isolate; /* keeps the background layer contained behind hero content */
}

.hero__bg {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: var(--hero-photo);
  background-size: cover;
  background-position: right center;
  opacity: 0.18;
  -webkit-mask-image: linear-gradient(to left, black 15%, transparent 70%);
          mask-image: linear-gradient(to left, black 15%, transparent 70%);
}

[data-theme="dark"] .hero__bg {
  opacity: 0.22;
}

.hero__text {
  flex: 1 1 65%;
  min-width: 0;
}

.hero__photo {
  flex: 1 1 33%;
  max-width: 33%;
}

.hero__photo img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  object-position: 35% center;
  border: 1px solid var(--c-border);
}

@media (max-width: 640px) {
  .hero {
    flex-direction: column-reverse;
    gap: 1.5rem;
  }
  .hero__photo {
    max-width: 100%;
    align-self: center;
  }
  .hero__photo img {
    aspect-ratio: auto; /* let the original landscape ratio show through, no crop */
    height: auto;
    object-fit: contain;
  }
}

.hero h1 {
  font-size: clamp(2.0rem, 5.5vw, 3.4rem); /* Lifted the mobile minimum up safely since Charis fits easily */
  white-space: nowrap;
  margin: 0 0 0.3rem; /* fixed value instead of the em-based default, so it doesn't scale up with this large font-size */
}

.hero__role {
  color: var(--c-text-dim);
  font-size: 1.1rem;
  margin: 0.6rem 0 1rem; /* clearer, deliberate gap above the role line */
}

.hero__status {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--c-accent);
  letter-spacing: 0.06em;
  margin: 0 0 0.35rem;
}

/* ==========================================================================
   Section headers
   ========================================================================== */

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--c-border);
  padding-bottom: 0.75rem;
}

.section-header h2 {
  font-size: 1.4rem;
  margin: 0;
}

.section-header a {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-decoration: none;
  color: var(--c-text-dim);
}

.section-header a:hover { color: var(--c-accent); }

/* ==========================================================================
   Cards: projects + articles
   ========================================================================== */

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
}

.project-card,
.article-card {
  position: relative;
  display: block;
  text-decoration: none;
  color: var(--c-text);
  background: var(--c-card-bg);
  border: 1px solid var(--c-border);
  padding: 1.25rem;
  transition: transform 0.15s ease;
}

.project-card:hover,
.article-card:hover {
  transform: translateY(-2px);
}

.project-card img {
  width: 100%;
  aspect-ratio: 16/10;
  object-fit: cover;
  margin-bottom: 1rem;
}

.project-card h3,
.article-card h3 {
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
}

.project-card__tag,
.article-card__meta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--c-accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 0.5rem;
}

.article-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ==========================================================================
   Filters
   ========================================================================== */

.project-filters,
.article-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.filter-btn {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: none;
  border: 1px solid var(--c-border);
  color: var(--c-text-dim);
  padding: 0.4rem 0.8rem;
  border-radius: 3px;
  cursor: pointer;
}

.filter-btn:hover { border-color: var(--c-accent); color: var(--c-text); }

.filter-btn.is-active {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: var(--c-accent-contrast);
}

/* ==========================================================================
   Resume download button (About page)
   ========================================================================== */

.resume-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.7rem 1.4rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--c-accent-contrast);
  background: var(--c-accent);
  border: 1px solid var(--c-accent);
  border-radius: 3px;
  transition: opacity 0.15s ease;
}

.resume-btn:hover {
  opacity: 0.85;
}

/* ==========================================================================
   Individual project / article pages
   ========================================================================== */

.article__meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--c-text-dim); /* Set the base text and date to a clean, subtle gray */
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.project__tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--c-accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.article__tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  
  /* Layout and Shape */
  padding: 0.25rem 0.65rem;
  margin-right: 0.4rem;
  margin-bottom: 0.4rem;
  border-radius: 3px;
  
  /* Theme Colors */
  background-color: var(--c-bg-alt);
  color: var(--c-text-dim);
  border: 1px solid var(--c-border);
}

.article__tag:last-child {
  margin-right: 0;
}

.project__cover,
.article__cover {
  width: 100%;
  margin: 1.5rem 0;
  border: 1px solid var(--c-border);
}

.project__gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

.gallery-img {
  cursor: pointer;
  transition: opacity 0.15s ease;
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
}

.gallery-img:hover {
  opacity: 0.82;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 3rem 2rem;
}

.lightbox.is-active {
  display: flex;
}

.lightbox__image {
  max-width: 90vw;
  max-height: 88vh;
  width: auto;
  object-fit: contain;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

.lightbox__close {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--c-border);
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.lightbox__close:hover {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: var(--c-accent-contrast);
}

.video-embed {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  margin: 1.5rem 0;
  border: 1px solid var(--c-border);
}

.video-embed iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
}

/* Fallback for videos with embedding disabled: linked thumbnail with play button */
.video-thumbnail-link {
  position: relative;
  display: block;
  aspect-ratio: 16/9;
  overflow: hidden;
  border: 1px solid var(--c-border);
  margin: 1.5rem 0;
}
 
.video-thumbnail-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}
 
.video-thumbnail-link:hover img {
  transform: scale(1.03);
}
 
.video-thumbnail-link__play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--c-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}
 
.video-thumbnail-link:hover .video-thumbnail-link__play {
  transform: translate(-50%, -50%) scale(1.08);
}
 
.video-thumbnail-link__play::after {
  content: "";
  width: 0;
  height: 0;
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
  border-left: 18px solid var(--c-accent-contrast);
  margin-left: 4px; /* optically center the triangle */
}

/* ==========================================================================
   Accessibility: visible focus, reduced motion
   ========================================================================== */

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 640px) {
  .site-nav {
    display: flex;
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
    row-gap: 0.4rem;
  }

  .site-nav__brand {
    font-size: 0.75rem;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .theme-toggle {
    font-size: 0.6rem;
    padding: 0.25rem 0.45rem;
    flex-shrink: 0;
  }

  .theme-toggle__mode {
    display: none; /* hide "MODE:" label on mobile, keep just LIGHT/DARK */
  }

  .site-nav__links {
    order: 3;
    flex-basis: 100%;
    width: 100%;
    justify-content: flex-start;
    gap: 0.9rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .site-nav__links a {
    font-size: 0.68rem;
    white-space: nowrap;
  }

  .site-nav__links::-webkit-scrollbar {
    display: none;
  }

  .site-content { padding: 1.5rem 1rem 3rem; }

  .project__gallery {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }
}
