/* ==========================================================================
   DBELLERIVE.CA — Global Styles
   Organization:
     0) Design tokens
     1) Reset & base
     2) Layout & structural shells
     3) Typography (global + blog)
     4) Media / imagery helpers
     5) Links & buttons
     6) Components (values grid, stories, pager, social, 404, homepage, bio)
     7) Utilities
     8) Media queries
     9) Dark mode (token overrides)
   ========================================================================== */

/* == 0) DESIGN TOKENS ===================================================== */
:root{
  /* Fonts */
  font-family: Inter, sans-serif;
  font-feature-settings: "liga" 1, "calt" 1;

  /* Brand palette (staples — DO NOT theme-swap) */
  --brand-navy-900: #0F172A;
  --brand-slate-900: #111827;
  --brand-red-600:  #B90000;
  --brand-red-700:  #960000;
  --brand-gray-50:  #F8FAFC;
  --brand-gray-100: #F1F5F9;
  --brand-gray-200: #E5E7EB;
  --brand-gray-600: #475569;
  --brand-gray-800: #1F2937;

  /* Semantic tokens (LIGHT default) */
  --bg: var(--brand-gray-50);
  --surface: #FFFFFF;
  --surface-2: var(--brand-gray-100);

  /* Text */
  --text: #0B1220;
  --ink:  #0B1220;
  --muted: #334155;
  --muted-2: var(--brand-gray-600);

  /* UI */
  --border: rgba(15, 23, 42, .10);
  --border-2: rgba(15, 23, 42, .14);

  --link: var(--brand-red-600);
  --link-hover: var(--brand-red-700);

  --chip: var(--brand-gray-100);
  --chip-hover: #FFFFFF;

  --btn-bg: var(--brand-navy-900);
  --btn-fg: #FFFFFF;

  /* Header/Footer staple colors */
  --chrome-dark: #0F172A;
  --chrome-light: #E5E7EB;

  /* Blog code/blockquote tokens (light) */
  --blockquote-bg: #F8FAFC;
  --code-bg: #F1F5F9;
  --kbd-bg: #F8FAFC;

  /* Layout */
  --container: 1300px;
  --radius: 10px;

  /* Shadows tuned for light */
  --shadow-1: 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-2: 0 6px 18px rgba(15, 23, 42, .10);
  --shadow-3: 0 10px 28px rgba(15, 23, 42, .12);

  /* Motion */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --fast: .2s;
  --med: .3s;

  /* Blog media */
  --media-width: 70%;
}

@supports (font-variation-settings: normal){
  :root{ font-family: InterVariable, sans-serif; }
}

/* == 1) RESET & BASE ====================================================== */
html, body{
  width: 100%;
  margin: 0;
  padding: 0;
}

html{
  background: var(--bg);
}

/* key changes: paint on body + use dynamic viewport height */
body{
  min-height: 100dvh;      /* lets the page extend behind iOS bars */
  background: var(--bg);   /* ensures there is *actual* paint for Safari to sample */
  color: var(--text);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* == 2) LAYOUT & STRUCTURE =============================================== */
main{
  flex: 1;
  width: min(var(--container), 100% - 2rem);
  margin-inline: auto;
  padding: 0;
  color: var(--text);
}

.body-section:first-of-type{ margin-top: 1rem; }

.body-section{
  padding: 1rem;
  margin-bottom: 15px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-3);
}

/* == 3) TYPOGRAPHY ======================================================== */
/* Global headings (outside blog context) */
h2{
  margin: 0 0 1rem;
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: .02em;
}

h3{
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0;
  line-height: 1;
}

/* Blog container & rhythm */
.blog-section{
  color: var(--ink);
  line-height: 1.9;
  font-size: 1rem;

  /* center the tighter column */
  max-width: 900px;
  margin-inline: auto;
}

/* NOTE: this overrides the 900px on post pages.
   If you want 900px there too, delete this block or bump it. */
#post .blog-section{
  max-width: 72ch;
  margin-inline: auto;
}

.blog-section > *:first-child{ margin-top: 0; }

.blog-section p,
.blog-section ul,
.blog-section ol,
.blog-section blockquote,
.blog-section pre,
.blog-section table,
.blog-section figure,
.blog-section .callout{
  margin: 0 0 1rem;
}

/* Post title */
#post-title{
  font-size: clamp(1.9rem, 2.2vw + 1rem, 2.5rem);
  line-height: 1.2;
  font-weight: 400;
  letter-spacing: .01em;
  margin: 0 0 .5rem;
  color: var(--ink);
}

/* In-post headings */
.blog-section h1{
  font-size: clamp(1.5rem, 1.2vw + 1rem, 1.75rem);
  line-height: 1.25;
  font-weight: 700;
  margin: 1.5rem 0 .5rem;
}
.blog-section h2{
  font-size: clamp(1.3rem, 1.1vw + .9rem, 1.5rem);
  line-height: 1.3;
  font-weight: 600;
  margin: 2rem 0 .45rem;
}
.blog-section h3{
  font-size: clamp(1.15rem, .9vw + .85rem, 1.25rem);
  line-height: 1.35;
  font-weight: 500;
}
.blog-section h4{ line-height: 1.15; font-weight: 500; }
.blog-section h5{ line-height: 1.05; font-weight: 500; }

/* Anchor scroll offset */
.blog-section h1[id],
.blog-section h2[id],
.blog-section h3[id],
.blog-section h4[id],
.blog-section h5[id],
.blog-section h6[id]{
  scroll-margin-top: 72px;
}

/* Blog blocks */
.blog-section blockquote{
  margin: 1rem 0;
  padding: .75rem 1rem;
  border-left: 4px solid #6b0000;
  background: var(--blockquote-bg);
  border-radius: 8px;
}
.blog-section blockquote p:last-child{ margin-bottom: 0; }

.blog-section code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .95em;
  background: var(--code-bg);
  padding: .15em .35em;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.blog-section pre{
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.blog-section pre code{
  background: transparent;
  border: 0;
  padding: 0;
  font-size: .95rem;
  display: block;
}

.blog-section kbd{
  background: var(--kbd-bg);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: .1em .4em;
  font-family: inherit;
  font-size: .9em;
}

.blog-section hr{
  border: 0;
  height: 1px;
  background: var(--border);
  margin: 1rem 0;
}

/* Blog media */
.blog-section img,
.blog-section a img{
  display: block;
  max-width: var(--media-width);
  max-height: 700px;
  margin: 1rem auto;
  border-radius: var(--radius);
}

.blog-section figure{
  margin: 1.25rem auto;
  max-width: 100%;
  text-align: center;
}
.blog-section figure img{ margin: 0 auto; }
.blog-section figcaption{
  margin-top: .5rem;
  color: var(--muted);
  font-size: .9rem;
}

.blog-section iframe,
.blog-section figure iframe{
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 16/9;
  border: 0;
  margin-inline: auto;
}
.blog-section figure:where(.video, .embed, .iframe),
.blog-section figure iframe{
  max-width: var(--media-width);
}

/* Blog tables */
.blog-section table{
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;

  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
}
.blog-section thead th{
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.blog-section th,
.blog-section td{
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.blog-section tbody tr:nth-child(odd){
  background: rgba(0, 0, 0, .015);
}

#post .post-meta{
  color: var(--muted);
  font-size: .95rem;
  margin: .25rem 0 1.25rem;
}

/* == 4) MEDIA / IMAGERY HELPERS ========================================== */
.image-content{
  flex: 1 1 0;
  max-width: 100%;
  min-width: 0;
}

.image-content-headshot{
  flex: 0 1 350px;
  max-width: 350px;
}

.image-content img,
.image-content-headshot img{
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  object-fit: contain;
}

.icon-container{
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

.icon{
  position: relative;
  width: 100%;
  height: 100%;
}

.png-icon{
  width: 100%;
  display: block;
  border-radius: var(--radius);
  transition: opacity var(--med) var(--ease);
}

.svg-icon{
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: 70%;
  pointer-events: none;
}

.video-icon{
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  transition: opacity var(--med) var(--ease);
}

.video-icon:hover,
.icon:hover .png-icon{
  opacity: .7;
}

/* == 5) LINKS & BUTTONS =================================================== */
.body-section a{
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.body-section a:hover{
  color: var(--link-hover);
  text-decoration-thickness: 2px;
}
.body-section a:focus{ color: var(--link-hover); }

.button,
.error-btn{
  display: block;
  width: max-content;
  max-width: 100%;
  padding: 5px 20px;
  font-weight: 300;
  font-style: italic;
  background: var(--btn-bg);
  color: var(--btn-fg) !important;
  text-decoration: none !important;
  border-radius: var(--radius);
  text-align: center;
  margin-inline: auto;
  transition: opacity var(--med) var(--ease);
}
.button:hover,
.error-btn:hover{ opacity: .7; }

.button-inline{
  display: inline-block;
  width: auto;
  margin: 0;
}

.button-secondary{
  background: var(--chip);
  color: var(--text) !important;
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-1);
}
.button-secondary:hover,
.button-secondary:focus{ opacity: .85; }

/* CTA row */
.cta-row{
  display: flex;
  justify-content: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-top: .75rem;
}
.cta-row .button,
.cta-row .error-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  width: 220px;
  max-width: 100%;
}

/* == 6) COMPONENTS ======================================================== */
/* Skip link */
.skip-link{
  position: absolute;
  left: 10px;
  top: 10px;
  padding: .6rem .9rem;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-2);
  transform: translateY(-200%);
  transition: transform var(--fast) var(--ease);
  z-index: 9999;
}
.skip-link:focus{
  transform: translateY(0);
  outline: none;
}

/* Flex text/image layouts */
.two-column,
.two-column-reverse{
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: center;
}
.two-column{ flex-direction: row-reverse; }

.text-content{
  flex: 1 1 0;
  min-width: 0;
  overflow-wrap: break-word;
}

/* Proof bar */
ul.proof-bar{
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding: 0;
  margin: .75rem 0 1rem;
  list-style: none;
}
ul.proof-bar li{
  padding: .45rem .7rem;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-1);
  font-size: .95rem;
  line-height: 1.2;
}
ul.proof-bar li::marker{ content: ""; }
ul.proof-bar strong{ font-weight: 700; }

/* 3-up card grid */
.three-column{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  width: 100%;
}

.card{
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--chip);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-1);
  transition: background-color var(--med) var(--ease), box-shadow var(--med) var(--ease);
}
.card:hover{
  background: var(--chip-hover);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
}
.card h3{
  margin-bottom: .5rem;
  line-height: 1.2;
}
.card p{ margin: 0 0 .75rem; }
.card p:last-child{ margin-bottom: 0; }

/* Values grid */
.grid-values{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
  width: 100%;
}
.grid-values .value-box p{
  margin-bottom: .25rem;
  line-height: 1.3;
}

.value-box{
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--chip);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-1);
  transition: background-color var(--med) var(--ease), box-shadow var(--med) var(--ease);
}
.value-box:hover{
  background: var(--chip-hover);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
}

/* Stories index + cards */
.stories-index{
  padding: 1rem;
  color: var(--text);
}
.stories-index h1{
  font-size: 1.75rem;
  margin-bottom: 1rem;
}

.stories-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.story-card{
  background: var(--chip);
  border-radius: var(--radius);
  border: 1px solid var(--border-2);
  overflow: hidden;
  box-shadow: var(--shadow-2);
  transition: background-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
  content-visibility: auto;
  contain-intrinsic-size: 260px 360px;
}
.story-card a{
  display: flex;
  flex-direction: column;
  height: 100%;
  color: inherit;
  text-decoration: none !important;
}
.story-card img{
  aspect-ratio: 16 / 10;
  width: 100%;
  height: auto;
  object-fit: cover;
  object-position: center;
  display: block;
}
.story-card h3{
  font-size: 1.2rem;
  margin: 1rem 1rem .5rem;
  line-height: 1.4;
}
.story-card .meta{
  font-size: .85rem;
  color: var(--muted-2);
  margin: 0 1rem .5rem;
}
.story-card p{
  margin: 0 1rem 1rem;
  font-size: .95rem;
  color: var(--text);
  opacity: .92;
}
.story-card:hover{
  background: var(--chip-hover);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
}

/* Post pager */
.post-pager{
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  color: var(--text);
  gap: 1rem;
  margin-top: 1rem;
  border-radius: var(--radius);
  background: var(--chip);
  font-weight: 700;
}
nav.post-pager{ padding: 1rem; }

.post-pager .pager-link{
  flex: 1;
  display: block;
  padding: .75rem 1rem;
  border-radius: 8px;
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border-2);
  transition: background-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.post-pager .pager-link:hover,
.post-pager .pager-link:focus{
  background: var(--chip-hover);
}
.post-pager .pager-link.newer{ text-align: left; }
.post-pager .pager-link.older{ text-align: right; }

.pager-title{
  display: block;
  margin-top: .25rem;
  font-size: .9rem;
  font-weight: 400;
  color: var(--muted-2);
}

/* Social icons */
.social-icons{
  display: flex;
  justify-content: center;
  align-items: center;
  list-style: none;
  padding: 0;
  gap: 24px;
}
.social-icons li,
.social-icons a{
  display: flex;
  justify-content: center;
  align-items: center;
}
.social-icons a{
  width: 40px;
  height: 40px;
  color: var(--text);
  transition: opacity var(--med) var(--ease);
}
.social-icons a:hover,
.social-icons a:focus-visible{
  opacity: .7;
  outline: none;
}
.social-icons svg{
  width: 24px;
  height: 24px;
  fill: currentColor;
  display: block;
  transition: opacity var(--med) var(--ease);
}

/* 404 button group */
.error-buttons{
  display: flex;
  gap: .75rem;
  justify-content: center;
  flex-wrap: wrap;
}
.error-buttons .error-btn{
  flex: 0 1 auto;
  min-width: 150px;
  white-space: nowrap;
  max-width: 300px;
}

/* BIO / HERO SECTION */
.bio{
  margin: 1.5rem 0;
  padding: 0;
}
.bio .two-column{ align-items: center; }
.bio h1{
  font-size: clamp(2rem, 2.5vw + 1rem, 2.6rem);
  max-width: 34ch;
  font-weight: 400;
  margin: 0 0 1rem;
  line-height: 1.15;
}
.bio p{ margin: 0 0 1rem; }
.bio .proof-bar{ margin: .75rem 0 1rem; }
.bio .accent{
  font-weight: 700;
  color: var(--brand-gray-600);
}

/* == 7) UTILITIES ========================================================= */
.visually-hidden{
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* == 8) MEDIA QUERIES ===================================================== */
@media (max-width: 850px){
  .two-column,
  .two-column-reverse{
    flex-direction: column;
    align-items: stretch;
    text-align: left;
    gap: 0;
    width: 100%;
  }

  .grid-values{
    grid-template-columns: 1fr;
    gap: .5rem;
  }

  .three-column{
    grid-template-columns: 1fr;
    gap: .75rem;
  }

  .cta-row{ justify-content: stretch; }

  .cta-row .button,
  .cta-row .error-btn{
    width: 100%;
  }

  .image-content{
    flex: 1 1 auto;
    max-width: 100%;
    width: 100%;
    display: block;
  }

  .image-content-headshot{
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    margin-bottom: 1rem;
  }

  .image-content-headshot img{
    width: 100%;
    max-width: 350px;
    height: auto;
    border-radius: var(--radius);
    display: block;
    margin: 0 auto;
  }

  .text-content{
    flex: 1 1 100%;
    max-width: 100%;
    width: 100%;
    display: block;
  }

  .blog-section img,
  .blog-section a img{
    max-width: 100%;
    max-height: none;
  }

  .blog-section figure:where(.video, .embed, .iframe),
  .blog-section figure iframe{
    max-width: 100%;
  }
}

@media (max-width: 750px){
  .post-pager{ flex-direction: column; }

  .post-pager .pager-link{
    flex: unset;
    width: 100%;
    padding-top: 1rem;
  }
}

@media (max-width: 500px){
  .error-buttons{
    flex-direction: column;
    align-items: center;
  }

  .error-buttons .error-btn{
    width: 100%;
    max-width: 300px;
  }
}

@media (prefers-reduced-motion: reduce){
  .button,
  .error-btn,
  .story-card,
  .post-pager .pager-link,
  .social-icons a,
  .png-icon,
  .video-icon,
  .story-card a{
    transition: none !important;
  }
}

/* == 9) DARK MODE ======================================================== */
@media (prefers-color-scheme: dark){
  :root{
    --bg: #111111;
    --surface: #141414;
    --surface-2: #292929;

    --text: rgba(255, 255, 255, .92);
    --ink: rgba(255, 255, 255, .92);
    --muted: rgba(255, 255, 255, .70);
    --muted-2: rgba(255, 255, 255, .62);

    --border: rgba(255, 255, 255, .12);
    --border-2: rgba(255, 255, 255, .16);

    --chip: rgba(255, 255, 255, .06);
    --chip-hover: rgba(255, 255, 255, .09);

    --btn-bg: var(--brand-red-600);
    --btn-fg: #0A0C10;

    --blockquote-bg: rgba(255, 255, 255, .05);
    --code-bg: rgba(255, 255, 255, .06);
    --kbd-bg: rgba(255, 255, 255, .07);

    --shadow-1: 0 1px 3px rgba(0, 0, 0, .45);
    --shadow-2: 0 8px 20px rgba(0, 0, 0, .55);
    --shadow-3: 0 12px 28px rgba(0, 0, 0, .60);
  }

  html, body{ background: var(--bg); }
}