/**
 * Recipe print styles — screen preview + @media print.
 *
 * This file styles the standalone print template (print-oppskrift.php).
 * Screen styles show an A4-like preview; @media print rules handle
 * page breaks, margins, and toolbar hiding.
 */

/* ========================================
   Reset & base
   ======================================== */

*,
*::before,
*::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

html {
	font-size: 11pt;
	-webkit-print-color-adjust: exact;
	print-color-adjust: exact;
}

body {
	font-family: 'DM Sans', sans-serif;
	font-weight: 400;
	line-height: 1.6;
	color: #1a1a1a;
	background: #f5f5f5;
}

h1, h2, h3 {
	font-family: 'Baloo 2', cursive, sans-serif;
	font-weight: 600;
	line-height: 1.2;
	color: #1a1a1a;
}

img {
	max-width: 100%;
	height: auto;
}

a {
	color: #cc2e2e;
	text-decoration: none;
}

hr {
	border: none;
	border-top: 1px solid #ddd;
}

ul {
	list-style: none;
}

ol {
	list-style: none;
}

/* ========================================
   Options panel (screen only)
   ======================================== */

.print-toolbar {
	position: sticky;
	top: 0;
	z-index: 100;
	background: #f7f7f7;
	border-bottom: 2px solid #e0e0e0;
	padding: 24px 20px;
}

.print-toolbar__panel {
	max-width: 480px;
	margin: 0 auto;
}

.print-toolbar__header {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 4px;
}

.print-toolbar__header svg {
	flex-shrink: 0;
	color: #cc2e2e;
}

.print-toolbar__header h2 {
	font-size: 16pt;
	margin: 0;
}

.print-toolbar__desc {
	font-size: 0.9rem;
	margin-bottom: 20px;
}

/* --- Options (toggle switches) --- */

.print-toolbar__options {
	margin-bottom: 20px;
	padding: 14px 16px;
	background: #fff;
	border-radius: 8px;
	border: 1px solid #e0e0e0;
}

.print-toolbar__toggle {
	display: flex;
	align-items: center;
	gap: 12px;
	font-size: 0.95rem;
	font-weight: 500;
	cursor: pointer;
	user-select: none;
}

.print-toolbar__toggle + .print-toolbar__toggle {
	margin-top: 12px;
	padding-top: 12px;
	border-top: 1px solid #e0e0e0;
}

/* iOS-style toggle switch */
.print-toolbar__switch {
	position: relative;
	flex-shrink: 0;
	width: 44px;
	height: 24px;
}

.print-toolbar__switch input {
	opacity: 0;
	width: 0;
	height: 0;
	position: absolute;
}

.print-toolbar__slider {
	position: absolute;
	inset: 0;
	background: #ccc;
	border-radius: 24px;
	transition: background 0.2s;
	cursor: pointer;
}

.print-toolbar__slider::before {
	content: '';
	position: absolute;
	left: 2px;
	top: 2px;
	width: 20px;
	height: 20px;
	background: #fff;
	border-radius: 50%;
	transition: transform 0.2s;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.print-toolbar__switch input:checked + .print-toolbar__slider {
	background: #cc2e2e;
}

.print-toolbar__switch input:checked + .print-toolbar__slider::before {
	transform: translateX(20px);
}

.print-toolbar__switch input:focus-visible + .print-toolbar__slider {
	outline: 2px solid #cc2e2e;
	outline-offset: 2px;
}

/* --- Actions --- */

.print-toolbar__actions {
	display: flex;
	align-items: center;
	gap: 16px;
}

.print-toolbar__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	flex: 1;
	padding: 14px 24px;
	font-family: 'DM Sans', sans-serif;
	font-size: 1rem;
	font-weight: 700;
	color: #fff;
	background: #cc2e2e;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	transition: background 0.15s;
}

.print-toolbar__btn:hover {
	background: #a82525;
}

.print-toolbar__btn svg {
	flex-shrink: 0;
}

.print-toolbar__link {
	flex-shrink: 0;
	font-size: 0.85rem;
	white-space: nowrap;
}

.print-toolbar__link:hover {
	color: #cc2e2e;
}

/* ========================================
   Print page (screen preview)
   ======================================== */

.print-page {
	max-width: 210mm;
	margin: 20px auto;
	padding: 15mm 20mm;
	background: #fff;
	box-shadow: 0 1px 8px rgba(0, 0, 0, 0.1);
}

/* ========================================
   Header
   ======================================== */

.print-header {
	position: relative;
	margin-bottom: 6mm;
}

.print-header__image {
	float: right;
	width: 55mm;
	height: 55mm;
	margin-left: 6mm;
	margin-bottom: 4mm;
	overflow: hidden;
	border-radius: 4mm;
}

.print-header__image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.print-header__logo {
	display: block;
	width: auto;
	height: 14mm;
	margin-bottom: 4mm;
}

.print-header__title {
	font-size: 22pt;
	font-weight: 700;
	margin-bottom: 2mm;
}

.print-header__meta {
	font-size: 0.85rem;
	color: #1a1a1a;
	margin-bottom: 2mm;
}

.print-header__desc {
	font-size: 0.95rem;
	color: #1a1a1a;
	margin-bottom: 2mm;
}

/* Clear float after header */
.print-header::after {
	content: '';
	display: table;
	clear: both;
}

/* ========================================
   Quick facts
   ======================================== */

.print-facts {
	display: flex;
	flex-wrap: wrap;
	gap: 4mm 8mm;
	margin-bottom: 4mm;
	padding: 3mm 0;
}

.print-facts__item {
	display: flex;
	align-items: baseline;
	gap: 2mm;
	font-size: 0.9rem;
}

.print-facts__item strong {
	text-transform: uppercase;
	font-size: 0.75rem;
	letter-spacing: 0.5px;
	color: #1a1a1a;
}

/* ========================================
   Divider
   ======================================== */

.print-divider {
	margin-bottom: 6mm;
}

/* ========================================
   Two-column body
   ======================================== */

.print-body {
	display: grid;
	grid-template-columns: 40fr 60fr;
	gap: 8mm;
	align-items: start;
}

/* --- Ingredients (left) --- */

.print-ingredients {
	grid-column: 1;
}

.print-ingredients h2 {
	font-size: 13pt;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	border-bottom: 1px solid #ddd;
	padding-bottom: 2mm;
	margin-bottom: 4mm;
}

.print-ingredients h3 {
	font-size: 11pt;
	font-weight: 700;
	margin-top: 4mm;
	margin-bottom: 2mm;
}

.print-ingredients__group {
	margin-bottom: 3mm;
}

.print-ingredients ul li {
	padding: 1mm 0;
	font-size: 0.9rem;
	line-height: 1.5;
	border-bottom: 1px dotted #e8e8e8;
}

.print-ingredients ul li:last-child {
	border-bottom: none;
}

.ing-qty {
	font-weight: 600;
}

.ing-note {
	color: #1a1a1a;
	font-style: italic;
}

.ing-note::before {
	content: ', ';
}

/* --- Instructions (right) --- */

.print-instructions {
	grid-column: 2;
}

.print-instructions h2 {
	font-size: 13pt;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	border-bottom: 1px solid #ddd;
	padding-bottom: 2mm;
	margin-bottom: 4mm;
}

.print-instructions h3 {
	font-size: 11pt;
	font-weight: 700;
	margin-top: 5mm;
	margin-bottom: 2mm;
}

.print-steps {
	counter-reset: none;
}

.print-step {
	margin-bottom: 4mm;
	padding-left: 0;
}

.print-step strong {
	display: block;
	font-size: 0.95rem;
	margin-bottom: 1mm;
}

.print-step p {
	font-size: 0.9rem;
	margin-bottom: 1mm;
}

.print-step__note {
	font-size: 0.85rem;
	color: #1a1a1a;
	font-style: italic;
	padding-left: 3mm;
	border-left: 2px solid #e0e0e0;
	margin-top: 1mm;
}

/* ========================================
   Gallery
   ======================================== */

.print-gallery {
	margin-top: 8mm;
}

.print-gallery h2 {
	font-size: 13pt;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	border-bottom: 1px solid #ddd;
	padding-bottom: 2mm;
	margin-bottom: 4mm;
}

.print-gallery__grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 4mm;
}

.print-gallery__grid figure {
	overflow: hidden;
}

.print-gallery__grid img {
	width: 100%;
	height: 35mm;
	object-fit: cover;
	border-radius: 2mm;
}

.print-gallery__grid figcaption {
	font-size: 0.75rem;
	color: #1a1a1a;
	margin-top: 1mm;
	line-height: 1.3;
}

/* ========================================
   Footer
   ======================================== */

.print-footer {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	margin-top: 8mm;
	padding-top: 4mm;
	border-top: 1px solid #ddd;
	font-size: 0.8rem;
	color: #1a1a1a;
}

.print-footer__url {
	word-break: break-all;
}

/* ========================================
   @media print
   ======================================== */

@media print {
	/* Page setup — use minimal @page margins so the browser's "Default"
	   margin setting doesn't add excessive whitespace on top of ours.
	   The .print-page padding handles the internal spacing. */
	@page {
		size: A4;
		margin: 5mm 5mm 8mm 5mm;
	}

	/* Hide toolbar */
	.print-toolbar {
		display: none;
	}

	/* Reset screen preview wrapper */
	body {
		background: #fff;
	}

	.print-page {
		max-width: none;
		margin: 0;
		padding: 10mm 15mm;
		box-shadow: none;
	}

	/* Image safety — prevent page-eating images */
	img {
		max-height: 80mm;
	}

	.print-header__image img {
		max-height: none; /* controlled by the container */
	}

	/* Page break control */
	.print-ingredients__group {
		break-inside: avoid;
	}

	.print-step {
		break-inside: avoid;
	}

	.print-step p {
		orphans: 3;
		widows: 3;
	}

	h2, h3 {
		break-after: avoid;
	}

	.print-gallery {
		break-before: auto;
	}

	.print-gallery__grid figure {
		break-inside: avoid;
	}

	.print-footer {
		break-inside: avoid;
	}

	/* Links: don't show href in print */
	a[href]::after {
		content: none;
	}
}
