/* quailworks.com. Two colors only: the quail's indigo and white. One family: Source Serif 4. */

:root {
  /* Colors */
  --ink: #24105B;
  --paper: #FFFFFF;

  /* Type: one family, four text sizes at each width. The headline grows with
     the screen: 52px at 1024, 62px at 1440, 64px from about 1530 up. Sizes
     are in rem (16px at the browser's default text size, so 22px is
     1.375rem) and grow when a visitor sets a larger default. */
  --serif: "Source Serif 4", "Source Serif 4 Fallback Georgia", "Source Serif 4 Fallback Noto", Georgia, serif;
  --t-display: clamp(3.25rem, 2.404vw + 1.7125rem, 4rem);
  --t-lead: 1.375rem;
  --t-body: 1.1875rem;
  --t-small: 1rem;

  /* Spacing steps */
  --space-1: 8px;
  --space-2: 14px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-7: 56px;
  --space-8: 64px;
  --space-9: 72px;
  --space-10: 96px;

  /* Page frame */
  --gap: var(--space-6);             /* column gutter */
  --margin: clamp(24px, 8vw, 120px); /* page margin */
  --measure: 1200px;                 /* content width */
  --section: 160px;                  /* space between sections */
  --masthead: 76px;                  /* 32px above a 44px row */

  /* The bird's height: 393px at 1024, 452px at 1440, 500px from 1786
     up, and never more than 62% of the screen's height. */
  --bird-h: min(clamp(340px, 14vw + 250px, 500px), 62svh);
}

/* Served from the site: the Latin subset of the variable font, upright, used at
   400 and 600 only. It keeps the optical-size axis the page is set with
   (font-optical-sizing: auto), so the headline gets the display cut and the
   links the text cut. Static 400/600 files are a smaller, wider cut and break
   the headline onto four lines. */
@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("../assets/fonts/source-serif-4-latin-opsz-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Stand-ins for the moment before the serif arrives, sized to match it so
   nothing moves when it swaps in and the headline keeps its three lines:
   Georgia where there is Georgia, then Noto Serif (Android has no Georgia).
   size-adjust matches the widths, measured against Source Serif 4 at its
   own optical sizes: at 600, the middle of the headline's range (Georgia
   Bold 80-84%, Noto Serif Bold 81-85% from 64px down to 40px); at 400, the
   body text. The overrides are scaled by size-adjust, so each is Source
   Serif 4's own metric (ascent 1.036, descent 0.335, no line gap) divided
   by it, and the baseline sits where the serif's will. */
@font-face {
  font-family: "Source Serif 4 Fallback Georgia";
  font-style: normal;
  font-weight: 600;
  src: local("Georgia Bold"), local("Georgia-Bold");
  size-adjust: 82%;
  ascent-override: 126.34%;
  descent-override: 40.85%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "Source Serif 4 Fallback Georgia";
  font-style: normal;
  font-weight: 400;
  src: local("Georgia");
  size-adjust: 103%;
  ascent-override: 100.58%;
  descent-override: 32.52%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "Source Serif 4 Fallback Noto";
  font-style: normal;
  font-weight: 600;
  src: local("Noto Serif Bold"), local("NotoSerif-Bold");
  size-adjust: 83%;
  ascent-override: 124.82%;
  descent-override: 40.36%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "Source Serif 4 Fallback Noto";
  font-style: normal;
  font-weight: 400;
  src: local("Noto Serif"), local("Noto Serif Regular"), local("NotoSerif"), local("NotoSerif-Regular");
  size-adjust: 95%;
  ascent-override: 109.05%;
  descent-override: 35.26%;
  line-gap-override: 0%;
}

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

html {
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--t-body);
  font-weight: 400;
  line-height: 1.6;
  font-optical-sizing: auto;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  caret-color: var(--ink);
}

::selection { background: var(--ink); color: var(--paper); }

h1, h2, h3, p { margin: 0; }

p { text-wrap: pretty; }

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

.wrap {
  width: min(var(--measure), 100% - 2 * var(--margin));
  margin-inline: auto;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gap);
}

/* ---------- Masthead: the name is the wordmark ---------- */

.masthead {
  display: flex;
  align-items: baseline;            /* name and links share one baseline */
  justify-content: space-between;
  min-height: var(--masthead);
  padding-top: var(--space-4);
}

.wordmark,
.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
}

.wordmark {
  font-size: var(--t-lead);
  font-weight: 600;
  letter-spacing: -0.008em;
}

.nav { display: flex; gap: 36px; }

.nav a { font-size: var(--t-small); }

/* Hover only where the pointer can hover: on a touch screen a tap would leave it stuck. */
@media (hover: hover) {
  .wordmark:hover,
  .nav a:hover {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.25em;
  }
}

/* ---------- First screen ---------- */

/* The bird, placed on purpose:
   1. Halves. The first screen uses the page's two halves, the same split
      as the contact band below. The headline block holds the left half;
      the bird's beak touches the first line of the right half, the line
      the form starts on, so the bird and the form share one edge.
   2. Gap. That puts the beak 182px past the headline's longest line at
      1440 (76px at 1024, 168px at 1920), instead of the 320px it had;
      the beak itself points at the shorter middle line. The tail ends
      216px inside the content's right edge at 1440.
   3. Height. It scales with the screen (see --bird-h), so the bird stays
      about one and a half times the height of the text block beside it.
   4. Level. Its crest is light and its body heavy, so its optical center
      sits 58% of the way down. That point sits on the center of the
      headline-plus-button block: a bottom margin of 16% of its height
      lifts it by the 8% difference.
   5. Very tall screens. The first screen fills the window up to 1004px,
      its height at 1920x1080, and stops growing there. */
.hero {
  min-height: min(calc(100svh - var(--masthead)), 1004px);
  padding-block: var(--space-9) var(--space-10);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: var(--gap);
  align-items: center;
}

.hero-text { grid-column: 1; grid-row: 1; }

.hero-bird {
  grid-column: 2;
  grid-row: 1;
  justify-self: start;
  margin: 0 0 calc(var(--bird-h) * 0.16);
}

.hero-bird img {
  display: block;
  height: var(--bird-h);
  width: auto;
}

/* The bird's box: it wraps the image and its motion layers (below) and takes
   over the image's placement, so the layers sit on the bird exactly. The
   image keeps its sizes. It answers taps (js/motion.js), so no gray tap box
   on phones, and it stays out of text selections. */
.bird {
  display: block;
  position: relative;
  width: fit-content;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

h1 {
  max-width: 7.8em;                 /* always the same three lines */
  font-size: var(--t-display);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 0 30px;
  border: 0;
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-size: var(--t-body);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.005em;
  text-decoration: none;
  cursor: pointer;
}

@media (hover: hover) {
  .button:hover {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.25em;
  }
}

/* While the form sends (the script holds the button's width meanwhile). */
.button:disabled {
  cursor: default;
  text-decoration: none;
}

.hero .button { margin-top: var(--space-7); }

/* ---------- The three areas ---------- */

.areas {
  border-top: 1px solid var(--ink);   /* the page's only rule */
  padding-top: var(--space-8);
  row-gap: var(--space-7);
}

.areas-intro { grid-column: 1 / 7; }

.areas-intro p { margin-top: var(--space-2); }

.area { grid-column: span 4; }

.areas-intro + .area { grid-column: 1 / span 4; }   /* the three start a row of their own */

h2, h3 {
  font-size: var(--t-lead);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.005em;
}

.area p { margin-top: var(--space-2); max-width: 34em; }

/* ---------- Contact ---------- */

.contact {
  margin-top: var(--section);
  scroll-margin-top: var(--space-6);
}

.contact-intro { grid-column: 1 / 7; }

.contact-intro p { margin-top: var(--space-2); }

.email {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

@media (hover: hover) {
  .email:hover { text-decoration-thickness: 2px; }
}

.email-line { margin-top: 2px; }

.email-line a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

form,
#contact-status { grid-column: 7 / 13; }   /* the thank-you line takes the form's place */

/* Focus moves to the thank-you line only so screen readers announce it; it is not a control. */
#contact-status:focus-visible { outline: 0; }

.field + .field { margin-top: var(--space-3); }

/* The spam trap: present for bots, hidden from sight, from assistive technology and from the tab order. */
.trap { display: none; }

label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--t-small);
  line-height: 1.4;
}

input, textarea {
  display: block;
  width: 100%;
  margin: 0;
  padding: 13px 16px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: var(--t-body);
  line-height: 1.4;
  -webkit-appearance: none;
  appearance: none;
}

textarea { min-height: 176px; resize: none; }

input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

form .button { margin-top: var(--space-4); }

/* ---------- Footer ---------- */

footer {
  margin-top: var(--section);
  padding-bottom: var(--space-6);
  font-size: var(--t-small);
}

/* ---------- Narrower laptops and tablets ---------- */

@media (max-width: 1100px) {
  .area,
  .areas-intro + .area { grid-column: 1 / -1; }
  .area p { max-width: 36em; }
}

/* Below 1000px the halves are too narrow for the headline: the bird
   goes first and the text follows, as on the phone. */
@media (max-width: 999px) {
  /* Equal space above and below the bird as the eye measures it: 72px
     from the links' baseline to the crest (56 + 16), 72px from the
     bird's base to the headline's capitals (60 + 12). */
  .hero {
    display: block;
    min-height: 0;
    padding-block: var(--space-7) var(--space-10);
  }

  /* Centered on its optical center, not its box. The face juts left and
     the light tail right, and the mass center sits at 41.6% of the
     width; by eye the bird reads centered with its 43.75% point on the
     content's center line, so the box moves right 6.25% of its width:
     17px here, 12px on the phone. The text stays left-aligned. */
  .hero-bird { justify-self: stretch; margin: 0 0 60px; }

  .hero-bird img { height: 340px; }

  .bird {
    margin-inline: auto;
    left: 17px;
  }
}

/* ---------- Phone ---------- */

@media (max-width: 720px) {
  :root {
    --t-display: clamp(2rem, 10.4vw, 2.5rem);
    --t-lead: 1.25rem;
    --t-body: 1.125rem;
    --t-small: 0.9375rem;
    --margin: 24px;
    --section: 112px;
    --masthead: 96px;               /* 8px above two 44px rows */
  }

  .grid { display: block; }

  .masthead {
    flex-direction: column;
    align-items: stretch;
    padding-top: var(--space-1);
  }

  .wordmark { align-self: flex-start; }

  .nav { justify-content: space-between; gap: 0; }

  .nav a { min-width: 44px; }

  /* The bird goes first, optically centered (12px right of its box's
     center, snapped to a whole pixel). The space
     above it equals the space below it as the eye measures it: 61px
     from the links' baseline down to the crest, 61px from the bird's
     base down to the headline's capitals (the links sit 17px above
     their row's bottom, the capitals 9px below their line's top).
     The bird is drawn at its file's own size, 192 by 241, so each pixel
     of the 1x, 2x and 3x files lands on one screen pixel. */
  .hero {
    min-height: min(calc(100svh - var(--masthead)), 1004px);
    padding-block: 44px var(--space-6);
  }

  .hero-bird { margin: 0 0 52px; }

  .hero-bird img {
    width: 192px;
    height: 241px;
  }

  .bird {
    margin-left: round(down, (100% - 192px) / 2, 1px);
    left: 12px;
  }

  .hero .button { margin-top: var(--space-5); }

  .button { width: 100%; min-height: 52px; }

  .areas { padding-top: var(--space-6); }

  .areas-intro + .area,
  .area + .area { margin-top: var(--space-7); }

  .area p { margin-top: 10px; }

  form,
  #contact-status { margin-top: var(--space-5); }

  footer { padding-bottom: var(--space-4); }
}

/* ---------- Stacked, on its side ---------- */

/* A phone or tablet on its side: the stacked bird is never taller than
   30% of the screen, so the headline's first line shows on the first
   screen. Same proportions, and the shift shrinks with it (17/340 of its
   height, 12/241 on the phone). Upright screens keep the bird as above. */
@media (max-width: 999px) and (orientation: landscape) {
  .hero-bird img { height: min(340px, 30svh); }
  .bird { left: min(17px, 1.5svh); }
}

@media (max-width: 720px) and (orientation: landscape) {
  .hero-bird img {
    width: min(192px, 30svh * 192 / 241);
    height: min(241px, 30svh);
  }

  .bird {
    margin-left: round(down, (100% - min(192px, 30svh * 192 / 241)) / 2, 1px);
    left: min(12px, 30svh * 12 / 241);
  }
}

/* ---------- The quail's motion ---------- */

/* The bird moves in three small ways (js/motion.js): the topknot flicks
   (and jiggles while the page scrolls), the eye blinks, the pupil looks.
   It is never redrawn: its layers are
   copies of the same image and one small drawing, laid over it in
   fractions of the image box measured from the 758x951 master, and all
   out of sight at rest, so the page at rest is the page without them.
   - plume-base: the bird with everything above y 164.5 cut away, so no
     stub of the stem stays upright when the crest tips
   - plume: only the crest, plus a short root that drops from the two
     corners where the stem meets the head into the solid head (x 168.3
     to 223, inside the stem's own edges, so its corner never shows); it
     turns on the stem's base (196.5, 166)
   - socket: a white disc under the pupil, inside the white eye ring
   - pupil: only the pupil (an ellipse of radius 34 around 166.65, 322.17)
   - eyelid: an indigo lid that slides down inside the eye ring, then the
     closed eye, a short curved white dash at the logo's line weight
   All the moving is done by the script, with transform and opacity only;
   this holds the layers' shapes and their rest. */
.bird > .layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  pointer-events: none;
  user-select: none;
}

/* Hidden until the script has seen this stylesheet in force (the rule above
   for the bird's images would otherwise undo the hidden attribute). */
.bird > .layer[hidden] { display: none; }

.bird > .plume-base { clip-path: inset(17.2976% 0 0 0); }

.bird > .plume {
  clip-path: polygon(-10% -10%, 110% -10%, 110% 16.6141%, 30.4749% 16.6141%, 29.4195% 17.4343%, 29.4195% 18.0862%, 22.2032% 18.0862%, 22.2032% 17.4027%, 21.6359% 16.6141%, -10% 16.6141%);
  transform-origin: 25.9235% 17.4553%;
}

.bird > .socket {
  left: 16.7082%;
  top: 29.6708%;
  width: 10.5541%;
  height: 8.4122%;
  border-radius: 50%;
  background: var(--paper);
}

.bird > .pupil { clip-path: ellipse(4.4855% 3.5752% at 21.9852% 33.8769%); }

.bird.looking > .socket,
.bird.looking > .pupil { opacity: 1; }

.bird > .eyelid {
  left: 12.6649%;
  top: 24.8160%;
  width: 18.4697%;
  height: 17.6656%;
  opacity: 1;
  overflow: hidden;
}

.bird > .eyelid > svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* At rest the lid waits above the eye, outside its clip, and the line is off. */
.lid-shut { transform: translateY(-128px); }
.lid-line { opacity: 0; }

/* Forced colors (Windows High Contrast): the image keeps its ink and its white
   lines show the forced page color, so the closed eye and the disc under the
   pupil take that color (Canvas) and the lid keeps the ink. */
@media (forced-colors: active) {
  .bird > .socket,
  .bird > .eyelid { forced-color-adjust: none; }
  .bird > .socket { background: Canvas; }
  .lid-line path { stroke: Canvas; }
  .lid-line circle { fill: Canvas; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Print: ink on paper, and no empty first screen ---------- */

@media print {
  .button { background: none; color: var(--ink); outline: 1px solid; }
  .hero { min-height: 0; }

  /* The bird prints as the plain image: no looking pupil without its white
     disc (backgrounds are dropped), no flick caught halfway. */
  .bird > .layer { display: none !important; }
  .bird > .bird-img { opacity: 1 !important; }
}
