/* ── Flipboard: Train Station Departures ── */
.flipboard {
  max-width: 100%;
  width: 100%;
  margin: 0 auto 4px;
  background: #000000;
  border-radius: 16px;
  border: 2px solid #2a2a2a;
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.05), inset 0 -2px 4px rgba(0,0,0,0.5), 0 4px 16px rgba(0,0,0,0.5);
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.flipboard.flipboard-compact {
  border-radius: 14px;
}

.fb-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 2px 28px;
  justify-content: space-between;
}
.fb-clock {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-right: 8px;
}
.fb-clock-char {
  width: 20px;
  height: 32px;
  font-size: 15px;
}
.fb-clock-colon {
  color: #14B8A6;
  font-size: 18px;
  font-weight: 700;
  margin: 0 1px;
}
.fb-logo {
  height: 28px;
  width: auto;
}
.fb-title {
  font-family: 'Cinzel', serif;
  font-size: 22px;
  font-weight: 600;
  color: #14B8A6;
  letter-spacing: 1px;
  position: relative;
  left: -6px;
}

/* Column headers */
.fb-col-header {
  background: #000;
  border-bottom: none;
  padding: 8px 8px 4px !important;
}
.fb-col-header .fb-cell {
  font-size: 13px;
  font-weight: 700;
  color: #14B8A6;
  letter-spacing: 2px;
  text-transform: uppercase;
}
/* Header flex matches data row ratios */
.fb-col-header .fb-time { flex: 5; }
.fb-col-header .fb-dest { flex: 22; }
.fb-col-header .fb-author { flex: 16; }
.fb-col-header .fb-track { flex: 2; }
.fb-col-header .fb-status { flex: 8; }

/* Rows */
.fb-rows {
  position: relative;
  overflow: hidden;
  padding-bottom: 10px;
}
.fb-row {
  display: flex;
  align-items: center;
  padding: 0;
  border-bottom: none;
  min-height: 44px;
  padding-left: 8px;
  padding-right: 8px;
  transition: background 0.3s;
}
.fb-row:last-child {
  border-bottom: none;
}
.fb-row:hover {
  background: rgba(255,255,255,0.02);
}
.fb-row:hover .fb-dest .fb-text {
  color: #FACC15;
}

/* Cells */
.fb-cell {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  font-size: 15px;
  font-weight: 600;
  color: #C8C8C8;
  overflow: hidden;
  white-space: nowrap;
  gap: 3px;
}
.fb-time { flex: 5; }
.fb-dest { flex: 22; }
.fb-author { flex: 16; }
.fb-track { flex: 2; }
.fb-status { flex: 8; }

/* Flap cell — individual character */
.fb-char {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 14px;
  max-width: 24px;
  height: 32px;
  background: #111111;
  border-radius: 3px;
  border: 1px solid #2a2a2a;
  position: relative;
  isolation: isolate;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.fb-char-blank {
  /* Same as regular flap, just no text */
}
.fb-text {
  position: relative;
  z-index: 1;
}
.fb-char::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: rgba(0,0,0,0.4);
  pointer-events: none;
  z-index: 0;
}
/* blank flaps get same crease as regular */

/* Status colors */
.fb-boarding { color: #14B8A6 !important; text-shadow: 0 0 8px rgba(20,184,166,0.4); }
.fb-delayed { color: #F0736E !important; }

/* ── Flip animation ── */
@keyframes flipDown {
  0% { transform: rotateX(0deg); }
  30% { transform: rotateX(-90deg); }
  31% { transform: rotateX(-90deg); }
  100% { transform: rotateX(0deg); }
}
.fb-char.fb-flipping {
  animation: flipDown 0.9s ease-in-out;
  transform-origin: center center;
  backface-visibility: hidden;
}
.fb-char.fb-flipping::before {
  content: '';
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-image: var(--flip-cover);
  opacity: 0;
  animation: showCover 0.9s ease-in-out;
}
@keyframes showCover {
  25% { opacity: 1; }
  45% { opacity: 1; }
  55% { opacity: 0; }
}

/* New row slide in from below */
.fb-row-new {
  animation: slideInUp 0.6s ease-out;
}
@keyframes slideInUp {
  from { opacity: 0; transform: translateY(44px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Book popup modal ── */
.fb-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.fb-popup-card {
  background: #111;
  border: 1px solid #2a2a2a;
  border-radius: 16px;
  max-width: 480px;
  width: 90%;
  padding: 28px;
  position: relative;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.05);
  animation: popIn 0.25s ease-out;
}
@keyframes popIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.fb-popup-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: #666;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}
.fb-popup-close:hover { color: #aaa; }
.fb-popup-content {
  display: flex;
  gap: 20px;
}
.fb-popup-cover {
  width: 120px;
  height: auto;
  aspect-ratio: 2/3;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.fb-popup-info {
  flex: 1;
  min-width: 0;
}
.fb-popup-title {
  font-family: 'Cinzel', serif;
  font-size: 20px;
  font-weight: 600;
  color: #FACC15;
  margin-bottom: 4px;
}
.fb-popup-author {
  font-size: 14px;
  color: #FFFFFF;
  margin-bottom: 12px;
  font-weight: 500;
}
.fb-popup-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.fb-popup-year {
  font-size: 13px;
  color: #AAA;
}
.fb-popup-genre {
  font-size: 11px;
  font-weight: 600;
  color: #CCC;
  background: #333;
  padding: 3px 10px;
  border-radius: 10px;
}
.fb-popup-summary {
  font-size: 14px;
  color: #AAA;
  line-height: 1.6;
}
@media (max-width: 500px) {
  .fb-popup-content { flex-direction: column; align-items: center; text-align: center; }
  .fb-popup-cover { width: 100px; }
  .fb-popup-meta { justify-content: center; }
}

/* ── Responsive — scale the whole board to fit ── */
@media (max-width: 720px) {
  .flipboard.flipboard-compact .fb-header {
    padding: 10px 10px 4px 14px;
    gap: 8px;
  }
  .flipboard.flipboard-compact .fb-title {
    font-size: 16px;
    letter-spacing: 0.6px;
    left: 0;
  }
  .flipboard.flipboard-compact .fb-clock {
    gap: 2px;
    margin-right: 0;
  }
  .flipboard.flipboard-compact .fb-clock-char {
    width: 14px;
    height: 24px;
    font-size: 11px;
  }
  .flipboard.flipboard-compact .fb-col-header {
    padding: 6px 6px 2px !important;
  }
  .flipboard.flipboard-compact .fb-col-header .fb-cell {
    font-size: 9px;
    letter-spacing: 1px;
  }
  .flipboard.flipboard-compact .fb-row {
    min-height: 34px;
    padding-left: 4px;
    padding-right: 4px;
  }
  .flipboard.flipboard-compact .fb-cell {
    padding: 4px 4px;
    gap: 2px;
    font-size: 11px;
  }
  .flipboard.flipboard-compact .fb-time { flex: 5; }
  .flipboard.flipboard-compact .fb-dest { flex: 19; }
  .flipboard.flipboard-compact .fb-track { flex: 3; }
  .flipboard.flipboard-compact .fb-status { flex: 7; }
  .flipboard.flipboard-compact .fb-char {
    min-width: 8px;
    max-width: 13px;
    height: 24px;
    font-size: 10px;
    border-radius: 2px;
  }
  .flipboard.flipboard-compact .fb-popup-card {
    width: calc(100% - 24px);
    padding: 22px 18px;
  }
}
@media (max-width: 420px) {
  .flipboard.flipboard-compact .fb-title {
    font-size: 14px;
  }
  .flipboard.flipboard-compact .fb-char {
    min-width: 7px;
    max-width: 12px;
    height: 22px;
    font-size: 9px;
  }
  .flipboard.flipboard-compact .fb-clock-char {
    width: 12px;
    height: 22px;
    font-size: 10px;
  }
}
