/* ─── Reset & base ───────────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background: #000;
  /* Keep [left-expander][board][right-expander] on one inline line so
     the horizontal expanders are in the same formatting context as the
     board and actually shift it left/right during bounce animations. */
  white-space: nowrap;
}

/* ─── 2D Board ───────────────────────────────────────────────────────────── */

.board {
  /* inline-grid keeps it in the same line-box as the h-expanders */
  display: inline-grid;
  vertical-align: top;
  white-space: normal; /* reset so cell content wraps normally */
  grid-template-columns: repeat(4, 100vw);
  grid-template-rows:    repeat(4, 100vh);
  width:  400vw;
  height: 400vh;
}

/* ─── Scroll expanders ───────────────────────────────────────────────────── */
/* The library injects these divs; they grow during bounce/elastic overshoot. */

[data-scrolltosmooth-expand="left"],
[data-scrolltosmooth-expand="right"] {
  /* Stay in the same inline line as .board */
  display: inline-block !important;
  vertical-align: top;
  /* Width is set/removed by the library during animation; CSS provides fallback */
  width: 0;
  min-height: 100vh;
  overflow: hidden;
  background-size:       cover;
  background-position:   center;
  background-attachment: fixed;
}

[data-scrolltosmooth-expand="top"],
[data-scrolltosmooth-expand="bottom"] {
  display: block;
  width: 100%;
  /* Height is set/removed by the library during animation */
  height: 0;
  overflow: hidden;
  background-size:       cover;
  background-position:   center;
  background-attachment: fixed;
}

/* ─── Cell ───────────────────────────────────────────────────────────────── */

.cell {
  width:  100vw;
  height: 100vh;
  position: relative;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  overflow: hidden;
  cursor: pointer;
}

.cell-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.08) 0%,
    rgba(0, 0, 0, 0.60) 100%
  );
  transition: background 0.3s;
}

.cell:hover .cell-overlay {
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.04) 0%,
    rgba(0, 0, 0, 0.45) 100%
  );
}

.cell-content {
  position: absolute;
  bottom: 3rem;
  left:   3rem;
  color: #fff;
  user-select: none;
}

.cell-num {
  display: block;
  font-size: clamp(3.5rem, 8vw, 7.5rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.05em;
  opacity: 0.92;
}

.cell-pos {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  opacity: 0.65;
  margin-top: 0.6rem;
}

/* ─── Fixed header ───────────────────────────────────────────────────────── */

.sts-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), transparent);
  color: #fff;
  pointer-events: none;
}

.sts-header strong {
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.sts-header span {
  font-size: 0.75rem;
  opacity: 0.6;
}

.sts-header code {
  background: rgba(255, 255, 255, 0.14);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.8em;
}

/* ─── Controls wrapper (nav + minimap side by side) ──────────────────────── */

.controls {
  position: fixed;
  bottom: 1.5rem;
  right:  1.5rem;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  gap: 1rem;
}

/* ─── Directional nav cross ──────────────────────────────────────────────── */

.nav-cross {
  display: grid;
  grid-template-areas:
    ". up ."
    "left center right"
    ". down .";
  grid-template-columns: 38px 38px 38px;
  grid-template-rows:    38px 38px 38px;
  gap: 4px;
}

#nav-up    { grid-area: up;     }
#nav-left  { grid-area: left;   }
#nav-home  { grid-area: center; }
#nav-right { grid-area: right;  }
#nav-down  { grid-area: down;   }

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width:  38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.nav-btn:hover  { background: rgba(255, 255, 255, 0.28); }
.nav-btn:active { background: rgba(255, 255, 255, 0.42); transform: scale(0.92); }

.nav-btn-home {
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.08);
}

/* ─── Minimap ─────────────────────────────────────────────────────────────── */

.minimap {
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 10px 12px 12px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.minimap-title {
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
}

#cell-indicator {
  color: rgba(255, 255, 255, 0.8);
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: none;
  font-variant-numeric: tabular-nums;
}

.minimap-grid {
  display: grid;
  grid-template-columns: repeat(4, 44px);
  gap: 4px;
}

.minimap-dot {
  display: block;
  width:  44px;
  height: 33px;
  border-radius: 4px;
  border: 2px solid transparent;
  background-size: cover;
  background-position: center;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.2s, border-color 0.2s, transform 0.2s;
}

.minimap-dot:hover  { opacity: 0.8; }

.minimap-dot.active {
  opacity: 1;
  border-color: #fff;
  transform: scale(1.08);
}

/* ─── Dat Gui ────────────────────────────────────────────────────────────── */
#dat-gui {
  position: fixed;
  right: 75px;
  z-index: 1001;
}

/* ─── GitHub corner ──────────────────────────────────────────────────────── */
.github-corner {
  position:fixed;
  top:0;
  border:0;
  right:0;
  z-index: 1000;
}

.github-corner:hover .octo-arm {
  animation: octocat-wave 560ms ease-in-out;
}

@keyframes octocat-wave {
  0%, 100% { transform: rotate(0); }
  20%, 60%  { transform: rotate(-25deg); }
  40%, 80%  { transform: rotate(10deg); }
}

@media (max-width: 500px) {
  .github-corner:hover .octo-arm { animation: none; }
  .github-corner .octo-arm       { animation: octocat-wave 560ms ease-in-out; }
}

body {
  font-family: 'Montserrat', sans-serif;
  background-image: linear-gradient(60deg, #29323c 0%, #485563 100%);
  background-repeat: no-repeat;
  background-attachment: fixed;
}

strong {
  font-size: 80px;
  text-align: center;
  display: block;
}

.hljs, code {
  font-family: 'Space Mono', monospace;
}

.hljs {
  font-size: 14px;
  padding: 0 26px;
  border-radius: 4px;
  -webkit-box-flex: 1;
          flex: 1;
  overflow: auto;
  line-height: 1.6;
}

pre {
  margin: 1rem 0;
  display: -webkit-box;
  display: flex;
}

.options dt {
  margin-bottom: 10px;
}
.options dd {
  line-height: 24px;
  margin-left: 0;
  border-bottom: 1px solid #000;
  margin-bottom: 20px;
}
.options dd:last-child {
  margin-bottom: 0;
  border-bottom: 0;
}
.options code {
  font-weight: bold;
  background: #f7f7f7;
  font-size: 90%;
  font-weight: normal;
  padding: 1px 5px;
  border-radius: 2px;
  color: #000;
}

@media (max-width: 840px) {
  strong {
    font-size: 40px;
  }

  section {
    padding: 2rem;
  }
}

/* ── Horizontal scroll demo ──────────────────────────────────── */

section#section-4 {
  background-color: #2c3e50;
  min-height: 100vh;
  flex-direction: column;
  gap: 1.5rem;
  padding: 4rem 2rem;
}

.h-demo-wrapper {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}

.h-demo-wrapper strong {
  font-size: 48px;
}

.h-demo-wrapper p {
  margin: 0;
  font-size: 1rem;
  opacity: 0.85;
}

.h-scroll-container {
  display: flex;
  overflow-x: hidden; /* STS drives scrollLeft, so native overflow is hidden */
  width: 100%;
  border-radius: 8px;
}

.h-slide {
  flex: 0 0 100%;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 900;
  color: #fff;
  border-radius: 8px;
  user-select: none;
}

.h-scroll-nav {
  position: static;
  transform: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.h-scroll-nav a {
  position: static;
  display: inline-block;
  width: auto;
  height: auto;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 20px;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.45rem 1.1rem;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  filter: none;
  text-decoration: none;
}

.h-scroll-nav a:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: #fff;
}

.h-scroll-btn-row {
  display: flex;
  gap: 1rem;
}

.h-scroll-btn-row button {
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  padding: 0.5rem 1.25rem;
  border-radius: 20px;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}

.h-scroll-btn-row button:hover {
  background: rgba(255, 255, 255, 0.3);
}

.h-demo-note {
  font-size: 0.8rem;
  opacity: 0.7;
  text-align: center;
}

.h-demo-note code {
  background: rgba(255, 255, 255, 0.15);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: monospace;
}
