* { box-sizing: border-box; }
html, body {
	margin: 0;
	height: 100%;
	font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
	background: #000;
	color: #fff;
	overflow: hidden;
}

#app {
	height: 100%;
	display: flex;
	flex-direction: column;
}
#app.hidden { display: none; }

.err-screen {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 2rem;
	text-align: center;
	font-size: 1.2rem;
	color: #cbd5e1;
	background: #0f172a;
}
.err-screen.hidden { display: none; }

/* Header 135px – logo midt, 25px luft over/under logo */
#hdr {
	--hdr-logo-pad-y: 25px;
	position: relative;
	flex: 0 0 135px;
	height: 135px;
	min-height: 135px;
	overflow: hidden;
}
.hdr-gradient {
	position: absolute;
	inset: 0;
	z-index: 0;
	opacity: 0.82;
	background: linear-gradient(
		125deg,
		var(--g1, #1D60FB),
		var(--g2, #2563eb),
		var(--g1, #1D60FB)
	);
	background-size: 320% 320%;
	pointer-events: none;
}
#hdr.hdr-animated .hdr-gradient {
	animation: scrinHdrGrad 14s ease-in-out infinite;
}
#hdr:not(.hdr-use-gradient) .hdr-gradient {
	display: none;
}

@keyframes scrinHdrGrad {
	0%, 100% { background-position: 0% 40%; }
	50% { background-position: 100% 60%; }
}

.hdr-inner {
	position: relative;
	z-index: 1;
	height: 100%;
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(120px, 360px) minmax(0, 1fr);
	align-items: stretch;
	gap: 0.75rem 1rem;
	padding: 0.35rem 1.25rem;
	box-sizing: border-box;
}

.hdr-left {
	min-width: 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
}
.hdr-left h1 {
	font-size: calc(clamp(1.35rem, 3.4vw, 2.35rem) + 10px);
	margin: 0;
	font-weight: 700;
	line-height: 1.12;
	letter-spacing: -0.02em;
}
.muted { opacity: 0.88; font-size: clamp(0.75rem, 1.4vw, 0.95rem); }

.hdr-center {
	display: flex;
	align-items: center;
	justify-content: center;
	justify-self: center;
	max-width: 100%;
	padding: var(--hdr-logo-pad-y) 0;
	box-sizing: border-box;
}
#logo {
	max-height: calc(135px - 2 * var(--hdr-logo-pad-y) - 0.7rem);
	max-width: min(280px, 26vw);
	width: auto;
	height: auto;
	object-fit: contain;
	object-position: center;
	display: block;
}
#logo.hidden { display: none !important; }

.hdr-right {
	justify-self: end;
	align-self: center;
	text-align: right;
	min-width: 0;
	display: flex;
	align-items: center;
	justify-content: flex-end;
}

.hdr-time-stack {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	justify-content: center;
	gap: 0.2rem;
	min-width: 0;
}

.clock {
	font-variant-numeric: tabular-nums;
	font-size: calc(clamp(1.7rem, 3.5vw, 2.75rem) + 15px);
	font-weight: 700;
	line-height: 1.05;
	letter-spacing: 0.02em;
}
.clock.hidden { display: none !important; }

#hdr-sub.hdr-date {
	margin: 0;
	font-variant-numeric: tabular-nums;
	font-size: calc(clamp(1.15rem, 2.2vw, 1.75rem) + 7px);
	font-weight: 600;
	line-height: 1.15;
	opacity: 0.94;
	white-space: nowrap;
}
#hdr-sub.hdr-date.hidden { display: none !important; }

/* Stage – hoved 16:9 ut fra høyde, 0 padding/kil; sidekolonne = rest (1fr) */
#stage {
	flex: 1;
	min-height: 0;
	min-width: 0;
	container-name: stage;
	container-type: size;
	display: grid;
	gap: 0;
	align-content: stretch;
	align-items: stretch;
}
.layout-split {
	grid-template-columns: max-content minmax(0, 1fr);
}
.layout-full {
	grid-template-columns: 1fr;
}
.layout-full #side-slot {
	display: none;
}

.main-wrap {
	display: flex;
	align-items: stretch;
	justify-content: flex-start;
	min-width: 0;
	min-height: 0;
	padding: 0;
	margin: 0;
	height: 100%;
	box-sizing: border-box;
}

#main-slot {
	position: relative;
	/* Største 16:9 som passer i stage (høyde/ bredde), siden får resten */
	width: min(calc(100cqh * 16 / 9), 100cqi);
	aspect-ratio: 16 / 9;
	height: auto;
	max-height: 100cqh;
	max-width: 100cqi;
	overflow: hidden;
	background: #000;
	box-sizing: border-box;
	flex: 0 0 auto;
}

.layout-full .main-wrap {
	grid-column: 1 / -1;
	justify-content: center;
}
.layout-full #main-slot {
	width: min(calc(100cqh * 16 / 9), 100cqi);
}

#side-slot {
	position: relative;
	min-height: 0;
	min-width: 0;
	overflow: hidden;
	background: #0a0a0a;
	align-self: stretch;
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

.slide-layer, .side-layer {
	position: absolute;
	inset: 0;
	opacity: 0;
	pointer-events: none;
	display: flex;
	align-items: center;
	justify-content: center;
}
.slide-layer.active, .side-layer.active {
	opacity: 1;
	pointer-events: auto;
	z-index: 2;
}
.slide-layer.prev, .side-layer.prev { z-index: 1; }

.slide-layer img, .slide-layer video {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
}
.slide-layer iframe, .side-layer iframe {
	width: 100%;
	height: 100%;
	border: none;
	background: #111;
}

.side-html {
	width: 100%;
	height: 100%;
	padding: 1rem 1.1rem;
	overflow: auto;
	line-height: 1.45;
	font-size: clamp(14px, 1.5vw, 20px);
}
.side-html img { max-width: 100%; height: auto; }

.tr-fade .slide-layer, .tr-fade .side-layer { transition: opacity 0.8s ease; }
.tr-cut .slide-layer, .tr-cut .side-layer { transition: none; }
.tr-slide .slide-layer, .tr-slide .side-layer {
	transition: transform 0.7s ease, opacity 0.7s ease;
	transform: translateX(8%);
}
.tr-slide .slide-layer.active, .tr-slide .side-layer.active { transform: translateX(0); }

/* Footer / vær – sted/kreditt venstre + 6 dager */
:root {
	--ftr-h: 170px;
}

.ftr {
	flex: 0 0 var(--ftr-h);
	min-height: var(--ftr-h);
	max-height: var(--ftr-h);
	display: flex;
	flex-direction: column;
	align-items: stretch;
	justify-content: center;
	padding: 0.2rem 0 0.15rem 25px;
	border-top: 1px solid rgba(255, 255, 255, 0.12);
	background: rgba(12, 14, 22, 0.95);
	font-size: clamp(0.72rem, 1.15vw, 0.95rem);
	box-sizing: border-box;
}
.ftr.hidden { display: none !important; }

.ftr-row {
	display: flex;
	flex-direction: row;
	align-items: stretch;
	width: 100%;
	flex: 1;
	min-height: 0;
	min-width: 0;
}

.ftr-meta {
	flex: 0 0 minmax(7.5rem, 19%);
	max-width: min(240px, 28vw);
	min-width: 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 0.12rem;
	padding: 0.08rem 0.45rem 0.08rem 0.35rem;
	box-sizing: border-box;
	border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.ftr-place-block {
	display: flex;
	flex-direction: column;
	gap: 0.1rem;
	min-width: 0;
}

.ftr-place-line1 {
	font-weight: 800;
	font-size: clamp(1.05rem, 2.1vw, 1.55rem);
	line-height: 1.12;
	letter-spacing: -0.02em;
	opacity: 0.98;
	word-break: break-word;
}

.ftr-place-line2 {
	font-weight: 700;
	font-size: clamp(0.95rem, 1.75vw, 1.28rem);
	line-height: 1.15;
	opacity: 0.92;
	word-break: break-word;
}

.ftr-grid {
	display: grid;
	grid-template-columns: repeat(6, 1fr);
	flex: 1;
	min-width: 0;
	min-height: 0;
	width: auto;
	align-items: center;
}

/* Per dag: linje 1 = ikon+grader, linje 2 = dag, linje 3 = dato */
.ftr-day {
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 0;
	width: 100%;
	padding: 0.2rem 0.3rem;
	box-sizing: border-box;
	border-right: 1px solid rgba(255, 255, 255, 0.08);
}
.ftr-day:last-child {
	border-right: none;
}

.ftr-day-inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.2rem;
	max-width: 100%;
	min-width: 0;
	flex-shrink: 0;
}

.ftr-day-line1 {
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: center;
	gap: 0.35rem;
	flex-shrink: 0;
}

.ftr-day .d-temp {
	font-weight: 700;
	font-size: clamp(1.35em, 2.4vw, 2rem);
	line-height: 1;
	min-width: 2.1em;
	text-align: center;
	flex-shrink: 0;
	font-variant-numeric: tabular-nums;
}

.ftr-day img {
	width: 64px;
	height: 64px;
	max-width: min(64px, 14vw);
	max-height: min(64px, 14vw);
	object-fit: contain;
	image-rendering: auto;
	flex-shrink: 0;
	display: block;
}

.ftr-day .d-text {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.08rem;
	min-width: 0;
	width: 100%;
	flex: 0 1 auto;
	text-align: center;
}

.ftr-day .d-title {
	font-weight: 700;
	opacity: 0.96;
	font-size: clamp(1.05rem, 2vw, 1.45rem);
	line-height: 1.12;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 100%;
}
.ftr-day .d-date {
	opacity: 0.82;
	font-size: clamp(0.85rem, 1.35vw, 1.05rem);
	line-height: 1.15;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 100%;
}

.ftr-meta .ftr-credit {
	width: 100%;
	text-align: left;
	font-size: clamp(0.78rem, 1.3vw, 1rem);
	font-weight: 600;
	opacity: 0.75;
	line-height: 1.3;
	padding: 0.35rem 0 0;
	margin: 0;
	max-width: none;
	flex-shrink: 0;
	white-space: normal;
}

@media (max-width: 720px) {
	.layout-split {
		grid-template-columns: 1fr;
		grid-template-rows: auto 1fr;
	}
	#side-slot { max-height: 28vh; }
	.hdr-inner {
		grid-template-columns: 1fr;
		grid-template-rows: auto auto auto;
		text-align: center;
	}
	.hdr-right { justify-self: center; text-align: center; }
	.hdr-time-stack { align-items: center; }
	.hdr-left { text-align: center; }
}
