/*
Theme Name: EMK
Description: Shared theme for the Europe Makine keyword sites. Renders each page from sites/<EMK_SITE>.json through the emk-core mu-plugin. Editorial-industrial: a technical drawing set, not a landing page.
Author: Kilij Digital
Version: 1.0.0
Requires PHP: 8.2
Text Domain: emk
*/

/* ---------- Fonts (self-hosted, SIL OFL 1.1, see fonts/LICENSE.txt) ---------- */

@font-face {
  font-family: "Saira Semi Condensed";
  src: url("fonts/saira-semi-condensed-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Saira Semi Condensed";
  src: url("fonts/saira-semi-condensed-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Hanken Grotesk";
  src: url("fonts/hanken-grotesk-latin-wght-normal.woff2") format("woff2-variations"),
       url("fonts/hanken-grotesk-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ---------- Base ---------- */

:root {
  --display: "Saira Semi Condensed", "Arial Narrow", sans-serif;
  --body: "Hanken Grotesk", ui-sans-serif, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --max: 84rem;
  --gutter: clamp(1rem, 4vw, 3rem);
  --measure: 66ch;
  --margin-col: 7rem;
  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: clamp(1.5rem, 1.2rem + 1.2vw, 2.125rem);
  --step-3: clamp(2.25rem, 1.6rem + 3vw, 4.25rem);
}

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

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

body {
  margin: 0;
  font-family: var(--body);
  font-size: var(--step-0);
  line-height: 1.6;
  font-weight: 400;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.005em;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
.hero :focus-visible { outline-color: var(--hero-link); }
.colophon :focus-visible { outline-color: var(--band-ink); }
main:focus { outline: none; }

.wrap {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip {
  position: absolute;
  left: 1rem;
  top: -10rem;
  z-index: 10;
  padding: 0.75rem 1rem;
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-weight: 600;
}
.skip:focus { top: 1rem; }

.screen-reader-text {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

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

.masthead {
  background: var(--paper);
  border-bottom: 3px solid var(--ink);
}
.masthead__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: space-between;
  gap: 0 2rem;
}
.brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.85rem 0;
  color: var(--ink);
  text-decoration: none;
}
.brand__name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.375rem;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.brand__by {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.nav ul {
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
  height: 100%;
}
.nav li { display: flex; }
.nav a {
  display: flex;
  align-items: center;
  padding: 0.9rem 0.85rem;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.0625rem;
  color: var(--ink);
  text-decoration: none;
  border-left: 1px solid var(--rule);
  box-shadow: inset 0 0 0 var(--accent);
}
.nav li:last-child a { border-right: 1px solid var(--rule); }
.nav a:hover { box-shadow: inset 0 -4px 0 var(--accent); }
.nav a[aria-current="page"] { box-shadow: inset 0 -4px 0 var(--ink); }

@media (max-width: 52em) {
  .masthead__inner { padding-inline: 0; }
  .brand { padding-inline: var(--gutter); }
  .nav { width: 100%; border-top: 1px solid var(--rule); }
  .nav ul { display: grid; grid-template-columns: 1fr 1fr; }
  .nav a { flex: 1 1 auto; border-left: 0; border-bottom: 1px solid var(--rule); padding-inline: var(--gutter); min-height: 3rem; }
  .nav li:nth-child(odd) a { border-right: 1px solid var(--rule); }
  .nav li:last-child a { border-right: 0; }
  .nav li:nth-last-child(-n+2) a { border-bottom: 0; }
}

/* ---------- Hero ---------- */

.hero {
  background: var(--hero-bg);
  color: var(--hero-ink);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  border-bottom: 1px solid var(--ink);
}
.hero a { color: var(--hero-link); }
.hero__text {
  padding: clamp(2rem, 5vw, 4.5rem) var(--gutter) clamp(1.5rem, 3vw, 2.5rem);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: calc(var(--max) / 2 + 6rem);
}
.hero h1 {
  font-size: var(--step-3);
  max-width: 16ch;
}
.hero__intro {
  font-size: var(--step-1);
  line-height: 1.5;
  max-width: 44ch;
  color: var(--hero-ink);
}
.hero__meta {
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--hero-muted);
}
.hero__action { margin: 0.25rem 0 0; }
.hero__photo { margin: 0; position: relative; min-height: 16rem; background: var(--hero-rule); }
.hero__photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 4 / 3;
}

@media (min-width: 64em) {
  .hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .hero--plain, .hero--nophoto { grid-template-columns: minmax(0, 1fr); }
  .hero__text {
    padding-left: max(var(--gutter), calc((100vw - var(--max)) / 2 + var(--gutter)));
    justify-content: center;
    max-width: none;
  }
  .hero__photo { border-left: 1px solid var(--ink); }
  .hero__photo img { position: absolute; inset: 0; aspect-ratio: auto; }
  .hero--plain .hero__text { max-width: none; padding-right: max(var(--gutter), calc((100vw - var(--max)) / 2 + var(--gutter))); }
}

.hero--plain .hero__text { padding-top: clamp(1.75rem, 4vw, 3rem); padding-bottom: clamp(1.75rem, 4vw, 3rem); }
.hero--plain h1 { font-size: var(--step-3); max-width: 24ch; }

/* ---------- Title block (drawing corner) ---------- */

.titleblock {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  margin: 0.75rem 0 0;
  border: 1px solid currentColor;
  font-family: var(--mono);
}
.titleblock__cell {
  padding: 0.5rem 0.75rem;
  border-left: 1px solid currentColor;
  min-width: 0;
}
.titleblock__cell:first-child { border-left: 0; }
.titleblock dt {
  font-size: 0.75rem;
  color: var(--hero-muted);
}
.titleblock dd {
  margin: 0.15rem 0 0;
  font-size: 0.9375rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.hero .titleblock { color: var(--hero-rule); }
.hero .titleblock dd { color: var(--hero-ink); }
.hero .titleblock dd a { color: var(--hero-link); }

@media (max-width: 30em) {
  .titleblock { grid-template-columns: auto minmax(0, 1fr); }
  .titleblock__cell:last-child { grid-column: 1 / -1; border-left: 0; border-top: 1px solid currentColor; }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3rem;
  padding: 0.75rem 1.25rem;
  background: var(--btn-bg);
  color: var(--btn-ink) !important;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: 0.01em;
  text-decoration: none;
  border: 0;
}
.btn::after {
  content: "";
  width: 1.4rem;
  height: 0.7rem;
  background: currentColor;
  clip-path: polygon(0 42%, 70% 42%, 70% 0, 100% 50%, 70% 100%, 70% 58%, 0 58%);
  transition: transform 0.15s ease-out;
}
.btn:hover::after { transform: translateX(3px); }
.hero .btn { outline-offset: 4px; }

/* ---------- Sheet and clauses ---------- */

.sheet { padding-block: clamp(1rem, 3vw, 2rem) clamp(3rem, 6vw, 5rem); }

.clause {
  display: grid;
  grid-template-columns: var(--margin-col) minmax(0, 1fr);
  gap: 0 clamp(1rem, 3vw, 2.5rem);
  padding-block: clamp(2rem, 4vw, 3.25rem);
  border-top: 1px solid var(--rule);
}
.clause:first-child { border-top: 0; }
.clause__no {
  margin: 0;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 1.5rem;
  line-height: 1.1;
  color: var(--link);
  border-top: 3px solid var(--accent);
  padding-top: 0.5rem;
  align-self: start;
}
.clause__body { min-width: 0; }
.clause h2 {
  font-size: var(--step-2);
  margin-bottom: 1.25rem;
  max-width: 28ch;
}
.prose { max-width: var(--measure); }
.prose p { margin-bottom: 1em; }

@media (max-width: 40em) {
  .clause { grid-template-columns: minmax(0, 1fr); }
  .clause__no { border-top: 0; padding-top: 0; font-size: 1rem; margin-bottom: 0.5rem; }
}

/* specs */
.specs-scroll { overflow-x: auto; max-width: 52rem; }
.specs {
  width: 100%;
  border-collapse: collapse;
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}
.specs th, .specs td {
  text-align: left;
  vertical-align: top;
  padding: 0.7rem 0.75rem 0.7rem 0;
  border-bottom: 1px solid var(--rule);
}
.specs tr:last-child th, .specs tr:last-child td { border-bottom: 0; }
.specs th { font-weight: 600; width: 38%; padding-right: 1.5rem; }
.specs td { font-family: var(--mono); font-size: 0.9375rem; }
.specs tr:nth-child(even) { background: var(--panel); }
.specs__source { margin-top: 0.75rem; font-family: var(--mono); font-size: var(--step--1); color: var(--muted); }

/* steps */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 52rem;
  counter-reset: none;
}
.steps__item {
  display: grid;
  grid-template-columns: 4rem minmax(0, 1fr);
  column-gap: 1rem;
  position: relative;
  padding-bottom: 1.75rem;
}
.steps__item::before {
  content: "";
  position: absolute;
  left: 1.25rem;
  top: 2.25rem;
  bottom: 0.25rem;
  width: 2px;
  background: var(--rule);
}
.steps__item:last-child { padding-bottom: 0; }
.steps__item:last-child::before { display: none; }
.steps__n {
  grid-row: 1 / span 2;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.9375rem;
  width: 2.75rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border: 2px solid var(--accent);
  color: var(--ink);
  background: var(--paper);
}
.steps h3 { font-size: var(--step-1); font-weight: 600; margin: 0.2rem 0 0.35rem; }
.steps p { max-width: var(--measure); }

/* figures */
.plate {
  margin: 0;
  padding-block: clamp(1.5rem, 3vw, 2.5rem);
  border-top: 1px solid var(--rule);
}
.plate__frame { border: 1px solid var(--ink); background: var(--paper); }
.plate__frame img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.plate__frame--drawing {
  padding: clamp(0.75rem, 2vw, 1.5rem);
  overflow-x: auto;
  background:
    linear-gradient(var(--panel) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, var(--panel) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--paper);
}
.plate figcaption {
  margin-top: 0.75rem;
  font-size: var(--step--1);
  color: var(--muted);
  max-width: var(--measure);
}
.fig {
  font-family: var(--mono);
  font-weight: 500;
  color: var(--ink);
  margin-right: 0.5rem;
}

/* diagrams */
.dg { width: 100%; min-width: 40rem; font-family: var(--mono); }
.dg text, .dg .dg-label { font-family: var(--mono); font-size: 14px; fill: var(--ink); }
.dg .dg-strong { font-weight: 500; }
.dg .dg-small { font-size: 12.5px; fill: var(--muted); }
.dg .dg-num { fill: var(--link); font-weight: 500; }
.dg-ink { stroke: var(--ink); stroke-width: 2; fill: none; }
.dg-heavy { stroke-width: 3; }
.dg-thin { stroke: var(--ink); stroke-width: 1; fill: none; }
.dg-hatch { stroke: var(--muted); stroke-width: 1; fill: none; }
.dg-dash { stroke: var(--muted); stroke-width: 1.25; stroke-dasharray: 6 5; fill: none; }
.dg-acc { stroke: var(--accent); stroke-width: 2; fill: none; }
.dg-dash-acc { stroke-dasharray: 6 5; }
.dg-flow { stroke-width: 3.5; }
.dg-muted-line { stroke: var(--muted); stroke-width: 1.75; fill: none; }
.dg-fill { fill: var(--panel); }
.dg-paper { fill: var(--paper); }
.dg-acc-fill { fill: var(--panel); }
.dg-head { fill: var(--ink); }
.dg-head-acc { fill: var(--accent); }
.dg-drop { fill: var(--accent); }
.dg-foam { fill: var(--paper); stroke: var(--accent); stroke-width: 1.5; }
.dg-sludge { fill: var(--muted); }
.dg .dg-acc-fill.dg-acc { fill: var(--panel); }

/* questions */
.qa { margin: 0; max-width: 60rem; border-top: 2px solid var(--ink); }
.qa__row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 0.5rem 2rem;
  padding-block: 1.1rem;
  border-bottom: 1px solid var(--rule);
}
.qa dt { font-family: var(--display); font-weight: 600; font-size: 1.1875rem; line-height: 1.25; }
.qa dd { margin: 0; }
@media (max-width: 48em) { .qa__row { grid-template-columns: minmax(0, 1fr); } }

/* link index */
.index { list-style: none; margin: 0; padding: 0; max-width: 60rem; border-top: 2px solid var(--ink); }
.index li { border-bottom: 1px solid var(--rule); }
.index a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.25rem 1.5rem;
  padding: 0.9rem 0;
  color: var(--ink);
  text-decoration: none;
}
.index__label {
  font-family: var(--display);
  font-weight: 600;
  font-size: var(--step-1);
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
.index a:hover .index__label { text-decoration-thickness: 2px; }
.index__url { font-family: var(--mono); font-size: var(--step--1); color: var(--muted); overflow-wrap: anywhere; }
.index__url::after { content: " \2192"; color: var(--accent); }
@media (max-width: 40em) { .index a { grid-template-columns: minmax(0, 1fr); } }

/* route to europemakine.com */
.route {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem 3rem;
  align-items: end;
  margin-top: clamp(1.5rem, 3vw, 2.5rem);
  padding: clamp(1.5rem, 4vw, 2.75rem);
  background: var(--panel);
  border-top: 6px solid var(--accent);
  border-bottom: 1px solid var(--ink);
}
.route h2 { font-size: var(--step-2); margin-bottom: 0.75rem; max-width: 26ch; }
.route p { max-width: 54ch; }
.route__action { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; margin: 0; }
.route__url { font-family: var(--mono); font-size: var(--step--1); color: var(--muted); }
@media (min-width: 52em) { .route { grid-template-columns: minmax(0, 1fr) auto; } }

/* ---------- Breadcrumbs ---------- */

/* Inline, so a long current page wraps as text instead of dropping below "Home". */
.crumbs ol { margin: 0; padding: 0; list-style: none; font-family: var(--mono); font-size: 0.8125rem; line-height: 1.6; }
.crumbs li { display: inline; color: var(--hero-muted); }
.crumbs li + li::before { content: "/"; margin: 0 0.6rem; color: var(--hero-muted); }
.crumbs a { color: var(--hero-link); }
.crumbs [aria-current] { color: var(--hero-ink); }

/* ---------- Blog ---------- */

.ledger { list-style: none; margin: 0 0 2rem; padding: 0; border-top: 2px solid var(--ink); }
.ledger__row {
  display: grid;
  grid-template-columns: 8rem minmax(0, 1fr) auto;
  gap: 0.5rem 2rem;
  padding-block: 1.4rem;
  border-bottom: 1px solid var(--rule);
}
.ledger__date { font-family: var(--mono); font-size: var(--step--1); color: var(--muted); padding-top: 0.3rem; }
.ledger__title { font-size: var(--step-1); font-weight: 600; margin-bottom: 0.4rem; line-height: 1.2; }
.ledger__title a { color: var(--ink); text-decoration-color: var(--accent); }
.ledger__main p { color: var(--muted); max-width: var(--measure); }
.ledger__cat { font-family: var(--mono); font-size: var(--step--1); padding-top: 0.3rem; }
.ledger__empty { padding-block: 2rem; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule); color: var(--muted); }
@media (max-width: 48em) {
  .ledger__row { grid-template-columns: minmax(0, 1fr); gap: 0.25rem; }
  .ledger__date, .ledger__cat { padding-top: 0; }
}

.navigation.pagination { margin: 1rem 0 2rem; }
.nav-links { display: flex; flex-wrap: wrap; gap: 0.5rem; font-family: var(--mono); }
.nav-links .page-numbers { display: inline-grid; place-items: center; min-width: 2.75rem; min-height: 2.75rem; padding: 0 0.75rem; border: 1px solid var(--rule); color: var(--ink); text-decoration: none; }
.nav-links .current { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.article { max-width: 52rem; padding-top: clamp(1.5rem, 3vw, 2.5rem); }
.article__photo { margin: 0 0 2rem; border: 1px solid var(--ink); }
.article__photo img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.article__faq { margin-top: 3rem; }
.article__faq h2 { font-size: var(--step-2); margin-bottom: 1rem; }

.prose--article, .prose--legal { font-size: 1.125rem; }
.prose--legal { padding-top: clamp(1.5rem, 3vw, 2.5rem); }
.prose--article h2, .prose--legal h2 { font-size: var(--step-2); margin: 2.25rem 0 0.75rem; }
.prose--article h3 { font-size: var(--step-1); font-weight: 600; margin: 1.75rem 0 0.5rem; }
.prose ul, .prose ol { padding-left: 1.4rem; margin: 0 0 1em; }
.prose li { margin-bottom: 0.35em; }
.prose li::marker { color: var(--accent); }
.prose table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: 1rem; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 0.6rem 0.75rem 0.6rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.prose thead th { border-bottom: 2px solid var(--ink); font-family: var(--display); font-weight: 600; }
.prose td { font-variant-numeric: tabular-nums; }
.prose img { margin: 1.5rem 0; }

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

.colophon {
  background: var(--band-bg);
  color: var(--band-ink);
  padding-block: clamp(2rem, 5vw, 3.5rem) 2rem;
}
.colophon a { color: var(--band-ink); }
.titleblock--footer {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  color: var(--band-ink);
  margin: 0 0 2rem;
}
.titleblock--footer dt { color: var(--band-ink); opacity: 1; }
.titleblock--footer dd { font-size: 0.875rem; }
.titleblock--footer .titleblock__cell--wide dd { font-family: var(--display); font-weight: 700; font-size: 1.125rem; letter-spacing: 0.02em; }
@media (max-width: 52em) {
  .titleblock--footer { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .titleblock--footer .titleblock__cell:nth-child(odd) { border-left: 0; }
  .titleblock--footer .titleblock__cell:nth-child(n+3) { border-top: 1px solid currentColor; grid-column: auto; }
}
@media (max-width: 30em) {
  .titleblock--footer { grid-template-columns: minmax(0, 1fr); }
  .titleblock--footer .titleblock__cell { border-left: 0; border-top: 1px solid currentColor; }
  .titleblock--footer .titleblock__cell:first-child { border-top: 0; }
}
.colophon__nav ul { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; margin: 0 0 1.5rem; padding: 0; list-style: none; }
.colophon__nav a { display: inline-block; padding-block: 0.4rem; text-decoration: none; border-bottom: 1px solid currentColor; }
.colophon__legal { font-family: var(--mono); font-size: 0.8125rem; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

@media print {
  .masthead .nav, .skip, .route .btn { display: none; }
  .hero { background: none; color: #000; }
}
