/*
Theme Name: BW Portfolio
Theme URI: http://brooks-williams.com/
Author: Built for Brooks Williams
Description: A quiet, image-first photography portfolio theme. Galleries use the standard WordPress Gallery block (no gallery plugin needed), with a full-screen viewer, several gallery layouts, and a one-time tool that moves galleries over from NextGEN Gallery. Appearance is set under Appearance → Customize → Portfolio Look.
Version: 1.0.0
Requires at least: 6.3
Tested up to: 7.1
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: bw-portfolio
*/

/* ------------------------------------------------------------------
   1. Tokens — colour schemes, type, spacing
   ------------------------------------------------------------------ */
:root {
	--bg: #0d0d0d;
	--bg-2: #161616;
	--fg: #e9e7e3;
	--muted: #8c8a86;
	--line: #2a2a2a;
	--accent: #d9ff5b;
	--overlay: rgba(8, 8, 8, .97);

	--font-body: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--font-display: "Hanken Grotesk", system-ui, sans-serif;
	--display-weight: 600;
	--display-track: .28em;
	--display-case: uppercase;

	--gap: 12px;
	--row: 300px;
	--tile: 260px;
	--cols: 3;
	--pad: clamp(16px, 4vw, 48px);
	--header-h: 84px;
	--side-w: 250px;
	--measure: 64ch;
}

body.bw-scheme-white {
	--bg: #ffffff;
	--bg-2: #f4f4f3;
	--fg: #141414;
	--muted: #75736f;
	--line: #e6e5e2;
	--accent: #141414;
	--overlay: rgba(255, 255, 255, .98);
}
body.bw-scheme-paper {
	--bg: #f1eee7;
	--bg-2: #e8e4db;
	--fg: #26241f;
	--muted: #6f695e;
	--line: #d9d3c6;
	--accent: #b4462b;
	--overlay: rgba(241, 238, 231, .98);
}
body.bw-scheme-graphite {
	--bg: #24272b;
	--bg-2: #2d3035;
	--fg: #e4e2dd;
	--muted: #979aa0;
	--line: #3a3e44;
	--accent: #ffb454;
	--overlay: rgba(28, 30, 33, .97);
}

body.bw-type-serif {
	--font-display: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
	--display-weight: 500;
	--display-track: .06em;
	--display-case: none;
}
body.bw-type-mono {
	--font-display: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
	--font-body: "IBM Plex Sans", system-ui, sans-serif;
	--display-weight: 500;
	--display-track: .14em;
	--display-case: uppercase;
}

body.bw-size-small  { --row: 210px; --tile: 180px; --cols: 4; }
body.bw-size-medium { --row: 300px; --tile: 260px; --cols: 3; }
body.bw-size-large  { --row: 430px; --tile: 380px; --cols: 2; }

body.bw-gap-none   { --gap: 0px; }
body.bw-gap-tight  { --gap: 4px; }
body.bw-gap-normal { --gap: 12px; }
body.bw-gap-airy   { --gap: 32px; }

@media (max-width: 700px) {
	body.bw-size-small  { --row: 130px; --tile: 110px; --cols: 2; }
	body.bw-size-medium { --row: 170px; --tile: 150px; --cols: 2; }
	body.bw-size-large  { --row: 240px; --tile: 100%; --cols: 1; }
	body.bw-gap-airy    { --gap: 16px; }
	:root { --header-h: 64px; }
}

/* ------------------------------------------------------------------
   2. 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; } }

body {
	margin: 0;
	background: var(--bg);
	color: var(--fg);
	font-family: var(--font-body);
	font-size: 16px;
	line-height: 1.6;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	transition: background-color .3s ease;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: .2em; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { background: var(--accent); color: var(--bg); }

.screen-reader-text {
	position: absolute !important; width: 1px; height: 1px; overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px); white-space: nowrap;
}
.skip-link:focus {
	clip: auto; width: auto; height: auto; z-index: 1000;
	top: 8px; left: 8px; padding: 10px 16px; background: var(--fg); color: var(--bg);
}

/* ------------------------------------------------------------------
   3. Header — top bar (default) and side column
   ------------------------------------------------------------------ */
.site-header {
	position: sticky; top: 0; z-index: 50;
	display: flex; align-items: center; justify-content: space-between; gap: 24px;
	min-height: var(--header-h);
	padding: 0 var(--pad);
	background: var(--bg);
}
.admin-bar .site-header { top: 32px; }
@media (max-width: 782px) { .admin-bar .site-header { top: 46px; } }
@media (max-width: 600px) { .admin-bar .site-header { top: 0; } }

.site-title {
	margin: 0;
	font-family: var(--font-display);
	font-weight: var(--display-weight);
	letter-spacing: var(--display-track);
	text-transform: var(--display-case);
	font-size: clamp(15px, 1.5vw, 19px);
	line-height: 1.2;
	white-space: nowrap;
}
body.bw-type-serif .site-title { font-size: clamp(22px, 2.2vw, 28px); }
.site-title a { text-decoration: none; }
.site-tagline { margin: 4px 0 0; color: var(--muted); font-size: 13px; letter-spacing: .02em; }

.main-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 28px; }
.main-nav li { position: relative; }
.main-nav a {
	display: inline-block; padding: 6px 0;
	text-decoration: none; font-size: 14px; letter-spacing: .06em;
	color: var(--muted);
	transition: color .2s ease;
}
body.bw-type-mono .main-nav a { font-family: var(--font-display); font-size: 13px; text-transform: uppercase; }
.main-nav a:hover, .main-nav .current-menu-item > a, .main-nav .current_page_item > a,
.main-nav .current-menu-ancestor > a, .main-nav .current_page_ancestor > a { color: var(--fg); }
.main-nav .current-menu-item > a, .main-nav .current_page_item > a {
	box-shadow: inset 0 -1px 0 var(--accent);
}
/* dropdowns */
.main-nav .sub-menu, .main-nav .children {
	position: absolute; left: -14px; top: 100%; min-width: 200px;
	display: block; padding: 10px 14px; background: var(--bg-2);
	border: 1px solid var(--line);
	opacity: 0; visibility: hidden; transform: translateY(4px);
	transition: opacity .15s ease, transform .15s ease, visibility .15s;
}
.main-nav li:hover > .sub-menu, .main-nav li:focus-within > .sub-menu,
.main-nav li:hover > .children, .main-nav li:focus-within > .children { opacity: 1; visibility: visible; transform: none; }
.main-nav .sub-menu a, .main-nav .children a { display: block; }

.menu-toggle {
	display: none;
	appearance: none; background: none; border: 0; color: var(--fg);
	font: inherit; font-size: 13px; letter-spacing: .12em; text-transform: uppercase;
	padding: 10px 0; cursor: pointer;
	align-items: center; gap: 10px;
}
.menu-toggle .bars { width: 22px; height: 10px; position: relative; display: inline-block; }
.menu-toggle .bars::before, .menu-toggle .bars::after {
	content: ""; position: absolute; left: 0; right: 0; height: 1.5px; background: currentColor;
	transition: transform .25s ease, top .25s ease;
}
.menu-toggle .bars::before { top: 0; }
.menu-toggle .bars::after { top: 8px; }
.nav-open .menu-toggle .bars::before { top: 4px; transform: rotate(45deg); }
.nav-open .menu-toggle .bars::after { top: 4px; transform: rotate(-45deg); }

@media (max-width: 900px) {
	.menu-toggle { display: inline-flex; }
	.main-nav {
		position: fixed; inset: var(--header-h) 0 0 0; z-index: 49;
		background: var(--bg); padding: 24px var(--pad);
		overflow-y: auto;
		opacity: 0; visibility: hidden; transform: translateY(-8px);
		transition: opacity .2s ease, transform .2s ease, visibility .2s;
	}
	.admin-bar .main-nav { top: calc(var(--header-h) + 46px); }
	.nav-open .main-nav { opacity: 1; visibility: visible; transform: none; }
	.main-nav ul { flex-direction: column; gap: 0; }
	.main-nav a { font-size: 24px; padding: 10px 0; color: var(--fg); font-family: var(--font-display); letter-spacing: .02em; text-transform: none; }
	.main-nav .sub-menu, .main-nav .children { position: static; opacity: 1; visibility: visible; transform: none; border: 0; background: none; padding: 0 0 0 18px; }
	.main-nav .sub-menu a, .main-nav .children a { font-size: 18px; color: var(--muted); }
	.nav-open { overflow: hidden; }
}

/* Side-column header (desktop only) */
@media (min-width: 1000px) {
	body.bw-header-side .site-wrap {
		display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr);
	}
	body.bw-header-side .site-header {
		position: sticky; top: 0; height: 100vh; min-height: 0;
		flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 48px;
		padding: 48px 32px 32px var(--pad);
		background: transparent;
	}
	body.admin-bar.bw-header-side .site-header { top: 32px; height: calc(100vh - 32px); }
	body.bw-header-side .site-title { white-space: normal; }
	body.bw-header-side .main-nav ul { flex-direction: column; gap: 2px; }
	body.bw-header-side .main-nav .sub-menu, body.bw-header-side .main-nav .children {
		position: static; opacity: 1; visibility: visible; transform: none; border: 0; background: none; padding: 0 0 6px 14px;
	}
	body.bw-header-side .site-main { padding-top: 48px; }
}

/* ------------------------------------------------------------------
   4. Layout
   ------------------------------------------------------------------ */
.site-main { padding: 24px var(--pad) 80px; min-height: 60vh; }
.entry-header { margin: 8px 0 32px; }
.entry-title {
	margin: 0;
	font-family: var(--font-display);
	font-weight: var(--display-weight);
	letter-spacing: calc(var(--display-track) * .5);
	text-transform: var(--display-case);
	font-size: clamp(16px, 1.8vw, 22px);
	line-height: 1.2;
}
body.bw-type-serif .entry-title { font-size: clamp(30px, 4vw, 52px); letter-spacing: 0; }
.entry-meta { margin-top: 8px; color: var(--muted); font-size: 13px; }

.entry-content > * { max-width: var(--measure); }
.entry-content > .wp-block-gallery,
.entry-content > .wp-block-image,
.entry-content > .alignwide,
.entry-content > .alignfull,
.entry-content > .wp-block-cover,
.entry-content > .wp-block-columns,
.entry-content > .wp-block-embed,
.entry-content > .wp-block-video,
.entry-content > .wp-block-media-text { max-width: none; }
.entry-content > .alignfull { margin-left: calc(var(--pad) * -1); margin-right: calc(var(--pad) * -1); }
.entry-content p, .entry-content li { font-size: 17px; }
.entry-content h2, .entry-content h3 { font-family: var(--font-display); font-weight: var(--display-weight); line-height: 1.25; margin: 2em 0 .6em; }
.entry-content .wp-block-image { margin: 0 0 var(--gap); }
.entry-content .wp-block-image figcaption,
.entry-content .wp-element-caption { color: var(--muted); font-size: 13px; margin-top: 8px; }
.entry-content hr { border: 0; border-top: 1px solid var(--line); margin: 48px 0; }
.entry-content blockquote { margin: 32px 0; padding-left: 20px; border-left: 2px solid var(--accent); font-style: italic; }

/* Pages where the text sits beside a photo (e.g. About) look better centred */
body.bw-center-text .entry-content > :not(.wp-block-gallery) { margin-left: auto; margin-right: auto; }

.page-links, .posts-navigation { margin-top: 48px; font-size: 14px; color: var(--muted); }
.posts-navigation .nav-links { display: flex; justify-content: space-between; }

.site-footer {
	padding: 32px var(--pad) 40px;
	color: var(--muted);
	font-size: 12px; letter-spacing: .08em;
	display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.site-footer a { text-decoration: none; }
.footer-nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 0; padding: 0; }
.site-footer a:hover { color: var(--fg); }

/* ------------------------------------------------------------------
   5. Galleries — the theme restyles the standard Gallery block.
   The class .bw-gal is added by the theme; the doubled :not(#…) keeps
   these rules ahead of WordPress's own gallery styles.
   ------------------------------------------------------------------ */
.bw-gal.wp-block-gallery { gap: var(--gap) !important; margin: 0 0 var(--gap); }
.bw-gal > figure.wp-block-image:not(#bwa):not(#bwb) {
	margin: 0; position: relative; overflow: hidden;
	background: var(--bg-2);
}
.bw-gal > figure.wp-block-image:not(#bwa):not(#bwb) > a { display: block; cursor: zoom-in; }
.bw-gal > figure.wp-block-image:not(#bwa):not(#bwb) img {
	cursor: zoom-in;
	transition: opacity .6s ease, transform .6s cubic-bezier(.2,.7,.2,1), filter .3s ease;
}
.bw-gal > figure.wp-block-image:not(#bwa):not(#bwb):hover img { transform: scale(1.015); }
body.bw-hover-dim .bw-gal:hover > figure.wp-block-image:not(#bwa):not(#bwb) img { filter: brightness(.72) saturate(.9); }
body.bw-hover-dim .bw-gal > figure.wp-block-image:not(#bwa):not(#bwb):hover img { filter: none; }

/* captions: hidden on thumbnails (shown in the viewer), unless "one at a time" */
.bw-gal > figure.wp-block-image:not(#bwa):not(#bwb) figcaption { display: none; }
.bw-gal > figure.wp-block-image:not(#bwa):not(#bwb)::before { display: none; }

/* fade in as photos load */
.bw-js .bw-gal > figure.wp-block-image:not(#bwa):not(#bwb) img.bw-pending { opacity: 0; }

/* 5a. Justified rows — every photo keeps its shape, rows line up */
.bw-gal--justified.wp-block-gallery { display: flex !important; flex-wrap: wrap; }
.bw-gal--justified::after { content: ""; flex: 1000000 1 0; }
.bw-gal--justified > figure.wp-block-image:not(#bwa):not(#bwb) {
	/* grow in proportion to the photo's shape (x100 so a lone photo still fills its row) */
	flex: calc(var(--r, 1.5) * 100) 1 calc(var(--r, 1.5) * var(--row));
	width: auto !important;
	max-width: 100%;
}
.bw-gal--justified > figure.wp-block-image:not(#bwa):not(#bwb) img {
	width: 100% !important; height: auto !important;
	aspect-ratio: var(--r, 1.5); object-fit: cover;
}

/* 5b. Square grid */
.bw-gal--grid.wp-block-gallery {
	display: grid !important;
	grid-template-columns: repeat(auto-fill, minmax(min(var(--tile), 100%), 1fr));
}
.bw-gal--grid > figure.wp-block-image:not(#bwa):not(#bwb) { width: auto !important; aspect-ratio: 1; }
.bw-gal--grid > figure.wp-block-image:not(#bwa):not(#bwb) > a { height: 100%; }
.bw-gal--grid > figure.wp-block-image:not(#bwa):not(#bwb) img {
	width: 100% !important; height: 100% !important; object-fit: cover;
}

/* 5c. Masonry columns */
.bw-gal--masonry.wp-block-gallery { display: block !important; column-count: var(--cols); column-gap: var(--gap); }
.bw-gal--masonry > figure.wp-block-image:not(#bwa):not(#bwb) {
	width: 100% !important; display: block; break-inside: avoid; margin: 0 0 var(--gap);
}
.bw-gal--masonry > figure.wp-block-image:not(#bwa):not(#bwb) img {
	width: 100% !important; height: auto !important; aspect-ratio: var(--r, auto); object-fit: cover;
}

/* 5d. One at a time — large, stacked, with captions */
.bw-gal--single.wp-block-gallery { display: flex !important; flex-direction: column; align-items: center; gap: clamp(32px, 8vh, 96px) !important; }
.bw-gal--single > figure.wp-block-image:not(#bwa):not(#bwb) {
	width: 100% !important; max-width: 1400px; background: none; overflow: visible;
	display: flex; flex-direction: column; align-items: center;
}
.bw-gal--single > figure.wp-block-image:not(#bwa):not(#bwb) > a { width: 100%; }
.bw-gal--single > figure.wp-block-image:not(#bwa):not(#bwb) img {
	margin-left: auto; margin-right: auto;
	width: auto !important; height: auto !important; max-width: 100% !important;
	max-height: calc(100vh - var(--header-h) - 80px); object-fit: contain;
}
.bw-gal--single > figure.wp-block-image:not(#bwa):not(#bwb):hover img { transform: none; }
.bw-gal--single > figure.wp-block-image:not(#bwa):not(#bwb) figcaption {
	display: block; position: static; background: none; color: var(--muted);
	text-shadow: none; padding: 12px 0 0; font-size: 13px; overflow: visible;
}

/* ------------------------------------------------------------------
   6. Home page
   ------------------------------------------------------------------ */
.bw-home { padding-top: 8px; }

/* 6a. Single hero image — fits the screen */
.bw-home-single .entry-content .wp-block-image img,
.bw-home-single .bw-hero-img {
	max-height: calc(100vh - var(--header-h) - 110px); width: auto; margin: 0 auto; object-fit: contain;
}
.bw-home-single .entry-content > * { margin-left: auto; margin-right: auto; }
.bw-home-single .entry-content .wp-block-image { display: flex; flex-direction: column; align-items: center; }

/* 6b. Slideshow */
.bw-slideshow {
	position: relative; margin: 0 auto;
	height: calc(100vh - var(--header-h) - 110px); min-height: 320px;
}
body.bw-header-side .bw-slideshow { height: calc(100vh - 150px); }
.bw-slide {
	position: absolute; inset: 0; margin: 0;
	opacity: 0; transition: opacity 1.4s ease;
	display: flex; align-items: center; justify-content: center;
}
.bw-slide.is-active { opacity: 1; }
.bw-slide img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.bw-slideshow-ui {
	display: flex; align-items: center; justify-content: space-between; gap: 16px;
	margin-top: 18px; color: var(--muted); font-size: 12px; letter-spacing: .1em;
}
.bw-slideshow-ui button {
	appearance: none; background: none; border: 0; color: inherit; font: inherit; letter-spacing: inherit;
	cursor: pointer; padding: 6px 0; text-transform: uppercase;
}
.bw-slideshow-ui button:hover { color: var(--fg); }
.bw-slide-count { font-variant-numeric: tabular-nums; }
.bw-progress { flex: 1; height: 1px; background: var(--line); position: relative; overflow: hidden; max-width: 320px; }
.bw-progress span { position: absolute; inset: 0; background: var(--fg); transform-origin: left; transform: scaleX(0); }
.bw-progress span.run { transition: transform linear; transform: scaleX(1); }

/* 6c. Index of galleries */
.bw-index {
	display: grid; gap: calc(var(--gap) + 20px) var(--gap);
	grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
}
.bw-index a { text-decoration: none; display: block; }
.bw-index .bw-tile-img { aspect-ratio: 4 / 3; overflow: hidden; background: var(--bg-2); }
.bw-index .bw-tile-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .8s cubic-bezier(.2,.7,.2,1); }
.bw-index a:hover .bw-tile-img img { transform: scale(1.03); }
.bw-index .bw-tile-title {
	display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
	margin-top: 12px; font-family: var(--font-display); font-weight: var(--display-weight);
	letter-spacing: calc(var(--display-track) * .5); text-transform: var(--display-case); font-size: 14px;
}
body.bw-type-serif .bw-index .bw-tile-title { font-size: 22px; }
.bw-index .bw-tile-count { color: var(--muted); font-family: var(--font-body); font-size: 12px; letter-spacing: .06em; text-transform: none; font-weight: 400; }

/* ------------------------------------------------------------------
   7. Full-screen viewer (lightbox)
   ------------------------------------------------------------------ */
.bw-lb {
	position: fixed; inset: 0; z-index: 100000;
	background: var(--overlay); color: var(--fg);
	display: grid; grid-template-rows: auto 1fr auto;
	opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s;
	touch-action: pan-y pinch-zoom;
}
.bw-lb.is-open { opacity: 1; visibility: visible; }
.bw-lb-top, .bw-lb-bottom {
	display: flex; align-items: center; justify-content: space-between; gap: 16px;
	padding: 14px var(--pad); font-size: 12px; letter-spacing: .1em; color: var(--muted);
	min-height: 56px;
}
.bw-lb-count { font-variant-numeric: tabular-nums; }
.bw-lb-stage { position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 0 clamp(8px, 6vw, 96px); }
.bw-lb-img {
	max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
	user-select: none; -webkit-user-drag: none;
	transition: opacity .25s ease, transform .25s ease;
}
.bw-lb-img.is-loading { opacity: 0; }
.bw-lb button {
	appearance: none; background: none; border: 0; color: var(--muted); cursor: pointer;
	font: inherit; letter-spacing: inherit; padding: 8px; line-height: 0;
	transition: color .15s ease;
}
.bw-lb button:hover { color: var(--fg); }
.bw-lb-nav { position: absolute; top: 0; bottom: 0; width: 18%; min-width: 56px; display: flex; align-items: center; }
.bw-lb-prev { left: 0; justify-content: flex-start; padding-left: clamp(8px, 2vw, 32px) !important; }
.bw-lb-next { right: 0; justify-content: flex-end; padding-right: clamp(8px, 2vw, 32px) !important; }
.bw-lb-caption { flex: 1; text-align: center; font-size: 14px; letter-spacing: .02em; color: var(--fg); }
.bw-lb-caption:empty { visibility: hidden; }
.bw-lb svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.3; }
.bw-lb-spinner {
	position: absolute; width: 28px; height: 28px; border-radius: 50%;
	border: 1.5px solid var(--line); border-top-color: var(--fg);
	animation: bw-spin .8s linear infinite; opacity: 0; transition: opacity .2s;
}
.bw-lb.is-loading .bw-lb-spinner { opacity: 1; }
@keyframes bw-spin { to { transform: rotate(360deg); } }
@media (hover: none) { .bw-lb-nav { display: none; } }
@media (prefers-reduced-motion: reduce) {
	.bw-lb, .bw-lb-img, .bw-slide, .bw-gal img { transition: none !important; }
}

/* ------------------------------------------------------------------
   8. Misc
   ------------------------------------------------------------------ */
.bw-empty { color: var(--muted); padding: 40px 0; }
.search-form input { font: inherit; padding: 8px 10px; background: var(--bg-2); color: var(--fg); border: 1px solid var(--line); }
.alignleft { float: left; margin: 0 24px 16px 0; }
.alignright { float: right; margin: 0 0 16px 24px; }
.aligncenter { margin-left: auto; margin-right: auto; }
.wp-caption-text { color: var(--muted); font-size: 13px; }
.sticky, .bypostauthor, .gallery-caption { }
