/*
Theme Name: Fallback Engineering Field Manual
Theme URI: https://fallbackengineering.com/
Author: Eric Howell / KM7GHS
Description: A dark field-manual theme for Fallback Engineering projects and Field Notes.
Version: 1.1.0
Text Domain: fallback-engineering
*/

:root {
  --fe-amber: #c88b3a;
  --fe-amber-bright: #e0aa5d;
  --fe-bone: #dacdb2;
  --fe-bone-bright: #efe5cf;
  --fe-charcoal: #0a0c0c;
  --fe-ash: #1a1d1d;
  --fe-ash-raised: #232727;
  --fe-copper: #8f7351;
  --fe-red: #a64032;
  --fe-muted: #aa9c81;
  --fe-line: rgba(143, 115, 81, 0.44);
  --fe-content: 790px;
  --fe-wide: 1160px;
  --fe-radius: 3px;
  --fe-shadow: 0 26px 80px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--fe-charcoal);
  color: var(--fe-bone);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  opacity: 0.11;
  background-image:
    linear-gradient(rgba(200, 139, 58, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(200, 139, 58, 0.12) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 82%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.045;
  background-image: repeating-linear-gradient(115deg, transparent 0 5px, #fff 6px, transparent 7px 12px);
}

a {
  color: var(--fe-amber-bright);
  text-decoration-color: rgba(200, 139, 58, 0.58);
  text-underline-offset: 0.18em;
}
a:hover, a:focus { color: #f2c57f; }
img { max-width: 100%; height: auto; }

h1, h2, h3, h4, h5, h6 {
  color: var(--fe-bone-bright);
  line-height: 1.1;
  letter-spacing: -0.025em;
  margin: 0 0 0.65em;
}
h1 { font-size: clamp(3rem, 7vw, 6rem); }
h2 { font-size: clamp(2rem, 4vw, 3.35rem); }
h3 { font-size: clamp(1.25rem, 2vw, 1.65rem); }
p, ul, ol, blockquote, figure, table { margin-top: 0; margin-bottom: 1.4rem; }

::selection { background: var(--fe-amber); color: var(--fe-charcoal); }

.screen-reader-text {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
.screen-reader-text:focus {
  clip: auto !important;
  width: auto; height: auto;
  padding: 0.75rem 1rem;
  top: 0.5rem; left: 0.5rem;
  background: var(--fe-bone-bright);
  color: var(--fe-charcoal);
  z-index: 100000;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  border-top: 3px solid var(--fe-amber);
  border-bottom: 1px solid var(--fe-line);
  background: rgba(10, 12, 12, 0.95);
  backdrop-filter: blur(18px);
}
.site-header__inner {
  width: min(calc(100% - 2rem), var(--fe-wide));
  margin: 0 auto;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}
.site-branding {
  display: flex;
  align-items: center;
  min-width: 0;
}
.site-logo,
.site-logo .custom-logo-link {
  display: flex;
  align-items: center;
}
.custom-logo {
  display: block;
  width: auto;
  max-width: min(430px, 43vw);
  max-height: 48px;
  object-fit: contain;
  object-position: left center;
}
.site-title {
  color: var(--fe-bone-bright);
  font-size: 1.05rem;
  font-weight: 820;
  letter-spacing: 0.095em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}
.site-title::before {
  content: "FE";
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-right: 0.8rem;
  border: 1px solid var(--fe-amber);
  color: var(--fe-amber);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.primary-nav ul {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.primary-nav a {
  display: block;
  padding: 0.68rem 0.72rem;
  color: var(--fe-muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid transparent;
}
.primary-nav a:hover,
.primary-nav a:focus,
.primary-nav .current-menu-item > a,
.primary-nav .current_page_item > a {
  color: var(--fe-bone-bright);
  border-color: var(--fe-line);
  background: var(--fe-ash);
}

.menu-toggle {
  display: none;
  border: 1px solid var(--fe-line);
  background: var(--fe-ash);
  color: var(--fe-bone-bright);
  padding: 0.65rem 0.85rem;
  border-radius: var(--fe-radius);
  font-weight: 750;
}

.site-main { min-height: 70vh; }
.site-main--standard,
.post-shell {
  width: min(calc(100% - 2rem), var(--fe-content));
  margin: 0 auto;
  padding: clamp(3rem, 7vw, 6rem) 0;
}
.post-shell--wide { width: min(calc(100% - 2rem), var(--fe-wide)); }
.entry-header { margin-bottom: 3rem; }
.entry-kicker,
.project-label {
  color: var(--fe-amber) !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem !important;
  font-weight: 800;
  letter-spacing: 0.12em !important;
  text-transform: uppercase !important;
}
.entry-meta { color: var(--fe-muted); font-size: 0.92rem; }

/* Single homepage masthead, supplied through WordPress Custom Header. */
.brand-masthead {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--fe-line);
  background: #050606;
}
.brand-masthead::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 -80px 90px rgba(0,0,0,.32);
}
.brand-masthead img {
  display: block;
  width: 100%;
  min-height: 390px;
  max-height: 700px;
  object-fit: cover;
  object-position: center;
}

.front-page-content { overflow: clip; }
.front-page-content > .wp-block-group:first-child {
  position: relative;
  isolation: isolate;
  border-bottom: 1px solid var(--fe-line) !important;
  background:
    radial-gradient(circle at 80% 20%, rgba(200,139,58,.10), transparent 36%),
    var(--fe-ash);
}
.front-page-content > .wp-block-group:first-child > .wp-block-group__inner-container {
  width: min(calc(100% - 2rem), var(--fe-wide));
  margin: 0 auto;
  padding: clamp(4rem, 8vw, 7rem) 0;
}
.front-page-content:not(.has-brand-cover) > .wp-block-group:first-child {
  min-height: min(720px, calc(100vh - 76px));
  display: flex;
  align-items: center;
  background:
    linear-gradient(90deg, rgba(10,12,12,.92), rgba(10,12,12,.66)),
    radial-gradient(circle at 78% 48%, rgba(200,139,58,.18), transparent 30%),
    var(--fe-charcoal);
}
.front-page-content:not(.has-brand-cover) > .wp-block-group:first-child h1 {
  max-width: 10ch;
  font-size: clamp(3.4rem, 8vw, 7rem) !important;
  line-height: .94 !important;
}
.front-page-content:not(.has-brand-cover) > .wp-block-group:first-child p:first-child {
  color: var(--fe-amber) !important;
}

/* The cover already contains the publication name and tagline. Avoid duplicating them. */
.has-brand-cover > .wp-block-group:first-child h1,
.has-brand-cover > .wp-block-group:first-child p:first-of-type {
  display: none;
}
.has-brand-cover > .wp-block-group:first-child p:nth-of-type(2) {
  max-width: 760px;
  color: var(--fe-bone-bright);
  font-size: clamp(1.7rem, 3.5vw, 3rem) !important;
  font-weight: 760;
  line-height: 1.12 !important;
  letter-spacing: -0.025em;
}
.has-brand-cover > .wp-block-group:first-child p:nth-of-type(3) {
  max-width: 820px;
  color: var(--fe-bone);
  font-size: 1.12rem !important;
}
.has-brand-cover > .wp-block-group:first-child p:nth-of-type(4) {
  color: var(--fe-muted);
}

.front-page-content .alignwide,
.entry-content .alignwide {
  width: min(calc(100% - 2rem), var(--fe-wide));
  max-width: none;
  margin-inline: auto;
}
.front-page-content .alignfull,
.entry-content .alignfull {
  width: 100%;
  max-width: none;
  margin-inline: 0;
}
.front-page-content .wp-block-group__inner-container,
.entry-content .wp-block-group__inner-container {
  width: min(calc(100% - 2rem), var(--fe-wide));
  margin-inline: auto;
}
.front-page-content .alignwide > .wp-block-group__inner-container,
.entry-content .alignwide > .wp-block-group__inner-container {
  width: 100%;
}

.wp-block-group.has-background { border-color: var(--fe-line) !important; }
.wp-block-column.has-background,
.wp-block-group.has-background:not(.alignfull) {
  border-radius: var(--fe-radius);
  box-shadow: var(--fe-shadow);
}
.wp-block-columns { gap: clamp(1rem, 2.5vw, 2rem); }
.wp-block-column { min-width: 0; }

/* Translate the original cyan draft blocks into the established Ghost palette. */
[style*="color:#6bd5ff"],
[style*="color: #6bd5ff"] { color: var(--fe-amber-bright) !important; }
[style*="border-color:#6bd5ff"],
[style*="border-color: #6bd5ff"] { border-color: var(--fe-amber) !important; }
[style*="background-color:#6bd5ff"],
[style*="background-color: #6bd5ff"] {
  background-color: var(--fe-amber) !important;
  color: var(--fe-charcoal) !important;
}
[style*="background-color:#11181d"],
[style*="background-color: #11181d"] { background-color: var(--fe-charcoal) !important; }
[style*="background-color:#18242b"],
[style*="background-color: #18242b"] { background-color: var(--fe-ash) !important; }
[style*="color:#eef4f7"],
[style*="color: #eef4f7"],
[style*="color:#d7e1e6"],
[style*="color: #d7e1e6"] { color: var(--fe-bone) !important; }
[style*="color:#9fb8c4"],
[style*="color: #9fb8c4"] { color: var(--fe-copper) !important; }
[style*="border-color:#3a4b55"],
[style*="border-color: #3a4b55"],
[style*="border-color:#2c3a42"],
[style*="border-color: #2c3a42"] { border-color: var(--fe-line) !important; }

.wp-block-button__link,
button,
input[type="submit"] {
  border-radius: var(--fe-radius) !important;
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease, filter 160ms ease, background 160ms ease;
}
.wp-block-button__link:hover,
button:hover,
input[type="submit"]:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}
.wp-block-button:not(.is-style-outline) .wp-block-button__link {
  background: var(--fe-amber);
  color: var(--fe-charcoal);
}
.wp-block-button.is-style-outline .wp-block-button__link {
  border-color: var(--fe-amber) !important;
  color: var(--fe-amber-bright) !important;
  background: transparent !important;
}

.wp-block-table {
  overflow-x: auto;
  border: 1px solid var(--fe-line);
  border-radius: var(--fe-radius);
  box-shadow: var(--fe-shadow);
}
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--fe-ash);
}
th, td {
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--fe-line);
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--fe-bone-bright);
  background: #111414;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
tr:last-child td { border-bottom: 0; }

blockquote,
.wp-block-quote {
  margin: 2.4rem 0;
  padding: 1.4rem 1.5rem;
  border-left: 4px solid var(--fe-amber);
  background: var(--fe-ash);
  color: var(--fe-bone-bright);
}

.entry-content > *:not(.alignwide):not(.alignfull),
.post-content > *:not(.alignwide):not(.alignfull) {
  max-width: var(--fe-content);
  margin-left: auto;
  margin-right: auto;
}

.post-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}
.post-card {
  border: 1px solid var(--fe-line);
  background: var(--fe-ash);
  border-radius: var(--fe-radius);
  overflow: hidden;
  box-shadow: var(--fe-shadow);
}
.post-card__body { padding: 1.4rem; }
.post-card__title { font-size: 1.35rem; }
.post-card__title a { color: var(--fe-bone-bright); text-decoration: none; }
.post-card__meta { color: var(--fe-copper); font-size: 0.86rem; }

.site-footer {
  border-top: 1px solid var(--fe-line);
  background: #050606;
}
.site-footer__inner {
  width: min(calc(100% - 2rem), var(--fe-wide));
  margin: 0 auto;
  padding: 2.5rem 0;
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  color: var(--fe-muted);
  font-size: 0.9rem;
}
.site-footer a { color: var(--fe-muted); }

@media (max-width: 960px) {
  .menu-toggle { display: inline-flex; }
  .primary-nav {
    display: none;
    position: absolute;
    top: 76px;
    left: 0;
    right: 0;
    padding: 0.75rem 1rem 1rem;
    background: rgba(10,12,12,.99);
    border-bottom: 1px solid var(--fe-line);
  }
  .primary-nav.is-open { display: block; }
  .primary-nav ul { flex-direction: column; align-items: stretch; }
  .primary-nav a { padding: 0.9rem 1rem; }
  .brand-masthead img { min-height: 330px; }
  .post-card-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  .site-header__inner { min-height: 66px; }
  .primary-nav { top: 66px; }
  .custom-logo { max-width: 235px; max-height: 40px; }
  .site-title { font-size: 0.88rem; letter-spacing: 0.06em; }
  .site-title::before { width: 30px; height: 30px; margin-right: 0.55rem; }
  .brand-masthead img {
    min-height: 310px;
    object-position: 60% center;
  }
  .front-page-content > .wp-block-group:first-child > .wp-block-group__inner-container {
    padding: 3.5rem 0;
  }
  .has-brand-cover > .wp-block-group:first-child p:nth-of-type(2) {
    font-size: 2rem !important;
  }
  .wp-block-columns { flex-direction: column; }
  .post-card-grid { grid-template-columns: 1fr; }
  .site-footer__inner { flex-direction: column; }
}
