.sureforecast-table-wrap {
	background: #fff;
	border: 1px solid var(--sf-border);
	border-radius: 5px;
	box-sizing: border-box;
	max-width: 100%;
	min-width: 0;
	position: relative;
	width: 100%;
}

.sureforecast-season {
	border-radius: 5px;
	overflow: visible;
}

/*
 * Tables can be wider than their block, including in a desktop two-column
 * layout. The wrapper, rather than the page or adjacent block, owns that
 * horizontal overflow at every viewport width.
 */
.sureforecast-calendar,
.sureforecast-calendar .sureforecast-panel {
	max-width: 100%;
	min-width: 0;
}

.sureforecast-calendar {
	/*
	 * A calendar can be narrow on a wide screen when it lives in a
	 * Gutenberg or Stackable column. Size the seasonal label column from
	 * this block's available width, rather than from the viewport.
	 */
	container-type: inline-size;
}

.sureforecast-calendar .sureforecast-table-wrap {
	-webkit-overflow-scrolling: touch;
	isolation: isolate;
	overflow-x: auto;
	overflow-y: hidden;
	overscroll-behavior-x: contain;
	scrollbar-gutter: stable;
}

.sureforecast-calendar .sureforecast-table thead th {
	background: #fff;
	position: static;
	z-index: 3;
}

.sureforecast-calendar .sureforecast-table thead th:first-child {
	background: #fff;
	box-shadow: 1px 0 0 var(--sf-border);
	left: 0;
	position: sticky;
	z-index: 4;
}

/* Keep the table title readable while the date columns scroll sideways. */
.sureforecast-calendar .sureforecast-table caption {
	background: #fff;
	left: 0;
	position: sticky;
	text-align: left;
	z-index: 5;
}

/*
 * The horizontal table wrapper is intentionally scrollable. A table header
 * inside that wrapper cannot also stick to the document viewport, so the
 * script mirrors it in this fixed layer while the original header scrolls
 * out of view.
 */
.sureforecast-sticky-head {
	display: none;
	overflow: hidden;
	pointer-events: none;
	position: fixed;
	z-index: 100;
}

.sureforecast-sticky-head.is-visible {
	display: block;
}

.sureforecast-sticky-head__table {
	background: #fff;
	border-collapse: collapse;
	table-layout: fixed;
}

.sureforecast-sticky-head__table thead th,
.sureforecast-sticky-head__table thead th:first-child {
	background: #fff;
	left: auto;
	position: static;
}

.sureforecast-sticky-head__first {
	align-items: center;
	background: #fff;
	box-shadow: 1px 0 0 var(--sf-border);
	box-sizing: border-box;
	display: flex;
	font: inherit;
	left: 0;
	position: absolute;
	top: 0;
	z-index: 1;
}

/* Keep the pollen name visible when a narrow desktop column is scrolled. */
.sureforecast-calendar .sureforecast-table tbody tr > :first-child {
	background: #fff;
	box-shadow: 1px 0 0 var(--sf-border);
	left: 0;
	position: sticky;
	z-index: 3;
}

.sureforecast-calendar .sureforecast-history tr > :first-child {
	min-width: 8.5rem;
}

/* The wrapper owns the single outer edge; table cells only draw internal dividers. */
.sureforecast-calendar .sureforecast-table {
	background: #fff;
	border: 0;
}

.sureforecast-calendar .sureforecast-table tbody tr:last-child > * {
	border-bottom: 0;
}

.sureforecast-calendar .sureforecast-table tr > :first-child {
	border-left: 0;
}

.sureforecast-calendar .sureforecast-table tr > :last-child {
	border-right: 0;
}

.sureforecast-calendar .sureforecast-table-wrap:focus-visible {
	outline: 2px solid var(--sf-accent);
	outline-offset: 2px;
}

.sureforecast-season__cell {
	background: #fff !important;
	height: 3.75rem;
	overflow: visible;
	position: relative;
}

.sureforecast-season__marker {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	grid-template-rows: repeat(3, minmax(0, 1fr));
	gap: 0;
	height: 50px;
	padding: 5px 0;
	/* Cover the two shared cell borders so adjacent active periods form one band. */
	width: calc(100% + 2px);
	margin: 0 -1px;
	position: relative;
	z-index: 1;
}

/* Do not paint into the pollen-name column or beyond the final month. */
.sureforecast-season tbody tr > td:first-of-type .sureforecast-season__marker {
	width: calc(100% + 1px);
	margin-left: 0;
}

.sureforecast-season tbody tr > td:last-child .sureforecast-season__marker {
	width: calc(100% + 1px);
	margin-right: 0;
}

.sureforecast-season__band {
	display: block;
	border-radius: 0;
}

.sureforecast-season__band.period-1 {
	grid-column: 1;
}

.sureforecast-season__band.period-2 {
	grid-column: 2;
}

.sureforecast-season__band.period-3 {
	grid-column: 3;
}

.sureforecast-season__band--low {
	background: var(--sf-season-low);
	grid-row: 3;
}

.sureforecast-season__band--moderate {
	background: var(--sf-season-moderate);
	grid-row: 2;
}

.sureforecast-season__band--high {
	background: var(--sf-season-high);
	grid-row: 1;
}

.sureforecast-season__band.is-start {
	border-radius: 999px 0 0 999px;
}

.sureforecast-season__band.is-end {
	border-radius: 0 999px 999px 0;
}

.sureforecast-season__band.is-start.is-end {
	border-radius: 999px;
}

.sureforecast-season__source {
	margin: .75rem 0 0;
	font-size: .86em;
}

.sureforecast-calendar .sureforecast-table th:first-child {
	padding-left: 10px;
}

.sureforecast-calendar .sureforecast-table tbody th[scope="row"] {
	font-size: 1.1rem;
}

.sureforecast-calendar .sureforecast-season th:first-child {
	min-width: 13rem;
	width: 13rem;
}

/*
 * Preserve room for the month grid inside narrow desktop columns as well as
 * on phones. Seven rem keeps the longest pollen labels readable on one line.
 */
@container (max-width: 64rem) {
	.sureforecast-calendar .sureforecast-season th:first-child {
		min-width: 7rem;
		width: 7rem;
	}
}

.sureforecast-history-wrap {
	border-radius: 5px;
	background: #fff;
}

.sureforecast-history-wrap .sureforecast-history {
	background: #fff;
	border: 0;
}

.sureforecast-history-wrap .sureforecast-history caption {
	background: #fff;
	border-radius: 4px 4px 0 0;
}

/* Retain the internal divider between the caption and sticky header. */
.sureforecast-history-wrap .sureforecast-history thead tr:first-child > * {
	border-top: 1px solid var(--sf-border);
}

/* Keep the archive disclaimer clear of the archive table and its controls. */
.sureforecast-panel[data-panel="history"]:not([hidden]) ~ .sureforecast-calendar__notice {
	margin-top: 1.25rem;
}

/* Use the active theme's standard WordPress button tokens for calendar tabs. */
.sureforecast-tabs .wp-element-button.sureforecast-tabs__button {
	background: var(--sf-tab-active-background, var(--theme-button-background-initial-color, var(--sf-accent))) !important;
	border: var(--sf-tab-active-border-width, 0) var(--sf-tab-active-border-style, solid) var(--sf-tab-active-border-color, var(--theme-button-background-initial-color, var(--sf-accent))) !important;
	border-radius: var(--sf-tab-active-border-radius, var(--theme-button-border-radius, 10px)) !important;
	box-shadow: var(--theme-button-shadow, none) !important;
	color: var(--sf-tab-active-color, var(--theme-button-text-initial-color, #fff)) !important;
	font-family: var(--theme-button-font-family, inherit) !important;
	font-size: var(--theme-button-font-size, inherit) !important;
	font-weight: var(--theme-button-font-weight, inherit) !important;
	line-height: normal;
	min-height: var(--theme-button-min-height, auto);
	padding: var(--theme-button-padding, .5rem .9rem) !important;
	text-transform: var(--theme-button-transform, none);
}

.sureforecast-tabs .wp-element-button.sureforecast-tabs__button[aria-selected="false"] {
	background: var(--sf-tab-inactive-background, transparent) !important;
	border: var(--sf-tab-inactive-border-width, 0) var(--sf-tab-inactive-border-style, solid) var(--sf-tab-inactive-border-color, var(--theme-button-background-initial-color, var(--sf-accent))) !important;
	border-radius: var(--sf-tab-inactive-border-radius, var(--theme-button-border-radius, 10px)) !important;
	box-shadow: inset 0 0 0 2px var(--sf-tab-inactive-border-color, var(--theme-button-background-initial-color, var(--sf-accent))) !important;
	color: var(--sf-tab-inactive-color, var(--theme-button-background-initial-color, var(--sf-accent))) !important;
}

.sureforecast-tabs .wp-element-button.sureforecast-tabs__button:hover,
.sureforecast-tabs .wp-element-button.sureforecast-tabs__button:focus-visible {
	background: var(--sf-tab-hover-background, var(--theme-button-background-hover-color, var(--theme-button-background-initial-color, var(--sf-accent))) !important;
	border-color: var(--sf-tab-hover-border-color, var(--theme-button-background-hover-color, var(--theme-button-background-initial-color, var(--sf-accent))) !important;
	box-shadow: none !important;
	color: var(--sf-tab-hover-color, var(--theme-button-text-hover-color, #fff)) !important;
}

.sureforecast-tabs .wp-element-button.sureforecast-tabs__button:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}
