/* Light Mode */
:root {
    --ink: #1a1a1a;
    --muted: #666;
    --faint: #999;
    --line: #e8e8e4;
    --bg: #fdfdfb;
    --accent: #b3502d;
    --card-bg: #fff;
    --nav-bg: rgba(253, 253, 251, .92);
    --backdrop-bg: rgba(0, 0, 0, 0.25);
    --max: 720px;
  }

  /* Dark Mode */
  :root:has(#dark-mode:checked) {
    --ink: #f0f0ee;
    --muted: #a3a39e;
    --faint: #73736c;
    --line: #2e2e2a;
    --bg: #141413;
    --accent: #e07a5f;
    --card-bg: #1f1f1d;
    --nav-bg: rgba(20, 20, 19, .92);
    --backdrop-bg: rgba(0, 0, 0, 0.45);
  }

  * { margin: 0; padding: 0; box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  body {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    transition: background-color .25s ease, color .25s ease;
  }
  .wrap { max-width: var(--max); margin: 0 auto; padding: 0 1.5rem; }

  /* Nav */
  nav {
    position: sticky; top: 0; z-index: 20;
    background: var(--nav-bg); backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
    transition: background-color .25s ease, border-color .25s ease;
  }
  nav .wrap { display: flex; justify-content: space-between; align-items: center; height: 3.5rem; position: relative; }
  nav .logo { font-weight: 600; letter-spacing: .02em; font-size: .95rem; }
  .nav-right { display: flex; align-items: center; gap: 1.25rem; }
  .nav-links { display: flex; gap: 1.5rem; list-style: none; }
  nav a { text-decoration: none; color: var(--muted); font-size: .85rem; transition: color .2s; }
  nav a:hover { color: var(--accent); }

  /* Theme Toggle */
  .theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 6px;
    cursor: pointer;
    color: var(--muted);
    transition: color .2s, background-color .2s;
    user-select: none;
  }
  .theme-toggle:hover {
    color: var(--accent);
    background: rgba(128, 128, 128, 0.12);
  }
  .theme-toggle .icon-sun { display: none; }
  .theme-toggle .icon-moon { display: block; }
  :root:has(#dark-mode:checked) .theme-toggle .icon-sun { display: block; }
  :root:has(#dark-mode:checked) .theme-toggle .icon-moon { display: none; }

  /* Burger Menu Button (hidden on desktop) */
  .burger-btn {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 22px;
    height: 16px;
    cursor: pointer;
    user-select: none;
    padding: 1px 0;
  }
  .burger-btn span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--ink);
    border-radius: 2px;
    transition: transform .25s ease, opacity .25s ease, background-color .25s ease;
    transform-origin: center;
  }

  /* Backdrop for mobile menu */
  .menu-backdrop {
    display: none;
    display: block;
    position: fixed;
    inset: 0;
    z-index: 15;
    background: rgba(0, 0, 0, 0.3);
    background: var(--backdrop-bg, rgba(0, 0, 0, 0.25));
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .25s ease, visibility .25s ease, background-color .25s ease;
  }

  /* Hero */
  header.hero { padding: 6rem 0 4.5rem; }
  .hero h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
  .hero .role { color: var(--accent); font-size: 1.1rem; margin-top: .75rem; font-weight: 500; }
  .hero p.tagline { color: var(--muted); margin-top: 1.25rem; max-width: 56ch; font-size: 1.05rem; }

  /* Sections */
  section { padding: 3.5rem 0; border-top: 1px solid var(--line); }
  h2 {
    font-size: .8rem; text-transform: uppercase; letter-spacing: .15em;
    color: var(--faint); font-weight: 600; margin-bottom: 1.75rem;
  }
  section p + p { margin-top: 1rem; }
  .about p { max-width: 62ch; }

  /* Skills */
  .skill-group { margin-bottom: 1.5rem; }
  .skill-group h3 { font-size: .95rem; font-weight: 600; margin-bottom: .6rem; }
  .tags { display: flex; flex-wrap: wrap; gap: .5rem; }
  .tags span {
    font-size: .8rem; padding: .3rem .7rem; border: 1px solid var(--line);
    border-radius: 999px; color: var(--muted); background: var(--card-bg);
    transition: background-color .25s ease, border-color .25s ease, color .25s ease;
  }

  /* Experience Section & Pure CSS Switcher */
  .exp-view-radio {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
    margin: 0;
  }

  .exp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
  }
  .exp-header h2 {
    margin-bottom: 0;
  }

  /* Segmented Pill Selector */
  .exp-toggle-group {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: background-color .25s ease, border-color .25s ease;
  }
  :root:has(#dark-mode:checked) .exp-toggle-group {
    background: rgba(255, 255, 255, 0.05);
  }

  .exp-toggle-glider {
    position: absolute;
    top: 3px;
    bottom: 3px;
    left: 3px;
    width: calc(50% - 3px);
    background: var(--bg);
    border-radius: 999px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--line);
    transition: transform .22s cubic-bezier(0.4, 0, 0.2, 1), background-color .25s ease, border-color .25s ease;
    pointer-events: none;
    z-index: 1;
  }
  :root:has(#dark-mode:checked) .exp-toggle-glider {
    background: #282824;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45);
  }

  .exp-toggle-btn {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.35rem 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    border-radius: 999px;
    user-select: none;
    transition: color .2s ease;
    white-space: nowrap;
  }
  .exp-toggle-btn:hover {
    color: var(--ink);
  }
  .tab-icon {
    flex-shrink: 0;
    color: var(--faint);
    transition: color .2s ease;
  }

  /* Zero-jump pure CSS toggle state */
  #exp-view-company:checked ~ .exp-header .toggle-company {
    color: var(--ink);
    font-weight: 600;
  }
  #exp-view-company:checked ~ .exp-header .toggle-company .tab-icon {
    color: var(--accent);
  }
  #exp-view-company:checked ~ .exp-header .exp-toggle-glider {
    transform: translateX(0);
  }

  #exp-view-role:checked ~ .exp-header .toggle-role {
    color: var(--ink);
    font-weight: 600;
  }
  #exp-view-role:checked ~ .exp-header .toggle-role .tab-icon {
    color: var(--accent);
  }
  #exp-view-role:checked ~ .exp-header .exp-toggle-glider {
    transform: translateX(100%);
  }

  /* View Display & Smooth Fade-in */
  .exp-view {
    display: none;
  }
  #exp-view-company:checked ~ .exp-view-company {
    display: block;
    animation: expFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }
  #exp-view-role:checked ~ .exp-view-role {
    display: block;
    animation: expFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

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

  /* View 1: By Company Layout */
  .company-card {
    margin-bottom: 2.5rem;
    padding-bottom: 2.25rem;
    border-bottom: 1px dashed var(--line);
    transition: border-color .25s ease;
  }
  .company-card:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
  }
  .company-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.15rem;
  }
  .company-meta {
    flex: 1 1 200px;
    flex: 1 1 auto;
    min-width: 0;
  }
  .company-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
  }
  .company-sub {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 0.1rem;
  }
  .company-tenure {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-left: auto;
    text-align: right;
    justify-content: flex-end;
  }
  .tenure-badge {
    font-size: 0.82rem;
    color: var(--faint);
    white-space: nowrap;
  }
  .tenure-duration {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.55rem;
    background: var(--card-bg);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--accent);
    white-space: nowrap;
    transition: background-color .25s ease, border-color .25s ease, color .25s ease;
  }

  /* Company Timeline & Role Progression */
  .company-timeline {
    position: relative;
    padding-left: 0.25rem;
  }
  .timeline-role {
    position: relative;
    padding-left: 1.6rem;
    margin-bottom: 1.75rem;
  }
  .timeline-role:last-child {
    margin-bottom: 0;
  }
  /* Connector spine between nested roles */
  .timeline-role:not(:last-child)::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 14px;
    bottom: -1.75rem;
    width: 2px;
    background-color: var(--line);
    transition: background-color .25s ease;
  }
  .role-marker {
    position: absolute;
    left: 0;
    top: 0.35rem;
  }
  .marker-dot {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--faint);
    box-sizing: border-box;
    transition: border-color .25s ease, background-color .25s ease;
  }
  .timeline-role.current .marker-dot {
    border-color: var(--accent);
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(179, 80, 45, 0.18);
  }
  :root:has(#dark-mode:checked) .timeline-role.current .marker-dot {
    box-shadow: 0 0 0 3px rgba(224, 122, 95, 0.25);
  }
  .role-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem 1rem;
    flex-wrap: wrap;
  }
  .role-title {
    font-size: 1.02rem;
    font-weight: 600;
    color: var(--ink);
    flex: 1 1 180px;
    flex: 1 1 auto;
    min-width: 0;
  }
  .role-dates {
    font-size: 0.82rem;
    color: var(--faint);
    white-space: nowrap;
    margin-left: auto;
    text-align: right;
    flex-shrink: 0;
  }
  .role-context {
    font-size: 0.86rem;
    color: var(--muted);
    margin-top: 0.15rem;
  }
  .role-bullets {
    margin: 0.65rem 0 0 1.1rem;
    color: var(--muted);
    font-size: 0.92rem;
  }
  .role-bullets li + li {
    margin-top: 0.35rem;
  }

  /* View 2: By Experience (Chronological Timeline) */
  .job-timeline {
    position: relative;
    padding-left: 0.25rem;
  }
  .job-item {
    position: relative;
    padding-left: 1.6rem;
    margin-bottom: 2.25rem;
  }
  .job-item:last-child {
    margin-bottom: 0;
  }
  .job-item:not(:last-child)::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 14px;
    bottom: -2.25rem;
    width: 2px;
    background-color: var(--line);
    transition: background-color .25s ease;
  }
  .job-item-marker {
    position: absolute;
    left: 0;
    top: 0.35rem;
  }
  .job-marker-dot {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--faint);
    box-sizing: border-box;
    transition: border-color .25s ease, background-color .25s ease;
  }
  .job-marker-dot.current {
    border-color: var(--accent);
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(179, 80, 45, 0.18);
  }
  :root:has(#dark-mode:checked) .job-marker-dot.current {
    box-shadow: 0 0 0 3px rgba(224, 122, 95, 0.25);
  }
  .job-item-card .top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem 1rem;
    flex-wrap: wrap;
  }
  .job-item-card .top > div:first-child {
    flex: 1 1 200px;
    flex: 1 1 auto;
    min-width: 0;
  }
  .job-item-card h3 {
    font-size: 1.05rem;
    font-weight: 600;
  }
  .job-item-card .where {
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 0.15rem;
  }
  .job-item-card .when {
    color: var(--faint);
    font-size: 0.85rem;
    white-space: nowrap;
    flex-shrink: 0;
    text-align: right;
    margin-left: auto;
  }
  .job-item-card ul {
    margin: 0.75rem 0 0 1.1rem;
    color: var(--muted);
    font-size: 0.92rem;
  }
  .job-item-card li + li {
    margin-top: 0.35rem;
  }

  /* Education */
  .edu {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem 1rem;
    padding: .85rem 0;
    border-bottom: 1px dashed var(--line);
  }
  .edu:last-child { border-bottom: none; }
  .edu > div:first-child {
    flex: 1;
    min-width: 0;
  }
  .edu strong { font-weight: 600; font-size: .95rem; }
  .edu .school { color: var(--muted); font-size: .88rem; }
  .edu .yr {
    color: var(--faint);
    font-size: .85rem;
    white-space: nowrap;
    flex-shrink: 0;
    text-align: right;
    margin-left: auto;
  }

  /* Contact */
  .contact-links { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: .5rem; }
  .contact-links a {
    text-decoration: none; color: var(--ink); border: 1px solid var(--line);
    padding: .55rem 1.1rem; border-radius: 6px; font-size: .9rem; background: var(--card-bg);
    transition: border-color .2s, color .2s, background-color .25s ease;
  }
  .contact-links a:hover { border-color: var(--accent); color: var(--accent); }

  footer { padding: 2.5rem 0 3rem; color: var(--faint); font-size: .8rem; text-align: center; }
  footer .heart { color: #e25555; }

  @media (max-width: 640px) {
    header.hero { padding: 4rem 0 3rem; }

    .burger-btn {
      display: flex;
    }

    .nav-links {
      display: none;
      position: absolute;
      top: 3.5rem;
      left: 0;
      right: 0;
      background: var(--bg);
      border-bottom: 1px solid var(--line);
      flex-direction: column;
      gap: 0;
      padding: 0.5rem 0;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
      transition: background-color .25s ease, border-color .25s ease;
    }

    .nav-links li {
      width: 100%;
    }

    .nav-links a {
      display: block;
      padding: 0.85rem 1.5rem;
      font-size: 0.95rem;
      border-bottom: 1px solid var(--line);
    }

    .nav-links li:last-child a {
      border-bottom: none;
    }

    /* Open mobile menu when checkbox is checked */
    #menu-toggle:checked ~ nav .nav-links {
      display: flex;
    }

    #menu-toggle:checked ~ .menu-backdrop {
      display: block;
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
    }

    /* Animate burger icon to "X" */
    #menu-toggle:checked ~ nav .burger-btn span:nth-child(1) {
      transform: translateY(7px) rotate(45deg);
    }
    #menu-toggle:checked ~ nav .burger-btn span:nth-child(2) {
      opacity: 0;
    }
    #menu-toggle:checked ~ nav .burger-btn span:nth-child(3) {
      transform: translateY(-7px) rotate(-45deg);
    }

    /* Experience mobile tweaks */
    .exp-header {
      flex-direction: column;
      align-items: flex-start;
      gap: 1rem;
    }
    .exp-toggle-group {
      width: 100%;
    }
    .exp-toggle-btn {
      flex: 1 1 0;
      min-width: 0;
      padding: 0.4rem 0.5rem;
    }
    .company-header {
      flex-direction: column;
      align-items: stretch;
      gap: 0.5rem;
      gap: 0.35rem;
    }
    .company-meta {
      flex: none;
    }
    .company-tenure {
      align-self: flex-end;
      margin-left: auto;
    }
    .role-head {
      flex-direction: row;
      justify-content: space-between;
      align-items: baseline;
      gap: 0.25rem 0.75rem;
    }
    .role-dates {
      margin-left: auto;
      text-align: right;
    }
  }
