/*
  Fernandes Group

  Colour: white page, the logo's green for the two big panels, yellow for
  the lines that connect things, a pale green tint for cards.
  Type: Red Hat Display for headings (close to the logo's lettering),
  Red Hat Text for reading.
  Shape: three radii. Large for panels and photos, medium for cards,
  full for pills.
  Motif: a yellow line with dots. It fans from one card to eight in the hero
  and runs through the history timeline.
*/

:root {
  --white: #fff;
  --green: #164d3a;
  --green-deep: #103a2c;
  --yellow: #f5c41a;
  --yellow-soft: #fdf1bf;
  --tint: #eef4f0;
  --ink: #1d2b24;
  --muted: #5a6962;
  --on-green: #d3e2d9;

  --text-small: .875rem;
  --text-body: 1.0625rem;
  --text-lead: clamp(1.1875rem, 1.6vw, 1.375rem);
  --text-card: 1.25rem;
  --text-sector: clamp(1.375rem, 2vw, 1.625rem);
  --text-section: clamp(1.875rem, 3.2vw, 2.625rem);
  --text-hero: clamp(2.125rem, 4.1vw, 3.625rem);

  --r-panel: clamp(20px, 2.6vw, 32px);
  --r-card: 18px;
  --r-pill: 999px;

  --gutter: clamp(16px, 4vw, 48px);
  --gap: clamp(14px, 1.8vw, 24px);
  --block: clamp(64px, 9vw, 128px);
  --pad: clamp(24px, 4vw, 56px);

  --ease-out: cubic-bezier(.2, .7, .2, 1);

  --display: "Red Hat Display", "Helvetica Neue", Arial, sans-serif;
  --text: "Red Hat Text", "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--white); color: var(--ink); font-family: var(--text); font-size: var(--text-body); line-height: 1.55; }
h1, h2, h3, h4, p, ul, ol, address, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
address { font-style: normal; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
/* Yellow is too pale to see on white, so the focus ring is green there and yellow on green. */
:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }
.hero :focus-visible, .panel--green :focus-visible { outline-color: var(--yellow); }

h1, h2, h3, h4 { font-family: var(--display); color: var(--green); letter-spacing: -.02em; text-wrap: balance; }
h1 { font-size: var(--text-hero); font-weight: 800; line-height: 1.04; }
h2 { font-size: var(--text-section); font-weight: 800; line-height: 1.08; }
h3 { font-size: var(--text-sector); font-weight: 700; line-height: 1.15; }
h4 { font-size: var(--text-card); font-weight: 700; line-height: 1.2; letter-spacing: -.01em; }

.wrap { width: 100%; max-width: calc(1280px + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
.block { margin-top: var(--block); }
.skip-link { position: absolute; left: var(--gutter); top: -100px; z-index: 20; padding: 12px 20px; border-radius: var(--r-pill); background: var(--green); color: var(--white); }
.skip-link:focus { top: 12px; }

/* Pill: the one button shape. Outlined by default. */
.pill { display: inline-flex; align-items: center; justify-self: start; min-height: 44px; padding: 6px 16px; border: 1.5px solid currentColor; border-radius: var(--r-pill); color: var(--green); font-size: var(--text-small); font-weight: 600; transition: background-color .2s, border-color .2s, color .2s; }
.pill:hover { background: var(--green); border-color: var(--green); color: var(--white); }
/* Solid pill: the one primary action on a card. */
.pill--solid { background: var(--green); border-color: var(--green); color: var(--white); }
.pill--solid:hover { background: var(--green-deep); border-color: var(--green-deep); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Contact lines: address, phone, email, then a pill. */
.reach { display: grid; gap: 4px; align-content: start; justify-items: start; font-size: .9375rem; }
.reach address { color: var(--muted); }
.reach a:not(.pill) { font-weight: 500; color: var(--green); overflow-wrap: anywhere; text-decoration: underline; text-decoration-color: var(--yellow); text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
.reach a:not(.pill):hover { text-decoration-color: currentColor; }
@media (pointer: coarse) { .reach a:not(.pill) { padding-block: 7px; } }
.reach .pill { margin-top: 10px; }

/* Header */
.site-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 32px; padding-block: 18px; }
.brand { display: block; flex: none; }
.brand img { width: auto; height: 42px; }
.site-nav { display: flex; flex-wrap: wrap; gap: 4px; font-size: .9375rem; font-weight: 600; color: var(--green); }
.site-nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 14px; border-radius: var(--r-pill); transition: background-color .2s; }
.site-nav a:hover { background: var(--tint); }

/* Hero: one card on the left, eight companies on the right, yellow lines between. */
.hero { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--pad); align-items: center; padding: var(--pad); border-radius: var(--r-panel); background: var(--green); color: var(--on-green); }
.hero { position: relative; overflow: hidden; }
.hero > :not(.hero-pattern) { position: relative; z-index: 1; }
.hero h1 { color: var(--white); }

/*
  Hero background: fine diagonal rules. They sit behind everything and fade out
  before they reach the company list.
*/
.hero-pattern { position: absolute; top: 0; left: 0; z-index: 0; max-width: none; pointer-events: none; -webkit-mask-image: linear-gradient(90deg, #000 0, #000 440px, transparent 920px); mask-image: linear-gradient(90deg, #000 0, #000 440px, transparent 920px); }
.hero-pattern .rules path { fill: none; stroke: var(--white); stroke-opacity: .13; stroke-width: 1; }

.hero-text p { margin-top: 20px; max-width: 32em; font-size: var(--text-lead); line-height: 1.45; }

.diagram { display: grid; grid-template-columns: minmax(140px, 220px) minmax(48px, 1fr) auto; align-items: stretch; }
.origin { position: relative; align-self: center; border-radius: var(--r-card); background: var(--white); color: var(--muted); font-size: var(--text-small); line-height: 1.35; }
.origin img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-card) var(--r-card) 0 0; }
.origin p { padding: 12px 16px 14px; }
.origin strong { display: block; font-family: var(--display); font-size: 1.75rem; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; color: var(--green); }
.origin::after, .branches a::before { content: ""; position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%; background: var(--yellow); transform: translateY(-50%); }
.origin::after { right: -6px; }

.lines { width: 100%; height: 100%; overflow: visible; }
.lines path { fill: none; stroke: var(--yellow); stroke-width: 2; vector-effect: non-scaling-stroke; transition: stroke .2s, stroke-width .2s; }
/* Pointing at a company lights up its line back to the 1910 card. */
.diagram:has(li:nth-child(1) a:is(:hover, :focus-visible)) path:nth-child(1),
.diagram:has(li:nth-child(2) a:is(:hover, :focus-visible)) path:nth-child(2),
.diagram:has(li:nth-child(3) a:is(:hover, :focus-visible)) path:nth-child(3),
.diagram:has(li:nth-child(4) a:is(:hover, :focus-visible)) path:nth-child(4),
.diagram:has(li:nth-child(5) a:is(:hover, :focus-visible)) path:nth-child(5),
.diagram:has(li:nth-child(6) a:is(:hover, :focus-visible)) path:nth-child(6),
.diagram:has(li:nth-child(7) a:is(:hover, :focus-visible)) path:nth-child(7),
.diagram:has(li:nth-child(8) a:is(:hover, :focus-visible)) path:nth-child(8) { stroke: var(--white); stroke-width: 4; }

/* Eight equal rows, so each line ends at the middle of its company. */
.branches { display: grid; grid-auto-rows: 1fr; }
.branches li { display: flex; align-items: center; padding-block: 4px; }
.branches a { position: relative; display: flex; align-items: center; width: 100%; min-height: 44px; padding: 8px 18px 8px 20px; border-radius: var(--r-pill); background: var(--white); color: var(--green); font-family: var(--display); font-weight: 700; line-height: 1.2; white-space: nowrap; transition: background-color .2s, transform .2s cubic-bezier(.2, .7, .2, 1); }
.branches a::before { left: -6px; }
.branches a:hover { background: var(--yellow-soft); transform: translateX(4px); }

/* The one piece of load motion: the lines grow out of the card, then the companies arrive. */
@media (prefers-reduced-motion: no-preference) {
  .hero-pattern { animation: fade 1.4s ease-out both; }
  .hero-text > * { animation: rise .7s var(--ease-out) both; }
  .hero-text > :nth-child(2) { animation-delay: .1s; }
  .origin { animation: settle .7s .2s var(--ease-out) both; }
  .lines { animation: grow .9s .55s cubic-bezier(.65, 0, .2, 1) both; }
  .branches li { animation: arrive .45s calc(1.15s + var(--i) * 55ms) var(--ease-out) both; }
  .card:target { animation: land .7s var(--ease-out); }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes settle { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes grow { from { clip-path: inset(-10% 100% -10% 0); } to { clip-path: inset(-10% 0 -10% 0); } }
@keyframes arrive { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
@keyframes land { from { box-shadow: 0 0 0 12px rgba(245, 196, 26, 0); } to { box-shadow: 0 0 0 3px var(--yellow); } }

/* Photos */
.photo { position: relative; overflow: hidden; border-radius: var(--r-panel); background: var(--tint); }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo--low img { object-position: 50% 68%; }
.photo--left img { object-position: 28% 50%; }

/* Companies: per sector, a photo on the left and the company cards on the right. */
.sector { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); margin-top: clamp(36px, 5vw, 64px); }
.sector h3 { grid-column: 1 / -1; }
.sector .photo { min-height: 320px; }
.sector .photo img { position: absolute; inset: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--gap); }
.cards--stack { grid-template-columns: minmax(0, 1fr); }
/* A sector with four companies gets a full-width photo and its cards two by two. */
.sector--wide .photo { grid-column: 1 / -1; min-height: 0; aspect-ratio: 5 / 2; }
.sector--wide .cards { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 16px var(--gap); align-content: space-between; padding: clamp(20px, 2.2vw, 28px); border-radius: var(--r-card); background: var(--tint); scroll-margin-top: 24px; }
.card p { margin-top: 8px; color: var(--muted); font-size: .9375rem; }
.card:target { box-shadow: 0 0 0 3px var(--yellow); }
.cards--stack .card, .card:only-child { align-content: center; }

/* Panels: the tinted history panel and the green head-office panel. */
.panel { padding: var(--pad); border-radius: var(--r-panel); background: var(--tint); }
.panel--green { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--pad); align-items: center; background: var(--green); color: var(--on-green); }
.panel--green h2 { color: var(--white); }
.panel--green p { margin-top: 16px; max-width: 30em; font-size: var(--text-lead); line-height: 1.45; }
.panel--green .reach { font-size: var(--text-lead); }
.panel--green .reach address { color: var(--on-green); }
.panel--green .reach a:not(.pill) { color: var(--white); }
.panel--green .pill { color: var(--white); font-size: var(--text-small); }
.panel--green .pill:hover { background: var(--white); border-color: var(--white); color: var(--green); }

/* History: the yellow line again, now as a timeline. */
.timeline { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-block: clamp(28px, 4vw, 48px) clamp(24px, 3vw, 36px); }
.timeline li { position: relative; padding: 28px var(--gap) 0 0; }
.timeline li::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--yellow); transform-origin: left top; }
.timeline li::before { content: ""; position: absolute; z-index: 1; left: 0; top: -6px; width: 14px; height: 14px; border-radius: 50%; background: var(--yellow); }
.timeline strong { display: block; margin-bottom: 6px; font-family: var(--display); font-size: var(--text-sector); font-weight: 800; letter-spacing: -.02em; color: var(--green); }
.timeline p { max-width: 24em; color: var(--muted); }

/* Foundation */
.feature { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--pad); align-items: center; }
.feature .photo { aspect-ratio: 16 / 10; }
.feature-text > * + * { margin-top: 16px; }
.feature-text .pill { margin-top: 24px; }
.lead { font-size: var(--text-lead); line-height: 1.45; font-weight: 500; color: var(--ink); }
.feature-text p:not(.lead) { color: var(--muted); }

/* Footer */
.site-footer { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 20px 48px; margin-top: var(--block); padding-block: 0 40px; }
.small-print { flex: 1 1 320px; max-width: 68ch; font-size: var(--text-small); color: var(--muted); }
.small-print p + p { margin-top: 8px; }
.small-print a { text-decoration: underline; text-underline-offset: 3px; }

/*
  People: eight round photos, one per company, pooled in a row. Every other photo
  is larger than its column, so neighbours overlap a little.
*/
.people { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); row-gap: clamp(12px, 2vw, 20px); margin-top: clamp(36px, 5vw, 60px); padding-inline: 1%; }
.people-heading { text-align: center; }
.people li { position: relative; aspect-ratio: 1; }
.people li:nth-child(odd) { z-index: 1; }
.people img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 4px var(--white); }
.people li:nth-child(odd) img { inset: -8%; width: 116%; height: 116%; }

/*
  Scroll reveals. site.js adds .motion to <html> and .is-in to each element as it
  enters the screen. If the script is missing, or the visitor asks for reduced
  motion, .motion is never set and everything is simply visible.
*/
.motion [data-reveal] { opacity: 0; transform: translateY(18px); transition: opacity .7s var(--ease-out), transform .7s var(--ease-out); }
.motion [data-reveal].is-in { opacity: 1; transform: none; }
.motion .cards > [data-reveal]:nth-child(even) { transition-delay: .09s; }
.motion .cards--stack > [data-reveal]:nth-child(2) { transition-delay: .09s; }
.motion .cards--stack > [data-reveal]:nth-child(3) { transition-delay: .18s; }
.motion .feature-text[data-reveal] { transition-delay: .12s; }
/* Photos ease out of a slight zoom as they appear. */
.motion .photo[data-reveal] { transform: none; }
.motion .photo[data-reveal] img { transform: scale(1.05); transition: transform 1.2s var(--ease-out); }
.motion .photo[data-reveal].is-in img { transform: none; }
/* The timeline draws itself: each dot appears, its line runs to the next, its text follows. */
.motion .timeline[data-reveal] { opacity: 1; transform: none; }
.motion .timeline li::before { transform: scale(0); transition: transform .35s var(--ease-out) calc(var(--i) * .28s); }
.motion .timeline li::after { transform: scaleX(0); transition: transform .5s cubic-bezier(.65, 0, .2, 1) calc(var(--i) * .28s + .08s); }
.motion .timeline li > * { opacity: 0; transform: translateY(8px); transition: opacity .5s var(--ease-out) calc(var(--i) * .28s + .12s), transform .5s var(--ease-out) calc(var(--i) * .28s + .12s); }
.motion .timeline.is-in li::before, .motion .timeline.is-in li::after, .motion .timeline.is-in li > * { opacity: 1; transform: none; }
/* The people gather: each photo settles into the row in turn. */
.motion .people[data-reveal] { opacity: 1; transform: none; }
.motion .people li { opacity: 0; transform: scale(.86); transition: opacity .5s var(--ease-out) calc(var(--i) * .07s), transform .6s var(--ease-out) calc(var(--i) * .07s); }
.motion .people.is-in li { opacity: 1; transform: none; }

/* Tablet: hero text sits above the diagram, two-column sections stack. */
@media (max-width: 1100px) {
  .people { grid-template-columns: repeat(4, minmax(0, 1fr)); padding-inline: 2%; }
  .hero, .sector, .feature, .panel--green { grid-template-columns: minmax(0, 1fr); }
  .sector--wide .cards { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .card { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
  .sector .photo { min-height: 0; aspect-ratio: 16 / 9; }
  .timeline { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 32px; }
}

/* Phone: the fan becomes a tree, with a trunk down the left and a branch to each company. */
@media (max-width: 640px) {
  .people img { box-shadow: 0 0 0 3px var(--white); }
  .brand img { height: 36px; }
  .site-nav { margin-inline: -10px; font-size: .875rem; }
  .site-nav a { padding: 6px 10px; }
  .diagram { display: block; }
  .lines { display: none; }
  .origin { display: flex; align-items: center; }
  .origin img { width: 88px; border-radius: var(--r-card) 0 0 var(--r-card); }
  .origin::after { top: auto; right: auto; bottom: -6px; left: 22px; transform: none; }
  .branches { margin: 0 0 0 27px; padding-top: 14px; }
  .branches li { position: relative; padding: 5px 0 5px 30px; }
  .branches li::before { content: ""; position: absolute; left: 0; top: 0; width: 24px; height: 50%; border-left: 2px solid var(--yellow); border-bottom: 2px solid var(--yellow); border-bottom-left-radius: 14px; }
  .branches li:first-child::before { top: -14px; height: calc(50% + 14px); }
  .branches li:not(:last-child)::after { content: ""; position: absolute; left: 0; top: 50%; bottom: 0; border-left: 2px solid var(--yellow); }
  .branches a { white-space: normal; }
  .timeline { grid-template-columns: minmax(0, 1fr); row-gap: 0; }
  .timeline li { padding: 0 0 28px 28px; }
  .timeline li::after { right: auto; bottom: 0; width: 2px; height: auto; }
  .timeline li:last-child { padding-bottom: 0; }
  .timeline li::before { left: -6px; top: 6px; }
  .motion .timeline li::after { transform: scaleY(0); }
}

/* Printing shows everything, whether or not it has been scrolled into view. */
@media print {
  .motion [data-reveal], .motion [data-reveal] *, .motion .timeline li::before, .motion .timeline li::after { opacity: 1 !important; transform: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
