/* =========================================================
   Jenna Laatz - site extras
   Only CSS that Oxygen's class editor can't hold lives here:
   accessibility rules, reduced motion, hover-only effects, the
   windowsill animations, and styles that depend on ../js/site.js.
   Layout, colours and fonts are in Oxygen > Selectors and Variables.
   ========================================================= */


/* ---------- Keyboard focus ----------
   A clear outline whenever someone moves around with the Tab key.
   It doesn't show for mouse clicks. */
:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
	outline: 3px solid var(--colour-green, #2f5446);
	outline-offset: 3px;
	border-radius: 4px;
}

/* Oxygen's form styles remove the outline, so the contact form gets it back. */
.form-card .breakdance-form :is(input, textarea, select, button):focus-visible {
	outline: 3px solid var(--colour-green, #2f5446);
	outline-offset: 2px;
}

/* Text only screen readers hear, such as which project a
   "Read the story behind it" link goes to. */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* On the dark green footer, the outline switches to a light colour. */
.site-footer :where(a, button):focus-visible {
	outline-color: var(--colour-lamplight, #f4e3a1);
}


/* ---------- Home page: windowsill, prints and tabs ----------
   Each block says what it does. The class names match the
   elements on the Home page in Oxygen. */
/* Prints and photos start slightly faded and "develop" on hover, only on
   devices with a mouse. Phones always see them sharp. */
@media (hover: hover) {
  .print-develop .print-image { filter: sepia(0.5) saturate(0.6) blur(1px) brightness(1.04); }
  .print-develop:hover .print-image,
  .print-develop:focus-visible .print-image { filter: none; }
  .frame .frame-photo { filter: saturate(0.8) brightness(1.02); }
  .frame:hover .frame-photo { filter: none; }
}

/* Drawings: pieces that move get their own pivot point. */
.pothos-leaf, .raisin-ear, .raisin-body, .raisin-tail, .jar-new-leaf, .camera-iris { transform-box: fill-box; }
.pothos-leaf { transform-origin: 50% 100%; }
.raisin-body { transform-origin: 50% 100%; }
.raisin-tail { transform-origin: 100% 30%; }
.raisin-ear { transform-origin: 50% 100%; }
.camera-iris { transform-origin: 50% 50%; transition: transform 0.12s ease-out; }
.camera-shutter { transition: transform 0.1s ease-out; }
.camera-flash { transition: fill 0.1s ease-out; }
.item-camera.is-clicking .camera-shutter { transform: translateY(4px); }
.item-camera.is-clicking .camera-iris { transform: scale(0.45); }
.item-camera.is-clicking .camera-flash { fill: #fffbe8; }

/* Raisin: eyes and "z"s */
.raisin-eyes-open { opacity: 0; }
.item-raisin.is-awake .raisin-eyes-open { opacity: 1; }
.item-raisin.is-awake .raisin-eyes-closed,
.item-raisin.is-awake .raisin-zzz { opacity: 0; }

/* Tablet doodle and jar roots draw themselves */
.draw-line { stroke-dasharray: 1; stroke-dashoffset: 0; }
.item-tablet.is-drawing .draw-line { animation: draw-line 1.2s ease-out both; }
.jar-roots path { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 1.4s ease-out; }
.item-jar.is-rooted .jar-roots path { stroke-dashoffset: 0; }
.jar-new-leaf { transform-origin: 0% 100%; transform: scale(0); transition: transform 0.5s var(--ease-soft) 1s; }
.item-jar.is-rooted .jar-new-leaf { transform: scale(1); }
.jar-bubble { opacity: 0; }

@keyframes draw-line { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes settle { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: none; } }
@keyframes breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.012, 1.03); } }
@keyframes breathe-again { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.012, 1.03); } }
@keyframes zzz { 0% { opacity: 0; transform: translate(0, 0); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(10px, -18px); } }
@keyframes swish { 0%, 100% { transform: rotate(0deg); } 30% { transform: rotate(-8deg); } 65% { transform: rotate(5deg); } }
@keyframes twitch { 0%, 100% { transform: rotate(0deg); } 40% { transform: rotate(-12deg); } 70% { transform: rotate(4deg); } }
@keyframes sway { 0%, 100% { transform: rotate(0deg); } 35% { transform: rotate(5deg); } 70% { transform: rotate(-3deg); } }
@keyframes bubble { 0% { opacity: 0; transform: translateY(0); } 20% { opacity: 0.9; } 100% { opacity: 0; transform: translateY(-44px); } }
@keyframes flash { 0% { opacity: 0; } 20% { opacity: 0.85; } 100% { opacity: 0; } }
@keyframes leaf-grow { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes paw { 0% { opacity: 0; transform: scale(0.6) rotate(var(--r)); } 15% { opacity: 1; transform: scale(1) rotate(var(--r)); } 80% { opacity: 1; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: no-preference) {
  /* One orchestrated moment: the windowsill settles in on load. */
  .item-pothos { animation: settle 0.5s ease-out 0.1s backwards; }
  .item-camera-wrap { animation: settle 0.5s ease-out 0.16s backwards; }
  .item-tablet { animation: settle 0.5s ease-out 0.22s backwards; }
  .item-raisin { animation: settle 0.5s ease-out 0.28s backwards; }
  .item-jar { animation: settle 0.5s ease-out 0.34s backwards; }

  /* Raisin breathes for a few breaths, then again whenever he's hovered. */
  .raisin-body { animation: breathe 4.5s ease-in-out 1s 3; }
  .item-raisin:hover .raisin-body { animation: breathe-again 4.5s ease-in-out 2; }
  .raisin-zzz text { animation: zzz 3s ease-in-out 1s 4 both; }
  .raisin-zzz text + text { animation-delay: 2.5s; }
  .item-raisin:hover .raisin-ear-r { animation: twitch 0.5s ease-out; }
  .item-raisin.is-awake .raisin-tail { animation: swish 0.9s ease-in-out 2; }

  .item-pothos:hover .pothos-leaf { animation: sway 1.4s ease-in-out; }
  .item-jar.is-rooted .jar-bubble { animation: bubble 1.6s ease-out both; }
  .item-jar.is-rooted .jar-bubble-2 { animation-delay: 0.3s; }
  .item-jar.is-rooted .jar-bubble-3 { animation-delay: 0.6s; }
  .flash.is-flashing { animation: flash 0.4s ease-out; }

  /* The pothos vine grows as you scroll down the first screen.
     Browsers without scroll-driven animation show it fully grown. */
  @supports (animation-timeline: scroll()) {
    .vine-path { stroke-dasharray: 1; animation: draw-line linear both; animation-timeline: scroll(root); animation-range: 0px 360px; }
    .vine-leaf { transform-box: fill-box; transform-origin: 50% 100%; animation: leaf-grow linear both; animation-timeline: scroll(root); }
    .vine-leaf-1 { animation-range: 40px 130px; }
    .vine-leaf-2 { animation-range: 110px 200px; }
    .vine-leaf-3 { animation-range: 180px 270px; }
    .vine-leaf-4 { animation-range: 250px 340px; }
  }
}

/* Jumping to a section lands below the sticky header, not under it. */
html { scroll-padding-top: calc(var(--wp-admin--admin-bar--height, 0px) + 104px); }
@media (max-width: 767px) { html { scroll-padding-top: calc(var(--wp-admin--admin-bar--height, 0px) + 84px); } }

/* On short laptop screens the hero tightens up so the windowsill shows
   in the first screen. (Oxygen can't store a screen-height rule.) */
@media (min-width: 1024px) and (max-height: 860px) {
  .hero.hero { padding-top: 24px; }
  .hero .hero-text { max-width: 66%; }
  .hero h1 { font-size: 76px; }
  .hero .hero-lead { margin-top: 12px; font-size: 19px; line-height: 1.5; }
  .hero .hero-note { margin-top: 8px; }
  .hero .hero-actions { margin-top: 18px; }
  .hero .sill-hint { margin-top: 10px; }
  .hero .sill { margin-top: 6px; }
}

/* The sticky header casts a soft shadow once you scroll (see site.js). */
.site-header { transition: box-shadow 0.25s ease-out; }
.site-header.is-scrolled { box-shadow: 0 1px 0 rgba(31, 58, 48, 0.06), 0 10px 18px -12px rgba(31, 58, 48, 0.35); }

/* ---------- Lightbox (see site.js) ----------
   The "View larger" button covers the picture. The magnifier badge
   shows on hover and keyboard focus, and always on touch screens. */
.zoom-button {
	position: absolute;
	inset: 0;
	z-index: 3;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: inherit;
	background: transparent;
	cursor: zoom-in;
}
.zoom-button svg {
	position: absolute;
	top: 12px;
	right: 12px;
	width: 38px;
	height: 38px;
	padding: 8px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.94);
	color: var(--colour-green-dark, #1f3a30);
	box-shadow: 0 2px 8px rgba(31, 58, 48, 0.25);
	opacity: 0;
	transition: opacity 0.2s ease-out;
}
.zoom-button:hover svg,
.zoom-button:focus-visible svg { opacity: 1; }
@media (hover: none) { .zoom-button svg { opacity: 1; width: 34px; height: 34px; padding: 7px; } }

html.has-lightbox { overflow: hidden; }
.lightbox {
	position: fixed;
	inset: 0;
	margin: auto;
	max-width: min(94vw, 1500px);
	max-height: 94vh;
	padding: 14px 14px 12px;
	border: 0;
	border-radius: 6px;
	background: var(--colour-paper, #fff);
	box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.55);
	overflow: hidden;
}
.lightbox::backdrop { background: rgba(20, 36, 30, 0.8); }
/* Quick clicks on the arrows shouldn't select (highlight) the picture. */
.lightbox { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.lightbox-image { -webkit-user-drag: none; }
.lightbox-figure { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 0; }
.lightbox-image {
	display: block;
	width: auto;
	height: auto;
	max-width: calc(94vw - 28px);
	max-height: calc(94vh - 74px);
	border-radius: 3px;
}
.lightbox-caption {
	font-family: var(--font-accent, cursive);
	font-size: 22px;
	line-height: 1.2;
	color: var(--colour-green-dark, #1f3a30);
	text-align: center;
}
.lightbox-caption:empty { display: none; }
.lightbox.is-tall { overflow-y: auto; }
.lightbox.is-tall .lightbox-image { width: min(1000px, calc(94vw - 28px)); max-height: none; }
.lightbox-close {
	position: fixed;
	top: 14px;
	right: 14px;
	z-index: 2;
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 50%;
	background: var(--colour-green-dark, #1f3a30);
	color: #fff;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
}
.lightbox-close:focus-visible { outline-color: var(--colour-lamplight, #f4e3a1); }
.lightbox-step {
	position: fixed;
	top: 50%;
	z-index: 2;
	display: grid;
	place-items: center;
	width: 48px;
	height: 48px;
	margin-top: -24px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.94);
	color: var(--colour-green-dark, #1f3a30);
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
	cursor: pointer;
}
.lightbox-step svg { width: 24px; height: 24px; }
.lightbox-prev { left: 14px; }
.lightbox-next { right: 14px; }
.lightbox.is-single .lightbox-step,
.lightbox.is-single .lightbox-count { display: none; }
.lightbox-count { margin: 0; font-size: 14px; color: var(--colour-ink-soft, #5b6b64); }
.lightbox-count:empty { display: none; }
/* Phones: the arrows sit at the bottom, out of the way of the picture. */
@media (max-width: 767px) {
	.lightbox-step { top: auto; bottom: 14px; margin-top: 0; }
}
/* Fade only: a scale would move the fixed close button while it plays. */
@keyframes lightbox-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: no-preference) {
	.lightbox[open] { animation: lightbox-fade 0.2s ease-out; }
	.lightbox[open]::backdrop { animation: lightbox-fade 0.2s ease-out; }
}

/* The peeking Raisin's eyes follow the pointer (see site.js). */
.peek-pupils { transition: transform 0.15s ease-out; }

/* Leave room for the bottom tabs on phones and tablets. */
@media (max-width: 1023px) { body:has(.tabs) .site-footer { padding-bottom: 96px; } }

.paws { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.paw { position: absolute; width: 34px; color: var(--colour-walnut); opacity: 0; animation: paw 2.4s ease-out both; }


/* ---------- Reduced motion ----------
   Visitors who ask their device for less motion get no animations
   or smooth scrolling. Everything still shows, just without movement. */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}
