/* ============================================================
   DIGITAL BUSINESS NUGGETS — Base Styles
   Reset, typography, elements
   ============================================================ */

@layer base {

  /* === Reset === */
  *, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }

  html {
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
    hanging-punctuation: first last;
    scrollbar-color: var(--color-scrollbar) transparent;
    scrollbar-width: thin;
  }

  @view-transition {
    navigation: auto;
  }

  body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    min-height: 100dvh;
    overflow-x: hidden;
    transition: background-color var(--duration-slow) var(--ease-default),
                color var(--duration-slow) var(--ease-default);
  }

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

  /* === Headings === */
  h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--color-heading);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
    text-wrap: balance;
    margin-block: 0;
  }

  h1 {
    font-size: var(--text-4xl);
    font-weight: var(--weight-bold);
    letter-spacing: -0.03em;
  }

  h2 {
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
  }

  h3 {
    font-size: var(--text-xl);
    font-weight: var(--weight-semibold);
  }

  h4 {
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
  }

  h5 {
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    font-family: var(--font-ui);
  }

  h6 {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    font-family: var(--font-ui);
    color: var(--color-text-secondary);
  }

  /* === Body Text === */
  p {
    margin-block-end: var(--space-6);
    text-wrap: pretty;
  }

  .lead {
    font-size: var(--text-lg);
    line-height: var(--leading-relaxed);
    color: var(--color-text-secondary);
  }

  small, .text-small {
    font-size: var(--text-sm);
  }

  strong, b {
    font-weight: var(--weight-bold);
  }

  em, i {
    font-style: italic;
  }

  /* === Links === */
  a {
    color: var(--color-link);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.15em;
    text-decoration-color: color-mix(in srgb, var(--color-link) 40%, transparent);
    transition: color var(--duration-fast) var(--ease-default),
                text-decoration-color var(--duration-fast) var(--ease-default);
  }

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

  a:visited {
    color: var(--color-link-visited);
  }

  a:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
  }

  /* === Lists === */
  ul, ol {
    padding-inline-start: var(--space-6);
    margin-block-end: var(--space-6);
  }

  li {
    margin-block-end: var(--space-2);
    padding-inline-start: var(--space-2);
  }

  li::marker {
    color: var(--color-accent);
  }

  /* === Blockquotes === */
  blockquote {
    position: relative;
    margin-block: var(--space-8);
    margin-inline: 0;
    padding: var(--space-6) var(--space-8);
    border-inline-start: 3px solid var(--color-accent);
    background: var(--color-accent-soft);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-size: var(--text-lg);
    font-style: italic;
    line-height: var(--leading-relaxed);
    color: var(--color-heading);
  }

  blockquote::before {
    content: '\201C';
    position: absolute;
    top: -0.15em;
    left: var(--space-3);
    font-family: var(--font-heading);
    font-size: var(--text-5xl);
    line-height: 1;
    color: var(--color-accent);
    opacity: 0.3;
  }

  blockquote p:last-child {
    margin-block-end: 0;
  }

  blockquote cite,
  blockquote footer {
    display: block;
    margin-block-start: var(--space-4);
    font-size: var(--text-sm);
    font-style: normal;
    font-family: var(--font-ui);
    color: var(--color-text-secondary);
    letter-spacing: var(--tracking-wide);
  }

  blockquote cite::before {
    content: '\2014\00a0';
  }

  /* === Horizontal Rule === */
  hr {
    border: none;
    border-block-start: 1px solid var(--color-border);
    margin-block: var(--space-12);
  }

  hr.ornamental {
    border: none;
    margin-block: var(--space-16);
    text-align: center;
  }

  hr.ornamental::after {
    content: '\25C6\00a0\00a0\25C6\00a0\00a0\25C6';
    color: var(--color-accent);
    font-size: var(--text-xs);
    letter-spacing: 0.3em;
  }

  /* === Code === */
  code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    background: var(--color-code-bg);
    color: var(--color-code-text);
    padding: 0.15em 0.4em;
    border-radius: var(--radius-sm);
    font-variant-ligatures: none;
  }

  pre {
    margin-block: var(--space-8);
    padding: var(--space-6);
    background: var(--color-code-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    -webkit-overflow-scrolling: touch;
  }

  pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
  }

  /* === Tables === */
  table {
    width: 100%;
    margin-block: var(--space-8);
    border-collapse: collapse;
    font-family: var(--font-ui);
    font-size: var(--text-sm);
  }

  thead {
    border-block-end: 2px solid var(--color-heading);
  }

  th {
    font-weight: var(--weight-semibold);
    text-align: start;
    padding: var(--space-3) var(--space-4);
    color: var(--color-heading);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    font-size: var(--text-xs);
  }

  td {
    padding: var(--space-3) var(--space-4);
    border-block-end: 1px solid var(--color-border);
    vertical-align: top;
  }

  tbody tr:hover {
    background-color: var(--color-surface-hover);
  }

  /* === Images === */
  img, picture, video, canvas, svg {
    display: block;
    max-width: 100%;
    height: auto;
  }

  figure {
    margin-block: var(--space-8);
  }

  figcaption {
    margin-block-start: var(--space-3);
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    text-align: center;
  }

  /* === Forms (base) === */
  input, button, textarea, select {
    font: inherit;
    color: inherit;
  }

  button {
    cursor: pointer;
    border: none;
    background: none;
  }

  /* === Misc === */
  abbr[title] {
    text-decoration: underline dotted;
    cursor: help;
  }

  mark {
    background: var(--color-accent-soft);
    color: var(--color-accent-text);
    padding: 0.1em 0.3em;
    border-radius: var(--radius-sm);
  }

  sup, sub {
    font-size: 0.75em;
  }

  /* === Reduced Motion === */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }

  /* === Print === */
  @media print {
    body {
      background: white;
      color: black;
      font-size: 12pt;
    }

    a { color: black; text-decoration: underline; }
    a[href]::after { content: ' (' attr(href) ')'; font-size: 0.8em; }

    nav, .theme-toggle, .subscribe-cta, footer { display: none; }

    h1, h2, h3 { break-after: avoid; }
    img { break-inside: avoid; }
  }
}
