/* ========================================   ABOUT — STORY HERO======================================== */

.history-hero {
  position: relative;
  width: 100%;
  padding: clamp(2rem, 5vw, 4.5rem);
  overflow: hidden;
}

/* ========================================   HERO LAYOUT======================================== */

.history-hero .row {
  position: static;
  align-items: center;
  margin: 0;
}

/* ========================================   HERO TEXT======================================== */

.history-hero .col-8 {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  width: min(68%, 850px);
  max-width: 850px;
}

/* ========================================   HERO ILLUSTRATION======================================== */

.history-hero .col-3 {
  position: absolute;
  top: 50%;
  right: clamp(1.5rem, 4vw, 4rem);
  width: clamp(220px, 18vw, 290px);
  padding: 0;
  transform: translateY(-50%);
}

.history-hero img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 290px;
  max-height: 280px;
  object-fit: contain;
}

/* ========================================   HISTORY SECTION======================================== */

.history-section {
  width: 100%;
}

.history-browser {
  width: 100%;
}

/* ========================================   HISTORY INTRO======================================== */

.history-browser-header {
  max-width: 70ch;
  margin-bottom: clamp(2rem, 4vw, 3rem);
}

.history-browser-header h1, .history-browser-header h2 {
  margin-bottom: 0.75rem;
}

.history-browser-header p {
  margin-bottom: 0;
  line-height: 1.6;
}

/* ========================================   TOP TIMELINE======================================== */

.history-timeline-nav {
  position: relative;
  width: 100%;
  margin-bottom: 2rem;
}

/* ========================================   ERA / DATE BUTTONS======================================== */

.history-era-buttons {
  position: relative;
  width: 100%;
  height: 2.4rem;
  margin-bottom: 0;
}

.history-era-button {
  --era-position: 0%;
  position: absolute;
  bottom: 0;
  left: var(--era-position);
  padding: 0 0 0.65rem !important;
  color: var(--bs-dark);
  background: transparent !important;
  border: 0 !important;
  border-radius: 0;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  box-shadow: none !important;
  transform: translateX(-50%);
  transition: color 0.2s ease, font-weight 0.2s ease, transform 0.2s ease;
}

.history-era-button:first-child {
  transform: translateX(0);
}

.history-era-button:last-child {
  transform: translateX(-100%);
}

.history-era-button:hover, .history-era-button.is-active {
  color: var(--bs-primary);
}

.history-era-button.is-active {
  font-weight: 700;
}

/* ========================================   TIMELINE DATE MARKERS======================================== */

.history-era-button::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -19px;
  width: 10px;
  height: 10px;
  background-color: var(--bs-light);
  border: 2px solid var(--bs-warning);
  border-radius: 50%;
  transform: translateX(-50%);
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.history-era-button:first-child::after {
  left: 0;
  transform: none;
}

.history-era-button:last-child::after {
  right: 0;
  left: auto;
  transform: none;
}

.history-era-button.is-active::after {
  background-color: var(--bs-secondary);
}

/* ========================================   DRAGGABLE TOP PROGRESS BAR======================================== */

.history-progress {
  --history-progress: 0%;
  position: relative;
  width: 100%;
  height: 32px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Background timeline */

.history-progress::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 4px;
  background-color: rgba(0, 0, 0, 0.12);
  border-radius: 100px;
  transform: translateY(-50%);
}

/* Completed portion */

.history-progress-fill {
  position: absolute;
  top: 50%;
  left: 0;
  width: var(--history-progress);
  height: 4px;
  background-color: var(--bs-warning);
  border-radius: 100px;
  transform: translateY(-50%);
  pointer-events: none;
}

/* Progress handle */

.history-progress-handle {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: var(--history-progress);
  width: 22px;
  height: 22px;
  background-color: var(--bs-light);
  border: 4px solid var(--bs-warning);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  cursor: grab;
  transform: translate(-50%, -50%);
  transition: width 0.15s ease, height 0.15s ease, box-shadow 0.15s ease;
}

.history-progress:hover .history-progress-handle {
  width: 24px;
  height: 24px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
}

.history-progress.is-dragging {
  cursor: grabbing;
}

.history-progress.is-dragging .history-progress-handle {
  width: 25px;
  height: 25px;
  cursor: grabbing;
}

/* ========================================   HORIZONTAL EVENT SCROLLER======================================== */

.history-track-wrap {
  position: relative;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-top: 0.25rem;
  padding-bottom: 0.75rem;
  cursor: grab;
  scroll-behavior: smooth;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  touch-action: pan-x pan-y;
  overscroll-behavior-x: contain;
}

.history-track-wrap::-webkit-scrollbar {
  display: none;
}

.history-track-wrap.is-dragging {
  cursor: grabbing;
  scroll-behavior: auto;
  scroll-snap-type: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ========================================   HISTORY TRACK======================================== */

.history-track {
  --history-end-space: 10vw;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: clamp(0.85rem, 1.5vw, 1.25rem);
  width: max-content;
  padding-right: var(--history-end-space);
}

/* ========================================   NORMAL EVENT CARD======================================== */

.history-event {
  position: relative;
  flex: 0 0 clamp(285px, 24vw, 355px);
  display: flex;
  flex-direction: column;
  min-height: 300px;
  padding: clamp(1.25rem, 2vw, 1.75rem);
  background-color: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.09);
  border-radius: 22px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
  scroll-snap-align: start;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.history-event:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
}

.history-event.is-current {
  border-color: rgba(0, 0, 0, 0.16);
}

/* ========================================   EVENT DATE======================================== */

.history-event-date {
  margin: 0 0 1rem;
  color: var(--bs-primary);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

/* ========================================   EVENT TITLE======================================== */

.history-event-title {
  margin: 0 0 0.75rem;
  font-weight: 600;
  line-height: 1.15;
}

/* ========================================   EVENT DESCRIPTION======================================== */

.history-event-description {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
}

/* ========================================   TEXT-ONLY EVENT   HEIGHT FOLLOWS CONTENT======================================== */

.history-track .history-event.history-event-text {
  min-height: 0 !important;
  height: fit-content !important;
  align-self: flex-start;
}

/* ========================================   SMALL HISTORY EVENT======================================== */

.history-track .history-event.history-event-small {
  flex: 0 0 clamp(173px, 13.2vw, 210px) !important;
  width: clamp(173px, 13.2vw, 210px) !important;
  min-width: clamp(173px, 13.2vw, 210px) !important;
  max-width: clamp(173px, 13.2vw, 210px) !important;
  min-height: 0 !important;
  height: fit-content !important;
  align-self: flex-start;
  padding: 0.9rem 1rem;
}

.history-event-small .history-event-date {
  margin-bottom: 0.65rem;
  font-size: 0.7rem;
  line-height: 1.15;
}

.history-event-small .history-event-title {
  margin-bottom: 0.7rem;
  font-size: 1.05rem;
  line-height: 1.2;
}

.history-event-small .history-event-description {
  margin-bottom: 0;
  font-size: 0.88rem;
  line-height: 1.5;
}

/* ========================================   IMAGE EVENT======================================== */

.history-track .history-event.history-event-with-image {
  min-height: 0 !important;
  height: fit-content !important;
  align-self: flex-start !important;
  padding-bottom: 0;
  overflow: hidden;
}

.history-track.history-event.history-event-with-image.history-event-description {
  margin-bottom: 0;
}

/* ========================================   IMAGE WRAPPER======================================== */

.history-track.history-event.history-event-with-image.history-event-image-wrap {
  position: relative;
  width: calc( 100% + (clamp(1.25rem, 2vw, 1.75rem) * 2) );
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  margin-top: 2.25rem !important;
  margin-right: calc(-1 * clamp(1.25rem, 2vw, 1.75rem));
  margin-left: calc(-1 * clamp(1.25rem, 2vw, 1.75rem));
  overflow: hidden;
}

/* ========================================   ACTUAL HISTORY IMAGE======================================== */

.history-track.history-event.history-event-with-image.history-event-image-wrap.history-event-image {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  object-fit: contain !important;
  object-position: center !important;
}

/* ========================================   FEATURED EVENT======================================== */

.history-event-featured {
  flex-basis: clamp(370px, 34vw, 500px);
  color: var(--bs-light);
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
}

.history-event-featured .history-event-date {
  color: var(--bs-secondary);
}

.history-event-featured .history-event-title, .history-event-featured .history-event-description {
  color: var(--bs-light);
}

/* ========================================   TABLET======================================== */

@media (max-width: 991.98px) {
  .history-event {
    flex-basis: clamp(280px, 42vw, 340px);
  }
}

/* Keep illustration from colliding with text */

@media (max-width: 991.98px) {
  .history-hero .col-8 {
    width: 62%;
  }
}

@media (max-width: 991.98px) {
  .history-hero .col-3 {
    right: 1.5rem;
    width: clamp(190px, 23vw, 230px);
  }
}

/* ========================================   MOBILE======================================== */

/* Hero becomes stacked again */

@media (max-width: 767.98px) {
  .history-hero {
    padding: 2rem;
  }
}

@media (max-width: 767.98px) {
  .history-hero .row {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
  }
}

@media (max-width: 767.98px) {
  .history-hero .col-8 {
    position: relative;
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
  }
}

@media (max-width: 767.98px) {
  .history-hero .col-3 {
    position: static;
    width: 170px;
    max-width: 170px;
    margin: 0 auto;
    padding: 0;
    transform: none;
  }
}

@media (max-width: 767.98px) {
  .history-hero img {
    width: 100%;
    max-width: 170px;
    max-height: 180px;
    margin: 0 auto;
  }
}

/* History section */

@media (max-width: 767.98px) {
  .history-section {
    padding-top: 3rem;
    padding-bottom: 3rem;
  }
}

@media (max-width: 767.98px) {
  .history-browser-header {
    margin-bottom: 2rem;
  }
}

@media (max-width: 767.98px) {
  .history-era-button {
    font-size: 0.7rem;
  }
}

/* Standard cards */

@media (max-width: 767.98px) {
  .history-event {
    flex-basis: 82vw;
    min-height: 290px;
  }
}

/* Content-height cards */

@media (max-width: 767.98px) {
  .history-track .history-event.history-event-text, .history-track .history-event.history-event-with-image {
    min-height: 0 !important;
    height: fit-content !important;
  }
}

/* Small history cards */

@media (max-width: 767.98px) {
  .history-track .history-event.history-event-small {
    flex: 0 0 48vw !important;
    width: 48vw !important;
    min-width: 48vw !important;
    max-width: 48vw !important;
    min-height: 0 !important;
    height: fit-content !important;
  }
}

/* Controls */

@media (max-width: 767.98px) {
  .history-controls {
    margin-top: 0.75rem;
  }
}

@media (max-width: 767.98px) {
  .history-arrow {
    width: 2.6rem;
    height: 2.6rem;
  }
}

/* ========================================   VERY SMALL SCREENS======================================== */

@media (max-width: 399.98px) {
  .history-era-button {
    font-size: 0.65rem;
  }
}

@media (max-width: 399.98px) {
  .history-event {
    flex-basis: 84vw;
  }
}

@media (max-width: 399.98px) {
  .history-track .history-event.history-event-small {
    flex: 0 0 48vw !important;
    width: 48vw !important;
    min-width: 48vw !important;
    max-width: 48vw !important;
  }
}

/* ========================================   REDUCED MOTION======================================== */

@media (prefers-reduced-motion: reduce) {
  .history-track-wrap {
    scroll-behavior: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .history-event, .history-arrow, .history-era-button, .history-progress-handle {
    transition: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .history-event:hover {
    transform: none;
  }
}

/* ========================================   HISTORY BOTTOM CONTROLS======================================== */

.history-controls {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
  margin-top: 1rem;
}

/* Put arrows first on the left */

.history-arrows {
  display: flex;
  order: 1;
  gap: 0.65rem;
}

/* Counter sits directly after arrows */

.history-count {
  order: 2;
  color: var(--bs-dark);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.history-count p {
  margin: 0;
}

/* ========================================   ARROW BUTTONS======================================== */

.history-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0 !important;
  color: var(--bs-light);
  background-color: var(--bs-warning);
  border: 1px solid var(--bs-warning);
  border-radius: 50%;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

.history-arrow:hover:not(:disabled) {
  color: var(--bs-danger);
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
  transform: scale(1.06);
}

.history-arrow:disabled {
  opacity: 0.3;
  cursor: default;
}

.history-arrow svg {
  display: block;
  width: 1rem;
  height: 1rem;
  margin: 0;
}

/* ========================================   MOBILE======================================== */

@media (max-width: 767.98px) {
  .history-controls {
    margin-top: 0.75rem;
  }
}

@media (max-width: 767.98px) {
  .history-arrow {
    width: 2.6rem;
    height: 2.6rem;
  }
}

