/* Chicken Scratch Development: shared styles. No external fonts, scripts or trackers.

   The page background is the whole picture, never cropped (so no head or tail is cut off):
   a tiny blurred copy of it is stretched behind the page to fill any space the 4:3 (or, on a phone, square) picture
   leaves at the sides, and the picture's own edges fade into that. Text sits straight on the picture in one colour
   per page (--text) with a glow of the opposite colour (--halo) so it stays readable wherever it lands. */
:root {
  --ink: #1c2540;
  --wash: none;
  --header-h: 3.25rem;
  /* width of the picture on screen: header, text and footer stay inside it so they always sit over the same part of it */
  --stage: min(100vw, calc(100vh * 4 / 3));
  --stage: min(100vw, calc(100dvh * 4 / 3));
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

/* One look per picture: the wash image, then text colour + glow colour for the header, the page text and the footer,
   chosen from measuring the picture under each (dark text where it is light, white where it is dark). */
.bg-home, .bg-contact, .bg-404 {
  --wash: url(/img/bg/chicken-facing-bg_wash_64x48_still.webp);
  --head-text: #101a35; --head-halo: rgba(255, 255, 255, 0.92);
  --text: #101a35;      --halo: rgba(255, 255, 255, 0.92);
  --foot-text: #ffffff; --foot-halo: rgba(8, 20, 46, 0.92);
}
.bg-design {
  --wash: url(/img/bg/chicken-egg-bg_wash_64x48_still.webp);
  --head-text: #2b1707; --head-halo: rgba(255, 246, 228, 0.95);
  --text: #2b1707;      --halo: rgba(255, 246, 228, 0.95);
  --foot-text: #2b1707; --foot-halo: rgba(255, 246, 228, 0.95);
}
.bg-development {
  --wash: url(/img/bg/chicken-keyboard-bg_wash_64x48_still.webp);
  --head-text: #ffffff; --head-halo: rgba(6, 12, 30, 0.92);
  --text: #ffffff;      --halo: rgba(6, 12, 30, 0.92);
  --foot-text: #101a35; --foot-halo: rgba(255, 244, 228, 0.95);
}
.bg-debugging {
  --wash: url(/img/bg/chicken-worm-bg_wash_64x48_still.webp);
  --head-text: #ffffff; --head-halo: rgba(6, 28, 14, 0.92);
  --text: #ffffff;      --halo: rgba(6, 28, 14, 0.92);
  --foot-text: #ffffff; --foot-halo: rgba(6, 28, 14, 0.92);
}
/* Side of the picture the page text uses (the hen is on the other side). */
.bg-design, .bg-development { --side: flex-end; --align: right; --bg-justify: flex-start; }
.bg-debugging, .bg-contact, .bg-404, .bg-home { --side: flex-start; --align: left; }

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font: 1.0625rem/1.6 var(--font);
  color: var(--text);
  background: #1c2540;
}
.site-header, main, .site-footer { width: 100%; max-width: var(--stage); margin-inline: auto; }

/* Blurred wash behind everything */
body::before {
  content: "";
  position: fixed;
  inset: -4%;
  z-index: -2;
  background: var(--wash) center / cover no-repeat;
  filter: blur(18px);
}

/* The picture: always shown whole, centred, with softly faded edges */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}
.bg img {
  display: block;
  flex: none;
  width: min(100vw, calc(100vh * 4 / 3));
  width: min(100vw, calc(100dvh * 4 / 3));
  height: auto;
  aspect-ratio: 4 / 3;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 3%, #000 97%, transparent), linear-gradient(to bottom, transparent, #000 3%, #000 97%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent, #000 3%, #000 97%, transparent), linear-gradient(to bottom, transparent, #000 3%, #000 97%, transparent);
  mask-composite: intersect;
}
/* Portrait (phones, tablets held upright): a square picture under the header, the page text below it on the wash */
@media (orientation: portrait) {
  :root { --stage: 100vw; }
  .bg { align-items: flex-start; padding-top: var(--header-h); }
  .home .bg { padding-top: 0; }
  .bg img {
    width: min(100vw, calc(100vh - var(--header-h)));
    width: min(100vw, calc(100dvh - var(--header-h)));
    aspect-ratio: 1;
  }
}

picture { display: contents; }
.bg { display: flex; }
source { display: none; }

/* Text that sits straight on the picture: a colour plus a glow of the opposite colour, per region */
.site-header { --c: var(--head-text); --h: var(--head-halo); }
main { --c: var(--text); --h: var(--halo); }
.site-footer { --c: var(--foot-text); --h: var(--foot-halo); }
.site-header, main, .site-footer, .site-header a, main a, .site-footer a {
  color: var(--c);
  text-shadow: 0 0 1px var(--h), 0 0 3px var(--h), 0 0 6px var(--h), 0 0 10px var(--h), 0 0 16px var(--h), 0 0 26px var(--h);
}
a { text-underline-offset: 0.2em; }
a:focus-visible { outline: 3px solid #ffbf47; outline-offset: 3px; border-radius: 6px; }

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  z-index: 10;
  padding: 0.5rem 1rem;
  background: #fff9ef;
  color: var(--ink);
  text-shadow: none;
  border-radius: 8px;
  font-weight: 700;
}
.skip-link:focus { top: 0.75rem; }

/* Header and navigation (all pages except Home, which uses the tiles) */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  min-height: var(--header-h);
  padding: 0.5rem clamp(1rem, 3vw, 2rem);
}
.brand { font-size: 1.1rem; font-weight: 800; text-decoration: none; }
.nav-list { display: flex; flex-wrap: wrap; gap: 0.1rem 0.4rem; margin: 0; padding: 0; list-style: none; }
.nav-list a {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-bottom: 3px solid transparent;
  font-weight: 700;
  text-decoration: none;
}
.nav-list a:hover { border-bottom-color: currentColor; }
.nav-list a[aria-current="page"] { border-bottom-color: currentColor; }

@media (max-width: 40rem) {
  .brand { display: none; }
  .site-header { justify-content: center; padding-inline: 0.5rem; }
  .nav-list { justify-content: center; gap: 0.1rem 0.15rem; }
  .nav-list a { padding-inline: 0.35rem; font-size: 0.85rem; }
}

/* Main content: straight on the picture, no panels */
main {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: var(--side, flex-start);
  padding: clamp(1rem, 4vh, 2.5rem) clamp(1rem, 4vw, 4rem);
}
.content { max-width: clamp(14rem, calc(var(--stage) * 0.33), 28rem); text-align: var(--align, left); }
.page-head { margin-bottom: 0.75rem; }
h1 { margin: 0; font-size: clamp(2.2rem, 6vw, 3.6rem); line-height: 1.1; }
.panel { padding: 0; background: none; }
.panel > :first-child { margin-top: 0; }
.panel > :last-child { margin-bottom: 0; }
p { font-size: 1.25rem; font-weight: 700; }
.contact-line { word-break: break-word; }
@media (orientation: portrait) {
  .page main { padding-top: calc(min(100vw, 100vh - var(--header-h)) + 1rem); align-items: center; }
  .page main { padding-top: calc(min(100vw, 100dvh - var(--header-h)) + 1rem); }
  .content { max-width: 28rem; text-align: center; }
}

/* Home */
.home-main { justify-content: center; gap: 1.5rem; }
.home-title { max-width: 9em; font-size: clamp(2rem, 3.6vw, 3.6rem); text-align: left; }
.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 9.5rem));
  gap: 0.75rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem;
  font-size: 1.15rem;
  font-weight: 800;
  text-decoration: none;
  transition: transform 0.18s ease;
}
.tile img { width: min(100%, 128px); height: auto; aspect-ratio: 1; border-radius: 18px; box-shadow: 0 6px 18px rgba(8, 12, 28, 0.35); }
.tile:hover, .tile:focus-visible { transform: translateY(-4px); }
.tile:hover span, .tile:focus-visible span { text-decoration: underline; text-underline-offset: 0.2em; }
@media (orientation: portrait) {
  .home-main { padding-top: calc(min(100vw, 100vh) + 0.5rem); padding-top: calc(min(100vw, 100dvh) + 0.5rem); align-items: center; justify-content: flex-start; gap: 0.75rem; }
  .home-title { max-width: none; text-align: center; font-size: clamp(1.7rem, 7vw, 3rem); }
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5rem; width: 100%; max-width: 34rem; }
  .tile { font-size: 0.85rem; }
  .tile img { width: min(100%, 84px); border-radius: 14px; }
}
/* Short landscape screens (phones on their side): the picture moves to one side and the page text takes the other */
@media (orientation: landscape) and (max-height: 32rem) {
  :root { --stage: calc(100vw - 100vh * 4 / 3 - 0.5rem); }
  body { align-items: var(--side, flex-start); }
  .site-header, main, .site-footer { margin-inline: 0; }
  .bg { justify-content: var(--bg-justify, flex-end); }
  .brand { display: none; }
  .site-header { justify-content: flex-start; padding-inline: 0.75rem; }
  .nav-list a { padding-inline: 0.35rem; font-size: 0.85rem; }
  .home-main { gap: 0.5rem; }
  .home-title { font-size: 1.5rem; }
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.35rem; width: 100%; }
  .tile { font-size: 0.62rem; padding: 0; }
  .tile img { width: min(100%, 52px); border-radius: 10px; }
  h1 { font-size: 1.8rem; }
  p { font-size: 1rem; }
  .site-footer { padding: 0.4rem 0.75rem 0.6rem; font-size: 0.8rem; }
}

/* Footer */
.site-footer { padding: 0.75rem 1.25rem 1rem; font-size: 0.95rem; font-weight: 700; text-align: center; }
.site-footer ul { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem 1.25rem; margin: 0 0 0.35rem; padding: 0; list-style: none; }
.site-footer p { margin: 0; font-size: 0.9rem; font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .tile { transition: none; }
  .tile:hover, .tile:focus-visible { transform: none; }
}
