/**
 * Bonus Immobiliare — Base styles (reset + element defaults + signature paper texture)
 * v2.0.0 — 2026-05-25 (DS migration Wave 0)
 *
 * @layer base — depends on @layer tokens defined in tokens.css.
 * Order: tokens → reset → base → layout → components → utilities → overrides.
 *
 * Component-level styles in components.css. Page-specific in pages/<area>.css.
 */

@layer reset {
  *, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }

  html {
    scroll-behavior: smooth;
    text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
  }

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

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

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

  a {
    color: inherit;
    text-decoration: none;
  }

  ul, ol {
    list-style: none;
  }
}

@layer base {
  body {
    font-family: var(--font-body);
    font-size: var(--text-body);
    line-height: var(--leading-relaxed);
    color: var(--fg-default);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    position: relative;
  }

  /* Signature paper texture overlay — body.brand-v2 always-on
     SVG noise STATIC base64 data-URI (NO feTurbulence runtime).
     paint cost: 1x al load, 0ms scroll/repaint (performance-oracle finding).
     Opt-out via class="no-texture" (form-heavy pages: report wizard, calc concordato).
  */
  body.brand-v2:not(.no-texture)::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    opacity: 0.025;
    background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='noise'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23noise)'/></svg>");
  }

  /* Typography — headings use display font (Overlock 700 default) */
  h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: var(--weight-bold);
    line-height: var(--leading-snug);
    color: var(--fg-heading);
    letter-spacing: -0.005em;
  }

  h1 { font-size: var(--text-article-h1); }
  h2 { font-size: var(--text-3xl); }
  h3 { font-size: var(--text-xl); }

  /* Signature italic em highlighting — 4 varianti per context
     (design-implementation-reviewer finding 2026-05-25):
     1) Default cream/light: terracotta italic medium
     2) On dark (olive bg): sage-pale italic
     3) Newsletter band (gradient olive): gold-light italic
     4) Blog hero: sage-pale italic
  */
  h1 em, h2 em, h3 em {
    font-style: italic;
    color: var(--terracotta);
    font-weight: var(--weight-medium);
  }
  .on-dark h1 em,
  .on-dark h2 em,
  .on-dark h3 em {
    color: var(--sage-pale);
  }
  .newsletter h2 em {
    color: var(--gold-light);
  }
  .blog-hero h1 em {
    color: var(--sage-pale);
  }

  p {
    margin-bottom: var(--space-md);
  }

  a {
    color: var(--fg-link);
    text-decoration: none;
    transition: color var(--transition-fast);
  }
  a:hover {
    color: var(--fg-link-hover);
  }

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

  /* Eyebrow label — terracotta uppercase + hairline tracking. */
  .eyebrow {
    font-family: var(--font-body);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    letter-spacing: var(--tracking-extreme);
    text-transform: uppercase;
    color: var(--terracotta);
  }

  /* Eyebrow flanked by hairlines for centered section headers
     "── In evidenza ──" */
  .eyebrow-flanked {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
  }
  .eyebrow-flanked::before,
  .eyebrow-flanked::after {
    content: '';
    width: 30px;
    height: 1px;
    background: currentColor;
    opacity: 0.5;
  }

  /* Focus visible — WCAG AA accessibility */
  :focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    border-radius: 4px;
  }

  /* Selection */
  ::selection {
    background: var(--terracotta-pale);
    color: var(--bark);
  }
}
