/* Backyard Permit Notes: base stylesheet */
:root {
  --ink: #18263a;
  --ink-soft: #3d4b5c;
  --muted: #606c76;
  --paper: #f6f8f4;
  --card: #ffffff;
  --line: #dce2de;
  --teal: #0e7478;
  --teal-dark: #0a585b;
  --sand: #d6a85c;
  --sand-soft: #f6ead5;
  --radius: 12px;
  --measure: 720px;
  --wide: 1080px;
  --font-body: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-ui: Inter, "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --step--1: clamp(0.84rem, 0.82rem + 0.1vw, 0.9rem);
  --step-0: clamp(1.02rem, 0.98rem + 0.2vw, 1.12rem);
  --step-1: clamp(1.2rem, 1.12rem + 0.4vw, 1.4rem);
  --step-2: clamp(1.45rem, 1.3rem + 0.8vw, 1.85rem);
  --step-3: clamp(1.8rem, 1.5rem + 1.5vw, 2.6rem);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 1.5rem;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.68;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
iframe {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
}

a {
  color: var(--teal);
  text-decoration-thickness: 0.07em;
  text-underline-offset: 0.18em;
  text-decoration-skip-ink: auto;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

a:hover,
a:focus-visible {
  color: var(--teal-dark);
  text-decoration-color: var(--sand);
}

a:focus-visible {
  outline: 3px solid var(--sand);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------- page frame ---------- */
.site {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.shell,
.frame {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

.top {
  background: var(--card);
  border-top: 6px solid var(--teal);
  border-bottom: 1px solid var(--line);
}

.top-in {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0.9rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  font-family: var(--font-ui);
}

.brand {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand a {
  color: var(--ink);
  text-decoration: none;
}

.nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
}

.nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: var(--step--1);
  font-weight: 500;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}

.nav a:hover,
.nav a:focus-visible {
  color: var(--teal);
  border-bottom-color: var(--sand);
}

.layout {
  flex: 1 1 auto;
}

.layout-in {
  max-width: var(--wide);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3.5rem) 1.25rem 4rem;
}

.main-in,
.article-in {
  max-width: var(--measure);
  margin: 0 auto;
}

/* ---------- article head ---------- */
.article-head {
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
h3 {
  font-family: var(--font-ui);
  color: var(--ink);
  line-height: 1.22;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

h1 {
  font-size: var(--step-3);
  font-weight: 800;
  margin: 0 0 0.9rem;
}

h2 {
  font-size: var(--step-2);
  font-weight: 750;
  margin: 2.8rem 0 0.9rem;
  padding-top: 1.4rem;
  border-top: 3px solid var(--sand-soft);
}

h3 {
  font-size: var(--step-1);
  font-weight: 700;
  margin: 2rem 0 0.6rem;
  color: var(--ink-soft);
}

.meta {
  font-family: var(--font-ui);
  font-size: var(--step--1);
  color: var(--muted);
  margin: 0 0 1.2rem;
}

.article-head p:not(.meta) {
  font-size: calc(var(--step-0) * 1.06);
  color: var(--ink);
}

p {
  margin: 0 0 1.1rem;
  hanging-punctuation: first;
}

/* ---------- sections and prose ---------- */
.sec {
  position: relative;
}

.sec-a,
.sec-b,
.sec-c,
.sec-d,
.prose,
.prose-inner {
  position: relative;
}

.prose-inner > :first-child {
  margin-top: 0;
}

ul,
ol {
  margin: 0 0 1.3rem;
  padding-left: 1.4rem;
}

li {
  margin: 0 0 0.45rem;
  padding-left: 0.2rem;
}

li::marker {
  color: var(--teal);
  font-weight: 700;
}

ol {
  counter-reset: item;
}

ol li::marker {
  font-family: var(--font-ui);
}

ul.sources {
  font-family: var(--font-ui);
  font-size: var(--step--1);
  padding-left: 1.1rem;
}

ul.sources li {
  margin-bottom: 0.35rem;
}

blockquote {
  margin: 1.4rem 0;
  padding: 0.9rem 1.2rem;
  border-left: 4px solid var(--sand);
  background: var(--sand-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
  color: var(--ink-soft);
}

blockquote p:last-child {
  margin-bottom: 0;
}

dl {
  margin: 0 0 1.6rem;
  padding: 1rem 1.2rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

dt {
  font-family: var(--font-ui);
  font-weight: 700;
  color: var(--teal-dark);
  margin-top: 0.8rem;
}

dt:first-child {
  margin-top: 0;
}

dd {
  margin: 0.15rem 0 0;
  color: var(--ink-soft);
}

address {
  font-style: normal;
  font-family: var(--font-ui);
  font-size: var(--step--1);
  margin: 0 0 1.4rem;
  padding: 0.8rem 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink-soft);
}

/* ---------- media ---------- */
.media {
  margin: 1.6rem 0 1.8rem;
}

.media-frame {
  position: relative;
}

.media-inner {
  position: relative;
}

.img-wrap {
  margin: 0;
}

.img-wrap a {
  display: block;
  border-radius: var(--radius);
}

.img-wrap a:hover img {
  border-color: var(--teal);
}

.video {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: #0d1720;
}

.video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---------- footer ---------- */
.foot {
  background: var(--ink);
  color: #c9d3dc;
  margin-top: auto;
}

.foot-in {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 1.6rem 1.25rem;
  font-family: var(--font-ui);
  font-size: var(--step--1);
}

.foot-in p {
  margin: 0;
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  body {
    line-height: 1.62;
  }

  .top-in {
    flex-direction: column;
    align-items: flex-start;
  }

  h2 {
    margin-top: 2.2rem;
    padding-top: 1rem;
  }

  dl,
  address,
  blockquote {
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }

  .media {
    margin-left: -0.4rem;
    margin-right: -0.4rem;
  }
}

@media (min-width: 1100px) {
  .media {
    margin-left: -3rem;
    margin-right: -3rem;
  }
}

/* ---------- dark mode ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e6ecef;
    --ink-soft: #c3ccd3;
    --muted: #93a0aa;
    --paper: #10181f;
    --card: #17222b;
    --line: #2a3742;
    --teal: #5cc3c4;
    --teal-dark: #8ad7d6;
    --sand: #e0b46a;
    --sand-soft: #2b2619;
  }

  img {
    background: #f6f8f4;
  }

  .foot {
    background: #0a1015;
  }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- print ---------- */
@media print {
  :root {
    --paper: #ffffff;
    --card: #ffffff;
  }

  .top,
  .foot,
  .video {
    display: none;
  }

  body {
    font-size: 11pt;
    line-height: 1.5;
    color: #000;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  .prose-inner a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    word-break: break-all;
  }

  h2,
  h3 {
    break-after: avoid;
    page-break-after: avoid;
  }

  img,
  dl,
  blockquote,
  address {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .media {
    margin: 0.8rem 0;
  }
}

/* ---------- selection and skip link ---------- */
::selection {
  background: var(--sand-soft);
  color: var(--ink);
}

.skip {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  z-index: 20;
  padding: 0.5rem 0.9rem;
  background: var(--ink);
  color: #fff;
  font-family: var(--font-ui);
  border-radius: 6px;
}

.skip:focus {
  left: 0.75rem;
}

/* ---------- scrollbars ---------- */
html {
  scrollbar-color: var(--teal) var(--paper);
  scrollbar-width: thin;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--paper);
}

::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 10px;
  border: 2px solid var(--paper);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--teal);
}

/* ---------- heading anchors ---------- */
h2[id],
h3[id] {
  scroll-margin-top: 1.5rem;
}

h2 + p,
h3 + p {
  margin-top: 0;
}

h2 + .media,
h3 + .media {
  margin-top: 0.8rem;
}

.prose-inner p + ul,
.prose-inner p + ol {
  margin-top: -0.3rem;
}

/* ---------- long words and numbers ---------- */
.prose-inner {
  overflow-wrap: break-word;
  hyphens: manual;
  font-variant-numeric: lining-nums proportional-nums;
}

.prose-inner a {
  overflow-wrap: anywhere;
}

ul.sources a {
  overflow-wrap: anywhere;
}

/* ---------- emphasis ---------- */
strong,
b {
  font-weight: 700;
  color: var(--ink);
}

em,
i {
  font-style: italic;
}

abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
}

small {
  font-size: 0.85em;
}

hr {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 2.4rem 0;
}

/* ---------- forced colors (Windows high contrast) ---------- */
@media (forced-colors: active) {
  .top,
  dl,
  address,
  blockquote,
  img {
    border: 1px solid CanvasText;
  }

  a {
    color: LinkText;
  }

  .nav a:hover,
  .nav a:focus-visible {
    border-bottom-color: Highlight;
  }

  li::marker {
    color: CanvasText;
  }
}

/* ---------- mid-size screens ---------- */
@media (min-width: 641px) and (max-width: 1099px) {
  .layout-in {
    padding-left: 2rem;
    padding-right: 2rem;
  }

  .media {
    margin-left: -1rem;
    margin-right: -1rem;
  }
}

/* ---------- very wide screens ---------- */
@media (min-width: 1500px) {
  :root {
    --measure: 760px;
    --wide: 1180px;
  }

  body {
    font-size: 1.15rem;
  }
}

/* ---------- small phones ---------- */
@media (max-width: 380px) {
  .layout-in {
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }

  h1 {
    font-size: 1.6rem;
  }

  .nav ul {
    gap: 0.3rem 0.9rem;
  }

  ul,
  ol {
    padding-left: 1.15rem;
  }
}

/* ---------- landscape phones ---------- */
@media (max-height: 480px) and (orientation: landscape) {
  .top {
    position: static;
  }

  .video {
    aspect-ratio: 21 / 9;
  }
}

/* ---------- hover-capable pointers ---------- */
@media (hover: hover) and (pointer: fine) {
  dl:hover,
  address:hover {
    border-color: var(--teal);
  }

  ul.sources li:hover {
    color: var(--teal-dark);
  }
}

/* ---------- touch targets ---------- */
@media (pointer: coarse) {
  .nav a {
    display: inline-block;
    padding: 0.5rem 0;
  }

  ul.sources li {
    margin-bottom: 0.6rem;
  }
}

/* ---------- index page list ---------- */
.index-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}

.index-list li {
  padding: 1rem 1.1rem;
  margin-bottom: 0.8rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.index-list li a {
  font-family: var(--font-ui);
  font-weight: 700;
  text-decoration: none;
}

.index-list li p {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: var(--step--1);
}

/* ---------- reduced data ---------- */
@media (prefers-reduced-data: reduce) {
  img {
    content-visibility: auto;
  }

  .video {
    background: var(--card);
  }
}

/* ---------- higher contrast preference ---------- */
@media (prefers-contrast: more) {
  :root {
    --muted: #3f4a53;
    --line: #9aa6ae;
  }

  a {
    text-decoration-thickness: 0.12em;
  }

  .meta {
    color: var(--ink-soft);
  }
}

/* ---------- print page setup ---------- */
@page {
  margin: 18mm 16mm;
}

@media print {
  .article-head {
    border-bottom: 1px solid #999;
  }

  h1 {
    font-size: 20pt;
  }

  h2 {
    font-size: 15pt;
    border-top: 1px solid #999;
  }

  h3 {
    font-size: 12.5pt;
  }

  dl,
  address {
    border: 1px solid #999;
  }

  blockquote {
    background: none;
    border-left: 3px solid #999;
  }
}

/* ---------- article footer spacing ---------- */
.sec:last-of-type .prose-inner {
  padding-bottom: 1rem;
}

.sec + .sec {
  margin-top: 0.4rem;
}

.article-body > .sec:first-of-type h2 {
  margin-top: 1.8rem;
}

.article-head .meta + p::first-line {
  font-weight: 600;
}

/* ---------- list rhythm inside sections ---------- */
.prose-inner li:last-child {
  margin-bottom: 0;
}

.prose-inner ol li {
  padding-left: 0.35rem;
}
