/*
 * Image archive viewer — archive.v1.0.css
 * Loaded after style.v3.0.css and uses its colour tokens, buttons and
 * header/footer. Two columns on desktop, one column (viewer first) on phones.
 */

.archive-page { max-width: 1440px; }
#header h1 a { color: inherit; text-decoration: none; }
#header h1 a:hover, #header h1 a:focus-visible { text-decoration: underline; }

.arch {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 300px;
	grid-template-areas: "viewer side";
	gap: 20px;
	align-items: start;
	padding-top: 16px;
}
.arch-viewer { grid-area: viewer; min-width: 0; }
.arch-side   { grid-area: side; display: grid; gap: 14px; }
.arch-viewer:focus { outline: none; }

/* ---------- Icons inside buttons ---------- */
.btn svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.icon-btn { padding: 6px 8px; justify-content: center; min-width: 40px; }
.btn[disabled] { opacity: 0.45; cursor: default; pointer-events: none; }

/* ---------- Toolbar: camera + day ---------- */
.arch-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 10px;
}
.cam-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.cam-picker .btn { min-width: 64px; justify-content: center; }
.cam-picker .btn[aria-pressed="true"] { color: #ffffff; }
.date-nav { display: flex; align-items: center; gap: 6px; }
.date-btn { min-width: 210px; justify-content: center; }

/* ---------- Stage ---------- */
.stage {
	position: relative;
	aspect-ratio: 3 / 2;
	background: #0e1a26;
	border-radius: 8px;
	overflow: hidden;
	box-shadow: var(--shadow);
	touch-action: pan-y pinch-zoom;   /* horizontal swipes are ours, vertical scroll stays the page's */
	user-select: none;
	-webkit-user-select: none;
}
.stage-link, .stage-link img { display: block; width: 100%; height: 100%; }
.stage-link img { object-fit: contain; -webkit-user-drag: none; }
.stage-link:focus-visible { outline-offset: -4px; }
.stage-video { display: block; width: 100%; height: 100%; object-fit: contain; background: #0e1a26; }
.stage.is-video .stage-arrow { top: 42%; }   /* clear of the video's own control bar */

/* Camera picker groups (stills / clips) */
.cam-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cam-group-label { font-size: 0.8rem; font-weight: bold; color: var(--muted); margin-right: 2px; }
.cam-picker.grouped { flex-direction: column; align-items: flex-start; gap: 6px; }

/* Filmstrip entry for a clip with no poster image */
.strip .no-poster {
	display: flex; align-items: center; justify-content: center;
	width: 100%; aspect-ratio: 3 / 2; border-radius: 3px;
	background: var(--sky-100); color: var(--navy-800);
}
.strip .no-poster svg { width: 28px; height: 28px; fill: currentColor; }

.stage-arrow {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 52px;
	height: 72px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 0;
	background: rgba(7, 29, 51, 0.55);
	color: #ffffff;
	cursor: pointer;
	opacity: 0;
	transition: opacity 0.15s;
}
.stage-arrow svg { width: 36px; height: 36px; fill: currentColor; }
.stage-arrow.prev { left: 0;  border-radius: 0 8px 8px 0; }
.stage-arrow.next { right: 0; border-radius: 8px 0 0 8px; }
.stage:hover .stage-arrow, .stage-arrow:focus-visible { opacity: 1; }
.stage-arrow:hover { background: rgba(7, 29, 51, 0.8); }
.stage-arrow:focus-visible { outline: 3px solid var(--focus-dark); outline-offset: -3px; }
.stage-arrow[disabled] { display: none; }
@media (hover: none) { .stage-arrow { opacity: 0.7; width: 40px; height: 56px; } }

.stage-busy {
	position: absolute;
	top: 10px; right: 10px;
	width: 34px; height: 34px;
	padding: 5px;
	border-radius: 50%;
	background: rgba(7, 29, 51, 0.6);
}
.spinner {
	display: block;
	width: 24px; height: 24px;
	border: 3px solid rgba(255, 255, 255, 0.35);
	border-top-color: #ffffff;
	border-radius: 50%;
	animation: arch-spin 0.8s linear infinite;
}
@keyframes arch-spin { to { transform: rotate(360deg); } }

.stage-empty {
	position: absolute;
	inset: 0;
	margin: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	color: #ffffff;
	font-weight: bold;
	text-align: center;
}

/* ---------- Caption + player ---------- */
.caption {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: baseline;
	gap: 4px 16px;
	margin: 10px 2px 6px;
}
.caption p { margin: 0; }
.caption-time { font-size: 1.2rem; font-weight: bold; color: var(--navy-800); }
.caption-pos  { color: var(--muted); font-size: 0.95rem; }

.player { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.play-btn { min-width: 110px; justify-content: center; }
.play-btn .i-pause, .play-btn[aria-pressed="true"] .i-play { display: none; }
.play-btn[aria-pressed="true"] .i-pause { display: block; }

.scrubber { margin: 10px 2px 4px; }
.scrubber input[type="range"] { width: 100%; accent-color: var(--blue-700); height: 28px; }
.scrubber input[type="range"]:focus-visible { outline: 3px solid var(--focus-light); outline-offset: 2px; }

/* ---------- Filmstrip ---------- */
.strip-wrap { margin-top: 6px; }
.strip {
	position: relative;   /* offsetLeft of items is measured from the strip */
	list-style: none;
	display: flex;
	gap: 6px;
	margin: 0;
	padding: 4px 2px 10px;
	overflow-x: auto;
	scroll-snap-type: x proximity;
	scrollbar-width: thin;
}
.strip li { flex: none; scroll-snap-align: center; }
.strip button {
	display: block;
	width: 120px;
	padding: 3px;
	border: 2px solid var(--border);
	border-radius: 6px;
	background: #ffffff;
	font: inherit;
	font-size: 0.75rem;
	color: var(--text);
	cursor: pointer;
}
.strip img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; background: var(--sky-100); border-radius: 3px; }
.strip span { display: block; margin-top: 2px; text-align: center; white-space: nowrap; }
.strip button:hover { border-color: var(--blue-600); }
.strip button[aria-current="true"] { border-color: var(--navy-800); background: var(--sky-100); font-weight: bold; box-shadow: 0 0 0 2px var(--navy-800); }

/* ---------- Side panels ---------- */
.panel {
	padding: 12px 14px 14px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--sky-50);
}
.panel h2 { margin: 0 0 8px; font-size: 1.1rem; color: var(--navy-800); }
.hint { margin: 10px 0 0; font-size: 0.85rem; color: var(--muted); }
kbd {
	display: inline-block;
	padding: 0 5px;
	border: 1px solid var(--border);
	border-bottom-width: 2px;
	border-radius: 4px;
	background: #ffffff;
	font-family: inherit;
	font-size: 0.8rem;
	color: var(--text);
}

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.cal-head h2 { margin: 0; text-align: center; flex: 1; }
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal th { padding: 2px 0 4px; font-size: 0.8rem; color: var(--muted); }
.cal th abbr { text-decoration: none; }
.cal td { padding: 2px; text-align: center; }
.cal td span, .cal td button {
	display: block;
	width: 100%;
	min-height: 34px;
	line-height: 30px;
	border-radius: 6px;
	font: inherit;
	font-size: 0.9rem;
}
.cal td span { color: var(--muted); font-weight: normal; }   /* no images: 7.3:1 on --sky-50 */
.cal td button {
	border: 2px solid var(--border);
	background: #ffffff;
	color: var(--link);
	font-weight: bold;
	cursor: pointer;
	padding: 0;
}
.cal td button:hover { border-color: var(--blue-600); background: var(--sky-100); }
.cal td button[aria-current="date"] { background: var(--navy-800); border-color: var(--navy-800); color: #ffffff; }
.cal td.today button, .cal td.today span { text-decoration: underline; text-underline-offset: 3px; }

/* Playback settings */
.mode { margin: 0 0 10px; padding: 0; border: 0; }
.mode legend { padding: 0; margin-bottom: 4px; font-weight: bold; }
.mode label, .check { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; }
.mode input, .check input { width: 18px; height: 18px; accent-color: var(--blue-700); margin: 0; }
.field { display: grid; gap: 3px; margin-bottom: 10px; }
.field label { font-weight: bold; }
.field select, .field input {
	min-height: 36px;
	padding: 4px 8px;
	border: 2px solid var(--border);
	border-radius: 6px;
	background: #ffffff;
	font: inherit;
	color: var(--text);
}
.field select:focus-visible, .field input:focus-visible, .mode input:focus-visible, .check input:focus-visible {
	outline: 3px solid var(--focus-light);
	outline-offset: 2px;
}
[hidden] { display: none !important; }

/* Tools */
.tools { display: flex; flex-wrap: wrap; gap: 8px; }
.tools .btn { flex: 1 1 auto; justify-content: center; }

/* Wide screens: keep the player and filmstrip on screen with the image. */
@media (min-width: 1000px) {
	.stage { max-height: calc(100vh - 290px); min-height: 360px; }
}

/* ---------- Narrow screens: viewer first, panels below ---------- */
@media (max-width: 999px) {
	.arch { grid-template-columns: minmax(0, 1fr); grid-template-areas: "viewer" "side"; }
	.arch-side { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
}
@media (max-width: 640px) {
	.arch { gap: 14px; padding-top: 8px; }
	.arch-toolbar { flex-direction: column; align-items: stretch; }
	.cam-picker .btn { flex: 1; }
	/* Stills + clips: label on its own line, buttons in compact rows of four. */
	.cam-picker.grouped { align-items: stretch; }
	.cam-picker.grouped .cam-group { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
	.cam-picker.grouped .cam-group-label { grid-column: 1 / -1; margin: 0; }
	.cam-picker.grouped .btn { min-width: 0; min-height: 44px; padding: 4px 6px; font-size: 0.85rem; line-height: 1.2; }
	.date-nav .date-btn { flex: 1; min-width: 0; }
	.stage { border-radius: 6px; }
	.caption-time { font-size: 1.05rem; }
	.player .btn { min-height: 44px; }        /* bigger touch targets */
	.icon-btn { min-width: 48px; }
	.strip button { width: 96px; }
}
@media (prefers-reduced-motion: reduce) {
	.spinner { animation-duration: 2.4s; }
}
