/*
 * Phones: the design of the legacy /mobi/ site (themes/header_mobi.css and kuvaton_mobi.css).
 * The legacy site sent phones there by user agent; here the same pages switch by screen width.
 */

.menu-toggle,
.mobile-menu,
.mobile-next {
	display: none;
}

@media (max-width: 767px) {
	html:has(.menu-open),
	body.menu-open {
		overflow: hidden;
	}

	body.menu-open .arrowPrev,
	body.menu-open .arrowNext {
		display: none;
	}

	#container {
		background: #fff;
	}

	#content:before {
		display: none;
	}

	/* Header bar: logo and burger button */
	#header-wrapper {
		position: sticky;
		top: 0;
		z-index: 1000;
		background: #fff;
		border-bottom: 1px solid #e5e5e5;
	}

	.header {
		flex-wrap: nowrap;
		justify-content: space-between;
		height: 64px;
		min-height: 0;
		padding: 0 12px 0 16px;
	}

	.header > .paalinkki,
	.header > .login {
		display: none;
	}

	#kuvaton-header-logo img {
		height: 28px;
		width: auto;
	}

	.menu-toggle {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 40px;
		height: 40px;
		padding: 8px;
		border: none;
		background: none;
		border-radius: 8px;
		cursor: pointer;
		color: #171717;
	}

	.menu-toggle:active {
		background: #f5f5f5;
	}

	.menu-toggle .icon-close,
	.menu-toggle[aria-expanded="true"] .icon-menu {
		display: none;
	}

	.menu-toggle[aria-expanded="true"] .icon-close {
		display: block;
	}

	/* Menu panel */
	.mobile-menu {
		position: fixed;
		top: 64px;
		left: 0;
		right: 0;
		z-index: 999;
		display: flex;
		flex-direction: column;
		max-height: 0;
		overflow: hidden;
		background: #fff;
		transition: max-height 0.3s ease;
	}

	.mobile-menu.is-open {
		max-height: calc(100vh - 64px);
		overflow-y: auto;
	}

	.mobile-menu * {
		box-sizing: border-box;
	}

	.menu-nav {
		border-bottom: 1px solid #e5e5e5;
		padding: 16px 0;
	}

	.menu-item-row {
		display: flex;
		align-items: stretch;
		min-height: 48px;
	}

	.menu-item-link {
		flex: 0 0 auto;
		display: flex;
		align-items: center;
		padding: 12px 0 12px 16px;
		white-space: nowrap;
		font-size: 16px;
		font-weight: 700;
		line-height: 24px;
		color: #404040;
		text-decoration: none;
	}

	.menu-item-toggle {
		flex: 1 1 auto;
		display: flex;
		align-items: center;
		justify-content: flex-end;
		padding: 12px 16px;
		border: none;
		background: none;
		border-radius: 8px;
		cursor: pointer;
		color: #404040;
	}

	.menu-item-toggle:active {
		background: #f5f5f5;
	}

	.menu-item-toggle .chevron {
		flex-shrink: 0;
		transition: transform 0.2s ease;
	}

	.menu-item.open .menu-item-toggle .chevron {
		transform: rotate(180deg);
	}

	.menu-item.cta {
		display: block;
		padding: 12px 18px;
		font-size: 16px;
		font-weight: 700;
		line-height: 24px;
		color: #16818d;
		text-decoration: none;
	}

	.submenu {
		max-height: 0;
		overflow: hidden;
		padding: 0 16px;
		transition: max-height 0.25s ease, padding 0.25s ease;
	}

	.menu-item.open .submenu {
		max-height: 500px;
		padding: 0 16px 8px;
	}

	.submenu::before {
		content: '';
		display: block;
		height: 5px;
		background: #e2530c;
		border-radius: 2px 2px 0 0;
	}

	.submenu a {
		display: block;
		padding: 12px 16px;
		font-size: 16px;
		font-weight: 700;
		line-height: 24px;
		color: #404040;
		text-decoration: none;
		background: #fff;
		border-left: 1px solid #e5e5e5;
		border-right: 1px solid #e5e5e5;
	}

	.submenu a:last-child {
		border-bottom: 1px solid #e5e5e5;
		border-radius: 0 0 4px 4px;
	}

	.submenu a:active {
		background: #f5f5f5;
	}

	/* Login, or the account links when logged in */
	.menu-login {
		flex: 1;
		padding: 24px 16px;
	}

	.menu-login form {
		display: flex;
		flex-direction: column;
		gap: 20px;
	}

	.menu-login .input-field {
		display: flex;
		flex-direction: column;
		gap: 6px;
	}

	.menu-login .input-label {
		font-size: 14px;
		line-height: 20px;
		color: #404040;
	}

	.menu-login .input-field input {
		width: 100%;
		height: 44px;
		padding: 10px 14px;
		border: 1px solid #d4d4d4;
		border-radius: 8px;
		font-family: 'Source Sans 3', sans-serif;
		font-size: 16px;
		line-height: 24px;
		color: #171717;
		background: #fff;
		box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
	}

	.menu-login .input-field input:focus {
		outline: none;
		border-color: #16818d;
		box-shadow: 0 0 0 2px rgba(22, 129, 141, 0.15);
	}

	.menu-login .remember {
		display: flex;
		align-items: center;
		gap: 8px;
		font-size: 14px;
		line-height: 20px;
		color: #404040;
		cursor: pointer;
	}

	.menu-login .remember input {
		width: 16px;
		height: 16px;
		margin: 0;
	}

	.login-btn {
		width: 100%;
		height: 44px;
		border: none;
		border-radius: 9999px;
		background: #16818d;
		color: #fff;
		font-family: 'Source Sans 3', sans-serif;
		font-size: 14px;
		font-weight: 700;
		line-height: 20px;
		cursor: pointer;
	}

	.login-btn:active {
		background: #126d77;
	}

	.logged-in {
		display: flex;
		flex-direction: column;
		gap: 12px;
		font-size: 16px;
	}

	.logged-in a {
		color: #16818d;
		font-weight: 700;
		text-decoration: none;
	}

	/* Language flags: one row instead of the desktop dropdown */
	.menu-login .lang-selector {
		flex-direction: row;
		flex-wrap: wrap;
		align-items: center;
		gap: 4px;
		margin-top: 24px;
	}

	.menu-login .lang-selector .item1::after {
		display: none;
	}

	.menu-login .lang-selector div.section {
		position: static;
		display: flex;
		flex-wrap: wrap;
		opacity: 1;
		visibility: visible;
		transform: none;
		border: none;
		box-shadow: none;
		background: none;
	}

	.menu-login .lang-selector div.section::before {
		display: none;
	}

	.menu-login .langlink {
		margin: 0;
		padding: 4px 6px !important;
	}

	/* The bar under the header only for login errors; its account links are in the menu */
	.logged:not(:has(.warning)) {
		display: none;
	}

	.logged {
		text-align: center;
		padding: 8px 16px;
	}

	.logged > a:has(img) {
		display: none;
	}

	/* Page navigation */
	.kuvanavi {
		gap: 10px;
	}

	a.sivulle,
	a.navi_o,
	a.navi_selected {
		font-size: 20px;
	}

	a.navi_a,
	a.navi_use,
	.kuvanavi div {
		font-size: 18px;
	}

	/* Kuva list */
	.kuvaboxi {
		padding: 0 12px;

		.kuvaotsikko {
			display: block;
			margin-bottom: 0;
		}
	}

	#kuvaboxi {
		a:not(.single-line-cta__button) {
			font-size: 14pt;
		}

		span a {
			font-size: 12pt;
		}
	}
	/* Kuva page: name and kuva first, then the rating and Seuraava; no neighbour thumbnails */
	#nayta_kuva {
		display: flex;
		flex-direction: column;
		padding: 10px 0 0;

		> * {
			order: 4;
		}
	}

	#nayta_nykyinen {
		order: 1;
		width: auto;
		padding: 0 20px;
	}

	#navi_seiska {
		order: 2;
	}

	#nayta_uudemmat,
	#nayta_vanhemmat {
		display: none;
	}

	#nayta_nykyinen_thumb {
		width: 100%;
		padding-top: 10px;
	}

	.mobile-next {
		order: 3;
		display: block;
		align-self: flex-end;
		margin: 10px 15px 0 0;
		font-weight: 700;
		color: #000;
		text-decoration: none;
	}

	p.kuvanimi {
		font-size: 12pt;
		overflow-wrap: anywhere;
	}

	#nayta_kuva > p {
		padding: 0 12px;
	}

	/* Comments: one line per comment, time in the name's tooltip */
	.kuvakommentit {
		width: auto;
		margin: 15px 12px;
		text-align: left;

		h2 {
			text-align: center;
		}

		table,
		tbody,
		tr {
			display: block;
			width: auto;
		}

		td {
			display: inline;
			width: auto !important;
			padding: 0;
			font-size: 14px;
			line-height: 1.4;
		}

		td.aika {
			display: none;
		}

		td.tunnus {
			margin-right: 4px;
		}

		table:not(:last-child) {
			padding: 4px 0;
			border-bottom: 1px solid #ddd;
		}

		td.kommentointi {
			display: block;
			text-align: center;
		}
	}

	.kommentointi input {
		width: 100%;
		box-sizing: border-box;
	}

	.kommentointi input.submit {
		width: auto;
		margin-top: 8px;
	}
}
