/* ============================================================================
   LAYOUT  —  the machine chassis.
   A 7 x 4 grid: a 10px frame of crosshair corners, a 120px header row split
   into identity / three nav cells / a composite cell, then a 250px sidebar
   next to the scrolling main panel. The container is painted with ink so the
   2px gaps read as manufacturing seams.
   ============================================================================ */

/* ------------------------------------------------------- pre-render wash */
.wait-for-data {
  position: fixed;
  inset: 0;
  background: var(--background);
  z-index: 100000;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--black);
  transition:
    opacity 0.5s ease,
    visibility 0.5s;
}
.wait-for-data span {
  margin: 20px;
}
.wait-for-data.is-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ------------------------------------------------------------------ grid */
.container {
  display: grid;
  grid-template-columns: var(--gutter) var(--sidebar-w) 1fr 1fr 1fr 1fr var(
      --gutter
    );
  grid-template-rows: var(--gutter) var(--head-h) 1fr var(--gutter);
  gap: var(--gap);
  grid-template-areas:
    "c0 c1 c2 c3 c4 c5 c6"
    "c7 nav0 nav1 nav2 nav3 nav4 c8"
    "c9 sidebar main main main main c10"
    "c11 c12 c13 c14 c15 c16 c17";
  width: 100vw;
  height: 100vh;
  background: var(--black);
  position: relative;
}

.container .corner {
  background: var(--background);
  position: relative;
}
.container .corner::before,
.container .corner::after {
  content: "";
  position: absolute;
  background: var(--black);
  opacity: 0;
  transition: opacity 0.4s ease;
}
.container .corner::before {
  left: 50%;
  top: 1px;
  bottom: 1px;
  width: 1px;
  transform: translateX(-50%);
}
.container .corner::after {
  top: 50%;
  left: 1px;
  right: 1px;
  height: 1px;
  transform: translateY(-50%);
}
.container .corner.is-in::before,
.container .corner.is-in::after {
  opacity: 0.45;
}

.c0 {
  grid-area: c0;
}
.c1 {
  grid-area: c1;
}
.c2 {
  grid-area: c2;
}
.c3 {
  grid-area: c3;
}
.c4 {
  grid-area: c4;
}
.c5 {
  grid-area: c5;
}
.c6 {
  grid-area: c6;
}
.c7 {
  grid-area: c7;
}
.c8 {
  grid-area: c8;
}
.c9 {
  grid-area: c9;
}
.c10 {
  grid-area: c10;
}
.c11 {
  grid-area: c11;
}
.c12 {
  grid-area: c12;
}
.c13 {
  grid-area: c13;
}
.c14 {
  grid-area: c14;
}
.c15 {
  grid-area: c15;
}
.c16 {
  grid-area: c16;
}
.c17 {
  grid-area: c17;
}

/* every panel is painted by two wipe layers driven by custom properties,
   which is how the reveal, the hover wipe and the page exit all work */
.grid-item {
  --grid-item-width: 0%;
  --grid-item-width2: 0%;
  position: relative;
  background: var(--background);
  overflow: hidden;
}
.grid-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: var(--grid-item-width);
  height: 100%;
  background: var(--background);
  z-index: 10;
  pointer-events: none;
}
.grid-item::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: var(--grid-item-width2);
  height: 100%;
  background: var(--black);
  z-index: 9;
  pointer-events: none;
}

/* pre-boot: everything is covered, so nothing flashes before the reveal */
body:not(.revealed) .grid-item,
body:not(.revealed) .main {
  --grid-item-width: 100%;
  --grid-item-width2: 100%;
}

.flex {
  display: flex;
}
.col {
  flex-direction: column;
}
.align-right {
  text-align: right;
}
.align-left {
  text-align: left;
}
.rule {
  height: 1px;
  background: var(--black);
  opacity: 0.35;
  width: 100%;
}

/* ------------------------------------------------------------ identity */
.nav0 {
  grid-area: nav0;
  background: var(--black);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 10px 8px;
}
.nav0 > [data-barcode]:first-child {
  width: 34px;
  height: 10px;
  margin-left: 15px;
}
.nav0 > [data-barcode]:last-child {
  width: calc(100% - 20px);
  height: 10px;
  margin-left: 10px;
}
.nav0 .flex {
  align-items: center;
  justify-content: space-between;
}
.nav0 h1 {
  font-family: var(--font-tech);
  font-weight: 700;
  color: var(--background);
  font-size: clamp(1.1rem, 2.3vw, 2rem);
  line-height: 1;
  letter-spacing: -0.02em;
}
.nav0 h4 {
  color: var(--background);
  text-align: right;
}
.nav0 > h1 {
  text-align: right;
  width: 100%;
}

/* ---------------------------------------------------------- nav cells */
.nav1 {
  grid-area: nav1;
}
.nav2 {
  grid-area: nav2;
}
.nav3 {
  grid-area: nav3;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-tech);
  font-weight: 700;
  font-size: clamp(0.9rem, 1.4vw, 1.5rem);
  letter-spacing: 0.04em;
}
.nav-item a {
  color: var(--black);
  text-decoration: none;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 11;
}
.nav-item.is-current a::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 14%;
  width: 22px;
  height: 2px;
  background: var(--black);
  transform: translateX(-50%);
}

/* ---------------------------------------------- composite nav4 cluster */
.nav4 {
  grid-area: nav4;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: var(--gap);
  background: var(--black) !important;
  overflow: hidden;
}
.nav4 > div {
  background: var(--background);
}

.nav4-0 {
  padding-bottom: 4px;
}
.nav4-0 h1 {
  font-family: var(--font-tech);
  font-style: italic;
  font-weight: 700;
  margin: 4px 0 0 25px;
  font-size: 1.5rem;
  line-height: 1;
}
.nav4-0 [data-barcode] {
  width: 60%;
  height: 25px;
  margin: 0 0 0 25px;
}
.nav4-0-0 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-inline: 25px;
  gap: 10px;
}

.nav4-1 {
  display: flex;
  width: 100%;
  height: 100%;
  justify-content: space-between;
  overflow: hidden;
}
.nav4-1-0 {
  display: grid;
  flex: 1;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: var(--gap);
  grid-template-areas:
    "marquee marquee"
    "mfg theme";
  background: var(--black) !important;
  min-width: 0;
}
.nav4-1-0 > div:not(.color-change) {
  background: var(--background);
}

.nav4-1-0-0 {
  grid-area: marquee;
  font-family: var(--font-display);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.nav4-1-0-1 {
  grid-area: mfg;
}
.nav4-1-0-2 {
  grid-area: theme;
}
.cell {
  padding: 2px 0 0 6px;
  position: relative;
  z-index: 0;
}
.cell h3 {
  font-size: 1rem;
  margin-top: -1px;
}

.color-change {
  background: var(--secondary);
}
.color-change h3 {
  color: var(--black);
}
body.dark-theme .color-change {
  background: var(--primary);
}

.nav4-1-1 {
  aspect-ratio: 1 / 1;
  align-self: stretch;
  border-left: var(--gap) solid var(--black);
  overflow: hidden;
  background: var(--background);
}
.nav4-1-1 img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ------------------------------------------------------------ sidebar */
.sidebar {
  grid-area: sidebar;
  background: var(--black);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  height: 100%;
  min-height: 0;
}
.sidebar > div {
  background: var(--background);
  position: relative;
}

.sidebar .s0 {
  height: 100px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
}
.sidebar .s0 h4 {
  margin: 8px 0 0 10px;
  font-family: var(--font-tech);
  font-weight: 600;
}
.sidebar .s0 .list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 4px 10px 10px;
  padding: 5px;
  position: relative;
}
.sidebar .s0 .list .crosshair {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.sidebar .s0 .list .crosshair > div {
  position: absolute;
  background: var(--black);
}
.sidebar .s0 .list .c1 {
  top: 0;
  left: 0;
  width: 7px;
  height: 2px;
}
.sidebar .s0 .list .c2 {
  top: 0;
  right: 0;
  width: 7px;
  height: 2px;
}
.sidebar .s0 .list .c3 {
  bottom: 0;
  right: 0;
  width: 7px;
  height: 2px;
}
.sidebar .s0 .list .c4 {
  bottom: 0;
  left: 0;
  width: 7px;
  height: 2px;
}
.sidebar .s0 .list .c5 {
  top: 0;
  left: 0;
  width: 2px;
  height: 7px;
}
.sidebar .s0 .list .c6 {
  top: 0;
  right: 0;
  width: 2px;
  height: 7px;
}
.sidebar .s0 .list .c7 {
  bottom: 0;
  right: 0;
  width: 2px;
  height: 7px;
}
.sidebar .s0 .list .c8 {
  bottom: 0;
  left: 0;
  width: 2px;
  height: 7px;
}

.sidebar .s0 .list-item {
  position: relative;
}
.sidebar .s0 .list-item a {
  display: block;
  color: var(--black);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 3px 7px;
  border: 1px solid transparent;
  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    color 0.2s ease;
  text-align: center;
}
.sidebar .s0 .list-item a:hover {
  border-color: var(--black);
}
.sidebar .s0 .list-item.is-active a {
  background: var(--black);
  color: var(--background);
  border-color: var(--black);
}

.sidebar .s1 {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px;
  overflow: hidden;
}
.sidebar .s1 > h4 {
  position: sticky;
  top: -10px;
  z-index: 4;
  margin: -10px -10px 6px;
  padding: 4px 10px 8px;
  background: var(--background);
  font-family: var(--font-tech);
  font-weight: 600;
}
.sidebar .s1 > h4 span {
  text-shadow: 0 0 14px var(--background);
}
.sidebar .s1 .projects {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  min-height: 0;
}
.sidebar .s1 .projects .toc-item {
  font-family: var(--font-tech);
  font-weight: 600;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
  padding: 1px 0;
}
.sidebar .s1 .projects .toc-item a {
  color: var(--black);
  text-decoration: none;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar .s1 .projects .toc-item:hover {
  transform: translateX(3px);
}
.sidebar .s1 .projects .toc-item.is-active {
  opacity: 1;
}
.sidebar .s1 .projects .toc-item.is-active a {
  color: var(--background);
  background: var(--black);
  padding: 1px 5px;
  margin-left: -5px;
}
.sidebar .s1 .projects .toc-item[data-indent="1"] {
  margin-left: 14px;
  font-size: 0.76rem;
}
.sidebar .s1 .projects .toc-item[data-indent="2"] {
  margin-left: 28px;
  font-size: 0.7rem;
}
.sidebar .s1 .projects .toc-item[data-indent="3"] {
  margin-left: 42px;
  font-size: 0.66rem;
}

.sidebar .s2 {
  flex: 0 0 auto;
  height: 92px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  padding: 5px;
}
.sidebar .s2 span {
  font-family: var(--font-tech);
  font-size: 0.42em;
  letter-spacing: 0.1em;
  line-height: 1.02;
  text-align: justify;
  word-break: break-all;
  opacity: 0.75;
  display: block;
  height: 100%;
  overflow: hidden;
}

.sidebar .s3 {
  flex: 0 0 auto;
  background: var(--black);
  display: flex;
  gap: var(--gap);
  padding: 0;
}
.sidebar .s3 > div {
  background: var(--background);
  height: 50px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar .s3 a {
  color: var(--black);
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  position: relative;
  z-index: 11;
}
.sidebar .s3 svg {
  width: 22px;
  height: 22px;
}

/* --------------------------------------------------------------- main */
.main {
  grid-area: main;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--black) !important;
  --grid-item-width: 0%;
  --grid-item-width2: 0%;
  scroll-behavior: auto;
}
.main::before,
.main::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  pointer-events: none;
  z-index: 60;
}
.main::before {
  width: var(--grid-item-width);
  background: var(--background);
}
.main::after {
  width: var(--grid-item-width2);
  background: var(--black);
}

main.main-content {
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--black) !important;
  gap: var(--gap);
}
