/* Phone and narrow-tablet layout, loaded after the desktop styles. */
:root { --dock-height: 104px; }

html, body { overflow-x: hidden; }

.timeline-page,
.timeline-dock-inner { width: calc(100% - 24px); }

.timeline-page {
  padding-top: 18px;
  padding-bottom: calc(var(--dock-height) + 24px);
}

.page-header { display: block; padding-bottom: 14px; }
.page-header h1 {
  white-space: normal;
  font-size: clamp(2.35rem, 12vw, 3.25rem);
}
.header-note {
  max-width: none;
  margin-top: 12px;
  font-size: .78rem;
  text-align: left;
}
.leader-search {
  width: 100%;
  min-width: 0;
  margin-top: 16px;
}
.leader-search > label { font-size: .59rem; }
.leader-search-controls {
  grid-template-columns: 42px minmax(0, 1fr) 42px;
}
.leader-search-controls input,
.leader-search-arrow { height: 42px; }
.leader-search-controls input {
  padding: 0 9px;
  font-size: .72rem;
}
.leader-search-status { font-size: .57rem; }

.diagram-shell {
  margin-right: 0;
  padding-top: 14px;
  overflow: visible;
}
.government-view { width: 100%; min-width: 0; zoom: 1; }

.major-event-row,
.major-event-row.is-empty { min-height: 92px; padding: 8px 0 14px; }
.major-event-card {
  width: 100%;
  min-height: 72px;
  grid-template-columns: 64px minmax(0, 1fr);
}
.event-year { font-size: 1rem; }
.major-event-copy { min-height: 70px; padding: 9px 11px 8px; }
.major-event-copy h2 { font-size: .92rem; }

.pre-federation-context {
  min-height: 0;
  display: block;
  padding: 17px 16px;
}
.pre-federation-context h2 { font-size: 1.35rem; }
.pre-federation-context p { max-width: none; font-size: .72rem; }
.pre-federation-context .pre-year {
  margin-top: 16px;
  font-size: 3.15rem;
  text-align: left;
}

.federal-system { height: auto; padding-bottom: 24px; }
.federal-system::after { height: 24px; }
.federal-jukebox {
  height: auto;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  grid-template-areas: 'previous panel next';
  gap: 0;
  overflow: visible;
}
.federal-jukebox > .federal-panel {
  grid-area: panel;
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: none;
  height: auto;
  min-height: 0;
  padding: 10px;
}
.federal-preview-stack.previous-terms { grid-area: previous; }
.federal-preview-stack.next-terms { grid-area: next; }
.federal-preview-stack {
  position: relative;
  z-index: 1;
  width: 40px;
  height: 100%;
  min-width: 0;
  display: block;
}
.federal-term-preview {
  position: absolute;
  top: 50%;
  display: block;
  padding: 0;
  border: 0;
  background: var(--party-colour);
  box-shadow: none;
  transform: translateY(-50%);
}
.federal-term-preview > * { display: none; }
.federal-term-preview.preview-near {
  z-index: 2;
  width: 30px;
  height: 74%;
  min-width: 0;
  opacity: 1;
}
.federal-term-preview.preview-far {
  z-index: 1;
  display: block;
  width: 14px;
  height: 54%;
  opacity: 1;
}
.federal-preview-stack.previous-terms .preview-near { right: -4px; }
.federal-preview-stack.previous-terms .preview-far { right: 26px; }
.federal-preview-stack.next-terms .preview-near { left: -4px; }
.federal-preview-stack.next-terms .preview-far { left: 26px; }
.federal-preview-stack.previous-terms .federal-term-preview {
  border-radius: 5px 0 0 5px;
}
.federal-preview-stack.next-terms .federal-term-preview {
  border-radius: 0 5px 5px 0;
}
.federal-term-preview:hover { transform: translateY(-50%); box-shadow: none; }

.federal-heading {
  min-height: 43px;
  gap: 10px;
  margin-bottom: 9px;
  padding-bottom: 8px;
}
.federal-heading h2 { font-size: 1.25rem; }
.federal-heading .year-badge { font-size: 1.3rem; }

.term-card,
.federal-jukebox > .federal-panel .term-card {
  height: auto;
  display: block;
  overflow: visible;
}
.term-top {
  min-height: 0;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  grid-template-areas: 'portrait summary' 'legacy legacy';
}
.pm-photo-link { grid-area: portrait; }
.pm-photo-link,
.pm-photo { width: 76px; height: 112px; min-height: 112px; }
.term-summary {
  grid-area: summary;
  min-width: 0;
  padding: 11px 10px 9px;
}
.term-summary h3 { font-size: 1.12rem; }
.term-summary .party-name { margin-bottom: 7px; font-size: .66rem; }
.term-dates { white-space: normal; }
.term-summary .term-dates { font-size: .6rem; }
.term-legacy {
  grid-area: legacy;
  padding: 10px;
  border-top: 1px solid var(--line);
}
.term-legacy p { font-size: .66rem; }
.term-content { display: block; overflow: visible; }
.term-content > div {
  min-height: 0;
  display: block;
  padding: 11px 10px 10px;
  overflow: visible;
}
.term-content > div + div { border-top: 1px solid var(--line); border-left: 0; }
.term-content .section-source { margin-top: 9px; padding-top: 0; }
.fact-list { font-size: .66rem; }

.state-carousel-section { height: auto; padding: 20px 0 22px; }
.state-jukebox {
  height: auto;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  grid-template-areas: 'previous panel next';
  gap: 0;
  overflow: visible;
}
.state-carousel-panel {
  grid-area: panel;
  position: relative;
  z-index: 3;
  max-width: none;
  height: auto;
  padding: 10px;
}
.state-preview-stack.previous-terms { grid-area: previous; }
.state-preview-stack.next-terms { grid-area: next; }
.state-preview-stack {
  position: relative;
  z-index: 1;
  width: 40px;
  height: 100%;
  min-width: 0;
  display: block;
}
.state-term-preview {
  position: absolute;
  top: 50%;
  display: block;
  padding: 0;
  border: 0;
  background: var(--party-colour);
  box-shadow: none;
  transform: translateY(-50%);
}
.state-term-preview > * { display: none; }
.state-term-preview.preview-near {
  z-index: 2;
  width: 30px;
  height: 74%;
  min-width: 0;
  opacity: 1;
}
.state-term-preview.preview-far {
  z-index: 1;
  display: block;
  width: 14px;
  height: 54%;
  opacity: 1;
}
.state-preview-stack.previous-terms .preview-near { right: -4px; }
.state-preview-stack.previous-terms .preview-far { right: 26px; }
.state-preview-stack.next-terms .preview-near { left: -4px; }
.state-preview-stack.next-terms .preview-far { left: 26px; }
.state-preview-stack.previous-terms .state-term-preview {
  border-radius: 5px 0 0 5px;
}
.state-preview-stack.next-terms .state-term-preview {
  border-radius: 0 5px 5px 0;
}
.state-term-preview:hover { transform: translateY(-50%); box-shadow: none; }
.state-carousel-heading {
  min-height: 42px;
  gap: 10px;
  margin-bottom: 8px;
}
.state-carousel-heading h2,
.state-carousel-heading .year-badge { font-size: 1.2rem; }
.state-term-card {
  height: auto;
  grid-template-columns: 76px minmax(0, 1fr);
  grid-template-areas: 'portrait summary' 'overview overview';
}
.state-carousel-photo-link {
  grid-area: portrait;
  width: 76px;
  height: 116px;
  min-height: 116px;
}
.state-carousel-photo { min-height: 116px; }
.state-carousel-summary { grid-area: summary; padding: 11px 10px 9px; }
.state-carousel-summary h3 { font-size: 1.08rem; }
.state-carousel-summary .party-name { margin-bottom: 7px; font-size: .65rem; }
.state-carousel-summary .term-dates { font-size: .59rem; }
.state-term-overview {
  grid-area: overview;
  padding: 10px;
  border-top: 1px solid var(--line);
  border-left: 0;
}
.state-empty-card {
  height: auto;
  min-height: 112px;
  padding: 18px;
  text-align: center;
}

.jurisdictions,
.pre-federation-jurisdictions { padding-top: 20px; }
.jurisdictions::before { height: 20px; }
.states-row,
.pre-federation-jurisdictions .states-row {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
  padding: 4px 0 9px;
}
.states-row::before,
.state-branch::before,
.pre-federation-jurisdictions .states-row::before,
.pre-federation-jurisdictions .state-branch::before { display: none; }
.state-branch {
  width: 100%;
  min-width: 0;
}
.jurisdiction-card.state-select-card,
.jurisdiction-card.state-select-card.has-status-transition {
  width: 100%;
  height: auto;
  min-height: 0;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  align-content: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--mobile-state-colour, #969b93);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .46);
}
.state-select-card .jurisdiction-card-heading {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto;
  place-items: center;
  align-content: center;
  justify-content: center;
  gap: 3px;
  padding: 0;
  border: 0;
}
.state-select-card .jurisdiction-code {
  display: block;
  width: 100%;
  color: inherit;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .05em;
  line-height: 1;
  text-align: center;
}
.state-select-card .jurisdiction-leader-surname {
  display: block;
  width: 100%;
  overflow: hidden;
  color: inherit;
  font-size: .44rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.state-select-card .jurisdiction-card-heading h3,
.state-select-card .state-party-banner,
.state-select-card .state-premier-summary,
.state-select-card .status-sequence,
.state-branch .local-connector,
.state-branch .local-government-card { display: none; }
.state-select-card.is-state-selected {
  outline-color: var(--ink);
  outline-offset: 2px;
}
.state-select-card:hover { transform: none; }
.jurisdiction-footnote { margin-top: 14px; font-size: .56rem; line-height: 1.35; }

.government-view,
.government-view button,
.timeline-dock,
.timeline-dock button,
.timeline-dock input { touch-action: manipulation; }

.timeline-dock,
.timeline-dock-inner { min-height: var(--dock-height); }
.timeline-dock-inner {
  grid-template-columns: 82px minmax(0, 1fr);
  grid-template-areas: 'year present' 'range range';
  gap: 4px 10px;
  padding: 6px 0 7px;
}
.year-control { grid-area: year; }
.year-control input {
  width: 82px;
  min-height: 36px;
  font-size: 1.3rem;
}
.present-button {
  grid-area: present;
  width: 100%;
  height: 36px;
  justify-content: center;
}
.timeline-stepper {
  grid-area: range;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  gap: 7px;
}
.year-step-button { width: 40px; height: 40px; }
.range-labels { font-size: .49rem; }
.range-labels small { font-size: .43rem; }

@media (max-width: 380px) {
  .timeline-page,
  .timeline-dock-inner { width: calc(100% - 16px); }
  .states-row,
  .pre-federation-jurisdictions .states-row { gap: 4px; }
  .state-select-card .jurisdiction-code { font-size: .62rem; }
  .state-select-card .jurisdiction-leader-surname { font-size: .4rem; }
  .timeline-stepper {
    grid-template-columns: 36px minmax(0, 1fr) 36px;
    gap: 5px;
  }
  .year-step-button { width: 36px; height: 36px; }
}
