/*
 * Phia EnergyFit - base styles (tokens, font, typography, accessibility, content).
 * Loaded on every theme-rendered page. Not loaded on the plugin landing page.
 * Kept compatible with older Silk/WebView builds: no :is(), inset or
 * aspect-ratio; vh fallbacks before dvh.
 */

/* ---------- Font (self-hosted Raleway variable, latin) ---------- */
@font-face {
	font-family: "Raleway";
	font-style: normal;
	font-weight: 100 900;
	font-display: swap;
	src: url("../fonts/raleway-latin-wght-normal.woff2") format("woff2");
}

/* ---------- Tokens ---------- */
:root {
	/* Phia gold. --phia-gold is 3.5:1 on white: use it for large type and
	   decoration only. Use the -text / -deep values for small text and buttons. */
	--phia-gold: #9e8844;
	--phia-gold-light: #d2b55b;
	--phia-gold-deep: #7d6c2f;   /* 5.2:1 with white text */
	--phia-gold-text: #75662c;   /* 5.7:1 on white */
	--phia-ink: #333333;         /* 12.6:1 */
	--phia-ink-soft: #4d4d4d;    /* 8.4:1 */
	--phia-line: #e5e7eb;
	--phia-paper: #ffffff;

	/* Latin Raleway first; Japanese glyphs fall back per character
	   (the survey offers Japanese). */
	--phia-font: "Raleway", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
		"Helvetica Neue", Arial, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
		"Yu Gothic", "Noto Sans JP", Meiryo, sans-serif;

	--phia-tap: 3rem;            /* 48px minimum touch target */
	--phia-gutter: 1rem;
	--phia-measure: 72rem;
}

/* ---------- Reset essentials ---------- */
*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	line-height: 1.5;
}

body {
	margin: 0;
	font-family: var(--phia-font);
	font-size: 1rem;
	color: var(--phia-ink);
	background: var(--phia-paper);
	-webkit-font-smoothing: antialiased;
	font-variant-numeric: lining-nums; /* Raleway defaults to old-style figures; lining is clearer for counters and phone numbers */
	overflow-wrap: break-word;
}

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

/* Form controls inherit the page font (browsers default to a system font).
   The survey plugin styles its own buttons and inputs but relies on this. */
button,
input,
select,
textarea {
	margin: 0;
	font-family: inherit;
	font-size: inherit;
	line-height: inherit;
}

/* ---------- Page frame ---------- */
.site {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	min-height: 100dvh;
	/* Respect device notches when viewport-fit=cover is set. */
	padding-left: env(safe-area-inset-left, 0);
	padding-right: env(safe-area-inset-right, 0);
}

.site-main {
	flex: 1 0 auto;
	width: 100%;
}

.content-wrap {
	width: 100%;
	max-width: var(--phia-measure);
	margin: 0 auto;
	padding: 2rem var(--phia-gutter) 3rem;
}

.content-wrap--center {
	text-align: center;
}

/* ---------- Typography ---------- */
h1,
h2,
h3,
h4 {
	margin: 0 0 0.75em;
	font-weight: 400;
	line-height: 1.2;
	color: var(--phia-ink);
}

.entry-title {
	font-size: 2rem;
	font-weight: 300;
	color: var(--phia-gold); /* large text: 3.5:1 passes AA-large */
}

.entry-title a {
	color: inherit;
	text-decoration: none;
}

.entry-content {
	max-width: 46rem;
	line-height: 1.7;
}

.content-wrap--center .entry-content {
	margin-left: auto;
	margin-right: auto;
}

p {
	margin: 0 0 1em;
}

a {
	color: var(--phia-gold-text);
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

a:hover {
	color: var(--phia-ink);
}

/* ---------- Focus (visible on keyboard, quiet on pointer) ---------- */
:focus {
	outline: 3px solid var(--phia-gold-deep);
	outline-offset: 3px;
}

:focus:not(:focus-visible) {
	outline: none;
}

/* ---------- Screen-reader utilities (WordPress standard) ---------- */
.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
	border: 0;
}

.screen-reader-text:focus {
	position: fixed;
	top: 0.5rem;
	left: 0.5rem;
	z-index: 1000;
	width: auto;
	height: auto;
	margin: 0;
	padding: 0.75rem 1rem;
	clip: auto;
	background: var(--phia-paper);
	color: var(--phia-ink);
	box-shadow: 0 0 0 3px var(--phia-gold-deep);
}

/* ---------- Button (gold outline, as on phialab.com) ---------- */
.phia-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: var(--phia-tap);
	padding: 0.75rem 1.75rem;
	border: 2px solid var(--phia-gold-deep);
	border-radius: 2px;
	background: transparent;
	color: var(--phia-gold-text);
	font: inherit;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-decoration: none;
	text-transform: uppercase;
	cursor: pointer;
}

.phia-button:hover {
	background: var(--phia-gold-deep);
	color: #ffffff;
}

/* ---------- WordPress content alignment ---------- */
.aligncenter {
	display: block;
	margin-left: auto;
	margin-right: auto;
}

.alignleft {
	float: left;
	margin: 0 1.5rem 1rem 0;
}

.alignright {
	float: right;
	margin: 0 0 1rem 1.5rem;
}

.wp-caption {
	max-width: 100%;
}

.wp-caption-text,
.gallery-caption {
	font-size: 0.875rem;
	color: var(--phia-ink-soft);
}

.pagination .nav-links {
	display: flex;
	gap: 0.75rem;
	flex-wrap: wrap;
}

.pagination a,
.pagination span {
	display: inline-flex;
	align-items: center;
	min-height: var(--phia-tap);
	padding: 0 0.75rem;
}

@media (min-width: 768px) {
	.entry-title {
		font-size: 2.75rem;
	}

	.content-wrap {
		padding-top: 3rem;
	}
}

/* ---------- Motion: only when the user has not asked to reduce it ---------- */
@media (prefers-reduced-motion: no-preference) {
	a,
	.phia-button {
		transition: color 0.15s ease, background-color 0.15s ease;
	}
}
