:root {
  --bg: #0a0a0a;
  --ink: #e8eaed;
  /* LCARS-inspired accents - refined */
  --accent-green: #7cb342;
  --accent-blue: #4285f4;
  --accent-purple: #9c27b0;
  --accent-yellow: #ff9800;
  --accent-red: #f44336;
  /* Panels */
  --card: #1a1a1a;
  --card-dark: #252525;
  --edge-column-width: 56px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family: "Roboto", "Quantico", -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.3;
  font-weight: 400;
  text-rendering: optimizeLegibility;
  font-feature-settings: "liga" 0;
  font-optical-sizing: auto;
  font-style: normal;
  font-variation-settings:
    "wdth" 100;
}

/* --- Layout --- */
.wrap {
  min-height: 100svh;
  display: grid; /* ✅ turn grid on */
  grid-template-columns: var(--edge-column-width) minmax(0, 1fr) 140px var(--edge-column-width); /* left bar | content | sidebar | name */
  gap: 8px;
  padding: 12px;
}

.content-frame {
  grid-column: 2;
  background: transparent;
  background-image:
    repeating-linear-gradient(
      to bottom,
      rgba(124, 179, 66, 0.08),
      rgba(124, 179, 66, 0.08) 6px,
      transparent 1px,
      transparent 48px
    ),
    repeating-linear-gradient(
      to right,
      rgba(124, 179, 66, 0.06),
      rgba(124, 179, 66, 0.06) 6px,
      transparent 1px,
      transparent 48px
    );
  padding: 24px;
  min-height: 65svh;
  border: 1px solid #333;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
  position: relative;
  overflow: hidden;
  transition: opacity 0.2s ease-in-out;
}

.content-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(
      to bottom,
      rgba(124, 179, 66, 0.18),
      rgba(124, 179, 66, 0.18) 1px,
      transparent 1px,
      transparent 48px
    ),
    repeating-linear-gradient(
      to right,
      rgba(124, 179, 66, 0.14),
      rgba(124, 179, 66, 0.14) 1px,
      transparent 1px,
      transparent 48px
    );
  filter: blur(6px);
  mix-blend-mode: screen;
  opacity: 0.5;
  z-index: 0;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}

.story-grid {
  display: grid;
  gap: 16px;
  position: relative;
  z-index: 1;
  width: 100%;
}

.story-card {
  background: var(--card);
  border: 1px solid #333;
  padding: 16px 20px;
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
  opacity: 0.95;
  width: 100%;
  align-self: start;
}

.story-card h2:first-child,
.story-card h3:first-child {
  margin-top: 0;
}

/* Technology stack badges */
.tech-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tech-badge {
  display: inline-block;
  padding: 4px 10px;
  background: rgba(124, 179, 66, 0.15);
  border: 1px solid rgba(124, 179, 66, 0.4);
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  color: var(--accent-green);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.title-card {
  background: rgba(12, 18, 29, 0.92);
  border: 1px solid rgba(66, 133, 244, 0.4);
  padding: 28px;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 12px, 100% 100%, 10px 100%, 0 calc(100% - 12px));
  box-shadow:
    0 6px 26px rgba(66, 133, 244, 0.28),
    inset 0 0 0 1px rgba(66, 133, 244, 0.32);
  position: relative;
  width: 100%;
  color: var(--ink);
  align-self: start;
  overflow: hidden;
}

.title-card h1,
.title-card h2 {
  margin: 0;
}

.title-card h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: 0.015em;
}

.title-card h2 {
  margin-top: 0.6em;
  font-weight: 500;
  color: rgba(232, 234, 237, 0.8);
}

.title-card .note {
  display: inline-block;
  margin-top: 1em;
  font-size: 0.85rem;
  color: rgba(232, 234, 237, 0.65);
  letter-spacing: 0.18em;
}

.story-card.span-2 {
  grid-column: span 2;
}

.title-card {
  grid-column: 1 / -1;
}

.story-grid.masonry {
  display: block;
  column-count: 2;
  column-gap: 16px;
}

.story-grid.masonry .story-card {
  display: inline-block;
  width: 100%;
  margin-bottom: 16px;
  break-inside: avoid;
}

.story-grid.masonry .story-card.span-2 {
  column-span: all;
  width: 100%;
  display: block;
}

.story-grid.masonry .title-card {
  column-span: all;
  display: block;
  margin-bottom: 20px;
}

.story-grid.masonry .story-card--ghost {
  display: none;
}

.story-card--ghost {
  background: transparent;
  border: none;
  opacity: 0;
  pointer-events: none;
}

.story-grid.grid-two,
.story-grid.grid-three {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

.story-grid.grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.story-grid.auto-fit {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-items: stretch;
  justify-items: stretch;
  justify-content: stretch;
  width: 100%;
  grid-auto-columns: 1fr;
}

.story-grid.auto-fit .story-card--intro {
  grid-column: 1 / -1;
}

.story-card--intro {
  display: flex;
  gap: 0px;
  align-items: center;
  flex-wrap: wrap;
}

.story-card--intro .headshot {
  float: none;
  margin: 0;
}

.title-card--intro {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.title-card--intro .headshot {
  float: none;
  margin: 0;
}

.left-column {
  grid-column: 1;
  width: var(--edge-column-width);
  min-height: 100vh;
  pointer-events: none;
}


.button-frame {
  border-radius: 0;
  height: 100%; /* ✅ fill sidebar column */
  justify-items: stretch; /* buttons expand */
  padding: 5px;
  display: grid;
  align-content: start; /* ✅ pin to top */
  gap: 8px;
}

/* --- Sidebar --- */
.sidebar {
  grid-column: 3;
  display: flex;
  flex-direction: column;
  position: fixed;
  right: 66px;
  top: 12px;
  bottom: 12px;
  width: 150px;
}

.tree-section {
  margin-top: 0px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  --tree-color: var(--accent-green);
  --tree-opacity: .5;
}

.links-section {
  margin-top: auto;
}

.navbtn {
  appearance: none;
  background: var(--card);
  color: var(--accent-yellow);
  width: 100%;
  min-height: 2.8em;
  padding: 10px 8px;
  font-size: 14px;
  font-weight: 500;
  text-align: right;
  cursor: pointer;
  border: 1px solid #333;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  white-space: normal;
  word-break: break-word;
  /*transition: background 0.1s ease;*/
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 0 100%);
  position: relative;
}

.navbtn:hover {
  background: var(--card-dark);
  color: var(--accent-green);
}

.navbtn:active {
  background: var(--card-dark);
}

.navbtn[aria-current="page"] {
  background: var(--accent-green);
  color: #000;
}

.navbtn:focus {
  outline: 2px solid var(--accent-yellow);
  outline-offset: 2px;
}

/* --- Navigation separator --- */
.nav-separator {
  margin-bottom: 12px;
  padding: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
  color: var(--accent-yellow);
  font-family: "JetBrains Mono", "Fira Code", monospace;
  border-top: 2px solid var(--accent-yellow);
  border-bottom: 2px solid var(--accent-yellow);
  background: rgba(255, 152, 0, 0.05);
}

/* --- Tree canvas --- */
#tree-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* --- Links separator --- */
.links-separator {
  margin-bottom: 12px;
  padding: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
  color: var(--accent-blue);
  font-family: "JetBrains Mono", "Fira Code", monospace;
  border-top: 2px solid var(--accent-blue);
  border-bottom: 2px solid var(--accent-blue);
  background: rgba(66, 133, 244, 0.05);
}

/* --- Links frame --- */
.links-frame {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 5px;
}

.linkbtn {
  appearance: none;
  display: block;
  background: var(--card);
  color: var(--accent-blue);
  width: 100%;
  min-height: 1.8em;
  padding: 6px 10px;
  font-size: 9px;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid #444;
  border-radius: 12px;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  white-space: normal;
  word-break: break-word;
  position: relative;
  line-height: 1.2;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.linkbtn:hover {
  background: var(--card-dark);
  color: var(--accent-purple);
  border-color: var(--accent-purple);
}

.linkbtn:active {
  background: var(--card-dark);
}

.linkbtn:focus {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* --- Vertical name column --- */
.name-column {
  grid-column: 4;
  display: flex;
  justify-content: center;
  align-items: center;
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-weight: 800;
  font-size: 28px;
  letter-spacing: 3px;
  text-transform: uppercase;
  font-family: "Quantico", -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--accent-purple);
  white-space: nowrap;
  position: fixed;
  right: 20px;
  top: 0;
  height: 100vh;
  width: var(--edge-column-width);
  background: transparent;
}

.outline {
  color: transparent;
  -webkit-text-stroke: 2px var(--accent-purple);
  text-stroke: 2px var(--accent-purple);
}
.spaceafter:after{
  content:"\00a0";
}

/* --- Typography --- */
h1,
h2,
h3 {
  font-family: "Quantico", -apple-system, BlinkMacSystemFont, sans-serif;
  margin: 0;
}

h1 {
  margin-top: 0.8em;
  margin-bottom: 0.5em;
  font-size: clamp(1.75rem, 3.5vw, 2.75rem);
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--accent-green);
}

h2 {
  margin-top: 1.5em;
  margin-bottom: 0.4em;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--accent-blue);
}

h3 {
  margin-top: 1.2em;
  margin-bottom: 0.4em;
  font-size: clamp(1.125rem, 2vw, 1.5rem);
  line-height: 1.4;
  font-weight: 600;
  letter-spacing: 0.005em;
  color: var(--accent-purple);
}

p {
  margin: 0 0 1.2em;
  color: var(--ink);
  font-size: clamp(1rem, 1.5vw, 1.1rem);
  line-height: 1.5;
}

a {
  color: var(--accent-yellow);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent-purple);
}

a:focus {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

ul {
  margin: 0 0 1.2em 1.5em;
  padding: 0;
}
ul li {
  margin: 0.4em 0;
  color: var(--ink);
  font-size: clamp(1rem, 1.5vw, 1.1rem);
  line-height: 1.4;
}

/* --- Footer --- */
footer {
  margin-top: 2.5em;
  padding-top: 1.2em;
  border-top: 1px solid #333;
  font-size: 12px;
  opacity: 0.6;
  color: #888;
  font-family: "JetBrains Mono", "Fira Code", monospace;
}
.headshot {
  float: right;
  max-width: 150px; /* adjust size */
  margin: 0 0 1.2em 1.5em; /* spacing from text */
  border: 2px solid #444;
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
}
.screenshot {
  float: right;
  max-width: 500px; /* adjust size */
  margin: 0 0 1.2em 1.5em; /* spacing from text */
  border: 2px solid #444;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}
/* --- Deprecated projects styling --- */
.deprecated {
  opacity: 0.65;
  color: #888;
  padding: 1.2em;
  margin: 1.5em 0;
  border-left: 3px solid #555;
  background: rgba(80, 80, 80, 0.03);
  clip-path: polygon(0 0, calc(100% - 4px) 0, 100% 4px, 100% 100%, 0 100%);
}
.deprecated h3 {
  color: #999;
  margin-top: 0;
}
.deprecated a {
  color: #aaa;
  text-decoration-style: dotted;
}


/* --- Responsive --- */

/* Tablet styles (768px - 880px) */
@media (max-width: 880px) and (min-width: 768px) {
  .wrap {
    grid-template-columns: minmax(0, 1fr) 200px;
    grid-template-rows: auto;
    gap: 12px;
    padding: 12px;
  }

  .left-column {
    display: none;
  }

  .name-column {
    display: none;
  }

  .content-frame {
    grid-column: 1;
    padding: 20px;
  }

  .sidebar {
    grid-column: 2;
    position: static;
    width: 100%;
    right: auto;
    top: auto;
    bottom: auto;
  }

  .story-grid.masonry {
    column-count: 1;
  }

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

  .story-grid.grid-three {
    grid-template-columns: 1fr;
  }

  /* Keep tree on tablets but make it smaller */
  .tree-section {
    max-height: 250px;
    min-height: 150px;
  }
}

/* Mobile styles (below 768px) */
@media (max-width: 767px) {
  .wrap {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    padding: 8px;
    gap: 8px;
  }

  .left-column {
    display: none;
  }

  .name-column {
    display: none;
  }

  .content-frame {
    grid-column: 1;
    grid-row: 2;
    padding: 16px;
    min-height: 50svh;
  }

  /* Make sidebar scrollable instead of fixed */
  .sidebar {
    grid-column: 1;
    grid-row: 1;
    position: static;
    width: 100%;
    flex-direction: column;
    right: auto;
    top: auto;
    bottom: auto;
  }

  /* Hide tree animation on small screens */
  .tree-section {
    display: none;
  }

  /* Stack navigation buttons horizontally on mobile */
  .button-frame {
    display: flex;
    flex-direction: row;
    gap: 6px;
    height: auto;
    align-content: center;
  }

  .navbtn {
    min-height: 44px;
    font-size: 12px;
    padding: 10px 8px;
    text-align: center;
  }

  /* Masonry to single column on mobile */
  .story-grid.masonry {
    column-count: 1;
  }

  .story-grid.grid-two,
  .story-grid.grid-three {
    grid-template-columns: 1fr;
  }

  .story-grid.auto-fit {
    grid-template-columns: 1fr;
  }

  /* Adjust headshot and screenshot sizes */
  .headshot {
    max-width: 120px;
  }

  .screenshot {
    max-width: 100%;
    float: none;
    margin: 1em 0;
  }

  /* Improve touch targets and layout for links */
  .links-frame {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .linkbtn {
    min-height: 44px;
    padding: 10px 8px;
    font-size: 11px;
  }

  /* Typography adjustments */
  h1 {
    font-size: 1.75rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  h3 {
    font-size: 1.25rem;
  }

  .title-card {
    padding: 20px;
  }

  .title-card h1 {
    font-size: clamp(1.5rem, 5vw, 2rem);
  }

  .story-card {
    padding: 14px 16px;
  }

  /* Ensure proper wrapping for intro card */
  .title-card--intro {
    flex-direction: column;
    align-items: flex-start;
  }

  .title-card--intro .headshot {
    max-width: 100px;
    margin-bottom: 16px;
  }
}
