/*
Theme Name: Grains & Gallons
Theme URI: https://grainsandgallons.com/
Author: Grains & Gallons
Description: A fast, reading-first theme for Grains & Gallons — hard water and water softener guides. Self-hosted fonts, no jQuery, responsive down to small phones, with built-in styling for Quick Answer boxes, comparison tables and Amazon buy buttons.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.6
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: grains-and-gallons
Tags: blog, one-column, custom-logo, custom-menu, featured-images, accessibility-ready
*/

/* ---------- Fonts (self-hosted, SIL OFL) ---------- */
@font-face { font-family: "Fraunces"; src: url("assets/fonts/fraunces-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("assets/fonts/fraunces-latin-600-italic.woff2") format("woff2"); font-weight: 600; font-style: italic; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("assets/fonts/manrope-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("assets/fonts/manrope-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("assets/fonts/manrope-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("assets/fonts/manrope-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

/* ---------- Tokens ---------- */
:root {
	--gg-navy: #0F3550;
	--gg-ink: #1B3245;
	--gg-slate: #56697A;
	--gg-blue: #1F78AD;      /* link blue: brand #2E8FC4 darkened for AA contrast on white */
	--gg-water: #2E8FC4;
	--gg-mist: #E8F4FA;      /* light water tint */
	--gg-foam: #F5FAFC;      /* page background */
	--gg-line: #D5E3EC;
	--gg-gold: #D9A93A;
	--gg-gold-soft: #FBF3DE;
	--gg-white: #FFFFFF;

	--gg-serif: "Fraunces", Georgia, "Times New Roman", serif;
	--gg-sans: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

	--gg-read: 42rem;        /* ~70 characters per line */
	--gg-wide: 72rem;
	--gg-gutter: clamp(1rem, 4vw, 2rem);
	--gg-radius: 10px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
body {
	margin: 0;
	background: var(--gg-foam);
	color: var(--gg-ink);
	font-family: var(--gg-sans);
	font-size: 1.0625rem;      /* 17px */
	line-height: 1.7;
	font-weight: 400;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}
img, svg, video, iframe { max-width: 100%; height: auto; }
a { color: var(--gg-blue); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--gg-navy); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--gg-gold); outline-offset: 2px; border-radius: 3px; }
::selection { background: var(--gg-gold-soft); color: var(--gg-navy); }

h1, h2, h3 { text-wrap: balance; }
h1, h2, h3, h4 { font-family: var(--gg-serif); font-weight: 600; color: var(--gg-navy); line-height: 1.2; margin: 0 0 0.6em; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 2.9rem); }
h2 { font-size: clamp(1.5rem, 1.2rem + 1.1vw, 1.9rem); margin-top: 2.2em; }
h3 { font-size: 1.3rem; margin-top: 1.8em; }
h4 { font-family: var(--gg-sans); font-weight: 700; font-size: 1.05rem; margin-top: 1.6em; }
p, ul, ol, table, figure, blockquote, details { margin: 0 0 1.25em; }
ul, ol { padding-left: 1.3em; }
li { margin-bottom: 0.4em; }
li::marker { color: var(--gg-water); }
strong { font-weight: 700; color: var(--gg-navy); }
hr { border: 0; height: 1px; background: var(--gg-line); margin: 2.5em 0; }

.screen-reader-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(1px,1px,1px,1px); white-space: nowrap; }
.skip-link:focus { position: fixed; top: 0.5rem; left: 0.5rem; z-index: 100; width: auto; height: auto; clip: auto; background: var(--gg-white); color: var(--gg-navy); padding: 0.6rem 1rem; border-radius: var(--gg-radius); }

.gg-wrap { width: 100%; max-width: var(--gg-wide); margin: 0 auto; padding: 0 var(--gg-gutter); }
.gg-read { max-width: var(--gg-read); margin-left: auto; margin-right: auto; }

/* ---------- Header ---------- */
.gg-header { background: var(--gg-white); border-bottom: 1px solid var(--gg-line); position: relative; z-index: 10; }
.gg-header .gg-wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 72px; }
.gg-brand { display: flex; align-items: center; flex-shrink: 0; }
.gg-brand img, .gg-brand .custom-logo { height: 46px; width: auto; display: block; }
.gg-nav { display: flex; align-items: center; gap: 0.75rem; }
.gg-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 0.25rem; align-items: center; }
.gg-nav li { margin: 0; }
.gg-nav a { display: block; padding: 0.5rem 0.8rem; color: var(--gg-navy); font-weight: 600; font-size: 0.97rem; text-decoration: none; border-radius: 8px; }
.gg-nav a:hover, .gg-nav .current-menu-item > a { background: var(--gg-mist); }
.gg-nav .sub-menu { display: none; }
.gg-header-search { margin-left: 0.25rem; }
.gg-has-hero .gg-header-search { display: none; }   /* the hero already has a big search box */
.gg-menu-toggle { display: none; }

@media (max-width: 860px) {
	.gg-brand img, .gg-brand .custom-logo { height: 38px; }
	.gg-menu-toggle {
		display: inline-flex; align-items: center; gap: 0.5rem;
		background: none; border: 1px solid var(--gg-line); border-radius: 8px;
		padding: 0.5rem 0.75rem; font: 600 0.95rem var(--gg-sans); color: var(--gg-navy); cursor: pointer;
	}
	.gg-menu-toggle svg { width: 18px; height: 18px; }
	.gg-nav { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--gg-white); border-bottom: 1px solid var(--gg-line); padding: 0.75rem var(--gg-gutter) 1.25rem; box-shadow: 0 12px 24px -16px rgba(15,53,80,.35); }
	.gg-nav.is-open { display: block; }
	.gg-has-hero .gg-header-search { display: block; }
	.gg-nav ul { flex-direction: column; align-items: stretch; }
	.gg-nav a { padding: 0.75rem 0.5rem; font-size: 1.05rem; }
	.gg-header-search { margin: 0.75rem 0 0; }
}

/* ---------- Search form ---------- */
.gg-search { display: flex; max-width: 100%; }
.gg-search input[type="search"] {
	flex: 1; min-width: 0; font: 500 1rem var(--gg-sans); color: var(--gg-ink);
	padding: 0.65rem 0.9rem; border: 1px solid var(--gg-line); border-right: 0;
	border-radius: 8px 0 0 8px; background: var(--gg-white);
}
.gg-search button {
	font: 700 0.95rem var(--gg-sans); padding: 0 1rem; border: 0; cursor: pointer;
	background: var(--gg-navy); color: var(--gg-white); border-radius: 0 8px 8px 0;
}
.gg-search button:hover { background: var(--gg-blue); }
.gg-header .gg-search input[type="search"] { width: 11rem; padding: 0.45rem 0.75rem; font-size: 0.93rem; }
.gg-header .gg-search button { font-size: 0.88rem; }
@media (max-width: 860px) { .gg-header .gg-search input[type="search"] { width: auto; } }

/* ---------- Hero (home) ---------- */
.gg-hero { background: var(--gg-navy); color: #DCEAF3; position: relative; padding: clamp(3rem, 8vw, 5.5rem) 0 clamp(4.5rem, 9vw, 6.5rem); }
.gg-hero h1 { color: var(--gg-white); font-size: clamp(2.4rem, 1.5rem + 4vw, 4rem); max-width: 18ch; margin-bottom: 0.4em; text-wrap: balance; }
.gg-hero p { font-size: clamp(1.05rem, 1rem + 0.4vw, 1.25rem); max-width: 38rem; margin-bottom: 1.6rem; }
.gg-hero .gg-search { max-width: 34rem; }
.gg-hero .gg-search input[type="search"] { border-color: transparent; padding: 0.9rem 1rem; font-size: 1.05rem; }
.gg-hero .gg-search button { background: var(--gg-gold); color: var(--gg-navy); padding: 0 1.3rem; font-size: 1rem; }
.gg-hero .gg-search button:hover { background: #E8BD55; }
.gg-hero-grains { position: absolute; right: max(var(--gg-gutter), calc((100vw - var(--gg-wide)) / 2 + 2rem)); top: 22%; width: clamp(90px, 16vw, 190px); opacity: 0.9; pointer-events: none; }
@media (max-width: 700px) { .gg-hero-grains { display: none; } }

/* The wave: the one recurring brand gesture (from the logo). */
.gg-wave { display: block; width: 100%; height: clamp(28px, 4vw, 56px); }
.gg-wave--hero { position: absolute; left: 0; right: 0; bottom: -1px; }
.gg-wave--footer { margin-bottom: -1px; }

/* ---------- Post lists ---------- */
.gg-main { padding: clamp(2rem, 5vw, 3.5rem) 0 4rem; }
.gg-section-title { font-size: clamp(1.4rem, 1.2rem + 0.8vw, 1.75rem); margin: 0 0 1.25rem; }
.gg-archive-head { padding: clamp(2rem, 5vw, 3rem) 0 0.5rem; }
.gg-archive-head p { color: var(--gg-slate); max-width: var(--gg-read); }

.gg-list { display: grid; grid-template-columns: 1fr; gap: 0; border-top: 1px solid var(--gg-line); }
.gg-item { display: grid; grid-template-columns: 1fr; gap: 0.35rem; padding: 1.5rem 0; border-bottom: 1px solid var(--gg-line); }
.gg-item h2, .gg-item h3 { font-size: clamp(1.2rem, 1.1rem + 0.5vw, 1.45rem); margin: 0; }
.gg-item h2 a, .gg-item h3 a { color: var(--gg-navy); text-decoration: none; }
.gg-item h2 a:hover, .gg-item h3 a:hover { color: var(--gg-blue); text-decoration: underline; }
.gg-item p { margin: 0; color: var(--gg-slate); max-width: 46rem; }
.gg-item .gg-meta { margin-top: 0.15rem; }
.gg-item--lead { padding: 2rem 0; }
.gg-item--lead h2 { font-size: clamp(1.6rem, 1.3rem + 1.4vw, 2.2rem); }
.gg-item--lead p { font-size: 1.1rem; }
@media (min-width: 900px) {
	.gg-list--home { grid-template-columns: 1fr 1fr; column-gap: 3rem; }
	.gg-list--home .gg-item--lead { grid-column: 1 / -1; }
}
.gg-thumb { display: block; border-radius: var(--gg-radius); overflow: hidden; margin-bottom: 0.6rem; aspect-ratio: 16 / 9; background: var(--gg-mist); }
.gg-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.gg-meta { color: var(--gg-slate); font-size: 0.9rem; }
.gg-meta a { color: inherit; }

.pagination, .nav-links { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 2.5rem; }
.page-numbers { padding: 0.45rem 0.85rem; border: 1px solid var(--gg-line); border-radius: 8px; text-decoration: none; color: var(--gg-navy); font-weight: 600; background: var(--gg-white); }
.page-numbers.current { background: var(--gg-navy); color: var(--gg-white); border-color: var(--gg-navy); }

/* ---------- Single article ---------- */
.gg-article { background: var(--gg-white); }
.gg-article-head { padding: clamp(1.75rem, 5vw, 3rem) 0 1.25rem; }
.gg-crumbs { font-size: 0.9rem; color: var(--gg-slate); margin-bottom: 1rem; }
.gg-crumbs a { color: var(--gg-slate); }
.gg-crumbs span[aria-hidden] { margin: 0 0.35rem; }
.gg-article-head h1 { margin-bottom: 0.5rem; }
.gg-byline { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.9rem; color: var(--gg-slate); font-size: 0.93rem; }
.gg-byline img { border-radius: 50%; width: 32px; height: 32px; }
.gg-byline strong { color: var(--gg-navy); font-weight: 600; }
.gg-featured { margin: 1.5rem 0 0; }
.gg-featured img { border-radius: var(--gg-radius); width: 100%; display: block; }

.entry-content { padding-bottom: 3rem; }
.entry-content > *:first-child { margin-top: 0; }
.entry-content h2 { scroll-margin-top: 1.5rem; }
.entry-content img { border-radius: 8px; }
.entry-content blockquote {
	margin-left: 0; margin-right: 0; padding: 1rem 1.25rem;
	border-left: 4px solid var(--gg-water); background: var(--gg-mist); border-radius: 0 var(--gg-radius) var(--gg-radius) 0;
}
.entry-content blockquote > *:last-child { margin-bottom: 0; }

/* Quick Answer / Quick Fix box — the first thing every reader sees. */
.entry-content .gg-answer {
	position: relative; border: 1px solid #CBE4F1; border-left: 0; border-radius: var(--gg-radius);
	background: var(--gg-mist); padding: 1.35rem 1.4rem 1.2rem 1.6rem; margin-bottom: 1.5rem;
	box-shadow: inset 5px 0 0 var(--gg-navy);
}
.entry-content .gg-answer::before {
	content: ""; position: absolute; top: 1.05rem; right: 1.1rem; width: 34px; height: 20px;
	background:
		radial-gradient(circle at 6px 12px, var(--gg-gold) 0 4px, transparent 4.5px),
		radial-gradient(circle at 18px 5px, var(--gg-gold) 0 3.2px, transparent 3.7px),
		radial-gradient(circle at 26px 14px, var(--gg-gold) 0 2.8px, transparent 3.3px);
	opacity: 0.9;
}
.entry-content .gg-answer > p:first-child { padding-right: 2.5rem; }
.entry-content .gg-answer table { background: var(--gg-white); }

/* Tables: scroll sideways on phones instead of breaking the layout */
.gg-table { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 0 1.5em; border: 1px solid var(--gg-line); border-radius: var(--gg-radius); background: var(--gg-white); }
.gg-table table { margin: 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; line-height: 1.5; }
th, td { text-align: left; vertical-align: top; padding: 0.7rem 0.85rem; border-bottom: 1px solid var(--gg-line); }
th { font-weight: 700; color: var(--gg-navy); background: var(--gg-foam); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
@media (max-width: 640px) { th, td { padding: 0.6rem 0.65rem; } table { font-size: 0.9rem; } .gg-table table { min-width: 34rem; } }

/* Amazon "Check price" links become buttons (added by functions.php) */
.gg-buy {
	display: inline-flex; align-items: center; gap: 0.45rem; margin: 0.2rem 0;
	background: var(--gg-navy); color: var(--gg-white) !important; text-decoration: none !important;
	font-weight: 700; font-size: 0.95rem; padding: 0.6rem 1.05rem; border-radius: 8px; line-height: 1.2;
}
.gg-buy::after { content: ""; width: 0.55em; height: 0.55em; border-top: 2px solid currentColor; border-right: 2px solid currentColor; transform: rotate(45deg); }
.gg-buy:hover { background: var(--gg-blue); }
td .gg-buy, .gg-answer .gg-buy { font-size: 0.85rem; padding: 0.45rem 0.75rem; white-space: nowrap; }

/* Table of contents */
.gg-toc { border: 1px solid var(--gg-line); border-radius: var(--gg-radius); padding: 0.85rem 1.1rem; margin: 0 0 2rem; background: var(--gg-foam); }
.gg-toc summary { cursor: pointer; font-weight: 700; color: var(--gg-navy); }
.gg-toc ol { margin: 0.75rem 0 0.25rem; padding-left: 1.2em; font-size: 0.97rem; }
.gg-toc li { margin-bottom: 0.3rem; }
.gg-toc a { text-decoration: none; }
.gg-toc a:hover { text-decoration: underline; }

/* Affiliate disclosure line (the italic paragraph right after the answer box) */
.entry-content .gg-answer + p > em:only-child { font-size: 0.88rem; color: var(--gg-slate); }

/* Author box */
.gg-author { display: grid; grid-template-columns: 64px 1fr; gap: 1rem; align-items: start; padding: 1.5rem; border: 1px solid var(--gg-line); border-radius: var(--gg-radius); background: var(--gg-foam); margin-bottom: 3rem; }
.gg-author img { border-radius: 50%; width: 64px; height: 64px; }
.gg-author h2 { font-size: 1.15rem; margin: 0 0 0.25rem; }
.gg-author p { margin: 0; color: var(--gg-slate); font-size: 0.97rem; }
@media (max-width: 520px) { .gg-author { grid-template-columns: 1fr; } }

/* Pages */
.gg-page .entry-content { padding-top: 0.5rem; }

/* 404 / empty */
.gg-empty { padding: 4rem 0 5rem; }
.gg-empty .gg-search { max-width: 30rem; margin-top: 1.25rem; }

/* WordPress core alignment & captions */
.alignleft { float: left; margin: 0.3rem 1.5rem 1rem 0; }
.alignright { float: right; margin: 0.3rem 0 1rem 1.5rem; }
.aligncenter { display: block; margin-left: auto; margin-right: auto; }
.wp-caption-text, figcaption { font-size: 0.88rem; color: var(--gg-slate); margin-top: 0.4rem; }
.wp-block-image { margin-bottom: 1.5em; }

/* ---------- Footer ---------- */
.gg-footer { background: var(--gg-navy); color: #B9CCDA; font-size: 0.95rem; }
.gg-footer .gg-wrap { padding-top: 2rem; padding-bottom: 2.5rem; display: grid; gap: 1.5rem; }
.gg-footer-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1.25rem; }
.gg-footer img.gg-footer-logo { height: 56px; width: auto; }
.gg-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.gg-footer li { margin: 0; }
.gg-footer a { color: var(--gg-white); text-decoration: none; }
.gg-footer a:hover { text-decoration: underline; }
.gg-footer p { margin: 0; max-width: 52rem; }
.gg-footer .gg-copy { border-top: 1px solid rgba(255,255,255,.12); padding-top: 1.25rem; font-size: 0.88rem; }
