/*
Theme Name: SCAN Merrimack Valley
Theme URI: https://scanmerrimackvalley.com
Author: MD w/ Claude
Description: A mobile-first block theme for SCAN Merrimack Valley, with light and dark modes. Based on the K1MDF Repeater Directory theme 3.1.
Version: 1.14
Requires at least: 6.4
Requires PHP: 7.4
License: GPL-2.0-or-later
Text Domain: scanmv
*/

:root { color-scheme: dark; }

/* Dark is the default. Light applies only when the visitor turns dark mode off. */
:root:not([data-theme="light"]) {
	color-scheme: dark;
	--wp--preset--color--base: #060709;
	--wp--preset--color--surface: #0f1114;
	--wp--preset--color--contrast: #eceef0;
	--wp--preset--color--muted: #a3a8ae;
	--wp--preset--color--accent: #ea6c2c;
	--wp--preset--color--line: #25292e;
	--wp--preset--color--danger: #ff6b6b;
}
:root[data-theme="light"] { color-scheme: light; }

body { -webkit-text-size-adjust: 100%; overflow-wrap: break-word; }
img, svg, video, iframe { max-width: 100%; height: auto; }

:where(a, button, input, select):focus-visible {
	outline: 3px solid var(--wp--preset--color--accent);
	outline-offset: 2px;
}

/* Header */
.smv-header {
	border-bottom: 1px solid var(--wp--preset--color--line);
	background: var(--wp--preset--color--surface);
}
.smv-header .wp-block-site-title a { text-decoration: none; color: inherit; }
.smv-theme-toggle {
	display: inline-flex; align-items: center; gap: 0.6rem;
	font: inherit; font-size: 0.9rem;
	min-height: 44px; padding: 0 0.25rem;
	border: 0; background: transparent; cursor: pointer;
	color: var(--wp--preset--color--contrast);
}
.smv-theme-toggle__track {
	position: relative; flex: none; box-sizing: border-box;
	width: 2.75rem; height: 1.5rem; border-radius: 999px;
	background: var(--wp--preset--color--line);
	border: 1px solid var(--wp--preset--color--muted);
	transition: background-color 0.15s, border-color 0.15s;
}
.smv-theme-toggle__knob {
	position: absolute; top: 50%; left: 0.2rem; width: 1.1rem; height: 1.1rem; margin-top: -0.55rem;
	border-radius: 50%; background: #fff; transition: transform 0.15s;
}
.smv-theme-toggle[aria-checked="true"] .smv-theme-toggle__track { background: var(--wp--preset--color--accent); border-color: var(--wp--preset--color--accent); }
.smv-theme-toggle[aria-checked="true"] .smv-theme-toggle__knob { transform: translateX(1.25rem); }
.smv-header .wp-block-navigation__responsive-container-open,
.smv-header .wp-block-navigation__responsive-container-close { min-width: 44px; min-height: 44px; }

/* Frequency numerals are the signature of the theme */
.smv-freq, .smv-tile__range {
	font-family: var(--wp--preset--font-family--mono);
	font-variant-numeric: tabular-nums;
}

/* Band and mode tiles */
.smv-tiles {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 0.75rem;
	grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}
.smv-tiles li { margin: 0; }
.smv-tiles a {
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
	min-height: 84px;
	padding: 0.9rem 1rem;
	text-decoration: none;
	color: var(--wp--preset--color--contrast);
	background: var(--wp--preset--color--surface);
	border: 1px solid var(--wp--preset--color--line);
	border-left: 4px solid var(--wp--preset--color--accent);
	border-radius: 4px;
}
.smv-tiles a:hover { border-color: var(--wp--preset--color--accent); }
.smv-tile__name { font-size: 1.25rem; font-weight: 700; }
.smv-tile__range { font-size: 0.875rem; color: var(--wp--preset--color--muted); }
.smv-tiles--modes { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.smv-tiles--modes a { min-height: 64px; justify-content: center; }

.smv-hero { border-bottom: 1px solid var(--wp--preset--color--line); }
.smv-footer { border-top: 1px solid var(--wp--preset--color--line); color: var(--wp--preset--color--muted); }
.smv-footer a { color: inherit; }

@media (prefers-reduced-motion: reduce) {
	* { transition: none !important; animation: none !important; }
}

@media (max-width: 600px) {
	.smv-header { gap: 0.5rem; }
	.smv-tiles a { min-height: 72px; padding: 0.75rem; }
	.smv-tile__name { font-size: 1.1rem; }
}

/* Top menu: body font, dropdown below the item in the header color */
.smv-header .wp-block-navigation {
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 500;
}
.smv-header .wp-block-navigation .wp-block-navigation-item__content {
	color: var(--wp--preset--color--contrast); text-decoration: none; padding: 0.6rem 1rem;
}
.smv-header .wp-block-navigation .wp-block-navigation-item__content:hover,
.smv-header .wp-block-navigation .wp-block-navigation-item__content:focus-visible { color: var(--wp--preset--color--accent); }
.smv-header .wp-block-navigation:not(.has-background) .wp-block-navigation__submenu-container {
	top: 100%; left: 0; right: auto; margin-top: 0; min-width: 12rem; padding: 0.25rem 0;
	background-color: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--contrast);
	border: 1px solid var(--wp--preset--color--line);
	border-radius: 0 0 4px 4px; box-shadow: none;
}
.smv-header .wp-block-navigation__submenu-container .wp-block-navigation-item__content { padding: 0.65rem 1rem; }
.smv-header .wp-block-navigation__responsive-container.is-menu-open {
	background-color: var(--wp--preset--color--surface); color: var(--wp--preset--color--contrast);
}

/* Room between the menu and the dark mode switch */
.smv-header .smv-header-actions { gap: 1.25rem; }
@media (max-width: 600px) { .smv-header .smv-header-actions { gap: 0.5rem; } }

/* The header stays in the dark theme in both modes */
.smv-header {
	color-scheme: dark;
	--wp--preset--color--base: #060709;
	--wp--preset--color--surface: #0f1114;
	--wp--preset--color--contrast: #eceef0;
	--wp--preset--color--muted: #a3a8ae;
	--wp--preset--color--accent: #ea6c2c;
	--wp--preset--color--line: #25292e;
	--wp--preset--color--danger: #ff6b6b;
	color: var(--wp--preset--color--contrast);
}

/* Dropdowns open to the right of the selected item, below it */
.smv-header .wp-block-navigation .wp-block-navigation__submenu-container {
	left: 0 !important;
	right: auto !important;
}

/* Divider between the menu items and the dark mode switch */
.smv-header .smv-theme-toggle {
	padding: 0 0.9rem 0 1rem;
	border: 0;
	border-radius: 999px;
	background: var(--wp--preset--color--base);
}
@media (max-width: 600px) { .smv-header .smv-theme-toggle { padding: 0 0.7rem 0 0.8rem; } }

/* Header logo */
.smv-logo { display: flex; align-items: center; align-self: center; margin: 0; padding: 0.4rem 0.25rem; line-height: 0; }
.smv-logo img { display: block; height: 40px; width: auto; margin: 0; }
@media (max-width: 600px) { .smv-logo img { height: 28px; } }

/* Footer: flag beside the text, lines tight together */
.smv-footer-row { gap: 0.75rem; }
.smv-flag { display: block; flex: none; width: 56px; height: auto; }
.smv-footer-text { flex: 1 1 auto; min-width: 0; }
.smv-footer-text p { margin: 0; line-height: 1.5; }

/* Home page section headings and tile groups */
.smv-section-title { padding-bottom: 0.6rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--wp--preset--color--line); }
.smv-tiles--ruled { padding-bottom: 2.25rem; margin-bottom: 0.5rem; border-bottom: 1px solid var(--wp--preset--color--line); }

/* The footer matches the header: always dark */
.smv-footer {
	color-scheme: dark;
	--wp--preset--color--base: #060709;
	--wp--preset--color--surface: #0f1114;
	--wp--preset--color--contrast: #eceef0;
	--wp--preset--color--muted: #a3a8ae;
	--wp--preset--color--accent: #ea6c2c;
	--wp--preset--color--line: #25292e;
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--muted);
}

/* Rounded header and footer */
.smv-header, .smv-footer { border: 1px solid var(--wp--preset--color--line); border-radius: 12px; }
.smv-header { margin-top: 0.5rem; }
.smv-footer { margin-bottom: 0.5rem; }

/* Keep everything in the header row centered on the same line */
.smv-header { align-items: center; }
.smv-header > p:empty, .smv-header > .wp-block-shortcode:empty { display: none; }

/* Light vertical line between the top-level menu items */
.smv-header .wp-block-navigation .wp-block-navigation__container { gap: 0; }
.smv-header .wp-block-navigation__responsive-container:not(.is-menu-open) .wp-block-navigation__container > .wp-block-navigation-item { position: relative; }
.smv-header .wp-block-navigation__responsive-container:not(.is-menu-open) .wp-block-navigation__container > .wp-block-navigation-item + .wp-block-navigation-item::before {
	content: ""; position: absolute; left: 0; top: 25%; bottom: 25%; width: 1px;
	background: rgba(236, 238, 240, 0.25);
}

/* Home page intro: the data credit sits close to the line above it */
.smv-hero > p + p { margin-block-start: 0.2rem; }

/* Dropdown arrows sit close to the menu text; the spacing to the next item moves to the arrow's right side */
.smv-header .wp-block-navigation .has-child > .wp-block-navigation-item__content { padding-right: 0.2rem; }
.smv-header .wp-block-navigation .has-child > .wp-block-navigation__submenu-icon,
.smv-header .wp-block-navigation .has-child > .wp-block-navigation-submenu__toggle { margin-left: 0; margin-right: 1rem; }

/* Header menu (Appearance > Menus) */
.smv-header { position: relative; z-index: 20; }
.smv-menu, .smv-menu ul { list-style: none; margin: 0; padding: 0; }
.smv-menu {
	display: flex; align-items: center;
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--medium); font-weight: 500;
}
.smv-menu li { position: relative; margin: 0; }
.smv-menu a { display: block; padding: 0.6rem 1rem; color: var(--wp--preset--color--contrast); text-decoration: none; }
.smv-menu a:hover, .smv-menu a:focus-visible,
.smv-menu .current-menu-item > a, .smv-menu .current-menu-ancestor > a { color: var(--wp--preset--color--accent); }

/* light separator between top-level items */
.smv-menu > li + li::before {
	content: ""; position: absolute; left: 0; top: 25%; bottom: 25%; width: 1px;
	background: rgba(236, 238, 240, 0.25);
}

/* dropdown arrow, close to the text */
.smv-menu .menu-item-has-children > a::after {
	content: ""; display: inline-block; width: 0.38em; height: 0.38em; margin-left: 0.45rem;
	border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
	transform: translateY(-0.15em) rotate(45deg);
}

/* dropdown opens below the item, extending to the right */
.smv-menu .sub-menu {
	display: none; position: absolute; top: 100%; left: 0; z-index: 30; min-width: 12rem; padding: 0.25rem 0;
	background: var(--wp--preset--color--surface); color: var(--wp--preset--color--contrast);
	border: 1px solid var(--wp--preset--color--line); border-radius: 0 0 6px 6px;
}
.smv-menu li:hover > .sub-menu, .smv-menu li:focus-within > .sub-menu, .smv-menu li.is-open > .sub-menu { display: block; }
.smv-menu .sub-menu a { padding: 0.65rem 1rem; white-space: nowrap; }

/* phone button: hidden on wide screens */
.smv-nav__toggle {
	display: none; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0;
	border: 0; border-radius: 8px; background: transparent; color: var(--wp--preset--color--contrast); cursor: pointer;
}

@media (max-width: 1100px) {
	.smv-nav__toggle { display: inline-flex; }
	.smv-menu {
		display: none; position: absolute; left: 0; right: 0; top: 100%; z-index: 40; margin-top: 4px; padding: 0.5rem;
		flex-direction: column; align-items: stretch;
		background: var(--wp--preset--color--surface); border: 1px solid var(--wp--preset--color--line); border-radius: 0 0 12px 12px;
	}
	.smv-nav.is-open .smv-menu { display: flex; }
	.smv-menu > li + li::before { display: none; }
	.smv-menu .menu-item-has-children > a::after { display: none; }
	.smv-menu .sub-menu {
		display: block; position: static; min-width: 0; margin-left: 1rem; padding: 0;
		border: 0; border-left: 2px solid var(--wp--preset--color--line); border-radius: 0;
	}
}

/* Header menu: force a single centered line, whatever spacing the page adds around it */
.smv-header .smv-header-actions { align-items: center; align-self: center; }
.smv-header .smv-header-actions > *, .smv-header > * { margin-top: 0; margin-bottom: 0; }
.smv-header .smv-nav { display: flex; align-items: center; align-self: center; margin: 0; padding: 0; }
.smv-header .smv-menu { margin: 0; padding: 0; align-items: center; }
.smv-header .smv-menu > li { display: flex; align-items: center; margin: 0; padding: 0; }
.smv-header .smv-menu > li > a { line-height: 1.4; }
.smv-header .smv-nav__toggle { display: none; }
.smv-header br, .smv-header p:empty { display: none; }
@media (max-width: 1100px) { .smv-header .smv-nav__toggle { display: inline-flex; } }

/* Above the menu-button breakpoint the header never wraps to a second line */
@media (min-width: 1101px) { .wp-block-group.smv-header { flex-wrap: nowrap; } }

/* Very small phones: the switch shows without its text label so the header stays on one line */
@media (max-width: 420px) {
	.smv-header .smv-theme-toggle { padding: 0 0.6rem; }
	.smv-theme-toggle__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* Menu button: icon plus the word "Menu" */
.smv-nav__toggle { width: auto; gap: 0.45rem; padding: 0 0.75rem; font: inherit; font-size: 0.95rem; }
.smv-nav__toggle-label { line-height: 1; }

/* Phones: logo left, dark mode switch top right, Menu button on its own row below */
@media (max-width: 600px) {
	.wp-block-group.smv-header { flex-wrap: wrap; row-gap: 0.25rem; }
	.smv-header .smv-header-actions { display: contents; }
	.smv-header .smv-logo { order: 1; }
	.smv-header .smv-theme-toggle { order: 2; margin-left: auto; }
	.smv-header .smv-nav { order: 3; flex: 0 0 100%; justify-content: flex-start; }
	.smv-header .smv-nav__toggle { padding-left: 0; }
}

/* Opened menu: items left-justified */
@media (max-width: 1100px) {
	.smv-header .smv-menu { align-items: stretch; text-align: left; }
	.smv-header .smv-menu > li { display: block; text-align: left; }
	.smv-header .smv-menu a { display: block; text-align: left; }
}

/* Footer padding on phones */
@media (max-width:600px){
.wp-block-group.smv-footer{padding:1.5rem 1.25rem!important}
.smv-footer-row{gap:1rem}
}

/* Text logo, used until a logo image is set in Site Identity */
.smv-logo--text { line-height: 1.2; font-size: 1.25rem; font-weight: 700; color: var(--wp--preset--color--contrast); text-decoration: none; white-space: nowrap; }
.smv-logo--text:hover { color: var(--wp--preset--color--accent); }
@media (max-width: 600px) { .smv-logo--text { font-size: 1.05rem; } }

/* Footer social icons, on the right */
.smv-footer .smv-social { margin: 0 0 0 auto !important; padding: 0; gap: 0.5rem; flex: none; }
.smv-footer .smv-social .wp-social-link { font-size: 22px; }
.smv-footer .smv-social.is-style-logos-only .wp-social-link,
.smv-footer .smv-social.is-style-logos-only .wp-social-link a { color: var(--wp--preset--color--contrast); background: none; }
.smv-footer .smv-social .wp-social-link a { padding: 0.5rem; display: flex; }
.smv-footer .smv-social .wp-social-link a:hover,
.smv-footer .smv-social .wp-social-link a:focus-visible { color: var(--wp--preset--color--accent); }

/* Menu text a little smaller */
.smv-header .smv-menu, .smv-header .wp-block-navigation { font-size: 0.95rem; }

/* Tables: a panel a step lighter than the page, orange rule under the heading row */
:root { --smv-table-bg: #ffffff; --smv-table-head: #eef0f2; --smv-table-stripe: #f8f9fa; --smv-table-hover: #f1f3f5; --smv-table-border: #d6d9dd; }
:root:not([data-theme="light"]) { --smv-table-bg: #171a1f; --smv-table-head: #23272e; --smv-table-stripe: #1c2025; --smv-table-hover: #272c33; --smv-table-border: #30363d; }
.wp-site-blocks main figure.wp-block-table { margin: 1.5rem 0; overflow-x: auto; }
.wp-site-blocks main table {
	width: 100%; margin: 1.5rem 0; border-collapse: separate; border-spacing: 0;
	background: var(--smv-table-bg); color: var(--wp--preset--color--contrast);
	border: 1px solid var(--smv-table-border); border-radius: 10px; overflow: hidden;
	font-size: 0.95rem; line-height: 1.45;
}
.wp-site-blocks main figure.wp-block-table table { margin: 0; }
.wp-site-blocks main table :is(th, td) {
	padding: 0.7rem 1rem; text-align: left; vertical-align: top;
	border: 0; border-bottom: 1px solid var(--smv-table-border);
}
.wp-site-blocks main table thead :is(th, td),
.wp-site-blocks main table tbody th {
	background: var(--smv-table-head); font-weight: 700;
}
.wp-site-blocks main table:not(:has(thead)) > tbody > tr:first-child > td {
	background: var(--smv-table-head); font-weight: 700;
}
.wp-site-blocks main table thead :is(th, td),
.wp-site-blocks main table:not(:has(thead)) > tbody > tr:first-child > td {
	font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em;
	border-bottom: 2px solid #e16020;
}
.wp-site-blocks main table:not(:has(thead)) > tbody > tr:first-child u { text-decoration: none; }
.wp-site-blocks main table tbody tr:nth-child(even) { background: var(--smv-table-stripe); }
.wp-site-blocks main table:not(:has(thead)) > tbody > tr:nth-child(even) { background: transparent; }
.wp-site-blocks main table:not(:has(thead)) > tbody > tr:nth-child(odd):not(:first-child) { background: var(--smv-table-stripe); }
.wp-site-blocks main .wp-block-table.is-style-stripes tbody tr:nth-child(odd) { background: transparent; }
.wp-site-blocks main .wp-block-table.is-style-stripes { border-bottom: 0; }
.wp-site-blocks main table tbody tr:hover,
.wp-site-blocks main table:not(:has(thead)) > tbody > tr:not(:first-child):hover { background: var(--smv-table-hover); }
.wp-site-blocks main table tbody tr:last-child :is(th, td),
.wp-site-blocks main table tfoot tr:last-child :is(th, td) { border-bottom: 0; }
.wp-site-blocks main table tfoot :is(th, td) {
	background: var(--smv-table-head); font-weight: 700;
	border-top: 1px solid var(--smv-table-border);
}
.wp-site-blocks main table a { color: var(--wp--preset--color--accent); }
.wp-site-blocks main figure.wp-block-table figcaption {
	margin-top: 0.5rem; font-size: 0.85rem; color: var(--wp--preset--color--muted); text-align: left;
}
@media (max-width: 600px) {
	.wp-site-blocks main table :is(th, td) { padding: 0.55rem 0.7rem; }
}

/* Home page feed cards: printed inline from functions.php (smv-feeds-css) so a cache or optimizer cannot serve them stale. */
