/* app.css — shared split-pane shell for index.html and ebook.html */

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

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "DM Sans", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--interior-bg);
  color: var(--interior-text);
}

/* ── App header (dark bar, always 48px) ─────────────────────── */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: var(--cover-bg);
  border-bottom: 0.5px solid var(--border-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}

.app-header-name {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--cover-text);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.app-header-sub {
  font-size: 11px;
  color: var(--ink-faint);
}

.app-header-link {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--ink-faint);
  text-decoration: none;
  letter-spacing: 0.08em;
  transition: color 0.15s;
}

.app-header-link:hover {
  color: var(--gold);
}

/* Breadcrumb (ebook header) */
.app-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-breadcrumb-sep {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: #3a3a36;
}

.app-breadcrumb-current {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 0.06em;
}

/* ── App shell (the full-height area below header) ──────────── */
.app-shell {
  position: fixed;
  top: 48px;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
}

/* When a footer is present, shrink to avoid overlap */
.app-shell.has-footer {
  bottom: 52px;
}

/* ── Left sidebar (shared, 180px) ───────────────────────────── */
.app-sidebar {
  width: 180px;
  flex-shrink: 0;
  border-right: 0.5px solid var(--border-light);
  background: var(--interior-bg);
  overflow-y: auto;
  padding: 16px 0;
}

.sidebar-label {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 0 16px;
  margin-bottom: 8px;
}

/* ── Timeline era items (homepage sidebar) ──────────────────── */
.ts-item {
  padding: 8px 16px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.15s;
}

.ts-item.active {
  border-left-color: var(--gold);
  background: var(--gold-faint);
}

.ts-item-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--interior-text);
}

.ts-item.active .ts-item-name {
  color: var(--gold-dark);
}

.ts-item-period {
  font-size: 10px;
  color: var(--ink-faint);
  margin-top: 2px;
}

/* ── Chapter rail items (ebook sidebar) ─────────────────────── */
.rail-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 16px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition:
    background 0.15s,
    color 0.15s;
}

.rail-item:hover .rail-item-title {
  color: var(--interior-text);
}

.rail-item:hover .rail-item-num {
  color: var(--ink-muted);
}

.rail-item.active {
  border-left-color: var(--gold);
  background: var(--gold-faint);
}

.rail-item-num {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--ink-faint);
  font-weight: 500;
  min-width: 22px;
  flex-shrink: 0;
  text-align: right;
}

.rail-item.active .rail-item-num {
  color: var(--gold);
}

.rail-item-title {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.35;
  transition: color 0.15s;
}

.rail-item.active .rail-item-title {
  color: var(--interior-text);
  font-weight: 500;
}

/* ── Right content area ─────────────────────────────────────── */
.app-content {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
  position: relative;
}

/* ── Ebook: chapter panels ───────────────────────────────────── */
.chapter {
  display: none;
  min-height: 100%;
}

.chapter.active {
  display: block;
}

/* ── Page-turn animations ────────────────────────────────────── */
@keyframes exitLeft {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(-36px); }
}

@keyframes exitRight {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(36px); }
}

@keyframes enterFromRight {
  from { opacity: 0; transform: translateX(36px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes enterFromLeft {
  from { opacity: 0; transform: translateX(-36px); }
  to   { opacity: 1; transform: translateX(0); }
}

.chapter.exit-left,
.chapter.exit-right {
  display: block !important;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  pointer-events: none;
}

.chapter.exit-left {
  animation: exitLeft 0.22s ease forwards;
}

.chapter.exit-right {
  animation: exitRight 0.22s ease forwards;
}

.chapter.enter-from-right {
  animation: enterFromRight 0.26s ease forwards;
}

.chapter.enter-from-left {
  animation: enterFromLeft 0.26s ease forwards;
}

.chapter.interior {
  background: var(--interior-bg);
  color: var(--interior-text);
}

/* ── Homepage: era content panels ───────────────────────────── */
.era-chapters {
  display: none;
  padding: 20px 24px 32px;
}

.era-chapters.active {
  display: block;
}

.era-header-block {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 0.5px solid var(--border-light);
}

.era-company-name {
  font-family: "DM Serif Display", serif;
  font-size: 24px;
  color: var(--interior-text);
  line-height: 1.1;
}

.era-role-text {
  font-family: "Lora", serif;
  font-style: italic;
  font-size: 13px;
  color: var(--ink-muted);
  margin-top: 4px;
}

.era-dates-text {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--gold);
  margin-top: 4px;
  letter-spacing: 0.08em;
}

.era-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.era-chip {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: rgba(196, 154, 60, 0.8);
  border: 0.5px solid rgba(196, 154, 60, 0.35);
  padding: 3px 8px;
  border-radius: 2px;
}

/* ── Chapter cards (homepage) ───────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.chapter-card {
  border: 0.5px solid var(--border-light);
  border-radius: 6px;
  padding: 14px 16px;
  background: #fff;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s;
}

.chapter-card:hover {
  border-color: var(--gold);
}

.chapter-num {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  font-weight: 500;
  color: var(--gold-dark);
  background: var(--gold-faint);
  border-radius: 3px;
  padding: 2px 6px;
  flex-shrink: 0;
  margin-top: 1px;
  letter-spacing: 0.04em;
  border: 0.5px solid rgba(196, 154, 60, 0.2);
}

.chapter-body {
  flex: 1;
  min-width: 0;
}

.chapter-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--interior-text);
}

.chapter-desc {
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 3px;
  line-height: 1.5;
}

.chapter-stat {
  font-size: 10px;
  font-weight: 500;
  color: var(--gold-dark);
  margin-top: 5px;
  letter-spacing: 0.03em;
}

.chapter-arrow {
  font-size: 11px;
  color: var(--ink-faint);
  flex-shrink: 0;
  margin-top: 2px;
}

/* ── Non-linked project cards (eras without chapters) ───────── */
.project-card {
  border: 0.5px solid var(--border-light);
  border-radius: 6px;
  padding: 14px 16px;
  background: #fff;
}

.project-card-name {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.project-card-desc {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 6px;
  line-height: 1.5;
}

/* ── Ebook footer (dark bar, 52px) ──────────────────────────── */
.ebook-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: var(--cover-bg);
  border-top: 0.5px solid var(--border-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}

.ebook-footer-btn {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 0;
  min-width: 120px;
  transition: color 0.15s;
}

.ebook-footer-btn:hover {
  color: var(--gold);
}

.ebook-footer-btn:disabled {
  opacity: 0;
  pointer-events: none;
}

#footer-prev {
  text-align: left;
}

#footer-next {
  text-align: right;
}

.ebook-footer-indicator {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #3a3a36;
  text-align: center;
  flex: 1;
  padding: 0 16px;
}

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-header {
    padding: 0 14px;
  }

  /* Collapse the redundant "Portfolio /" middle crumb — the back link
     and current-chapter label carry the same info in less space. */
  .app-breadcrumb .app-header-link,
  .app-breadcrumb .app-breadcrumb-sep:first-child {
    display: none;
  }

  .app-breadcrumb-current {
    font-size: 10.5px;
    max-width: 60vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Stack: sidebar becomes a horizontal chapter chip-rail above content */
  .app-shell {
    flex-direction: column;
  }

  .app-sidebar {
    width: 100%;
    height: auto;
    flex-shrink: 0;
    border-right: none;
    border-bottom: 0.5px solid var(--border-light);
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 12px;
    display: flex;
    align-items: stretch;
    gap: 4px;
    scrollbar-width: none;
  }

  .app-sidebar::-webkit-scrollbar {
    display: none;
  }

  .sidebar-label {
    display: none;
  }

  .rail-item,
  .ts-item {
    flex-shrink: 0;
    padding: 6px 10px;
    border-left: none;
    border-bottom: 2px solid transparent;
    gap: 6px;
  }

  .rail-item.active,
  .ts-item.active {
    border-left-color: transparent;
    border-bottom-color: var(--gold);
  }

  .rail-item-title {
    white-space: nowrap;
  }

  .ts-item-period {
    display: none;
  }

  /* Homepage card grid stacks too */
  .cards-grid {
    grid-template-columns: 1fr;
  }

  /* Footer: tighter padding, shrink Prev/Next, hide the duplicate
     chapter label — the header breadcrumb already shows it. */
  .ebook-footer {
    padding: 0 14px;
  }

  .ebook-footer-btn {
    min-width: 0;
    padding: 8px 6px;
    font-size: 10.5px;
  }

  .ebook-footer-indicator {
    display: none;
  }
}

@media (max-width: 480px) {
  .app-header {
    padding: 0 10px;
  }

  .app-header-link {
    font-size: 10px;
  }

  .app-breadcrumb-current {
    font-size: 10px;
    max-width: 50vw;
  }
}
