/*
Theme Name: Charlottesville Playwrights Collective
Description: Typewriter-inspired theme for the Charlottesville Playwrights Collective.
Version: 0.1.0
Requires at least: 6.0
Requires PHP: 7.4
Text Domain: cville-playwrights
*/

/* ---------- Fonts ---------- */
/* Courier Prime, served from the theme (SIL Open Font License, see assets/fonts/OFL.txt). */
@font-face {
  font-family: "Courier Prime";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("assets/fonts/courier-prime-400.woff2") format("woff2");
}

@font-face {
  font-family: "Courier Prime";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("assets/fonts/courier-prime-700.woff2") format("woff2");
}

/* ---------- Tokens ---------- */
:root {
  --cpc-navy: #1e1e5b;          /* main colour of the hero image */
  --cpc-dim: 0.75;              /* darkness of the hero overlay, 0 to 1; the page background follows it */
  --cpc-wheat: wheat;           /* site title and button text */
  --cpc-text: #1a1a1a;          /* body text on white */
  --cpc-navy-hover: #2e2e85;    /* buttons on hover */
  --cpc-type: "Courier Prime", "Courier New", Courier, monospace;  /* site title and buttons only */
  --cpc-sans: Arial, Helvetica, sans-serif;                        /* everything else */

  /* Hero image size: 2154 x 1630 */
  --cpc-hero-ratio: 2154 / 1630;

  /* Header sizes. The title scales with width, but also with height, so short
     wide screens still have room for the content below it. 3.75rem = 60px. */
  --cpc-title-size: clamp(1.375rem, min(4.2vw, 7vh), 3.75rem);
  --cpc-logo-size: calc(3.45 * var(--cpc-title-size)); /* 3 title lines x 1.15 line height */
  --cpc-logo-full: var(--cpc-logo-size); /* keeps the full size while the header is compact */
  --cpc-edge: 4%; /* space between the screen edges and the header / wide-screen content */
  --cpc-header-pad: clamp(1rem, 3vw, 2.5rem); /* space above the header */

  /* Compact header, after scrolling (desktop): title on one line, logo to match. */
  --cpc-title-compact: min(1.375rem, 2.3vw, var(--cpc-title-size)); /* 22px, a little less on narrow desktops */
  --cpc-logo-compact: calc(3.45 * var(--cpc-title-compact));
  --cpc-compact-pad: 0.75rem;

  /* Page background: the navy as it looks under the hero overlay, so the two match. */
  --cpc-page: #080817;
}

@supports (background-color: color-mix(in srgb, red, black 50%)) {
  :root {
    --cpc-page: color-mix(in srgb, var(--cpc-navy), black calc(var(--cpc-dim) * 100%));
  }
}

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

body {
  margin: 0;
  background-color: var(--cpc-page);
  color: var(--cpc-text);
  font-family: var(--cpc-sans);
}

/* ---------- Hero ---------- */
/* The image is a full-width backdrop. The title and the main content sit on top of it,
   so the content starts near the top of the screen however tall the image is. */
.cpc-hero {
  position: relative;
  width: 100%;
  /* At least as tall as the image; grows if the content is longer. */
  aspect-ratio: var(--cpc-hero-ratio);
  background-color: var(--cpc-page);
  background-image: url("assets/images/hero.png");
  background-size: 100% auto;
  background-position: top center;
  background-repeat: no-repeat;
}

/* Dark overlay over the image only. It fades into the page colour at the
   bottom, so there is no hard edge where the image ends. */
.cpc-hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  aspect-ratio: var(--cpc-hero-ratio);
  background-image: linear-gradient(
    to bottom,
    rgba(0, 0, 0, var(--cpc-dim)) 0%,
    rgba(0, 0, 0, var(--cpc-dim)) 75%,
    var(--cpc-page) 100%
  );
}

/* Header and main sit above the overlay. The header goes on top of main,
   so the panel's wide shadow never darkens the logo. */
.cpc-header,
.cpc-main {
  position: relative;
  z-index: 1;
}

.cpc-header {
  z-index: 2;
}

/* Header: logo at the top left, title to its right, menu at the top right,
   over the dark corner of the image. The header's font size sets the size
   of the logo and title, so they always line up. */
.cpc-header {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: var(--cpc-header-pad) var(--cpc-edge) 0;
  font-size: var(--cpc-title-size);
}

/* Logo: the SVG in a white square, as tall as the three lines of the title. */
.cpc-logo {
  flex: none;
  width: var(--cpc-logo-size);
  height: var(--cpc-logo-size);
  overflow: hidden; /* the orange stage at the bottom of the logo follows the rounded corners */
  background-color: #fff;
  border-radius: 4px;
  box-shadow: 0 0 24px 4px rgba(0, 0, 0, 0.45);
}

.cpc-logo a,
.cpc-logo img {
  display: block;
  width: 100%;
  height: 100%;
}

/* Site title. */
.cpc-site-title {
  margin: 0;
  color: var(--cpc-wheat);
  font-family: var(--cpc-type);
  font-weight: 700;
  font-size: 1em;
  line-height: 1.15;
  text-align: left;
}

.cpc-site-title a {
  color: inherit;
  text-decoration: none;
}

/* ---------- Top menu ---------- */
/* Pushed to the right of the header, level with the top of the logo. */
.cpc-nav {
  align-self: flex-start;
  margin-left: auto;
  padding-left: 1.5rem; /* always some space between the title and the menu */
}

.cpc-nav__list {
  display: flex;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cpc-nav__list a {
  color: var(--cpc-wheat);
  font-family: var(--cpc-sans);
  font-weight: 700;
  font-size: 0.9375rem;
  letter-spacing: 0.12em;
  white-space: nowrap;
  text-transform: uppercase; /* menu labels show in capitals however they're typed */
  text-decoration: none;
}

.cpc-nav__list a:hover,
.cpc-nav__list a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.3em;
}

/* Narrower screens: the title needs the full width, so the menu
   moves onto its own line above the logo, still on the right. */
@media (max-width: 760px) {
  .cpc-header {
    flex-wrap: wrap;
    padding-top: 0.75rem;
  }

  .cpc-nav {
    order: -1;
    flex-basis: 100%;
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.4em;
  }

  .cpc-nav__list a {
    font-size: 0.8125rem;
  }
}

/* Phones: fixed spacing from the screen edges. */
@media (max-width: 640px) {
  .cpc-header {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* ---------- Sticky, shrinking header (desktop) ---------- */
/* The header stays at the top of the screen. Once the page is scrolled
   (header.js adds .is-compact), the title drops to one line and the logo
   shrinks to match. */
@media (min-width: 900px) {
  .cpc-header {
    position: sticky;
    top: var(--wp-admin--admin-bar--height, 0px); /* below the admin bar when logged in */
    transition:
      font-size 0.25s ease,
      padding 0.25s ease,
      margin 0.25s ease,
      background-color 0.25s ease,
      box-shadow 0.25s ease;
  }

  .cpc-logo {
    transition: width 0.25s ease, height 0.25s ease, box-shadow 0.25s ease;
  }

  .cpc-header.is-compact {
    --cpc-title-size: var(--cpc-title-compact);
    --cpc-logo-size: var(--cpc-logo-compact);
    padding-top: var(--cpc-compact-pad);
    padding-bottom: var(--cpc-compact-pad);
    /* Makes up the height the header loses, so the page below doesn't jump. */
    margin-bottom: calc(
      var(--cpc-header-pad) + var(--cpc-logo-full) - 2 * var(--cpc-compact-pad) - var(--cpc-logo-compact)
    );
    background-color: rgba(8, 8, 23, 0.92);
    background-color: color-mix(in srgb, var(--cpc-page) 92%, transparent);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  }

  .cpc-header.is-compact .cpc-logo {
    box-shadow: none;
  }

  .cpc-header.is-compact .cpc-site-title {
    white-space: nowrap;
    /* While the text is still shrinking, clip it rather than let it run under the menu. */
    min-width: 0;
    overflow: hidden;
  }

  .cpc-header.is-compact .cpc-site-title br {
    display: none;
  }

  .cpc-header.is-compact .cpc-nav {
    align-self: center;
  }
}

@media (min-width: 900px) and (prefers-reduced-motion: reduce) {
  .cpc-header,
  .cpc-logo {
    transition: none;
  }
}

/* ---------- Layout ---------- */
.cpc-main {
  width: 100%;
  max-width: 60rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 5vh, 3rem) 1rem 3rem;
}

/* Wide screens: the content starts at the logo's right edge, with the
   same gap on the right, so it sits centred on the page. */
@media (min-width: 900px) {
  .cpc-main {
    max-width: none;
    padding-left: calc(var(--cpc-edge) + var(--cpc-logo-size));
    padding-right: calc(var(--cpc-edge) + var(--cpc-logo-size));
  }
}

/* ---------- Content panel ---------- */
.cpc-panel {
  /* 80% white: some of the image shows through, while body text keeps
     a contrast ratio of about 11:1 (well above the 4.5:1 accessibility minimum). */
  background-color: rgba(255, 255, 255, 0.8);
  color: var(--cpc-text);
  padding: clamp(1.25rem, 4vw, 2.5rem);
  border-radius: 4px;
  line-height: 1.6;
  /* A dark glow spreading out from behind the panel, to soften
     the step from the dark image to the white box. */
  box-shadow:
    0 0 24px 4px rgba(0, 0, 0, 0.45),
    0 0 80px 30px rgba(0, 0, 0, 0.4),
    0 0 160px 80px rgba(0, 0, 0, 0.3);
}

/* The box can be very wide; keep lines of text at a comfortable reading length,
   in a column centred in the box. */
.cpc-panel > * {
  max-width: 39rem; /* about 70 characters of body text; rem so larger headings share the same column */
  margin-left: auto;
  margin-right: auto;
}

/* Keeps the content's own top margin from pushing the first heading down. */
.cpc-panel > :first-child {
  margin-top: 0;
}

.cpc-panel + .cpc-panel {
  margin-top: 1.5rem;
}

/* ---------- Call-to-action button ---------- */
/* Every Button block in the editor gets this look automatically, whichever
   style is picked. .cpc-button gives a plain link the same look. */
.cpc-button,
.wp-block-button .wp-block-button__link {
  display: inline-block;
  padding: 1em 2.25em;
  border: 0;
  border-radius: 0;
  background-color: var(--cpc-navy);
  color: var(--cpc-wheat);
  font-family: var(--cpc-type);
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1.2;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.cpc-button:hover,
.wp-block-button .wp-block-button__link:hover {
  background-color: var(--cpc-navy-hover);
  color: var(--cpc-wheat);
}

.cpc-button:focus-visible,
.wp-block-button .wp-block-button__link:focus-visible {
  outline: 3px solid var(--cpc-navy);
  outline-offset: 3px;
}

/* ---------- Footer ---------- */
.cpc-footer {
  padding: 2rem 1rem;
  color: var(--cpc-wheat);
  font-family: var(--cpc-sans);
  font-size: 0.875rem;
  text-align: center;
}

.cpc-footer p {
  margin: 0;
}

.cpc-footer__sep {
  margin: 0 0.5em;
}

/* Phones: the location goes on its own line instead of after a separator. */
@media (max-width: 640px) {
  .cpc-footer__sep {
    display: none;
  }

  .cpc-footer__place {
    display: block;
    margin-top: 0.25rem;
  }
}
