/* ─── Reset pandoc's document layout (global.css) for our own app shell ───────*/
body {
  overflow: hidden;
}

header,
main,
footer {
  max-width: none;
  margin-inline: 0;
  padding-inline: 0;
}

header,
main {
  padding-top: 0;
  padding-bottom: 0;
}

/* ─── Nav ────────────────────────────────────────────────────────────────────*/

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  min-height: 3.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.brand {
  padding-inline: 1rem;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
}

.brand:hover {
  color: var(--accent);
}

/* ─── Home: horizontal project rail ───────────────────────────────────────────*/
.project-grid {
  display: grid;
  grid-auto-columns: minmax(28rem, min(86vw, 60rem));
  grid-auto-flow: column;
  height: calc(100dvh - 3.5rem);
  overflow-x: auto;
  overflow-y: hidden;
  border-bottom: 1px solid var(--border);
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.intro-panel,
.project-panel {
  min-width: 0;
  border-right: 1px solid var(--border);
  scroll-snap-align: start;
}

.intro-panel {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2rem;
  padding: clamp(1.5rem, 4vw, 3.5rem);
  overflow-y: auto;
}

.intro-copy {
  display: grid;
  gap: 1rem;
  max-width: var(--max-width);
}

.intro-copy h1,
.intro-copy p {
  margin: 0;
}

.intro-copy h1 {
  font-size: clamp(1.4rem, 3vw, 2.1rem);
  font-weight: 700;
  line-height: 1.2;
}

.intro-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.controls {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 12;
  display: flex;
  gap: 0.5rem;
}

.control {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 1.25rem;
}

.control:hover {
  border-color: var(--text);
  color: var(--accent);
}

/* ─── Project frame + loading state ───────────────────────────────────────────*/
.project-panel {
  position: relative;
  background: var(--bg);
}

.project-panel.is-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg-subtle);
  animation: pulse 1.4s ease-in-out infinite;
}

.project-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bg);
  opacity: 1;
  transition: opacity 0.2s ease;
}

.is-loading .project-frame {
  opacity: 0;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* ─── Detail page: full-width single project ──────────────────────────────────*/
.detail-main {
  height: calc(100dvh - 3.5rem);
}

.detail-main .project-panel {
  height: 100%;
}

@media (max-width: 760px) {
  .project-grid {
    grid-auto-columns: minmax(20rem, 92vw);
  }

  .intro-panel {
    grid-column: span 1;
    padding: 1.25rem;
  }
}
