:root{
  --rail-total: 460px;
  --content-max: 1180px;
  --border: #e6e6e6;
  --bg: #EEEEEE;
  --menu-height: 100svh;
  --menu-viewport-top: 0px;
  --menu-browser-bottom: 0px;
  --menu-bottom-clearance: calc(28px + var(--menu-browser-bottom) + env(safe-area-inset-bottom, 0px));
  --scroll-lock-top: 0px;
}

*{ box-sizing: border-box; }

body{
  margin: 0;
  font-family: "Raleway", sans-serif;
  background: var(--bg);
  color: #111;
  overflow-x: hidden;
}

p {
  line-height: 1.75rem;
}

/* --- Hjælpere --- */
.sr-only{
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0;
}

.icon-btn{
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 24px;
  min-width: 44px;
  min-height: 44px;
}

#menuBtn{
  font-size: 0;
  line-height: 1;
}

#menuBtn::before{
  content: "\2630";
  font-size: 28px;
}

/* =========================================================
   LAYOUT (FIXET MED GRID AREAS)
   ========================================================= */

/* Desktop default */
.layout{
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr var(--rail-total);
  grid-template-rows: 1fr;
  grid-template-areas: "content rail";
}

/* Placer elementer fast */
.topbar{ grid-area: topbar; }
.content{ grid-area: content; }
.sidebar{ grid-area: rail; }

/* Topbar skjult på desktop */
.topbar{
  display: none;
  justify-content: end;
  gap: 12px;
  padding: 10px 12px;
  background: #5c5c5c18;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar__title{ font-weight: 700; }

/* Content */
.content{
  width: min(calc(100% - 40px), var(--content-max));
  padding: clamp(20px, 2.4vw, 36px);
  margin: 20px auto;
  max-width: var(--content-max);
}

@media (min-width: 1400px){
  :root{
    --rail-total: clamp(420px, 26vw, 560px);
    --content-max: 1360px;
  }

  .content{
    width: calc(100% - 40px);
    margin: 20px auto;
  }
}

@media (min-width: 1025px){
  p {
    max-width: 82ch;
  }
}

.page{ display:none; }
.page.is-active{ display:block; }

.hero-title{
  margin: 0 0 14px;
  font-size: clamp(42px, 6vw, 84px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: #3366FF;
}

/* Sidebar / Rail kolonne */
.sidebar{
  width: var(--rail-total);
  height: 100vh;
  position: sticky;
  top: 0;
}

/* Mobil header inde i sidebar (skjult på desktop) */
.sidebar__header{
  display: none;
  align-items: center;
  justify-content: end;
  gap: 10px;
  padding: 12px;
  background: #ffffff;
  color: #fff;
}
.sidebar__close{ 
  display: none; 
  font-size: 24px;
}

/* Header on indexpage */
.indexpage__header{
  margin: 25px 0px 0px 0px;
}

/* =========================================================
   RAIL + ITEMS + FARVEBAGGRUND + OVERLAY
   ========================================================= */

.rail{
  height: 100%;
  width: 100%;
  display: flex;
}

/* Gælder både <button> og <a> */
.rail__item{
  font: inherit;
  position: relative;
  overflow: hidden;

  flex: 1 1 0;
  min-width: 70px;
  height: 100%;

  border: 0;
  cursor: pointer;
  color: #fff;
  text-decoration: none;

  display: grid;
  align-items: center;
  justify-items: start;
  padding-top: 50px;

  writing-mode: vertical-rl;
  transform: rotate(180deg);

  font-size: 40px;
  font-weight: 300;
  letter-spacing: 5px;

  transition: flex 0.35s ease;

  border: 1px solid var(--bg);
  border-top: 5px solid var(--bg);
  border-bottom: 5px solid var(--bg);
}

.rail__item:focus-visible,
.icon-btn:focus-visible{
  outline: 3px solid #cdff4e;
  outline-offset: -3px;
}

/* Hover = bredere */
.rail__item:hover{
  flex: 2.2;
}

/* Farvebaggrund */
.rail__bg{
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* Overlay ovenpå farven */
.rail__item::after{
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.38);
  z-index: 1;
  pointer-events: none;
  transition: opacity 0.3s ease;
}


/* Ikke valgt + hover = overlay væk */
.rail__item:hover::after{
  opacity: 0;
}

/* Valgt punkt = ingen overlay */
.rail__item.is-active::after{
  opacity: 0;
}

/* Tekstfarve på labels */
.rail__item .rail__label{
  color: rgba(255,255,255,0.38);
  transition: color 0.25s ease, letter-spacing 0.25s ease;
}

/* Hover på ikke aktive = tydelig tekst */
.rail__item:not(.is-active):hover .rail__label{
  color: rgba(255,255,255,0.85);
}

/* Aktivt menupunkt = helt hvid + bonus */
.rail__item.is-active .rail__label{
  color: #fff;
  letter-spacing: 10px;
}

.rail__label{
  position: relative;
  z-index: 2;
}

/* Farver pr. menupunkt */

.rail__item--home .rail__bg{
  background: #3366FF;  
}

.rail__item--projects .rail__bg{
  background: #3366FF;
}

.rail__item--courses .rail__bg{
  background: #3366FF;
}

.rail__item--aboutme .rail__bg{
  background: #3366FF;
}

.rail__item--contact .rail__bg{
  background: #3366FF;
}

/* Overlay (mobil) */
.overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 40;
}

/* ========================================================= 
   MOBIL: burger -> drawer med vertikale strips
   ========================================================= */
@media (max-width: 900px){

  .layout{
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "topbar"
      "content";
  }

  html.menu-open,
  body.menu-open{
    overflow: hidden;
    height: var(--menu-height);
    overscroll-behavior: none;
    overscroll-behavior-y: none;
  }

  body.menu-open{
    position: fixed;
    inset: var(--scroll-lock-top) 0 auto 0;
    width: 100%;
    touch-action: none;
  }

  .topbar{
    display: flex;
    align-items: center;
    min-height: 52px;
    padding: 6px 10px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .sidebar{
    position: fixed;
    top: var(--menu-viewport-top);
    left: 0;
    width: 100vw;
    height: var(--menu-height);
    max-height: var(--menu-height);
    transform: translateX(-110%);
    transition: transform 220ms ease;
    z-index: 60;
    box-shadow: 0 10px 30px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: contain;
    touch-action: none;
  }
  .sidebar.is-open{ transform: translateX(0); }

  .sidebar__header{
    display: flex;
    flex: 0 0 52px;
    padding: 8px 12px;
  }
  .sidebar__close{ display: inline-block; }

  .rail{
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    width: 100%;
    gap: 0;
    overflow: hidden;
    padding-bottom: var(--menu-bottom-clearance);
    background: #3366FF;
    touch-action: none;
  }

  .rail__item{
    min-width: 0 !important;
    flex: 1 1 0;
    height: 100%;
    padding-top: clamp(8px, 2.5svh, 28px);
    font-size: clamp(22px, 6svh, 32px);
    letter-spacing: clamp(2px, 1svh, 5px);
    touch-action: manipulation;
  }

  .rail__item.is-active .rail__label{
    letter-spacing: clamp(3px, 1.1svh, 6px);
  }

  .rail.has-active .rail__item:not(.is-active){
    flex: 0.65;
  }

  .rail.has-active .rail__item.is-active{
    flex: 2.8;
  }

  .content{
    width: 100%;
    margin: 0;
    padding: 16px clamp(10px, 3vw, 22px);
    max-width: none;
  }
}

@media (max-width: 767px){
  :root{
    --menu-bottom-clearance: calc(68px + var(--menu-browser-bottom) + env(safe-area-inset-bottom, 0px));
  }

  .content{
    padding: 12px 8px 24px;
  }

  .rail__item{
    padding-top: clamp(14px, 2.8svh, 22px);
    font-size: clamp(20px, 5.2svh, 29px);
    letter-spacing: clamp(1px, 0.75svh, 4px);
  }

  .rail__item.is-active .rail__label{
    letter-spacing: clamp(2px, 0.8svh, 5px);
  }

  .hero-title{
    margin-bottom: 10px;
  }
}

@media (hover: none){
  .rail__item:hover{
    flex: 1 1 0;
  }

  .rail.has-active .rail__item:not(.is-active){
    flex: 0.65;
  }

  .rail.has-active .rail__item.is-active{
    flex: 2.8;
  }
}

@media (max-width: 390px){
  :root{
    --menu-bottom-clearance: calc(84px + var(--menu-browser-bottom) + env(safe-area-inset-bottom, 0px));
  }
}
