:root {
  --bg: #f3ecdf;
  --bg-accent: #f8f4eb;
  --ink: #1f2a2c;
  --muted: #526062;
  --line: rgba(31, 42, 44, 0.12);
  --card: rgba(255, 250, 242, 0.72);
  --card-strong: #fffaf2;
  --highlight: #d86f45;
  --highlight-dark: #b95631;
  --shadow: 0 24px 70px rgba(77, 54, 34, 0.12);
  --radius-lg: 32px;
  --radius-md: 22px;
  --radius-sm: 14px;
  --max-width: 1120px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(216, 111, 69, 0.22), transparent 32%),
    radial-gradient(circle at top right, rgba(90, 143, 126, 0.18), transparent 26%),
    linear-gradient(180deg, #f8f2e8 0%, var(--bg) 48%, #efe5d4 100%);
  min-height: 100vh;
}

body.welcome-active {
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(31, 42, 44, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 42, 44, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent 80%);
}

body::after {
  content: "";
  position: fixed;
  top: 10.75rem;
  right: max(1rem, calc((100vw - var(--max-width)) / 2 + 1.5rem));
  width: min(340px, 28vw);
  aspect-ratio: 2 / 3;
  transform: none;
  border-radius: var(--radius-lg);
  background-color: rgba(255, 250, 242, 0.12);
  background-image: url("images/hero.png");
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  box-shadow: 0 24px 70px rgba(77, 54, 34, 0.18);
  pointer-events: none;
  z-index: 0;
}

body.welcome-active::after {
  display: none;
}

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

img {
  max-width: 100%;
}

.page-shell {
  width: min(calc(100% - 2rem), var(--max-width));
  margin: 0 auto;
  padding-bottom: 3rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 1.1rem;
  margin-top: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  background: rgba(248, 244, 235, 0.68);
  box-shadow: 0 14px 40px rgba(77, 54, 34, 0.08);
  backdrop-filter: blur(14px);
}

.brand,
.site-nav a,
.button,
.contact-links a {
  transition: transform 180ms ease, color 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.brand {
  display: inline-flex;
  align-items: center;
  height: 46px;
  font-weight: 700;
  letter-spacing: 0.16em;
  font-size: 0.9rem;
  overflow: visible;
}

.brand img {
  display: block;
  height: 76px;
  width: auto;
  transform: translateY(1px);
}

.brand:hover,
.site-nav a:hover,
.contact-links a:hover {
  color: var(--highlight);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  padding: 0.7rem 1.35rem;
  min-width: 360px;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.82);
}

.site-nav a {
  font-size: 0.95rem;
  color: var(--muted);
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.35rem;
  width: 3rem;
  height: 3rem;
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.82);
  border-radius: 50%;
  cursor: pointer;
}

.menu-toggle span {
  width: 1.15rem;
  height: 2px;
  background: var(--ink);
  transition: transform 180ms ease, opacity 180ms ease;
}

.section {
  padding: 5.5rem 0 0;
}

.welcome-banner {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  align-content: center;
  gap: 1rem;
  width: min(calc(100% - 2rem), var(--max-width));
  height: min(calc(100vh - 2rem), 920px);
  margin: auto;
  padding: 1.35rem 1.4rem;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-md);
  background: rgba(255, 250, 242, 0.96);
  box-shadow: 0 18px 40px rgba(77, 54, 34, 0.12);
  backdrop-filter: blur(12px);
}

.welcome-banner.is-hidden {
  display: none;
}

.welcome-close {
  justify-self: end;
  min-height: 2.8rem;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.92);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.welcome-copy {
  display: grid;
  gap: 0.25rem;
}

.welcome-image {
  display: block;
  width: 100%;
  height: auto;
}

.welcome-progress {
  overflow: hidden;
  height: 6px;
  border-radius: 999px;
  background: rgba(31, 42, 44, 0.08);
}

.welcome-progress-bar {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--highlight), #e7ad65);
  transform-origin: left center;
  animation: welcome-timeout 5s linear forwards;
}

@keyframes welcome-timeout {
  from {
    transform: scaleX(1);
  }

  to {
    transform: scaleX(0);
  }
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.9fr);
  gap: 2rem;
  align-items: end;
  min-height: calc(100vh - 6rem);
  padding-top: 2.25rem;
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 0 0 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  color: var(--highlight);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  line-height: 0.98;
}

h1 {
  font-size: clamp(3.5rem, 7vw, 6.8rem);
  max-width: 11ch;
}

h2 {
  font-size: clamp(2.25rem, 4vw, 3.6rem);
  max-width: 12ch;
}

h3 {
  font-size: 1.45rem;
  line-height: 1.1;
}

p,
li {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--muted);
}

.hero-text {
  max-width: 56ch;
  margin: 1.4rem 0 0;
  font-size: 1.08rem;
}

.hero-actions,
.contact-links,
.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
}

.hero-actions {
  margin-top: 2rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.8rem 1.2rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 500;
}

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

.button-primary {
  background: var(--highlight);
  color: #fffaf2;
}

.button-primary:hover {
  background: var(--highlight-dark);
}

.button-secondary {
  background: rgba(255, 250, 242, 0.7);
  background: rgba(255, 250, 242, 0.7);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.project-link {
  box-shadow: 0 10px 24px rgba(77, 54, 34, 0.08);
}

.video-trigger {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.hero-card,
.panel,
.project-card,
.contact-card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero-card {
  padding: 1.6rem;
  border-radius: var(--radius-lg);
}

.card-label,
.panel-title,
.project-index,
.timeline-year {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--ink);
}

.focus-list {
  margin: 1rem 0 0;
  padding-left: 1.1rem;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-top: 1.8rem;
}

.metric-row strong {
  display: block;
  font-size: 2rem;
  font-family: "Fraunces", Georgia, serif;
}

.metric-row span {
  color: var(--muted);
  font-size: 0.95rem;
}

.section-heading {
  position: relative;
  z-index: 1;
  margin-bottom: 1.8rem;
}

.section-grid,
.about-layout {
  display: grid;
  gap: 1.4rem;
}

.about-layout {
  grid-template-columns: 1.3fr 1fr;
}

.panel,
.project-card,
.contact-card {
  padding: 1.5rem;
  border-radius: var(--radius-md);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding: 0;
  margin: 1.2rem 0 0;
  list-style: none;
}

.tag-list li {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(216, 111, 69, 0.1);
  color: var(--ink);
  border: 1px solid rgba(216, 111, 69, 0.14);
  line-height: 1.2;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}

.project-card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.project-card p {
  margin-top: 0.9rem;
}

.project-links {
  margin-top: auto;
  padding-top: 1.5rem;
}

.more-projects-wrap {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  margin-top: 1.5rem;
}

.more-projects-toggle {
  min-width: 120px;
}

.more-projects {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.more-projects.is-hidden {
  display: none;
}

.more-timeline-wrap {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  margin-top: 1.5rem;
}

.more-timeline-toggle {
  min-width: 120px;
}

.more-timeline {
  margin-top: 1.5rem;
}

.more-timeline.is-hidden {
  display: none !important;
}

.more-timeline[hidden] {
  display: none !important;
}

.project-card-wide {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.9fr);
  gap: 1.5rem;
  align-items: stretch;
  width: 100%;
}

.project-card-wide .project-links {
  margin-top: auto;
  padding-top: 1rem;
}

.project-card-wide-main {
  display: grid;
  align-content: start;
  gap: 0.9rem;
}

.project-card-wide-main p {
  margin: 0;
}

.project-card-wide-side {
  display: grid;
  align-content: space-between;
  gap: 1.25rem;
  padding-left: 0.25rem;
}

.project-card-wide-side .tag-list {
  margin-top: 0;
  justify-content: flex-start;
}

.project-link,
.contact-links a {
  font-weight: 500;
}

.timeline {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.6rem;
  padding-left: 0;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 7.1rem;
  width: 8px;
  border-radius: 999px;
  background: #d9d9d9;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 5.5rem 4rem minmax(0, 1fr);
  gap: 0;
  align-items: center;
  padding: 0.7rem 0;
  border-top: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 6.85rem;
  top: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  transform: translateY(-50%);
  background: #fffaf2;
  border: 4px solid #b8bec7;
}

.timeline-year {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 5rem;
  min-height: 3rem;
  padding: 0.7rem 0.95rem;
  border-radius: 999px;
  background: #d86f45;
  color: #111111;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  font-size: 1rem;
  line-height: 1;
}

.timeline-year:empty {
  display: none;
}

.timeline-item > div h3,
.timeline-item > div p {
  color: #111111;
}

.timeline-item > div {
  grid-column: 3;
  min-width: 0;
  padding: 0.9rem 1rem;
  border-radius: 22px;
  background: rgba(255, 250, 242, 0.42);
}

.timeline-item > div h3 {
  line-height: 1.08;
}

.timeline-item > div p {
  margin: 0.4rem 0 0;
}

.contact-section {
  padding-bottom: 2rem;
}

.contact-card {
  display: grid;
  gap: 1rem;
}

.about-layout,
.project-grid,
.contact-card,
.site-footer {
  position: relative;
  z-index: 1;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 2.5rem;
  border-top: 1px solid var(--line);
}

.visitor-counter {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.65);
}

.visitor-counter-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.visitor-counter-value {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
}

/* Contribution Graph */
.contributions-panel {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.contribution-graph-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
}

.contribution-graph {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  grid-auto-flow: column;
  gap: 4px;
  /* Width will be determined by content */
}

.contribution-cell {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background-color: rgba(31, 42, 44, 0.05); /* Empty state */
  position: relative;
  cursor: pointer;
  transition: transform 0.1s ease, outline 0.1s ease;
}

.contribution-cell:hover {
  transform: scale(1.1);
  outline: 1px solid var(--highlight);
  z-index: 10;
}

/* Tooltip for the cell */
.contribution-cell::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  background: var(--ink);
  color: #fff;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}

.contribution-cell:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

/* Color levels based on theme */
.level-0 { background-color: rgba(31, 42, 44, 0.05); } /* --line equivalent but lighter */
.level-1 { background-color: rgba(216, 111, 69, 0.3); }
.level-2 { background-color: rgba(216, 111, 69, 0.55); }
.level-3 { background-color: rgba(216, 111, 69, 0.8); }
.level-4 { background-color: var(--highlight-dark); }

.contribution-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
  align-self: flex-end;
  margin-top: 0.5rem;
}

.legend-item {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend-label {
  margin: 0 4px;
}

.video-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.video-modal.is-hidden {
  display: none;
}

.video-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 22, 23, 0.48);
  backdrop-filter: blur(8px);
}

.video-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(860px, 100%);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 250, 242, 0.94);
  box-shadow: 0 24px 70px rgba(24, 20, 16, 0.24);
}

.video-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.video-modal-header h2 {
  font-size: clamp(1.4rem, 3vw, 2rem);
  max-width: none;
}

.video-modal-close {
  min-height: 2.75rem;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.9);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.video-frame-shell {
  overflow: hidden;
  border-radius: 18px;
  background: #000;
  aspect-ratio: 16 / 9;
}

.video-frame-shell iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.to-top-button {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
  transition: transform 180ms ease, opacity 180ms ease;
}

.to-top-button:hover {
  transform: translateY(-1px);
  opacity: 0.92;
}

.to-top-image {
  display: block;
  width: 96px;
  height: auto;
  margin-bottom: 0;
}

.to-top-text {
  margin: 0;
}

.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 700ms ease, transform 700ms ease;
}

.no-js .reveal {
  opacity: 1;
  transform: translateY(0);
}

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

@media (max-width: 900px) {
  body::after {
    width: min(280px, 42vw);
    top: 13rem;
    right: 1.25rem;
  }

  .hero,
  .about-layout,
  .project-grid,
  .project-card-wide {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: unset;
    padding-top: 2rem;
  }

  .project-card-wide-side {
    padding-left: 0;
  }
}

@media (max-width: 720px) {
  body::after {
    display: block;
    width: min(220px, 42vw);
    top: 11.5rem;
    right: 0.75rem;
    opacity: 0.9;
  }

  .welcome-banner {
    width: min(calc(100% - 1rem), var(--max-width));
    height: min(calc(100svh - 1rem), 920px);
    padding: 1rem;
  }

  .brand img {
    height: 58px;
  }

  .brand {
    height: 38px;
  }

  .page-shell {
    width: min(calc(100% - 1.2rem), var(--max-width));
  }

  .site-header {
    flex-wrap: wrap;
    border-radius: 28px;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .site-nav {
    display: none;
    width: 100%;
    min-width: 0;
    justify-content: space-around;
    border-radius: var(--radius-sm);
    padding: 0.9rem;
  }

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

  .menu-toggle[aria-expanded="true"] span:first-child {
    transform: translateY(4px) rotate(45deg);
  }

  .menu-toggle[aria-expanded="true"] span:last-child {
    transform: translateY(-4px) rotate(-45deg);
  }

  h1 {
    font-size: clamp(2.9rem, 12vw, 4.3rem);
  }

  h2 {
    font-size: clamp(2rem, 8vw, 2.9rem);
  }

  .section {
    padding-top: 4.5rem;
  }

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

  .timeline::before,
  .timeline-item::before {
    display: none;
  }

  .timeline-year {
    min-width: 0;
    width: fit-content;
  }

  .timeline-item > div {
    grid-column: auto;
    padding: 1rem;
    margin-top: 0;
  }

  .video-modal-dialog {
    padding: 0.85rem;
  }

  .video-modal-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .to-top-button {
    right: 0.75rem;
    bottom: 0.75rem;
    width: 78px;
  }

  .to-top-image {
    width: 62px;
    margin-bottom: 0;
  }

  .to-top-text {
    display: none;
  }
}
