/* ==========================================================================
   Base Styles and Variables
   ========================================================================== */
:root {
  /* CV Brand Colors */
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --text: #153650;
  --text-muted: #427890;
  --accent: #2c5770;
  --primary: #2c5770;
  --secondary: #427890;
  --accent-light: rgba(44, 87, 112, 0.08);
  --accent-hover: rgba(44, 87, 112, 0.15);

  /* Borders and UI */
  --line: rgba(21, 54, 80, 0.1);
  --panel: #ffffff;

  /* Effects */
  --shadow-sm: 0 4px 12px rgba(21, 54, 80, 0.05);
  --shadow: 0 10px 30px -5px rgba(21, 54, 80, 0.08);
  --shadow-hover: 0 20px 40px -10px rgba(21, 54, 80, 0.15);
  --radius: 12px;
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);

  /* Layout */
  --max: 1080px;
  --pad: 24px;

  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
  font-weight: 300;
  color: var(--text);
  background-color: var(--bg);
  line-height: 1.6;
}

/* Typography Defaults (Mobile First) */
h1,
h2,
h3,
h4,
h5,
h6,
.brand,
.btn {
  font-weight: 600;
  color: var(--text);
}

a {
  color: inherit;
  transition: var(--transition);
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 8px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 10px;
  background: var(--bg);
  color: var(--text);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 600;
  box-shadow: var(--shadow);
}

.skip-link:focus {
  left: 10px;
  z-index: 9999;
}

.container {
  width: 100%;
  padding: 0 var(--pad);
  margin: 0 auto;
  max-width: calc(var(--max) + (var(--pad) * 2));
}

.container--project {
  max-width: calc(1300px + (var(--pad) * 2));
}

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

.fw-bold {
  font-weight: 600;
}

.fst-italic {
  font-style: italic;
}

.text-accent {
  color: var(--accent);
}

.pt-0 {
  padding-top: 0;
}

.mb-0 {
  margin-bottom: 0;
}

.mb-xs {
  margin-bottom: 8px;
}

.mb-sm {
  margin-bottom: 12px;
}

.mr-sm {
  margin-right: 8px;
}

.mt-xs {
  margin-top: 8px;
}

.mt-sm {
  margin-top: 24px;
}

.mt-md {
  margin-top: 40px;
}

.mt-lg {
  margin-top: 64px;
}

.bold {
  font-weight: 600;
}

.flex-1 {
  flex: 1;
}

.flex-1-8 {
  flex: 1.8;
}

.aside-fill {
  display: flex;
  flex-direction: column;
}

.contact-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

/* Back to Top Button */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  background-color: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1000;
  border: none;
  cursor: pointer;
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  background-color: var(--accent);
  transform: translateY(-4px);
  color: white;
}

@media (max-width: 600px) {
  .back-to-top {
    bottom: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
  }
}


/* ==========================================================================
   Navigation (Header) - Mobile First Baseline
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  transition: var(--transition);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px var(--pad);
  position: relative;
  max-width: var(--max);
  margin: 0 auto;
}

.brand {
  text-decoration: none;
  font-size: 1.1rem;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  font-weight: 600;
  z-index: 10;
}

/* Mobile Toggle (Visible Default) */
.nav__toggle {
  display: inline-flex;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  color: var(--text);
  transition: var(--transition);
  z-index: 10;
}

.nav__toggle:hover {
  background: var(--accent-light);
}

.nav__toggle-bars {
  display: block;
  width: 22px;
  height: 14px;
  position: relative;
}

.nav__toggle-bars::before,
.nav__toggle-bars::after,
.nav__toggle-bars {
  background: transparent;
}

.nav__toggle-bars::before,
.nav__toggle-bars::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--text);
  border-radius: 999px;
  transition: var(--transition);
}

.nav__toggle-bars::before {
  top: 1px;
}

.nav__toggle-bars::after {
  bottom: 1px;
}

/* Nav Menu (Hidden & Stacked on Mobile Default) */
.nav__menu {
  display: none;
  position: absolute;
  left: var(--pad);
  right: var(--pad);
  top: 70px;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  gap: 8px;
  z-index: 50;
}

.nav__menu.is-open {
  display: flex;
  animation: fadeIn 0.3s ease-out;
}

.nav__link {
  text-decoration: none;
  padding: 12px 16px;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  width: 100%;
  text-align: left;
}

.nav__link:hover {
  background: var(--accent-light);
  color: var(--text);
}

.nav__link.is-active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

/* ==========================================================================
   Main Layout & Components (Mobile First Default)
   ========================================================================== */
.post-layout {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.main {
  min-height: calc(100vh - 140px);
  animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero {
  position: relative;
  padding: 40px 0 20px;
  overflow: hidden;
}

.hero__bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at top right, var(--bg-alt), transparent 60%);
}

.hero__content {
  position: relative;
  z-index: 1;
}

.hero__middle {
  display: flex;
  flex-direction: column-reverse;
  gap: 32px;
  margin: 32px 0;
}

.hero-avatar {
  box-sizing: border-box;
  width: 220px;
  height: 220px;
  border-radius: 16px;
  overflow: hidden;
  border: 10px solid var(--bg);
  box-shadow: var(--shadow-sm);
  margin: 0 auto;
}

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

.kicker {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-alt);
  color: var(--text);
  margin: 0 0 20px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.title {
  /* Mobile default font size */
  font-size: 2.2rem;
  line-height: 1.15;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0 0 24px;
}

.lead {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 70ch;
  margin: 0 0 32px;
}

.cta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 24px 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 24px;
  border-radius: 8px;
  text-decoration: none;
  background: var(--accent);
  color: var(--bg);
  font-weight: 500;
  border: 1px solid var(--accent);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.btn:hover {
  background: var(--text);
  border-color: var(--text);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.btn--ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--line);
}

.btn--ghost:hover {
  background: var(--accent-light);
  color: var(--text);
  border-color: var(--accent);
}

.btn--full {
  width: 100%;
}

.quick-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.chip {
  padding: 8px 16px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.9rem;
  font-weight: 600;
}

.chip__label {
  color: rgba(255, 255, 255, 0.7);
  margin-right: 6px;
  font-weight: 400;
}

.page-hero {
  padding: 32px 0 24px;
}

.section {
  padding: 40px 0;
}

.section--alt {
  background: var(--bg-alt);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.section__title {
  margin: 0 0 32px;
  font-size: 1.8rem;
  letter-spacing: -0.01em;
}

/* Strict mobile default card layout */
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 24px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
}

.card__title {
  margin: 0 0 12px;
  font-size: 1.25rem;
  position: relative;
}

.card__text {
  margin: 0 0 20px;
  color: var(--text-muted);
  position: relative;
  flex-grow: 1;
}

.card__meta {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
  position: relative;
}

.card__link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  /* position: static allows ::before to escape to .card bounds */
}

/* Expand the clickable area to cover the entire card */
.card__link::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.card__link::after {
  content: "\f061";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  transition: transform 0.2s ease;
  position: relative;
  z-index: 2;
}

.card__link:hover::after {
  transform: translateX(4px);
}

.card__tag {
  position: relative;
  display: inline-block;
  margin-top: auto;
  font-size: 0.85rem;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
  align-self: flex-start;
}

.page-hero {
  padding: 40px 0 20px;
  border-bottom: 1px solid var(--line);
  background: radial-gradient(circle at top, var(--bg-alt), transparent 70%);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  align-items: start;
}

.list {
  margin: 16px 0 32px;
  padding-left: 20px;
  color: var(--text);
}

.list li {
  margin: 12px 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  position: static;
}

.profile-avatar {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  background-color: var(--bg-alt);
  border: 1px solid var(--line);
  overflow: hidden;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 3rem;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-hero-img {
  width: 100%;
  height: 450px;
  object-fit: cover;
  object-position: center 35%;
  border-radius: var(--radius);
  margin-bottom: 32px;
  box-shadow: var(--shadow-sm);
}

.skills-heading {
  margin-bottom: 16px;
  font-size: 1.1rem;
}

.skills-heading--primary {
  color: var(--primary);
}

.skills-heading--secondary {
  color: var(--secondary);
}

.skills-list {
  list-style-position: inside;
  color: var(--text-muted);
  line-height: 1.6;
}

.iframe-embed {
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: white;
}

.panel__title {
  margin: 0 0 24px;
}

.cv-viewer {
  width: 100%;
  height: 85vh;
  min-height: 600px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.kv {
  margin: 0 0 24px;
}

.kv__row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.kv__row:last-child {
  border-bottom: none;
}

.kv__row dt {
  color: var(--text-muted);
  font-weight: 500;
}

.kv__row dd {
  margin: 0;
  color: var(--text);
  text-align: right;
  font-weight: 500;
}

.notice {
  margin-top: 40px;
  padding: 20px 24px;
  border-radius: 8px;
  border-left: 4px solid var(--accent);
  background: var(--accent-light);
  color: var(--text);
}

.footer {
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 32px 0;
  margin-top: auto;
}

.footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.footer__text {
  margin: 0;
  color: var(--text-muted);
  font-weight: 500;
}

.footer__text--small {
  font-size: 0.9rem;
}

/* ==========================================================================
   Responsive Breakpoints (Mobile First - Minimum Scaled Expansions)
   ========================================================================== */
@media (min-width: 640px) {
  /* Expand Header */
  .nav__toggle {
    display: none;
  }
  
  .nav__menu {
    display: flex;
    position: static;
    flex-direction: row;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    width: auto;
  }

  .nav__menu.is-open {
    animation: none; /* remove mobile toggling animation on desktop */
  }

  .nav__link {
    width: auto;
    padding: 8px 16px;
    text-align: center;
  }

  /* Expand Typography & Padding */
  .title {
    font-size: clamp(2.5rem, 4vw, 3.8rem);
  }

  .subtitle {
    font-size: clamp(1.4rem, 2.5vw, 2rem);
  }

  .hero {
    padding: 80px 0 20px;
  }

  .section {
    padding: 60px 0;
  }

  .page-hero {
    padding: 40px 0 32px;
  }

  /* Expand Layout Grid (Cards auto-fit) */
  .cards {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  }
}

@media (min-width: 900px) {
  .hero__content {
    max-width: 1000px;
  }
  .hero__middle {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .hero__middle-text {
    flex: 1;
    padding-right: 60px;
  }
  .hero__middle .hero-avatar {
    flex: 0 0 250px;
  }
  .hero-avatar {
    width: 250px;
    height: 250px;
    margin: 0;
  }

  /* Double Column Scalings */
  .two-col {
    grid-template-columns: 1.8fr 1fr;
    gap: 40px;
  }

  .two-col--equal {
    grid-template-columns: 1fr 1fr;
  }

  .panel {
    /* Sticky removed to prevent overlapping following content */
  }

  .post-layout {
    display: grid;
    grid-template-columns: 1.8fr 1fr;
    gap: 40px;
  }
}