/**
 * @file
 * APU Essay Review · engraved opening plaque.
 *
 * Styles the markup the essay review filter builds from
 *   {{opening: ...}}  → figure.fg-engraved.fg-engraved--opening
 *   {{opening_cta}}   → p.fg-engraved__cta (inside the plaque) or
 *                       div.fg-engraved.fg-engraved--solo (on its own)
 *
 * CSS only: wood, frame, corner scrolls, quotation marks and the burned-in
 * text effect are all gradients, borders and generated content. No images,
 * no JavaScript.
 *
 * Specificity: the theme styles body copy with
 *   .node__content figure              { margin: 32px 0 }        (0,1,1)
 *   .node__content .field--name-body p { max-width: 65ch }       (0,2,1)
 *   blockquote                         { border-left: 3px gold } (0,0,1)
 * and theme CSS loads after module CSS, so a tie goes to the theme. Every
 * rule here is scoped as .fg-engraved .fg-engraved__plaque … (0,3,x) or
 * .fg-engraved.fg-engraved (0,2,0) for the root, which beats those rules
 * without !important.
 *
 * Fonts: Great Vibes (the two quotation marks only) and Cormorant Garamond
 * Italic (body text: Latin, extended Latin, Vietnamese), both SIL Open Font License,
 * self-hosted in css/fonts so the strict CSP (font-src 'self') needs no
 * external domain. Licenses sit beside them.
 */

/* Great Vibes, cut down to the two curly quotation marks (2.6 KB):
   pyftsubset great-vibes-latin-400-normal.woff2 --unicodes=U+201C,U+201D
   unicode-range keeps the browser from fetching it for anything else. */
@font-face {
  font-family: "APU Great Vibes";
  src: url("fonts/great-vibes-quotes.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+201C, U+201D;
}

/* Cormorant Garamond Medium Italic, basic Latin. */
@font-face {
  font-family: "APU Cormorant";
  src: url("fonts/cormorant-garamond-latin-500-italic.woff2") format("woff2");
  font-weight: 500;
  font-style: italic;
  font-display: swap;
  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;
}

/* Extended Latin, so a name such as "Śruti" stays in one font. Only
   downloaded when the plaque text contains one of these characters. */
@font-face {
  font-family: "APU Cormorant";
  src: url("fonts/cormorant-garamond-latin-ext-500-italic.woff2") format("woff2");
  font-weight: 500;
  font-style: italic;
  font-display: swap;
  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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Vietnamese, so a name such as "Nguyễn" stays in one font. Only
   downloaded when the plaque text contains one of these characters. */
@font-face {
  font-family: "APU Cormorant";
  src: url("fonts/cormorant-garamond-vietnamese-500-italic.woff2") format("woff2");
  font-weight: 500;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

/* Georgia sized to Cormorant's measurements, used until Cormorant arrives,
   so the swap does not re-break the 23px lines and push the page down.
   Values: Cormorant (xWidthAvg 359/1000, ascent 924, descent 287) against
   Georgia's published metrics (xWidthAvg 913/2048) from @capsizecss/metrics.
   No published metrics exist for Georgia Italic, so these are close, not
   exact; confirm with a Lighthouse layout-shift check. */
@font-face {
  font-family: "APU Cormorant Fallback";
  src: local("Georgia Italic"), local("Georgia-Italic"), local("Georgia");
  font-style: italic;
  font-weight: 500;
  size-adjust: 80.53%;
  ascent-override: 114.74%;
  descent-override: 35.64%;
  line-gap-override: 0%;
}

/* ===== Root ===== */
.fg-engraved.fg-engraved {
  --fg-engraved-wood: #f6ebd3;
  --fg-engraved-burn: #6b3c13;
  --fg-engraved-hi: rgba(255, 250, 236, 0.8);
  --fg-engraved-halo: rgba(107, 60, 19, 0.22);
  --fg-engraved-script: "APU Great Vibes", "Segoe Script", cursive;
  --fg-engraved-serif: "APU Cormorant", "APU Cormorant Fallback", Georgia, serif;
  --fg-engraved-label: Arial, Helvetica, sans-serif;
  max-width: 640px;
  margin: 40px auto;
  padding: 0;
}

/* Desktop: left edge in line with the essay paragraphs. Below 768px the
   plaque stays centred (the essay-review CSS uses the same breakpoint). */
@media (min-width: 768px) {
  .fg-engraved.fg-engraved {
    margin-left: 0;
    margin-right: 0;
  }
}

/* ===== Plaque: light beech, no grain lines ===== */
.fg-engraved .fg-engraved__plaque {
  position: relative;
  isolation: isolate;
  padding: 62px 64px 44px;
  color: var(--fg-engraved-burn);
  background-color: var(--fg-engraved-wood);
  background-image:
    linear-gradient(100deg, rgba(255, 253, 246, 0.6) 0%, transparent 50%, rgba(170, 120, 62, 0.06) 100%),
    radial-gradient(125% 95% at 50% 45%, transparent 64%, rgba(140, 88, 36, 0.08) 100%);
  border-radius: 5px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 22px 34px -22px rgba(55, 30, 8, 0.42),
    0 2px 5px rgba(55, 30, 8, 0.12);
  /* Light edge below each stroke reads as letters cut into the wood. */
  text-shadow: 0 1px 0 var(--fg-engraved-hi), 0 0 1px var(--fg-engraved-halo);
}

/* ===== Quoted paragraphs (theme blockquote reset) ===== */
.fg-engraved .fg-engraved__plaque .fg-engraved__text {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--fg-engraved-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 23px;
  line-height: 1.62;
  color: inherit;
  text-align: center;
  quotes: "\201C" "\201D";
}

/* Child combinator: plaque typography stops at the essay paragraphs, so a
   comment note's own <p> inside the blockquote keeps its styling. */
.fg-engraved .fg-engraved__plaque .fg-engraved__text > p {
  max-width: none;
  margin: 0 0 0.6em;
  font: inherit;
  color: inherit;
}

.fg-engraved .fg-engraved__plaque .fg-engraved__text > p:last-of-type {
  margin-bottom: 0;
}

/* Quotation marks are generated, so editors type only the paragraph.
   Child-combinator and :*-of-type keep them on the first and last
   paragraphs even when an editor-note <aside> sits between or after. */
.fg-engraved .fg-engraved__plaque .fg-engraved__text > p:first-of-type::before,
.fg-engraved .fg-engraved__plaque .fg-engraved__text > p:last-of-type::after {
  position: relative;
  top: 0.32em;
  font-family: var(--fg-engraved-script);
  font-style: normal;
  font-size: 1.9em;
  line-height: 0;
}

.fg-engraved .fg-engraved__plaque .fg-engraved__text > p:first-of-type::before {
  content: open-quote;
  margin-right: 0.08em;
}

.fg-engraved .fg-engraved__plaque .fg-engraved__text > p:last-of-type::after {
  content: close-quote;
  margin-left: 0.06em;
}

/* ===== Editor notes opened inside the plaque =====
   A {{comment:}} in the opening puts its <aside> popover inside the
   blockquote, where it would inherit the italic, the centring and the
   engraved glow. Reset those; the note's own CSS does the rest. */
.fg-engraved .fg-engraved__plaque .apu-editor-note {
  /* Only properties the note CSS leaves to inheritance; its own rules set
     font-family, font-size, line-height and color, and this rule must
     not beat them. */
  font-style: normal;
  font-weight: 400;
  text-align: start;
  text-shadow: none;
  quotes: none;
}

/* ===== Guide CTA: Arial capitals between two hairlines ===== */
.fg-engraved .fg-engraved__plaque .fg-engraved__cta {
  max-width: none;
  margin: 30px 0 0;
  text-align: center;
}

.fg-engraved .fg-engraved__plaque .fg-engraved__cta a {
  display: inline-block;
  max-width: 30em;
  min-height: 44px; /* WCAG 2.2 touch target */
  padding: 10px 16px;
  font-family: var(--fg-engraved-label);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.55;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-wrap: balance;
  color: var(--fg-engraved-burn);
  text-decoration: none;
  border-top: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
}

.fg-engraved .fg-engraved__plaque .fg-engraved__cta a:hover {
  text-decoration: underline;
  text-decoration-style: solid;
  text-underline-offset: 4px;
}

.fg-engraved .fg-engraved__plaque .fg-engraved__cta a:focus-visible {
  outline: 2px solid var(--fg-engraved-burn);
  outline-offset: 3px;
}

/* ===== Store address at the foot ===== */
.fg-engraved .fg-engraved__plaque .fg-engraved__mark {
  max-width: none;
  margin: 22px 0 0;
  font-family: var(--fg-engraved-label);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-align: center;
  color: inherit;
  opacity: 0.85;
}

/* ===== Double burned frame ===== */
.fg-engraved .fg-engraved__plaque .fg-engraved__frame {
  position: absolute;
  inset: 14px;
  z-index: -1;
  border: 2px solid var(--fg-engraved-burn);
  outline: 1px solid var(--fg-engraved-burn);
  outline-offset: -7px;
  border-radius: 2px;
  pointer-events: none;
  filter: drop-shadow(0 1px 0 var(--fg-engraved-hi));
}

/* ===== Corner scrolls (top right, mirrored bottom left) ===== */
.fg-engraved .fg-engraved__plaque .fg-engraved__orn {
  --o: var(--fg-engraved-burn);
  position: absolute;
  z-index: -1;
  width: 92px;
  height: 92px;
  pointer-events: none;
  filter: drop-shadow(0 1px 0 var(--fg-engraved-hi));
  background:
    radial-gradient(circle at 100% 0, var(--o) 0 4.5px, transparent 5.5px),
    radial-gradient(circle at 100% 0, transparent 0 25px, var(--o) 26px 27.5px, transparent 28.5px),
    radial-gradient(circle at 100% 0, transparent 0 44px, var(--o) 45px 46px, transparent 47px),
    radial-gradient(circle at 60% 9%, var(--o) 0 2.4px, transparent 3.2px),
    radial-gradient(circle at 73% 25%, var(--o) 0 2.4px, transparent 3.2px),
    radial-gradient(circle at 89% 36%, var(--o) 0 2.4px, transparent 3.2px),
    radial-gradient(10px 4.5px at 34% 7%, var(--o) 0 92%, transparent 100%),
    radial-gradient(4.5px 10px at 94% 64%, var(--o) 0 92%, transparent 100%),
    radial-gradient(circle at 22% 20%, transparent 0 6px, var(--o) 6.5px 8px, transparent 8.6px),
    radial-gradient(circle at 80% 78%, transparent 0 6px, var(--o) 6.5px 8px, transparent 8.6px),
    linear-gradient(var(--o), var(--o)) 0 3px / 62% 1.5px no-repeat,
    linear-gradient(var(--o), var(--o)) calc(100% - 3px) 100% / 1.5px 62% no-repeat;
}

.fg-engraved .fg-engraved__plaque .fg-engraved__orn--tr {
  top: 22px;
  right: 22px;
}

.fg-engraved .fg-engraved__plaque .fg-engraved__orn--bl {
  bottom: 22px;
  left: 22px;
  transform: rotate(180deg);
}

/* ===== Solo CTA strip ===== */
.fg-engraved--solo .fg-engraved__plaque {
  padding: 34px 40px;
}

.fg-engraved--solo .fg-engraved__plaque .fg-engraved__cta {
  margin: 0;
}

/* ===== Small screens ===== */
@media (max-width: 560px) {
  .fg-engraved .fg-engraved__plaque {
    padding: 52px 34px 30px;
  }

  .fg-engraved .fg-engraved__plaque .fg-engraved__text {
    font-size: 20px;
  }

  .fg-engraved .fg-engraved__plaque .fg-engraved__orn {
    width: 62px;
    height: 62px;
  }

  .fg-engraved .fg-engraved__plaque .fg-engraved__orn--tr {
    top: 18px;
    right: 18px;
  }

  .fg-engraved .fg-engraved__plaque .fg-engraved__orn--bl {
    bottom: 18px;
    left: 18px;
  }

  .fg-engraved .fg-engraved__plaque .fg-engraved__cta a {
    font-size: 12px;
    letter-spacing: 0.1em;
  }
}

/* High-contrast preference: drop the engraving glow. */
@media (prefers-contrast: more) {
  .fg-engraved .fg-engraved__plaque {
    text-shadow: none;
  }
}

@media print {
  .fg-engraved .fg-engraved__plaque {
    box-shadow: none;
  }
}
