/*
Theme Name: Muistitalo
Theme URI: https://www.muistitalo.fi
Author: WProd
Description: Kevyt lohkoteema VivaElo Muistitalolle – muistisairauksien erikoisklinikka. Selkeä ajanvarauspolku, saavutettava ja nopea. Sisältää asiantuntijat-sisältötyypin, yhteystietoasetukset sekä rakenteisen datan (SEO/GEO).
Requires at least: 6.7
Tested up to: 7.1
Requires PHP: 8.0
Version: 1.0.1
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: muistitalo
Tags: block-patterns, full-site-editing, accessibility-ready, one-column, wide-blocks
*/

/* ---------- Perusasiat ---------- */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	*, *::before, *::after { transition: none !important; animation: none !important; }
}
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img { height: auto; }
:where(a, button, input, select, textarea, summary, .wp-block-navigation-item__content):focus-visible {
	outline: 3px solid var(--wp--preset--color--contrast);
	outline-offset: 3px;
	border-radius: 4px;
}
::selection { background: var(--wp--preset--color--primary); color: #fff; }

/* ---------- Painikkeet ---------- */
.wp-block-button__link { transition: background-color .15s ease, color .15s ease, border-color .15s ease; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; text-align: center; }
.wp-block-button.is-style-outline > .wp-block-button__link,
.wp-block-button .wp-block-button__link.is-style-outline {
	background: transparent;
	color: var(--wp--preset--color--primary-strong);
	border: 2px solid var(--wp--preset--color--primary);
}
.wp-block-button.is-style-outline > .wp-block-button__link:hover {
	background: var(--wp--preset--color--primary);
	color: #fff;
}
.has-primary-background-color .wp-block-button.is-style-outline > .wp-block-button__link,
.has-primary-soft-background-color .wp-block-button.is-style-outline > .wp-block-button__link,
.has-primary-strong-background-color .wp-block-button.is-style-outline > .wp-block-button__link { color: #fff; border-color: #fff; }
.has-primary-background-color .wp-block-button:not(.is-style-outline) > .wp-block-button__link,
.has-primary-strong-background-color .wp-block-button:not(.is-style-outline) > .wp-block-button__link { background: #fff; color: var(--wp--preset--color--primary-strong); border-color: #fff; }

/* ---------- Ylätunniste ---------- */
.mt-header { position: sticky; top: 0; z-index: 50; }
.admin-bar .mt-header { top: var(--wp-admin--admin-bar--height, 32px); }
@media (max-width: 600px) { .admin-bar .mt-header { top: 0; } }
.mt-header .wp-block-site-title a { display: inline-block; }
.mt-header .mt-brand { gap: .2rem; }
.mt-header .mt-location a { display: inline-flex; gap: .35rem; align-items: center; text-decoration: none; }
.mt-header .mt-location a::before {
	content: ""; width: 1em; height: 1em; flex: none;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a7 7 0 0 0-7 7c0 5.2 7 13 7 13s7-7.8 7-13a7 7 0 0 0-7-7Zm0 9.5A2.5 2.5 0 1 1 12 6a2.5 2.5 0 0 1 0 5.5Z'/%3E%3C/svg%3E") center/contain no-repeat;
	        mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a7 7 0 0 0-7 7c0 5.2 7 13 7 13s7-7.8 7-13a7 7 0 0 0-7-7Zm0 9.5A2.5 2.5 0 1 1 12 6a2.5 2.5 0 0 1 0 5.5Z'/%3E%3C/svg%3E") center/contain no-repeat;
}
.mt-header .wp-block-navigation__responsive-container.is-menu-open { padding: 1.5rem; }
.mt-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content { font-size: 1.35rem; gap: 1rem; }
@media (max-width: 781px) {
	.mt-header .mt-location { display: none; }
	.mt-header .mt-header-cta .wp-block-button__link { padding: .55rem 1rem; }
	.mt-header .wp-block-site-tagline { display: none; }
}
@media (max-width: 380px) {
	.mt-header .wp-block-site-title { font-size: 1.25rem !important; }
}
.wp-block-navigation .current-menu-item > a,
.wp-block-navigation a[aria-current="page"] { text-decoration: underline; text-underline-offset: .35em; text-decoration-thickness: 2px; }

/* ---------- Hero ---------- */
.mt-hero h1 { text-wrap: balance; }
.mt-hero .wp-block-image img { border-radius: var(--wp--custom--radius--card); aspect-ratio: 4 / 3; object-fit: cover; width: 100%; }
@media (max-width: 781px) {
	.mt-hero .wp-block-buttons { flex-direction: column; align-items: stretch; }
	.mt-hero .wp-block-buttons .wp-block-button { width: 100%; }
	.mt-hero .wp-block-buttons .wp-block-button__link { width: 100%; }
}

/* ---------- Kortit ---------- */
.is-style-kortti {
	background: var(--wp--preset--color--surface);
	border: 1px solid var(--wp--preset--color--line);
	border-radius: var(--wp--custom--radius--card);
	box-shadow: var(--wp--preset--shadow--card);
}

/* Koko kortti klikattava: kortin ENSIMMÄINEN linkki venytetään kortin kokoiseksi. */
.is-style-linkkikortti {
	position: relative;
	display: flex; flex-direction: column;
	background: var(--wp--preset--color--surface);
	border: 1px solid var(--wp--preset--color--line);
	border-radius: var(--wp--custom--radius--card);
	box-shadow: var(--wp--preset--shadow--card);
	transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
	height: 100%;
}
.is-style-linkkikortti :where(h2, h3, h4) a { text-decoration: none; color: inherit; }
.is-style-linkkikortti :where(h2, h3, h4) a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: 1; }
.is-style-linkkikortti:hover { transform: translateY(-2px); border-color: var(--wp--preset--color--primary-soft); box-shadow: 0 2px 4px rgba(30,42,34,.08), 0 14px 32px rgba(30,42,34,.10); }
.is-style-linkkikortti:hover :where(h2, h3, h4) a { text-decoration: underline; text-underline-offset: .2em; }
.is-style-linkkikortti:has(a:focus-visible) { outline: 3px solid var(--wp--preset--color--contrast); outline-offset: 3px; }
.is-style-linkkikortti :where(h2, h3, h4) a:focus-visible { outline: none; }
/* Koristeellinen nuoli oikeaan alakulmaan */
.is-style-linkkikortti::after {
	content: ""; position: absolute; right: 1.1rem; bottom: 1.1rem;
	width: 2.1rem; height: 2.1rem; border-radius: 50%;
	border: 1.5px solid currentColor; opacity: .75;
	background: no-repeat center / 1rem url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231E2A22' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E");
}
.is-style-linkkikortti.has-primary-soft-background-color::after,
.is-style-linkkikortti.has-primary-background-color::after {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E");
}
.is-style-linkkikortti.has-primary-soft-background-color,
.is-style-linkkikortti.has-primary-background-color { border-color: transparent; }
.is-style-linkkikortti .mt-card-pill { margin-top: auto; padding-right: 3rem; }
.is-style-linkkikortti .mt-card-pill span {
	display: inline-block; padding: .4rem .95rem; border-radius: 999px;
	background: var(--wp--preset--color--primary); color: #fff; font-weight: 600; font-size: .9rem;
}
.is-style-linkkikortti > p:last-child:not(.mt-card-pill) { padding-right: 2.75rem; }
.mt-card-icon img { width: 44px; height: 44px; }

/* Ruudukko: korttien sarakkeet tasakorkeiksi */
.mt-cards > .wp-block-column { display: flex; flex-direction: column; }
.mt-cards > .wp-block-column > .is-style-linkkikortti { flex: 1; }
@media (min-width: 782px) and (max-width: 1100px) {
	.mt-cards.wp-block-columns { flex-wrap: wrap !important; }
	.mt-cards.wp-block-columns > .wp-block-column { flex-basis: calc(50% - 1rem) !important; }
}

/* ---------- Listat ---------- */
.is-style-tarkistus { list-style: none; padding-left: 0; }
.is-style-tarkistus li { position: relative; padding-left: 1.9rem; margin-bottom: .55rem; }
.is-style-tarkistus li::before {
	content: ""; position: absolute; left: 0; top: .35em; width: 1.15rem; height: 1.15rem; border-radius: 50%;
	background: var(--wp--preset--color--primary) no-repeat center / .7rem url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}

/* ---------- Usein kysytyt (details) ---------- */
.wp-block-details summary { cursor: pointer; font-weight: 600; font-size: var(--wp--preset--font-size--medium); list-style: none; position: relative; padding-right: 2rem; }
.wp-block-details summary::-webkit-details-marker { display: none; }
.wp-block-details summary::after { content: "+"; position: absolute; right: .25rem; top: -.1rem; font-size: 1.5rem; line-height: 1; color: var(--wp--preset--color--primary); }
.wp-block-details[open] summary::after { content: "–"; }
.wp-block-details > :not(summary) { margin-top: .75rem; }

/* ---------- Taulukot ---------- */
.wp-block-table table { border-collapse: collapse; width: 100%; background: var(--wp--preset--color--surface); }
.wp-block-table table, .wp-block-table thead, .wp-block-table tfoot { border: 0; }
.wp-block-table th, .wp-block-table td { padding: .8rem 1rem; border: 0; border-bottom: 1px solid var(--wp--preset--color--line); text-align: left; vertical-align: top; }
.wp-block-table thead th { font-weight: 600; background: var(--wp--preset--color--subtle); border-bottom: 2px solid var(--wp--preset--color--primary); }
.wp-block-table td:last-child, .wp-block-table th:last-child { text-align: right; white-space: nowrap; }
.wp-block-table.is-style-teksti td:last-child, .wp-block-table.is-style-teksti th:last-child { text-align: left; white-space: normal; }
.wp-block-table { overflow-x: auto; border-radius: var(--wp--custom--radius--card); border: 1px solid var(--wp--preset--color--line); }
.wp-block-table figcaption { padding: .75rem 1rem; text-align: left; }

/* ---------- Leivänmuru / pieni yläotsikko ---------- */
.mt-eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .78rem !important; font-weight: 600; color: var(--wp--preset--color--muted); }
.has-primary-background-color .mt-eyebrow, .has-primary-strong-background-color .mt-eyebrow, .has-primary-soft-background-color .mt-eyebrow { color: rgba(255,255,255,.85); }

/* ---------- Asiantuntijat ---------- */
.mt-expert-card .wp-block-post-featured-image img { aspect-ratio: 4 / 5; object-fit: cover; border-radius: calc(var(--wp--custom--radius--card) - 4px); }
.mt-expert-card .wp-block-post-featured-image:empty,
.mt-expert-card .wp-block-post-featured-image:not(:has(img)) { display: none; }
.mt-expert-photo img { aspect-ratio: 4 / 5; object-fit: cover; border-radius: var(--wp--custom--radius--card); }
.mt-meta-list p:empty, .mt-meta-row:has(p:empty:last-child) { display: none; }

/* ---------- Alatunniste ---------- */
.mt-footer a { color: inherit; text-decoration-color: rgba(255,255,255,.4); text-underline-offset: .2em; }
.mt-footer a:hover { text-decoration-color: currentColor; }
.mt-footer .wp-block-site-title a { color: #fff; }
.mt-footer ul { list-style: none; padding: 0; margin: 0; }
.mt-footer li { margin: 0 0 .5rem; }

/* ---------- Muut ---------- */
.mt-mobile-call { display: none; }
@media (max-width: 781px) {
	.mt-mobile-call {
		display: flex; position: fixed; z-index: 60; left: 0; right: 0; bottom: 0;
		gap: .5rem; padding: .6rem 1rem calc(.6rem + env(safe-area-inset-bottom));
		background: var(--wp--preset--color--surface); border-top: 1px solid var(--wp--preset--color--line);
		box-shadow: 0 -6px 20px rgba(30,42,34,.08);
	}
	.mt-mobile-call a { flex: 1; text-align: center; padding: .7rem .5rem; border-radius: 999px; font-weight: 600; text-decoration: none; font-size: .95rem; }
	.mt-mobile-call .mt-call { border: 2px solid var(--wp--preset--color--primary); color: var(--wp--preset--color--primary-strong); }
	.mt-mobile-call .mt-book { background: var(--wp--preset--color--primary); color: #fff; border: 2px solid var(--wp--preset--color--primary); }
	body { padding-bottom: 4.5rem; }
}
.mt-notice { border-left: 4px solid var(--wp--preset--color--primary); }
.wp-block-post-template.is-layout-grid { gap: var(--wp--preset--spacing--30); }
.screen-reader-text:focus { clip: auto !important; }

/* ---------- Mobiilivalikon lisälinkki ---------- */
.wp-block-navigation .mt-mobile-only { display: none !important; }
.wp-block-navigation__responsive-container.is-menu-open .mt-mobile-only { display: flex !important; }

/* Tyhjät sidotut kentät piiloon */
.mt-footer p:empty, .mt-contact p:empty, .mt-contact p:empty + * { display: none; }
.mt-contact .mt-eyebrow:has(+ p:empty) { display: none; }
.mt-contact .mt-eyebrow { margin-bottom: -.4rem; }

/* ---------- Yhteydenottolomake ---------- */
.mt-form { max-width: 760px; }
.mt-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); column-gap: 1.25rem; }
.mt-form label { display: block; font-weight: 600; margin-bottom: .35rem; }
.mt-form input[type=text], .mt-form input[type=tel], .mt-form input[type=email], .mt-form select, .mt-form textarea {
	width: 100%; box-sizing: border-box; font: inherit; color: inherit;
	padding: .75rem .9rem; min-height: 48px;
	border: 1.5px solid #9C9585; border-radius: 10px; background: #fff;
}
.mt-form :is(input, select, textarea):focus { border-color: var(--wp--preset--color--primary); outline: 3px solid rgba(84,92,59,.35); outline-offset: 1px; }
.mt-form small { display: block; margin-top: .3rem; color: var(--wp--preset--color--muted); }
.mt-form .mt-consent label { font-weight: 400; display: flex; gap: .6rem; align-items: flex-start; }
.mt-form .mt-consent input { width: 1.25rem; height: 1.25rem; margin-top: .2rem; accent-color: var(--wp--preset--color--primary); flex: none; }
.mt-form button.wp-block-button__link { cursor: pointer; font-family: inherit; }
.mt-hp { position: absolute !important; left: -9999px !important; }
.mt-form-notice { padding: 1rem 1.25rem; border-radius: 10px; margin-bottom: 1.25rem; background: #fff; border-left: 4px solid var(--wp--preset--color--primary); }
.mt-form-notice.is-error { border-left-color: #A3361B; }

/* ---------- Osioiden sisäsäiliö: yhtenäinen vasen reuna, luettava rivinpituus ---------- */
.mt-inner > :where(p, ul, ol, h1, h2, .wp-block-details) { max-width: 48rem; }
.mt-inner > .wp-block-table { max-width: 62rem; }
.mt-inner > .wp-block-heading + .wp-block-columns { margin-top: var(--wp--preset--spacing--30); }
.mt-faq .mt-inner > .wp-block-details { margin-top: 0; }
.mt-faq .mt-inner > .wp-block-heading { margin-bottom: 1rem; }
.mt-inner > .wp-block-columns { margin-bottom: 0; }
.wp-site-blocks > :where(main, footer, aside, .wp-block-template-part) { margin-block-start: 0; }
.mt-inner > :where(p, ul, .wp-block-buttons) + h2 { margin-top: var(--wp--preset--spacing--40); }
@media (max-width: 781px) {
	.mt-hero .wp-block-image img { aspect-ratio: 16 / 9; }
}
/* Avattu mobiilivalikko: isot, vasemmalle tasatut linkit */
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content { align-items: flex-start !important; padding-top: 3rem; }
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container { align-items: flex-start !important; gap: 1.1rem !important; }
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content { font-family: var(--wp--preset--font-family--serif); font-size: 1.6rem; font-weight: 500; }
.wp-block-table:not(.is-style-teksti) :where(td, th):not(:first-child) { text-align: right; white-space: nowrap; }
.wp-block-table.is-style-teksti td:first-child { width: 14rem; }
@media (max-width: 600px) { .wp-block-table.is-style-teksti td:first-child { width: auto; } .wp-block-table.is-style-teksti tr { display: grid; } .wp-block-table.is-style-teksti td:first-child { border-bottom: 0; padding-bottom: 0; } }
