/* The example spreadsheet pages: project-map.html, feature-map.html and
   content-map.html. The page itself (background, header, hero, panels,
   buttons and type sizes) comes from styles.css, exactly as on the About
   page; this file styles the map switcher and the spreadsheet with its
   controls. The grid keeps the compact type of the app's own viewer. */

/* The current map in the switcher wears the button gradient. */
.map-switcher a[aria-current="page"] {
  color: var(--button-ink);
  background: linear-gradient(135deg, var(--button-start), var(--button-end));
  box-shadow: inset 0 0 0 1px var(--button-border);
}

.spreadsheet-panel-heading {
  display: grid;
  grid-template-columns: minmax(min-content, 1fr) minmax(0, auto);
  align-items: center;
  gap: 4px 12px;
}

.spreadsheet-panel-heading h2 { grid-column: 1 / -1; margin: 0; }
.spreadsheet-panel-actions { grid-column: 2; justify-self: end; display: flex; gap: 8px; }
.spreadsheet-panel-actions .button-link { min-height: 44px; }

.spreadsheet-toolbar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgb(72 102 85 / 16%);
  border-radius: 14px 14px 0 0;
  background: rgb(255 255 250 / 75%);
}

.spreadsheet-toolbar label { display: grid; gap: 4px; }
.spreadsheet-toolbar label > span {
  color: #617067;
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.spreadsheet-toolbar input,
.spreadsheet-toolbar select {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid rgb(60 91 74 / 26%);
  border-radius: 100px;
  color: #263d31;
  background: rgb(255 254 247 / 90%);
  font-size: var(--text-sm);
}
.search-control { flex: 1 1 280px; }
.search-control input { width: 100%; }
/* iOS zooms into a focused form field whose text is smaller than 16px. */
@supports (-webkit-touch-callout: none) {
  .spreadsheet-toolbar input,
  .spreadsheet-toolbar select { font-size: var(--text-md); }
}

.spreadsheet-readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 12px;
  border-inline: 1px solid rgb(72 102 85 / 16%);
  color: #5a6a61;
  background: rgb(250 251 244 / 85%);
  font-size: var(--text-sm);
}
.spreadsheet-readout output { flex: 0 0 auto; color: #315c48; font-weight: 700; }
.spreadsheet-readout p { margin: 0; line-height: 1.45; text-align: right; }
.spreadsheet-toolbar[hidden] + .spreadsheet-readout {
  border-top: 1px solid rgb(72 102 85 / 16%);
  border-radius: 14px 14px 0 0;
}
/* Touch screens get tap instructions instead of mouse and keyboard ones. */
.readout-touch { display: none; }

.spreadsheet-top-scroll {
  height: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-behavior: auto;
  border-inline: 1px solid rgb(72 102 85 / 16%);
  border-top: 1px solid rgb(72 102 85 / 16%);
  background: rgb(247 249 244 / 90%);
}
.spreadsheet-top-scroll-spacer { height: 1px; }

.spreadsheet-frame {
  position: relative;
  height: min(68vh, 780px);
  /* Stays shorter than a landscape phone screen so the page can still scroll. */
  min-height: min(430px, 70vh);
  min-height: min(430px, 70svh);
  border: 1px solid rgb(72 102 85 / 22%);
  border-radius: 0 0 14px 14px;
  overflow: hidden;
  background: #fff;
}

.spreadsheet-scroll {
  width: 100%;
  height: 100%;
  overflow: auto;
  contain: paint;
  overscroll-behavior: contain;
  scroll-behavior: auto;
}
.spreadsheet-scroll:focus-visible { outline: 2px solid #3b6552; outline-offset: -2px; }

.published-spreadsheet {
  --coordinate-height: 28px;
  width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  color: #37463e;
  background: #fff;
}

.published-spreadsheet th,
.published-spreadsheet td {
  border-right: 1px solid #d7ddd8;
  border-bottom: 1px solid #d7ddd8;
}

.sheet-coordinate-row { height: var(--coordinate-height); }
.sheet-corner,
.sheet-column-designator,
.sheet-row-designator {
  color: #59685f;
  background: #f0f3ed;
  font-size: 11px;
  font-weight: 650;
  text-align: center;
  user-select: none;
}

.sheet-corner,
.sheet-column-designator {
  position: sticky;
  z-index: 31;
  top: 0;
  height: var(--coordinate-height);
  padding: 0 8px;
  line-height: var(--coordinate-height);
}

.sheet-corner { z-index: 44; left: 0; padding: 0; }
.sheet-column-designator { cursor: pointer; }
.sheet-column-designator:hover { background: #e5ece3; }
.sheet-column-designator.is-selected,
.sheet-corner.is-selected { color: #1d5d98; background: #dcecff; }

.sheet-corner-button,
.sheet-row-button {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
}

.sheet-corner-button::after {
  content: "";
  position: absolute;
  right: 4px;
  bottom: 4px;
  border-bottom: 7px solid #758078;
  border-left: 7px solid transparent;
}

.sheet-header-cell {
  position: sticky;
  z-index: 22;
  top: var(--coordinate-height);
  padding: 8px 12px;
  color: #546259;
  background: #f7f9f4;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .025em;
  text-align: left;
  text-transform: uppercase;
}

.sheet-row-designator {
  position: sticky;
  z-index: 14;
  left: 0;
  width: 48px;
  min-width: 48px;
  padding: 0;
  vertical-align: middle;
}
.sheet-row-designator-header { z-index: 35; top: var(--coordinate-height); }
.sheet-row-designator.is-selected { color: #8b570d; background: #fff0c7; }

.sheet-data-cell {
  height: auto;
  padding: 7px 12px;
  color: #37463e;
  background: #fff;
  font-size: 13px;
  line-height: 1.35;
  vertical-align: top;
}

tbody tr:hover .sheet-data-cell { background: #f8faf7; }
.sheet-header-cell.is-column-selected,
.sheet-data-cell.is-column-selected { color: #174e83; background: #edf6ff; }
.sheet-header-cell.is-row-selected,
.sheet-data-cell.is-row-selected { color: #72470a; background: #fff8e6; }
.sheet-header-cell.is-row-and-column-selected,
.sheet-data-cell.is-row-and-column-selected { color: #46338b; background: #eee9ff; }

.sheet-cell-content { display: block; max-width: 100%; min-width: 0; }
.published-spreadsheet[data-horizontal-alignment="left"] :is(.sheet-header-cell, .sheet-data-cell) { text-align: left; }
.published-spreadsheet[data-horizontal-alignment="center"] :is(.sheet-header-cell, .sheet-data-cell) { text-align: center; }
.published-spreadsheet[data-horizontal-alignment="right"] :is(.sheet-header-cell, .sheet-data-cell) { text-align: right; }
.published-spreadsheet[data-vertical-alignment="top"] :is(.sheet-header-cell, .sheet-data-cell) { vertical-align: top; }
.published-spreadsheet[data-vertical-alignment="middle"] :is(.sheet-header-cell, .sheet-data-cell) { vertical-align: middle; }
.published-spreadsheet[data-vertical-alignment="bottom"] :is(.sheet-header-cell, .sheet-data-cell) { vertical-align: bottom; }
.published-spreadsheet[data-wrapping="clip"] .sheet-cell-content { overflow: hidden; text-overflow: clip; white-space: pre; }
.published-spreadsheet[data-wrapping="wrap"] .sheet-cell-content { overflow-wrap: anywhere; white-space: pre-wrap; }

.published-spreadsheet tr.is-resized > :is(.sheet-header-cell, .sheet-data-cell) { overflow: hidden; }
.published-spreadsheet tr.is-resized .sheet-cell-content { max-height: calc(var(--published-row-height) - 14px); overflow: hidden; }

.sheet-sort-button {
  position: absolute;
  top: 4px;
  right: 15px;
  min-width: 34px;
  height: 20px;
  padding: 1px 5px;
  border: 1px solid #a9c9e7;
  border-radius: 5px;
  color: #20588a;
  background: #fff;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.sheet-column-resize,
.sheet-row-resize {
  position: absolute;
  z-index: 5;
  touch-action: none;
}
.sheet-column-resize { inset: 0 -1px 0 auto; width: 12px; cursor: col-resize; }
.sheet-row-resize { inset: auto 0 -1px; height: 12px; cursor: row-resize; }
.sheet-column-resize::before,
.sheet-row-resize::before { content: ""; position: absolute; opacity: 0; background: #2563a8; }
.sheet-column-resize::after,
.sheet-row-resize::after {
  position: absolute;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border: 1px solid #2563a8;
  border-radius: 4px;
  color: #2563a8;
  background: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  opacity: 0;
}
.sheet-column-resize::before { inset: 0 0 0 auto; width: 2px; }
.sheet-column-resize::after { content: "↔"; top: 50%; right: 0; transform: translateY(-50%); }
.sheet-row-resize::before { inset: auto 0 0; height: 2px; }
.sheet-row-resize::after { content: "↕"; bottom: 0; left: 50%; transform: translateX(-50%); }
:is(.sheet-column-resize, .sheet-row-resize):is(:hover, :active, .is-resizing)::before,
:is(.sheet-column-resize, .sheet-row-resize):is(:hover, :active, .is-resizing)::after { opacity: 1; }

.sheet-empty { padding: 40px; color: #6a766f; text-align: center; }

/* Both native and in-page full screen use this class. Do not combine the
   fallback with :fullscreen in a selector list: older iOS drops that rule. */
.spreadsheet-panel.is-fullscreen {
  position: fixed;
  z-index: 500;
  inset: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 16px;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  border: 0;
  border-radius: 0;
  background: #f7f9eb;
  box-shadow: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.spreadsheet-panel.is-fullscreen > * { flex-shrink: 0; }
.spreadsheet-panel.is-fullscreen .spreadsheet-frame { flex: 1 0 120px; min-height: 120px; height: auto; }
.spreadsheet-panel.is-fullscreen .spreadsheet-panel-heading {
  position: sticky;
  z-index: 50;
  top: 0;
  background: #f7f9eb;
}
.spreadsheet-panel.is-fullscreen-fallback {
  top: var(--spreadsheet-viewport-top, 0px);
  bottom: auto;
  height: 100vh;
  height: 100dvh;
  height: var(--spreadsheet-viewport-height, 100dvh);
}
/* Fix the page in place on iOS as well, then restore its scroll on exit. */
html.spreadsheet-fullscreen-open { overflow: hidden; scroll-behavior: auto; }
.spreadsheet-fullscreen-open body {
  position: fixed;
  top: var(--spreadsheet-page-top, 0px);
  width: 100%;
  overflow: hidden;
}
.spreadsheet-fullscreen-open .about-main { z-index: 30; }

.viewer-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

@media (max-width: 900px) {
  .spreadsheet-readout { align-items: start; flex-direction: column; gap: 4px; }
  .spreadsheet-readout p { text-align: left; }
  .spreadsheet-frame { height: 65vh; }
  .spreadsheet-panel.is-fullscreen .spreadsheet-readout p { display: none; }
}

/* Three maps fit on phones when the switcher wraps instead of scrolling. */
@media (max-width: 700px) {
  .map-switcher { flex-wrap: wrap; }
}

@media (max-width: 560px) {
  .spreadsheet-panel-heading { column-gap: 8px; }
  .spreadsheet-panel-heading .section-number { font-size: 11px; letter-spacing: .04em; }
  .spreadsheet-panel-actions .button-link { padding-inline: 10px; }
  .spreadsheet-toolbar > label:not(.search-control) { flex: 1 1 30%; }
  .spreadsheet-toolbar select { width: 100%; }
  .spreadsheet-toolbar > .button-link { flex: 1 1 auto; }
}

/* Touch screens: a swipe that reaches the sheet's edge continues scrolling
   the page, and the mirrored top scrollbar is dropped because touch
   scrollbars only appear while scrolling, which leaves it an empty strip. */
@media (hover: none) and (pointer: coarse) {
  .spreadsheet-scroll { overscroll-behavior-y: auto; }
  .spreadsheet-top-scroll { display: none; }
  .readout-mouse { display: none; }
  .readout-touch { display: inline; }
}

/* Touch screens: the search box and menus are sized for a fingertip. */
@media (pointer: coarse) {
  .spreadsheet-toolbar input,
  .spreadsheet-toolbar select { min-height: 44px; }
}

@media print {
  html.content-page-root,
  body.content-page { background: #fff; }
  .content-page::before,
  .animation-scene,
  .site-header,
  .skip-link,
  .about-hero,
  .map-switcher,
  .spreadsheet-panel-heading,
  .spreadsheet-toolbar,
  .spreadsheet-readout,
  .spreadsheet-top-scroll { display: none !important; }
  .about-main { width: 100%; margin: 0; padding: 0; }
  .spreadsheet-panel { margin: 0; padding: 0; border: 0; background: none; box-shadow: none; }
  .spreadsheet-frame,
  .spreadsheet-scroll { width: auto; height: auto; min-height: 0; overflow: visible; border: 0; }
  .sheet-sort-button,
  .sheet-column-resize,
  .sheet-row-resize { display: none !important; }
}
