 html, body {
    margin: 0;
    padding: 0;
    font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
    overflow-x: hidden; /* prevents horizontal scroll */
  }
  
  body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: whitesmoke;
  }

  header {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto 1fr; /* left spacer | title | hamburger lane */
    align-items: center;
    background: whitesmoke;
    color: #333;
    padding: 50px;
    z-index: 20001;
  }

  .my-name {
    font-family: 'Palatino', 'Palatino Linotype', 'Palatino LT STD', 'Book Antiqua', Georgia, serif;
    color: #333;
    text-decoration: none;
    font-size: 300%;
    margin: 0;
    text-align: center;
    position: relative;
    z-index: 11;
    grid-column: 2;
    justify-self: center;
  }

  .my-name:hover {
    color: yellow;
  }
  
  .hamburger {
    grid-column: 3;
    justify-self: end;
    position: relative;
    width: 30px;
    height: 22px;
    cursor: pointer;
    padding: 10px;
    z-index: 26000; /* above overlay */
  }

  /* make bars overlap-friendly */
  .hamburger div {
    position: absolute;
    left: 10px;              /* matches padding */
    right: 10px;
    height: 3px;
    background: #333;
    border-radius: 2px;
    transition: transform 200ms ease, top 200ms ease, opacity 150ms ease, background-color 150ms ease;
  }
  /* bar positions */
  .hamburger div:nth-child(1){ top: 10px; }
  .hamburger div:nth-child(2){ top: 19px; }
  .hamburger div:nth-child(3){ top: 28px; }
  
  .hamburger:hover div{ background-color: yellow; }
  
  /* active = X */
  .hamburger.active div:nth-child(1){
    top: 19px;
    transform: rotate(45deg);
  }
  .hamburger.active div:nth-child(2){
    opacity: 0;
  }
  .hamburger.active div:nth-child(3){
    top: 19px;
    transform: rotate(-45deg);
  }

  .hamburger:hover div {
    background-color: yellow;
  }

  /* Vertival bar behind open title */
  #title-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: clamp(80px, 14vw, 150px); /* responsive width */
    height: 0;                 
    background: whitesmoke;
    z-index: 999998;                 /* below title */
    display: none;                   /* hidden until menu opens */
    pointer-events: none;
  }

  /* When menu opens, rail becomes visible and matches menu height */
  body.menu-open #title-bar {
    display: block;
    height: 100dvh;   /* modern mobile-safe viewport height */
    height: 100vh;    /* fallback */
  }

  /* Vertical title */
  body.menu-open .my-name {
    position: fixed;
    top: 80px;
    left: 40px;                        /* slight margin from rail edge */
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    color: #333;
    font-size: 2.8rem;
    background: transparent;           /* remove box */
    white-space: nowrap;
    z-index: 999999;                   /* above the rail */
    text-decoration: none;
    padding: 0;
  }

    body.menu-open .my-name:hover {
    color: yellow;
  }

  body.menu-open .overlay-container {
    z-index: 25000;
  }

  body.menu-open .overlay {
    z-index: 25001;
  }

  body.menu-open header {
    z-index: auto; /* IMPORTANT: not 0/1; auto removes the stacking context */
  }
 
  main {
    flex: 1;
    position: relative;
    visibility: hidden;
  }

  #image-container {
    position: relative;
    width: 100%;
  }

  #image-container img {
    position: absolute;
    cursor: pointer;
    width: 300px;
    max-width: 100%;
    height: auto;
    box-sizing: border-box;
  }

  footer {
    background: whitesmoke;
    color: #333;
    text-align: left;
    margin-left: 100px;
    padding: 20px;
    flex-shrink: 0;
  }

  /* Used by JS to lock the page */
  .no-scroll {
    overflow: hidden;
    height: 100%;
  }

  /* Overlay container (click outside to close) */
  .overlay-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;                  /* hidden by default */
    z-index: 9999;                  /* above everything */
    overscroll-behavior: contain;   /* prevents scroll chaining / bounce affecting the page behind */
  }

  /* Partial vertical overlay sidebar */
  .overlay {
    position: fixed;
    top: 0;
    right: -50vw;                     /* start hidden */
    width: 50vw;                     /* sidebar width */
    height: 100dvh;                  /* better on mobile than 100% */
    background: whitesmoke;
    display: grid;
    grid-template-columns: 1fr auto;               /* menu grows | icons fit content */
    grid-template-rows: max-content max-content; /* row 1: menu + icons, row 2: footer */
    column-gap: 24px;
    row-gap: 18px;
    align-content: start;
    align-items: start;
    /* scrollable overlay */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    /* spacing */
    padding: 80px 24px 24px;
    box-sizing: border-box;
    z-index: 10000;
  }

  /* Left column */
  .overlay-menu {
    grid-column: 1;
    grid-row: 1;
  }

  /* Right column */
  .overlay-symbol {
    grid-column: 2;
    grid-row: 1;
    margin-top: 0;          /* remove old margin-top: 40px */
    justify-self: end;      /* stick to the right edge of overlay */
    align-self: end;        /* <-- makes icons end where ABOUT ends */
    display: flex;
    flex-direction: column;
  
  }

  .overlay.active {
    right: 0;   /* slide in */
  }

  .overlay-menu a {
    display: block;
    width: fit-content;        /* shrink clickable width to the text */
    color: #333;
    font-size: 3.0rem;
    text-decoration: none;
    font-weight: 1000;
    margin: 12px 0;
    padding: 0;                /* ensure no extra hit area */
    line-height: 1.05;         /* reduce tall hitbox */
  }

  .overlay-symbol a {
    display: block;
    color: #333;
    text-decoration: none;
    font-size: 1.6rem;
    margin: 6px 30px 0 0;
  }

  .overlay-footer {
    grid-column: 1;         /* left column */
    grid-row: 2;
    margin-top: 80px;       /* space under ABOUT */
    font-size: 1rem;
    color: #333;
  }

  .overlay-footer a {
    display: inline-block;
    color: #333;
    text-decoration: none;
    margin-bottom: 8px;
  }

  .overlay-menu a:hover, .overlay-symbol a:hover, .overlay-footer a:hover {
    color: yellow;
  }

  /* Responsive adjustments */
  @media (max-width: 1200px) { #image-container img { width: 300px; } }

  @media (max-width: 860px) {
    .overlay{
      grid-template-columns: 1fr;
      grid-template-rows: max-content max-content max-content; /* menu | icons | footer */
      row-gap: 24px;
    }
    .overlay-menu{
      grid-column: 1;
      grid-row: 1;
    }
    .overlay-symbol{
      grid-column: 1;
      grid-row: 2;          /* <-- KEY: move icons to their own row */
      justify-self: start;
      align-self: start;    /* override align-self:end from desktop */
    }
    .overlay-footer{
      grid-column: 1;
      grid-row: 3;          /* footer comes after icons */
    }
  }

  @media (max-width: 768px) {
    #image-container img { width: 260px; }
    .my-name { font-size: 2.2rem; }
    .overlay-menu a { font-size: 1.6rem; }
    .overlay-symbol a { font-size: 1.2rem; }
    body.menu-open .my-name {
      left: 20px;
      font-size: 2.2rem;
    }
  }

  @media (max-width: 480px) {
    #image-container img { width: 180px; }
    header { padding: 30px; }
    .my-name { font-size: 1.5rem; }
    .hamburger { width: 25px; height: 18px; }
    .hamburger div { height: 3px; }
  }


  @media (max-width: 406px) {
    #image-container img { width: 180px; }
    .overlay { width: 70%; right: -70%; }
  }

  /* Landscape / short height handling */
  @media (max-height: 500px) {
    .overlay { padding-top: 20px; }
    .overlay-symbol { margin-top: 10px;}
  }
  
  @media (max-height: 600px){
    body.menu-open .my-name {
      left: 10px;
      white-space: normal;
    }
    #title-bar { width: clamp(80px, 14vw, 150px); }
  }