/* ==========================================================================
   Fonts — Courier Prime (SIL Open Font License), self-hosted
   ========================================================================== */

@font-face {
  font-family: "Courier Prime";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/courier-prime-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Courier Prime";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/courier-prime-latin.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;
}

/* ==========================================================================
   Design tokens
   ========================================================================== */

:root {
  --color-bg: #fff;
  --color-text: #111;
  --color-accent: #e8461e;
  --color-placeholder: #e8461e;

  --font-body: "Courier Prime", "Courier New", monospace;
  --font-size: 13px;
  --line-height: 1.5;

  --gutter: 24px;
  --image-width: 520px;
  --column-width: 260px;
  --column-gap: 40px;

  /* Vertical rhythm scales with viewport height so the page fits one screen */
  --space-block: clamp(24px, 6vh, 80px);
  --space-hero-text: clamp(24px, 5vh, 56px);
  /* Height reserved for header, text and spacing; the image takes the rest */
  --reserved-height: 380px;
}

/* ==========================================================================
   Base
   ========================================================================== */

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

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font: var(--font-size) / var(--line-height) var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1,
p,
figure {
  margin: 0;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover,
a:focus-visible {
  color: var(--color-accent);
}

a:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 4px;
}

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--gutter) 32px;
  text-transform: uppercase;
}

.site-title {
  font: inherit;
}

/* ==========================================================================
   Main — fills the space below the header and centers its content
   ========================================================================== */

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-hero-text);
  padding-block: var(--space-block);
}

/* ==========================================================================
   Hero image
   ========================================================================== */

.hero {
  display: flex;
  justify-content: center;
  padding-inline: var(--gutter);
}

/* The frame holds the image's space and shows a red rectangle while the
   image loads, or in its place if it fails to load. */
.hero-frame {
  /* Shrink on short screens so header, image and text fit without scrolling */
  width: min(
    var(--image-width),
    max(240px, (100svh - var(--reserved-height)) * 4 / 3)
  );
  max-width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--color-placeholder);
}

.hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Set by the image's onerror handler: hide the browser's broken-image
   icon and alt text so only the red rectangle remains. */
.hero img.is-broken {
  visibility: hidden;
}

/* ==========================================================================
   Intro text
   ========================================================================== */

.intro {
  display: grid;
  grid-template-columns: repeat(2, var(--column-width));
  gap: var(--column-gap);
  justify-content: center;
  padding-inline: var(--gutter);
}

/* ==========================================================================
   Small screens
   ========================================================================== */

@media (max-width: 640px) {
  :root {
    /* Text stacks into one taller column, so reserve more height for it */
    --reserved-height: 460px;
  }

  .intro {
    grid-template-columns: minmax(0, 320px);
    gap: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  a {
    transition: none;
  }
}
