/* CMS.js overrides */
body, html { font-family: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif; }
/* Prevent horizontal scroll without breaking position:sticky (clip ≠ hidden: no scroll container created) */
html { overflow-x: clip; }

/* Table styling for CV */
table { width: 100%; border-collapse: collapse; margin: 1em 0; }
table th { background-color: #f5f5f5; padding: 0.5em; text-align: left; font-weight: bold; }
table td { padding: 0.5em; border-bottom: 1px solid var(--color-divider); background-color: white; }
table td:first-child { white-space: nowrap; width: 1%; }

/* List indentation adjustments - minimal indent */
ul, ol { padding-left: 0; }
ul ul, ol ol, ul ol, ol ul { padding-left: 0; }

/* Accessibility improvements */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  z-index: 100000;
  padding: 8px 16px;
  background: #000;
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: bold;
}
.skip-link:focus {
  top: 6px;
}

/* General link underline styling - exclude navigation, masthead, and project cards */
a:not(nav a):not(.masthead-title a):not(.theme-switcher a):not(.project-card a) {
  text-decoration: underline;
  text-underline-offset: 0.3em;
  text-decoration-thickness: 0.1em;
}

/* Custom tilde bullets for unordered lists */
ul { list-style: none; }
ul li { 
  padding-left: 0.9em; 
  text-indent: -0.9em; 
}
ul li::before {
  content: "⚬ ";
  color: #b4b4b4;
  font-weight: normal;
}

/* Ordered list numbers inside content box */
ol { padding-left: 1.4em; }

/* Active navigation link and hover */
nav a[aria-current="page"],
nav a:hover {
  text-decoration: underline;
  text-underline-offset: 0.35em;
  text-decoration-thickness: 0.1em;
}

/* Exclude navigation from custom bullets and indentation */
nav ul { list-style: none; padding-left: 0; }
nav ul li { padding-left: 0; text-indent: 0; }
nav ul li::before { content: none; }

/* Masthead title sizing - match h2 headlines but less bold */
.masthead-title { font-size: 1.5rem; font-weight: normal; }
.masthead-title .tagline { display: block; font-size: 0.9rem; margin-top: 0.3rem; }

/* Logo underline - same style as nav links */
.masthead-title .sitename:hover {
  text-decoration: underline;
  text-underline-offset: 0.35em;
  text-decoration-thickness: 0.1em;
}

/* Color dot indicator for design system */
.color-dot {
  display: inline-block;
  width: 1em;
  height: 1em;
  border-radius: 50%;
  margin-right: 0.3em;
  vertical-align: middle;
  position: relative;
  top: -0.1em;
}
.color-dot.alpha {
  background:
    linear-gradient(var(--c), var(--c)),
    repeating-conic-gradient(#999 0% 25%, #eee 0% 50%) 0 0 / 6px 6px;
}

/* Variable font weight utilities */
.font-weight-450 { font-weight: 450; }  /* Between regular and medium */
.font-weight-500 { font-weight: 500; }  /* Medium */
.font-weight-550 { font-weight: 550; }  /* Between medium and semi-bold */
.font-weight-600 { font-weight: 600; }  /* Semi-bold */
.font-weight-650 { font-weight: 650; }  /* Between semi-bold and bold */
.font-weight-750 { font-weight: 750; }  /* Between bold and extra-bold */

/* Align navigation baseline with masthead title */
.masthead { display: flex; justify-content: space-between; align-items: baseline; }
.masthead-title { float: none; }
nav.nav { float: none; }

/* === Mobile Navigation Toggle (hamburger) === */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  margin: 0;
  -webkit-tap-highlight-color: transparent;
}
.nav-toggle-icon,
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--color-primary);
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.nav-toggle-icon {
  position: relative;
}
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  content: '';
  position: absolute;
  left: 0;
}
.nav-toggle-icon::before { top: -7px; }
.nav-toggle-icon::after { top: 7px; }

/* Animate to X when open */
.nav-toggle[aria-expanded="true"] .nav-toggle-icon {
  background-color: transparent;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-icon::before {
  top: 0;
  transform: rotate(45deg);
}
.nav-toggle[aria-expanded="true"] .nav-toggle-icon::after {
  top: 0;
  transform: rotate(-45deg);
}

/* === Theme Select (hidden on desktop) === */
.theme-select {
  display: none;
  font-family: var(--font-navigation);
  font-size: 0.85rem;
  color: var(--color-quaternary);
  background-color: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 3px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}

/* ===== DESKTOP STYLES (≥769px) ===== */
@media (min-width: 769px) {
  /* Increase container width for better text flow */
  .container { max-width: 72rem; }
  
  /* Reduce font size for main statements to prevent line breaks */
  .container h2 { font-size: 1.3rem; line-height: 1.4; }
  
  /* Sticky bar desktop - original size */
  body .bar { 
    font-size: 0.8em !important; 
    line-height: 0.8 !important;
    padding: 1.2em !important;
  }
  body .bar p, body .bar a {
    font-size: inherit !important;
  }
  
  /* Navigation desktop - inline with title */
  nav.nav { 
    float: none !important; 
    margin: 0 !important;
    padding: 0 !important;
  }
  .masthead { 
    display: flex; 
    justify-content: space-between; 
    align-items: baseline; 
  }
  /* Navigation links horizontal on desktop */
  nav ul { 
    display: flex; 
    gap: 1rem;
    margin: 0 !important; 
    padding: 0 !important; 
    text-align: left !important;
  }
  nav ul li { display: inline-block; }
}

/* ===== MOBILE STYLES (≤768px) ===== */
@media (max-width: 768px) {
  /* Sticky bar mobile - smaller to prevent line breaks */
  body .bar { 
    font-size: 0.8em !important; 
    line-height: 0.8 !important;
    padding: 1.2em !important;
  }
  body .bar p, body .bar a {
    font-size: inherit !important;
  }
  
  /* Navigation mobile - hamburger + overlay */
  .masthead { flex-direction: row; align-items: center; justify-content: space-between; }
  .nav-toggle { display: block; position: relative; z-index: 99998; }
  .nav-toggle[aria-expanded="true"] { z-index: 100002; }
  nav.nav { display: none; margin-top: 0; }

  /* Full-screen overlay when open */
  nav.nav.is-open {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100001;
    background-color: var(--color-surface);
    margin: 0;
    padding: 3rem 1.5rem;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    animation: fadein 0.2s ease;
  }
  nav.nav.is-open ul {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin: 0;
    padding: 0;
  }
  nav.nav.is-open ul li { display: block; }
  nav.nav.is-open ul li a { font-size: 1.5rem; }

  /* Mobile font size improvements */
  html { font-size: 18px; } /* Increase base font size from 16px to 18px */
  
  /* Larger headings for better mobile readability */
  h1 { font-size: 2.2rem; } /* Increase from 2rem */
  h2 { font-size: 1.8rem; } /* Increase from 1.5rem */
  h3 { font-size: 1.4rem; } /* Increase from 1.25rem */
  
  /* Page title specific mobile sizing */
  .page-title { font-size: 1.8rem; margin-bottom: 1.2rem; }
  
  /* Masthead title mobile adjustment */
  .masthead-title { font-size: 1.6rem; }
  
  /* Navigation links larger on mobile */
  nav ul li a { font-size: 1.1rem; }
  
  /* Body text slightly larger */
  p, li { font-size: 1.05rem; line-height: 1.6; }
  
  /* Better spacing for mobile */
  .container { padding-left: 1.2rem; padding-right: 1.2rem; }

  /* Page header: stack title and meta vertically on mobile */
  .page-header { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
  .page-header h1 { margin-bottom: 0; }

  /* Footer mobile: stack, right-aligned */
  .footer {
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
  }
  .footer .footer-text { text-align: right; }

  /* Hide inline theme links, show select */
  .theme-links { display: none; }
  .theme-switcher .footer-sep { display: none; }
  .theme-select { display: inline-block; }
  .theme-switcher {
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }
}

/* Horizontal rule spacing adjustments */
hr { margin-bottom: 0.5rem; }

/* === Footer with theme switcher === */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2rem;
}
.theme-switcher a {
  color: var(--color-quaternary);
  text-decoration: none;
  margin-left: 0.75rem;
}
.theme-switcher .footer-sep {
  margin-left: 0.75rem;
}
.theme-switcher a:hover {
  color: var(--color-primary);
}
.theme-switcher a.active {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 0.35em;
  text-decoration-thickness: 0.1em;
}

/* === Breadcrumb === */
.breadcrumb {
  font-size: 0.8rem;
  color: var(--color-quaternary);
  margin-bottom: 1rem;
}
.breadcrumb a {
  color: var(--color-quaternary);
}
.breadcrumb a:hover {
  color: var(--color-primary);
}

/* === Project page styles === */
/* Project header two-col: title left, description+meta right */
.project-header-two-col {
  margin-bottom: 1.5rem;
}
.project-header-two-col .project-title {
  margin: 0;
  font-size: 1.5rem;
}
.project-header-two-col .project-subtitle {
  margin-top: 0;
}
.project-header-two-col .project-meta {
  margin-top: 0.75rem;
}

/* === Page header with inline meta (title + language switcher or page note) === */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2rem;
}
.page-header h1 {
  margin-bottom: 0.5rem;
}
.page-header .cv-lang {
  font-size: 0.9rem;
  font-weight: normal;
  white-space: nowrap;
}

/* === Two-column structural layout === */
.two-col {
  display: grid;
  grid-template-columns: 30% 1fr;
  gap: 0 2rem;
  border-top: 1px solid var(--color-divider);
  padding-top: 0.75rem;
  margin-bottom: 2.5rem;
}

.two-col-label {
  grid-column: 1;
  grid-row: 1;
  color: var(--color-primary);
  font-weight: 550;
}

/* Collapsible two-col: <details> replacing <section> for theme color sections */
details.two-col {
  margin-bottom: 0;
}
details.two-col[open] {
  margin-bottom: 2.5rem;
}
details.two-col > summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  padding-bottom: 0.75rem;
}
details.two-col > summary::-webkit-details-marker { display: none; }
details.two-col > summary::after {
  content: '';
  display: inline-block;
  width: 0.45em;
  height: 0.45em;
  border-right: 1.5px solid var(--color-tertiary);
  border-bottom: 1.5px solid var(--color-tertiary);
  transform: rotate(-45deg);
  margin-left: 0.5em;
  vertical-align: middle;
  transition: transform 0.2s ease;
  position: relative;
  top: -0.1em;
}
details.two-col[open] > summary::after {
  transform: rotate(45deg);
  top: -0.1em;
}

.two-col-role {
  grid-column: 2;
  grid-row: 1;
  color: var(--color-secondary);
  margin-bottom: 0.75rem;
}

/* Default: content aligns with label at row 1 */
.two-col-content {
  grid-column: 2;
  grid-row: 1 / span 20;
}
.two-col-content > :first-child { margin-top: 0; }
/* Visual first children (images, grids) need a nudge back — the rule above
   collapses their natural top margin, leaving them too close to the divider. */
.two-col-content > .figure:first-child,
.two-col-content > .columns:first-child,
.two-col-content > .project-grid:first-child { margin-top: 0.6rem; }

/* When role is present, push content below it */
.two-col-role ~ .two-col-content {
  grid-row: 2 / span 20;
}

.two-col-note {
  grid-column: 1;
  grid-row: 2;
  font-size: 0.8rem;
  color: var(--color-quaternary);
  line-height: 1.4;
}

/* Side image placed in label column, paired with content-column image */
.two-col-side-image {
  grid-column: 1;
  grid-row: 21;
  align-self: start;
}
.two-col-side-image .figure {
  margin: 0;
}
.two-col-main-image {
  grid-column: 2;
  grid-row: 21;
}
.two-col-main-image .figure {
  margin: 0;
}
.two-col-remaining {
  grid-column: 2;
  grid-row: 22 / span 20;
}

/* Mobile: collapse to single column */
@media (max-width: 768px) {
  .two-col-side-image,
  .two-col-main-image,
  .two-col-remaining {
    grid-column: 1;
    grid-row: auto;
  }
  .two-col {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .two-col-label { margin-bottom: 1rem; }
  .two-col-role  { margin-bottom: 0.5rem; }
  .two-col-label,
  .two-col-role,
  .two-col-content,
  .two-col-note,
  .two-col-role ~ .two-col-content {
    grid-column: 1;
    grid-row: auto;
  }
  .two-col-note {
    margin-top: 0.15rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
  }
}

/* === Content table === */
.content-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  border: none;
}
.content-table td {
  padding: 0.5rem 1rem 0.5rem 0;
  vertical-align: top;
  border: none;
  border-bottom: 1px solid var(--color-divider);
  background: transparent !important;
  line-height: 1.4;
}
.content-table tr:first-child td {
  padding-top: 0;
}
p + .content-table tr:first-child td {
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-divider);
}
.content-table tr:last-child td {
  border-bottom: none;
  padding-bottom: 0;
}
.content-table tbody tr:nth-child(odd) td {
  background: transparent !important;
}
.content-table .pl-year {
  white-space: nowrap;
  color: var(--color-secondary);
  width: 1%;
}
.content-table .pl-name {
  white-space: normal;
  width: auto;
}
.content-table .pl-name strong {
  display: block;
}
.content-table .pl-name small {
  color: var(--color-quaternary);
}
.content-table .pl-desc {
  color: var(--color-secondary);
}

@media (max-width: 768px) {
  .content-table .pl-year { display: none; }
  .content-table .pl-name::after {
    content: attr(data-year);
    display: block;
    font-size: 0.75rem;
    color: var(--color-quaternary);
    margin-top: 0.2rem;
  }
}
