/* ==========================================================================
   Fonts
   ========================================================================== */

@font-face {
  font-family: 'Lato';
  font-weight: 100 900;
  font-style: normal;
  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;
}

/* ==========================================================================
   Design Tokens
   ========================================================================== */

:root {
  --color-white: #fff;
  --color-primary: #f7d708;
  --color-primary-light: #fdf7ce;
  --color-primary-accent: #f7d708;
  --color-secondary: #0F3A65;
  --color-text: #333;
  --color-text-muted: #666;
  --color-text-subtle: #777;
  --color-border: #e6e6e6;
  --color-surface: #fffdf8;
  --color-surface-alt: #f5f5f5;
  --color-surface-dark: #2c3e50;
  --color-text-light: #f0f0f0;
  --color-success: #388E3C;
  --color-error: #d32f2f;
  --color-on-primary: #333;
  --color-on-primary-muted: #555;
  --color-on-surface-dark: #f0f0f0;

  --color-selection-bg: #f7d708;
  --color-selection-text: #333;

  --font-body: 'Lato', system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: Consolas, "Liberation Mono", Menlo, Courier, monospace;
  --font-root-size: 19px;
  --font-line-height: 1.5263;

  --step-0: 1rem;
  --step-1: 1.3158rem;
  --step-2: 1.6316rem;
  --step-3: 2.6316rem;
  --step-4: 4.2105rem;

  --baseline: 1.5263rem;

  --space-4xs: calc(var(--baseline) * 0.125);
  --space-3xs: calc(var(--baseline) * 0.25);
  --space-2xs: calc(var(--baseline) * 0.375);
  --space-xs: calc(var(--baseline) * 0.5);
  --space-s: calc(var(--baseline) * 0.75);
  --space-m: var(--baseline);
  --space-l: calc(var(--baseline) * 1.5);
  --space-xl: calc(var(--baseline) * 2);
  --space-2xl: calc(var(--baseline) * 3);
  --space-3xl: calc(var(--baseline) * 4);

  --max-width: 1440px;
  --content-width: 85%;
  --measure: 45rem;

  --transition-fast: 0.2s ease-in-out;
  --transition-slow: 0.3s ease-in-out;
}

/* ==========================================================================
   Dark Mode Colors
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-white: #2c3e50;
    --color-primary: #03E221;
    --color-primary-light: #02B81A;
    --color-primary-accent: #03E221;
    --color-secondary: #2c3e50;
    --color-text: #e8e8e8;
    --color-text-muted: #a0a0a0;
    --color-text-subtle: #888;
    --color-border: #404040;
    --color-surface: #2c3e50;
    --color-surface-alt: #252525;
    --color-surface-dark: #1f2b38;
    --color-text-light: #f0f0f0;
    --color-success: #4CAF50;
    --color-error: #ef5350;
    --color-on-primary: #333;
    --color-on-primary-muted: #555;
    --color-selection-bg: #03E221;
    --color-selection-text: #333;
  }
}

:root[data-theme="dark"] {
  --color-white: #2c3e50;
  --color-primary: #03E221;
  --color-primary-light: #02B81A;
  --color-primary-accent: #03E221;
  --color-secondary: #edc10f;
  --color-text: #e8e8e8;
  --color-text-muted: #a0a0a0;
  --color-text-subtle: #888;
  --color-border: #404040;
  --color-surface: #2c3e50;
  --color-surface-alt: #252525;
  --color-surface-dark: #233240;
  --color-text-light: #f0f0f0;
  --color-success: #4CAF50;
  --color-error: #ef5350;
  --color-on-primary: #333;
  --color-on-primary-muted: #555;
  --color-selection-bg: #03E221;
  --color-selection-text: #333;
}

/* ==========================================================================
   Selection Highlight
   ========================================================================== */
::selection {
  background: var(--color-selection-bg);
  color: var(--color-selection-text);
}

::-moz-selection {
  background: var(--color-selection-bg);
  color: var(--color-selection-text);
}

/* ==========================================================================
   Modern Reset
   ========================================================================== */

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

body {
  background: var(--color-surface);
  margin: 0;
}

h1,
h2,
h3,
h4,
h5,
h6,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

ul[role="list"],
ol[role="list"] {
  list-style: none;
}

html {
  font-size: var(--font-root-size, 19px);
  -webkit-text-size-adjust: 100%;
}

html:focus-within {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: var(--font-line-height);
  font-family: var(--font-body);
  color: var(--color-text);
}

a:not([class]) {
  text-decoration-skip-ink: auto;
}

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

input,
button,
textarea,
select {
  font: inherit;
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1:not(.intro),
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4 {
  font-weight: bold;
  line-height: calc(var(--font-line-height) * 0.85);
  letter-spacing: -0.015em;
}

h1:not(.intro),
.h1 {
  font-size: var(--step-3);
  line-height: 1.16;
  margin-top: var(--baseline);
  margin-bottom: var(--baseline);
  font-weight: 700;
}

@media (min-width: 920px) {
  h1:not(.intro),
  .h1 {
    font-size: var(--step-4);
    line-height: 1.0875;
    margin-top: var(--baseline);
    margin-bottom: calc(var(--baseline) * 2);
    font-weight: 700;
  }
}

h2,
.h2 {
  font-size: var(--step-2);
  margin-top: var(--baseline);
  margin-bottom: 0;
}

@media (min-width: 920px) {
  h2,
  .h2 {
    font-size: var(--step-3);
    line-height: 1.16;
    margin-top: var(--baseline);
    margin-bottom: var(--baseline);
  }
}

h3,
.h3 {
  font-size: var(--step-0);
  margin-top: var(--baseline);
  margin-bottom: 0;
}

@media (min-width: 920px) {
  h3,
  .h3 {
    font-size: var(--step-2);
    line-height: 1.871;
    margin-top: var(--baseline);
    margin-bottom: 0;
  }
}

h4,
.h4 {
  font-size: var(--step-0);
  margin-top: var(--baseline);
  margin-bottom: 0;
}

@media (min-width: 920px) {
  h4,
  .h4 {
    font-size: var(--step-0);
    line-height: var(--font-line-height);
    margin-top: var(--baseline);
    margin-bottom: 0;
  }
}

p,
ul,
ol,
pre,
blockquote {
  margin-top: 0;
  margin-bottom: var(--baseline);
}

p {
  max-width: var(--measure);
}

ul ul,
ol ol,
ul ol,
ol ul {
  margin-top: 0;
  margin-bottom: 0;
}

a,
b,
i,
strong,
em,
small,
code {
  line-height: 0;
}

sub,
sup {
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sup {
  top: -0.5em;
}

sub {
  bottom: -0.25em;
}

hr {
  display: block;
  height: 1px;
  border: 0;
  border-top: 1px solid var(--color-text);
  margin: var(--space-m) 0;
  padding: 0;
}

pre {
  white-space: pre-wrap;
  word-wrap: break-word;
}

pre,
code {
  font-family: var(--font-mono);
  display: block;
  background: var(--color-border);
  padding: var(--space-m);
}

/* ==========================================================================
   Layout
   ========================================================================== */

.wrapper {
  width: var(--content-width);
  max-width: var(--max-width);
  margin: 0 auto;
  padding-bottom: var(--space-m);
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-gap: 0;
}

@media (min-width: 700px) {
  .wrapper {
    grid-column-gap: 1.4rem;
    grid-row-gap: 0;
  }
}

.full,
.post-header {
  grid-column: auto / span 12;
}

/* Content + sidebar */
.info-block,
.post-content,
article {
  grid-column: auto / span 12;
  position: relative;
}

@media (min-width: 700px) {
  .info-block,
  .post-content,
  article {
    grid-column: auto / span 8;
  }
}

aside {
  grid-column: auto / span 12;
  margin-top: 1em;
}

@media (min-width: 700px) {
  aside {
    grid-column: auto / span 4;
    position: sticky;
    top: 2rem;
    margin-top: 0;
    align-self: start;
  }
}

/* Page content */
div.page-content {
  background: var(--color-surface);
}

/* ==========================================================================
   Site Header
   ========================================================================== */

header.site-header {
  margin-bottom: var(--space-xl);
}

.site-header {
  background: var(--color-surface);
  height: auto;
}

.site-header nav {
  display: flex;
  align-items: center;
  grid-column: 1 / -1;
}

.site-header__logo {
  display: block;
  width: calc(var(--baseline) * 3);
  height: calc(var(--baseline) * 3);
  flex-shrink: 0;
  text-decoration: none;
  transition: transform var(--transition-fast);
  margin-left: -0.6rem;
}

@media (min-width: 700px) {
  .site-header__logo {
    margin-left: 0;
    width: calc(var(--baseline) * 2.5);
    height: calc(var(--baseline) * 2.5);
  }
}

.site-header__logo:hover {
  transform: scale(1.05);
}

.site-header__logo img {
  width: 100%;
  height: auto;
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .site-header__logo img {
    filter: invert(1) brightness(2);
    filter: invert(100%) sepia(0%) saturate(3715%) hue-rotate(184deg) brightness(114%) contrast(82%);
  }
}

[data-theme="dark"] .site-header__logo img {
  filter: invert(27%) sepia(100%) saturate(7299%) hue-rotate(7deg) brightness(95%) contrast(125%);
}

[data-theme="light"] .site-header__logo img {
  filter: invert(18%) sepia(60%) saturate(0%) hue-rotate(215deg) brightness(95%) contrast(97%);
}

.site-header__nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: center;
  list-style: none;
  padding: var(--space-2xs) 0;
  margin: 0;
  flex: 1;
  max-width: 12rem;
}

@media (min-width: 700px) {
  .site-header__nav {
    max-width: none;
    justify-content: flex-end;
    align-items: center;
    padding: 0;
  }
}

.site-header__nav-item a {
  display: block;
  padding: 0 var(--space-2xs);
  line-height: 1.3;
  font-size: var(--step-1);
  text-decoration: none;
  text-decoration-color: transparent;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
  color: var(--color-text);
  transition: text-decoration-color var(--transition-fast);
}

@media (min-width: 700px) {
  .site-header__nav-item a {
    display: flex;
    align-items: center;
    justify-content: center;
    height: calc(var(--baseline) * 2);
    padding: 0 var(--space-2xs);
    font-size: var(--step-1);
  }
}

.site-header__nav-item a:hover {
  color: var(--color-text);
  text-decoration: none;
  text-decoration-color: var(--color-text);
}

.site-header__nav-item.is-active a {
  font-weight: 700;
}

/* ==========================================================================
   Theme Toggle
   ========================================================================== */

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.3em;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text);
  opacity: 0.7;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.theme-toggle:hover {
  opacity: 1;
  transform: scale(1.1);
}

@media (max-width: 699px) {
  .site-header {
    position: relative;
  }

  .site-header__nav-item:last-child {
    position: absolute;
    right: 0.5rem;
    top: 0.5rem;
  }
}

.theme-toggle__sun {
  display: none;
}

.theme-toggle__moon {
  display: block;
}

@media (prefers-color-scheme: dark) {
  .theme-toggle__sun {
    display: block;
  }

  .theme-toggle__moon {
    display: none;
  }
}

:root[data-theme="dark"] .theme-toggle__sun {
  display: block !important;
}

:root[data-theme="dark"] .theme-toggle__moon {
  display: none !important;
}

:root[data-theme="light"] .theme-toggle__sun {
  display: none !important;
}

:root[data-theme="light"] .theme-toggle__moon {
  display: block !important;
}

/* ==========================================================================
   Example Header
   ========================================================================== */

header.example-header {
  grid-column: 1 / -1;
  border-bottom: solid 1px #ccc;
  margin-bottom: 1.4rem;
}
/* ==========================================================================
   Dark Mode: Homepage main content uses normal text (dark surface bg)
   ========================================================================== */
@media (prefers-color-scheme: dark) {

  body.home:not([data-theme="light"]) main,
  body.home:not([data-theme="light"]) main h1,
  body.home:not([data-theme="light"]) main h2,
  body.home:not([data-theme="light"]) main h3,
  body.home:not([data-theme="light"]) main p,
  body.home:not([data-theme="light"]) main li,
  body.home:not([data-theme="light"]) main a {
    color: var(--color-text);
  }

  body.home:not([data-theme="light"]) .info-block::after {
    background: var(--color-text);
  }
}

/* Manual dark mode toggle */
:root[data-theme="dark"] body.home main,
:root[data-theme="dark"] body.home main h1,
:root[data-theme="dark"] body.home main h2,
:root[data-theme="dark"] body.home main h3,
:root[data-theme="dark"] body.home main p,
:root[data-theme="dark"] body.home main li,
:root[data-theme="dark"] body.home main a {
  color: var(--color-text);
}

:root[data-theme="dark"] body.home .info-block::after {
  background: var(--color-text);
}

/* Theme toggle on homepage */
body.home .theme-toggle {
  color: var(--color-on-primary);
}

/* Logo on homepage - keep dark  */
@media (prefers-color-scheme: dark) {
  body.home:not([data-theme="light"]) .site-header__logo img {
    filter: none;
  }
}

:root[data-theme="dark"] body.home .site-header__logo img {
  filter: none;
}

/* Dark mode: Tile hover styles need higher specificity on homepage */
@media (prefers-color-scheme: dark) {

  body.home:not([data-theme="light"]) .tile:hover:not(.field-guide-promo),
  body.home:not([data-theme="light"]) .tile:hover:not(.field-guide-promo) h2,
  body.home:not([data-theme="light"]) .tile:hover:not(.field-guide-promo) h3,
  body.home:not([data-theme="light"]) .tile:hover:not(.field-guide-promo) p,
  body.home:not([data-theme="light"]) .tile:hover:not(.field-guide-promo) a {
    color: var(--color-on-primary);
  }
}

:root[data-theme="dark"] body.home .tile:hover:not(.field-guide-promo),
:root[data-theme="dark"] body.home .tile:hover:not(.field-guide-promo) h2,
:root[data-theme="dark"] body.home .tile:hover:not(.field-guide-promo) h3,
:root[data-theme="dark"] body.home .tile:hover:not(.field-guide-promo) p,
:root[data-theme="dark"] body.home .tile:hover:not(.field-guide-promo) a {
  color: var(--color-on-primary);
}


/* Header h1 */
header h1 {
  margin-top: 0.6rem;
}

/* ==========================================================================
   Footer
   ========================================================================== */

footer {
  background: var(--color-surface-dark);
  color: var(--color-text-light);
  margin-top: 6rem;
}

footer a {
  color: var(--color-text-light);
}

footer a:hover {
  color: var(--color-text-light);
}

.footer-meta {
  padding-top: 1em;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   Links
   ========================================================================== */

a {
  color: var(--color-secondary);
  text-decoration: none;
  text-decoration-skip-ink: auto;
  font-weight: 700;
}

a:hover {
  color: var(--color-secondary);
  text-decoration: none;
}

/* ==========================================================================
   Utilities
   ========================================================================== */

.pbn {
  padding-bottom: 0 !important;
}

.mbn {
  margin-bottom: 0;
}

.mtn {
  margin-top: 0;
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Archive / Case Studies page styles
   ========================================================================== */

img {
  border: none;
  width: 200%;
  max-height: 320px;
  object-fit: cover;
  margin-bottom: 2rem;
}

.setTop {
  object-position: calc(150 / 400 * 100%) calc(1 / 320 * 100%);
}

.date {
  margin-bottom: 3rem;
}

h2 {
  margin-top: 4rem;
  text-transform: uppercase;
  font-weight: 500;
  font-size: 2rem;
  line-height: 1;
  margin-right: 1rem;
}

.caption {
  font-weight: 300;
}

h3 {
  text-transform: uppercase;
  font-weight: 500;
  font-size: 1.5rem;
  margin-top: 1rem;
  margin-bottom: 2rem;
  line-height: 1;
}

/* ==========================================================================
   Anchor link on headings
   ========================================================================== */

@media (min-width: 700px) {
  .anchor-link {
    position: relative;
    padding-left: 1.5em;
    margin-left: -1.5em;
  }

  ol.principles .anchor-link {
    padding-left: 2em;
    margin-left: -2em;
  }

  .anchor-link::before {
    content: '';
    position: absolute;
    left: 0.4em;
    top: 0.15em;
    width: 0.8em;
    height: 0.8em;
    opacity: 0;
    cursor: pointer;
    transition: none;
    background-color: var(--color-text-muted);
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/%3E%3C/svg%3E");
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
  }

  ol.principles h2.anchor-link::before {
    left: 0.6em;
  }

  .anchor-link:not(.copied):hover::before {
    opacity: 1;
  }

  .anchor-link.copied::before {
    opacity: 1 !important;
    background-color: var(--color-success);
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  }
}