/*
Theme Name: Ali v2
Author: Danny Vink
Author URI: https://www.dannyvink.com/
Description: Sketchbook + orange portfolio theme for Ali Edwards. Homepage carousel and portfolio tiles are managed in WP admin (Homepage Carousel; Posts > Categories) via the "Ali Site" must-use plugin.
Version: 2.0.0
Requires PHP: 8.1
Text Domain: ali
*/

:root {
	--paper: #fbf8f3;
	--ink: #232020;
	--soft: #6e6762;
	--accent: #f2821e;       /* orange from Ali's mockup */
	--accent-dark: #d96a0c;
	--accent-ink: #a9550a;   /* darker orange for small text/icons: links, arrow chevrons (5:1 on paper, ≥4.5:1 under colour-blindness simulations) */
	--frame: #eeeae4;
	--line: #dcd6cd;
	--display: "Luckiest Guy", "Arial Black", Impact, sans-serif;
	--text: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
	--wrap: 1240px;
	--gutter: max(4vw, 16px);
}

/* ---- Base ---- */
html { scroll-behavior: smooth; }
body {
	background: var(--paper);
	color: var(--ink);
	font-family: var(--text);
	font-size: 16px;
	line-height: 1.6;
	overflow-x: clip;
}
a { color: var(--accent-ink); }
a:hover { color: var(--accent-dark); }
img { max-width: 100%; height: auto; }
h1, h2, h3, h4 { color: var(--ink); font-family: var(--text); font-weight: 500; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 4px; }
.skip-link:focus { left: 8px; color: #fff; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.wrap.narrow { max-width: 920px; }
.wrap.wide { max-width: 1680px; }

/* The display face: orange with an ink offset. */
.display-heading,
.site-title {
	font-family: var(--display);
	font-weight: 400;
	color: var(--accent);
	letter-spacing: .03em;
	line-height: 1.05;
	text-transform: none;
}
.display-heading {
	font-size: clamp(30px, 4vw, 42px);
	text-shadow: 2px 2px 0 var(--ink);
	text-align: center;
	margin: 0 0 24px;
}

/* ---- Header ---- */
#site-header { padding-top: 28px; }
.site-brand { position: relative; text-align: center; padding: 0 64px; }
.site-title { font-size: clamp(42px, 7.4vw, 82px); margin: 0; text-shadow: 3px 3px 0 var(--ink); }
.site-title a { color: inherit; text-decoration: none; }
.site-title a:hover { color: var(--accent-dark); text-decoration: none; }
.site-tagline {
	margin: 8px 0 0;
	font-size: 13px;
	letter-spacing: .16em;
	text-transform: uppercase;
	color: var(--soft);
}
.site-social { position: absolute; top: 4px; right: var(--gutter); width: 30px; height: 30px; color: var(--ink); }
.site-social:hover { color: var(--accent); }
.site-social svg { width: 100%; height: 100%; display: block; }

.hand-rule { display: block; width: 100%; height: 24px; margin-top: 18px; }
.hand-rule path { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; vector-effect: non-scaling-stroke; }

.site-nav ul { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px clamp(24px, 6vw, 80px); list-style: none; margin: 0; padding: 6px 16px 26px; }
.site-nav a {
	position: relative;
	color: var(--ink);
	text-decoration: none;
	text-transform: uppercase;
	letter-spacing: .12em;
	font-weight: 500;
	font-size: 15px;
	padding-bottom: 4px;
	transition: color .2s;
}
/* Hand-drawn squiggle under the current page (same style as the header rule); a lighter one on hover. */
.site-nav a::after {
	content: "";
	position: absolute;
	left: -6px;
	right: -6px;
	bottom: -8px;
	height: 9px;
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 9' preserveAspectRatio='none'%3E%3Cpath d='M2 4.5 Q7 3.7 12 4.5 Q17 4.2 22 4.1 Q27 5.1 32 4.4 Q37 4.5 42 4.5 Q47 4.5 52 4.3 Q57 4.0 62 4.7 Q67 3.9 72 4.4 Q77 4.6 82 4.8 Q87 4.3 92 4.1 Q97 4.0 102 4.7 Q107 4.6 112 4.5 L118 4.5' fill='none' stroke='%23f2821e' stroke-width='2' stroke-linecap='round' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E") no-repeat center / 100% 100%;
	opacity: 0;
	transform: scaleX(.6);
	transition: opacity .2s, transform .25s ease;
}
.site-nav a:hover { color: var(--ink); text-decoration: none; }
.site-nav a:hover::after { opacity: .45; transform: scaleX(1); }
.site-nav .current-menu-item > a::after,
.site-nav .current-menu-ancestor > a::after,
.site-nav .current-category-ancestor > a::after { opacity: 1; transform: none; }

#site-content { padding: 8px 0 56px; }

/* ---- Carousel: a deck of cards ----
   Each slide is a white "print" sized to its image, stacked with slight offsets.
   data-pos: 0 = top card, 1-2 = visible behind it, 3 = hidden at the back. */
.carousel { --deck-h: clamp(300px, 38vw, 500px); margin-bottom: 40px; }
.carousel-frame { position: relative; height: var(--deck-h); touch-action: pan-y; }
.slide {
	position: absolute;
	left: 50%;
	top: 50%;
	padding: 10px;
	background: #fff;
	border-radius: 4px;
	box-shadow: 0 1px 2px rgba(35, 32, 32, .12), 0 8px 22px rgba(35, 32, 32, .14);
	transform-origin: 50% 60%;
	transition: transform .6s cubic-bezier(.2, .7, .2, 1), opacity .4s, box-shadow .4s;
}
.slide a { display: block; }
.slide-zoom { cursor: zoom-in; }
.slide img {
	display: block;
	width: auto;
	height: auto;
	max-height: calc(var(--deck-h) - 64px);
	max-width: calc(min(1240px, 100vw) - 2 * var(--gutter) - 90px);
	border-radius: 2px;
}
.slide[data-pos="0"] { z-index: 30; transform: translate(-50%, -50%) rotate(0deg); }
.slide[data-pos="1"] { z-index: 20; transform: translate(calc(-50% + 22px), calc(-50% + 10px)) rotate(3deg); }
.slide[data-pos="2"] { z-index: 10; transform: translate(calc(-50% - 20px), calc(-50% + 14px)) rotate(-3.5deg); }
.slide[data-pos="3"] { z-index: 0; opacity: 0; transform: translate(calc(-50% - 20px), calc(-50% + 14px)) rotate(-3.5deg); }
.slide:not([data-pos="0"]) { pointer-events: none; box-shadow: 0 1px 2px rgba(35, 32, 32, .1), 0 4px 12px rgba(35, 32, 32, .1); }
/* Forward: the top card swings out to the left and tucks under the back of the deck. */
.slide.deal-out { animation: ae-deal-out .9s cubic-bezier(.3, .6, .25, 1) both; }
/* Backward: the back card swings out and lands on top. */
.slide.deal-in { animation: ae-deal-in .9s cubic-bezier(.3, .6, .25, 1) both; }
@keyframes ae-deal-out {
	0%   { z-index: 40; transform: translate(-50%, -50%) rotate(0deg); }
	45%  { z-index: 40; transform: translate(calc(-50% - 62%), calc(-50% - 4%)) rotate(-11deg); }
	55%  { z-index: 1; }
	100% { z-index: 1; transform: translate(calc(-50% - 20px), calc(-50% + 14px)) rotate(-3.5deg); }
}
@keyframes ae-deal-in {
	0%   { z-index: 1; opacity: 1; transform: translate(calc(-50% - 20px), calc(-50% + 14px)) rotate(-3.5deg); }
	45%  { z-index: 1; opacity: 1; transform: translate(calc(-50% - 62%), calc(-50% - 4%)) rotate(-11deg); }
	55%  { z-index: 40; }
	100% { z-index: 40; opacity: 1; transform: translate(-50%, -50%) rotate(0deg); }
}

/* Arrows: outlined in orange on paper; on hover, orange fill, white chevron, dark shadow. */
.carousel-arrow {
	position: absolute;
	top: 50%;
	z-index: 60; /* above the cards */
	width: 46px;
	height: 46px;
	margin-top: -23px;
	padding: 0;
	display: grid;
	place-items: center;
	border-radius: 50%;
	border: 2px solid var(--accent);
	background: var(--paper);
	color: var(--accent);
	box-shadow: 2px 2px 0 var(--accent);
	cursor: pointer;
	transition: background .2s, color .2s, transform .1s, box-shadow .1s;
}
.carousel-arrow.prev { left: 14px; }
.carousel-arrow.next { right: 14px; }
.carousel-arrow svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
/* Hover matches the portfolio tiles: dark offset shadow. */
.carousel-arrow:hover { background: var(--accent); color: #fff; box-shadow: 3px 4px 0 rgba(35, 32, 32, .85); }
.carousel-arrow:active { transform: translate(2px, 2px); box-shadow: 0 0 0 rgba(35, 32, 32, .85); }

/* Dots: orange outlines; the active one is filled and slightly larger (size + fill, not just colour). */
.carousel-dots { display: flex; justify-content: center; gap: 12px; margin-top: 22px; }
.carousel-dots button {
	width: 15px; height: 15px; padding: 0;
	border-radius: 50%;
	border: 2px solid var(--accent);
	background: transparent;
	cursor: pointer;
	position: relative;
}
.carousel-dots button::after { content: ""; position: absolute; inset: -14px; } /* bigger touch target */
.carousel-dots button.is-active { background: var(--accent); transform: scale(1.15); }

/* ---- Portfolio tiles ---- */
.portfolio { scroll-margin-top: 24px; }
.tiles {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: clamp(14px, 2.4vw, 32px);
	list-style: none;
	margin: 0;
	padding: 0;
}
.tile { position: relative; display: block; aspect-ratio: 1; transition: transform .3s ease, filter .3s ease; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Scale the whole tile (borders included) and follow the image's shape for the shadow (some tiles have transparent margins). */
.tile:hover, .tile:focus-visible { transform: scale(1.04); filter: drop-shadow(4px 5px 0 rgba(35, 32, 32, .85)); z-index: 1; }
.tile-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Archive / gallery ---- */
.archive-header { text-align: center; margin: 8px 0 24px; }
.archive-header .display-heading { margin-bottom: 8px; }
.archive-desc { color: var(--soft); max-width: 640px; margin: 0 auto; }
.back-link { display: inline-block; font-size: 14px; letter-spacing: .04em; color: var(--soft); text-decoration: none; margin-bottom: 10px; }
.back-link:hover { color: var(--accent-ink); text-decoration: none; }
.empty { text-align: center; color: var(--soft); }

#portfolio-gallery { margin: 0 -6px; }
#portfolio-gallery .grid-sizer,
#portfolio-gallery .grid-item { width: 100%; }
#portfolio-gallery .grid-item { padding: 6px; opacity: 0; transition: opacity .5s; }
#portfolio-gallery .grid-item.faded { opacity: 1; }
#portfolio-gallery .grid-item a { display: block; }
#portfolio-gallery .grid-item img { width: 100%; display: block; border-radius: 2px; transition: box-shadow .25s; }
#portfolio-gallery .grid-item a:hover img { box-shadow: 4px 4px 0 var(--ink); }

/* Lightbox: thumbnails as a horizontal strip along the bottom (not the default right-hand column).
   Selectors are prefixed with .fancybox-container because fancybox's own CSS loads after the theme's. */
.fancybox-container .fancybox-bg { background: #1d1a1b; }
.fancybox-container.fancybox-is-open .fancybox-bg { opacity: .95; }
.fancybox-container .fancybox-caption { text-align: center; font-family: var(--text); font-size: 15px; }
.fancybox-container .fancybox-caption a { color: #fff; text-decoration: underline; }
.fancybox-container .fancybox-thumbs {
	top: auto;
	left: 0;
	right: 0;
	bottom: 0;
	width: auto;
	height: 96px;
	padding: 10px 12px 0;
	background: rgba(0, 0, 0, .4);
}
.fancybox-container .fancybox-thumbs__list {
	display: flex;
	justify-content: center;
	gap: 0;
	white-space: nowrap;
	overflow-x: auto;
	overflow-y: hidden;
	width: 100% !important;
	height: 100%;
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 255, 255, .35) transparent;
}
.fancybox-container .fancybox-thumbs__list a { flex: 0 0 auto; float: none; width: 100px; height: 76px; max-width: none; max-height: none; border-radius: 3px; background-color: rgba(255, 255, 255, .08); }
.fancybox-container .fancybox-thumbs__list a::before { border-color: var(--accent); border-width: 3px; border-radius: 3px; }
.fancybox-container .fancybox-thumbs__list::-webkit-scrollbar { height: 6px; }
.fancybox-container .fancybox-thumbs__list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .35); border-radius: 6px; }
.fancybox-container.fancybox-show-thumbs .fancybox-inner { right: 0; bottom: 96px; }

/* ---- Pages / posts ---- */
.entry-content { font-size: 17px; }
.entry-content img { height: auto; }
.entry-content .wp-block-image { margin-bottom: 28px; }
.entry-content figcaption { color: var(--soft); font-size: 14px; text-align: center; }
.entry-hero { margin: 0 0 28px; }
.entry-hero img { width: 100%; border-radius: 3px; }
.flex-image-width img { width: 100%; height: auto; }

/* ---- Contact ---- */
.contact { margin-top: 28px; }
.contact-form { max-width: 620px; }
.contact-form .field { margin-bottom: 18px; }
.contact-form label { display: block; font-weight: 600; font-size: 14px; letter-spacing: .04em; margin-bottom: 6px; }
.contact-form input,
.contact-form textarea {
	width: 100%;
	font: inherit;
	font-size: 16px;
	padding: 11px 13px;
	color: var(--ink);
	background: #fff;
	border: 1.5px solid var(--line);
	border-radius: 4px;
	transition: border-color .2s, box-shadow .2s;
}
.contact-form input:focus,
.contact-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(242, 130, 30, .22); }
.btn-send {
	font-family: var(--display);
	font-size: 20px;
	letter-spacing: .05em;
	color: var(--ink);
	background: var(--accent);
	border: 2px solid var(--ink);
	border-radius: 6px;
	padding: 10px 26px 7px;
	box-shadow: 3px 3px 0 var(--ink);
	cursor: pointer;
	transition: transform .1s, box-shadow .1s, background .2s;
}
.btn-send:hover { background: var(--accent-dark); }
.btn-send:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.ae-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.notice { border-radius: 6px; padding: 14px 18px; margin-bottom: 20px; border: 1.5px solid; }
.notice p { margin: 0; }
.notice-ok { border-color: #2f7a4f; background: #eef7f1; }
.notice-err { border-color: var(--accent-dark); background: #fdf1e6; }

/* ---- Footer ---- */
#site-footer { border-top: 1px solid var(--line); text-align: center; color: var(--soft); font-size: 13px; padding: 20px var(--gutter); }
#site-footer p { margin: 0; }

/* ---- Responsive ---- */
@media (min-width: 576px) {
	#portfolio-gallery .grid-sizer,
	#portfolio-gallery .grid-item { width: 50%; }
	#portfolio-gallery .grid-item-w2 { width: 100%; }
}
@media (min-width: 768px) {
	#portfolio-gallery .grid-sizer,
	#portfolio-gallery .grid-item { width: 33.333%; }
	#portfolio-gallery .grid-item-w2 { width: 66.666%; }
}
/* Wide screens: arrows sit just outside the deck area so they never cover the art. */
@media (min-width: 1400px) {
	.carousel-arrow.prev { left: -66px; }
	.carousel-arrow.next { right: -66px; }
}
@media (max-width: 991px) {
	.tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 575px) {
	#site-header { padding-top: 20px; }
	.site-brand { padding: 0 44px; }
	.site-social { width: 24px; height: 24px; top: 2px; }
	.site-tagline { font-size: 11px; letter-spacing: .12em; }
	.site-nav a { font-size: 13px; }
	.carousel { --deck-h: clamp(240px, 78vw, 360px); }
	.slide { padding: 6px; }
	.slide img { max-height: calc(var(--deck-h) - 44px); max-width: calc(100vw - 2 * var(--gutter) - 40px); }
	.slide[data-pos="1"] { transform: translate(calc(-50% + 10px), calc(-50% + 6px)) rotate(2.5deg); }
	.slide[data-pos="2"],
	.slide[data-pos="3"] { transform: translate(calc(-50% - 9px), calc(-50% + 8px)) rotate(-3deg); }
	.carousel-arrow { width: 38px; height: 38px; margin-top: -19px; }
	.carousel-arrow.prev { left: 8px; }
	.carousel-arrow.next { right: 8px; }
}
@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	.slide, .tile, .carousel-arrow { transition: none; }
	.slide.deal-out, .slide.deal-in { animation: none; }
}

/* Visually hidden but still read by screen readers (page titles: the nav already shows where you are). */
.screen-reader-text { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.page .entry { padding-top: 12px; }

/* Password form for protected categories */
.ae-pw-form { margin: 8px auto 0; max-width: 460px; text-align: left; }
.ae-pw-intro { text-align: center; margin-bottom: 22px; }
.ae-pw-form .btn-send { width: 100%; }

/* Title row with a back chevron button (category pages, posts, password form).
   Three columns keep the title centred: button | title | empty spacer of the same width. */
.title-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; margin-bottom: 24px; }
.title-row .display-heading { margin: 0; }
/* Centre the letters (not the line box) on the button: trim the heading's box to cap height + baseline.
   Font line metrics differ per OS, so a fixed offset can't be right everywhere. */
@supports (text-box: trim-both cap alphabetic) {
	.title-row .display-heading { text-box: trim-both cap alphabetic; }
}
/* Fallback for browsers without text-box (Firefox): Luckiest Guy sits ~.145em high in its line box. */
@supports not (text-box: trim-both cap alphabetic) {
	.title-row .display-heading { position: relative; top: .145em; }
}
.title-row .back-btn { justify-self: end; }
.back-btn {
	width: 38px;
	height: 38px;
	flex: none;
	display: grid;
	place-items: center;
	border-radius: 50%;
	border: 2px solid var(--accent);
	background: var(--paper);
	color: var(--accent);
	box-shadow: 2px 2px 0 var(--accent);
	transition: background .2s, color .2s, transform .1s, box-shadow .1s;
}
.back-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.back-btn:hover { background: var(--accent); color: #fff; box-shadow: 3px 4px 0 rgba(35, 32, 32, .85); }
.back-btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 rgba(35, 32, 32, .85); }
.archive-header .title-row { margin-bottom: 8px; }
@media (max-width: 575px) {
	.title-row { gap: 10px; }
	.back-btn { width: 32px; height: 32px; }
	.back-btn svg { width: 15px; height: 15px; }
}
