/* Capitalism Deployment Company
   One screen, no scroll. Everything scales with the viewport. */

@font-face {
  font-family: "Libre Caslon Text";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/libre-caslon-text-400-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Libre Caslon Text";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/libre-caslon-text-700-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Libre Franklin";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/libre-franklin-latin.woff2") format("woff2");
}

:root {
  --paper: #FAF7F0;
  --ink: #0A3161;        /* Old Glory Blue: all text */
  --ink-soft: #3A557B;   /* ink, lifted toward the paper: secondary text (AA on paper) */
  --red: #B31942;        /* Old Glory Red: the flag only */
  --gold: #B8892F;

  --serif: "Libre Caslon Text", "Big Caslon", "Book Antiqua", Palatino, Georgia, serif;
  --sans: "Libre Franklin", "Franklin Gothic Medium", "Helvetica Neue", Arial, sans-serif;

  --gutter: clamp(16px, 4.4vw, 84px);
  --label: clamp(0.625rem, 0.56rem + 0.2vw, 0.75rem);
  --track: 0.16em;
}

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

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

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

p, h1 { margin: 0; }

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

/* ---------- Masthead ---------- */

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(14px, 3.6vh, 36px) var(--gutter) 0;
  font-family: var(--sans);
  font-size: var(--label);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: var(--track);
  text-transform: uppercase;
  white-space: nowrap;
}

.contact {
  display: inline-block;
  /* generous hit area without moving the baseline */
  margin: -0.9em calc(-0.6em - var(--track)) -0.9em -0.6em; /* also trims the trailing tracking */
  padding: 0.9em 0.6em;
  color: inherit;
  text-decoration: underline 1px transparent;
  text-underline-offset: 0.5em;
  transition: text-decoration-color 0.25s ease;
}
.contact:hover { text-decoration-color: currentColor; }
.contact:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
  border-radius: 2px;
}

/* ---------- Main: flag above, text below ---------- */

main {
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: clamp(20px, 5vh, 56px);
  padding: clamp(18px, 3.5vh, 40px) var(--gutter);
}

.flag-stage {
  --flag-align: center;
  order: -1;
  position: relative;
  flex: 0 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 132vh; /* keeps the flag from crowding the text on tall, wide screens */
  align-self: center;
  aspect-ratio: 19 / 10;
}

/* The canvas is positioned by flag.js: the flat flag fills the stage,
   and the canvas overhangs it slightly so the cloth has room to move. */
#flag {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.flag-static {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.copy {
  flex: 0 0 auto;
  min-width: 0;
}

h1 {
  font-weight: 400;
  font-size: clamp(1.9rem, min(10.6vw, 7.4vh), 5.5rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

h1 strong {
  font-weight: 700;
}

.rule {
  width: clamp(40px, 5vw, 72px);
  height: 1px;
  margin: clamp(14px, 2.6vh, 28px) 0 clamp(12px, 2.3vh, 24px);
  background: var(--gold);
}

.subline {
  max-width: 34em;
  font-size: clamp(0.9375rem, min(4.1vw, 2.5vh), 1.375rem);
  line-height: 1.5;
  color: var(--ink-soft);
  text-wrap: pretty;
}

/* ---------- Colophon ---------- */

.colophon {
  padding: 0 var(--gutter) clamp(12px, 3.2vh, 32px);
  font-family: var(--sans);
  font-size: clamp(0.65625rem, 0.6rem + 0.17vw, 0.78125rem);
  line-height: 1.55;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  text-wrap: balance;
}

/* ---------- Wide: text left, flag right ---------- */

@media (min-aspect-ratio: 6/5) and (min-width: 520px) {
  main {
    flex-direction: row;
    align-items: center;
    gap: clamp(20px, 4.6vw, 88px);
  }

  .copy {
    flex: 1 1 0;
  }

  .flag-stage {
    --flag-align: end;
    order: 0;
    flex: 1.18 1 0;
    width: auto;
    max-width: none;
    align-self: stretch;
    aspect-ratio: auto;
  }

  h1 {
    font-size: clamp(1.6rem, min(5.15vw, 11.5vh), 6.75rem);
  }

  .subline {
    font-size: clamp(0.875rem, min(1.45vw, 3.6vh), 1.625rem);
  }
}

/* ---------- Narrow phones: ease the tracking so the masthead fits ---------- */

@media (max-width: 359.98px) {
  :root { --track: 0.07em; }
}

/* ---------- Short viewports: drop the subline before anything clips ---------- */

@media (max-height: 430px) and (max-aspect-ratio: 6/5),
       (max-height: 430px) and (max-width: 519.98px),
       (max-height: 300px) {
  .subline,
  .rule { display: none; }
}

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