/* ==========================================================================
   LAYOUT UTILITIES CSS
   DigitalCalculator.info Standardized Layout System

   Version: 1.0
   Created: January 12, 2026

   This file provides:
   - Layout container classes
   - Sidebar layout support
   - Spacing utilities
   - Grid utilities
   - Ad zone placeholders (hidden by default)

   Usage: Import after styles.css
   <link rel="stylesheet" href="/layout-utilities.css">
   ========================================================================== */

/* ==========================================================================
   1. CSS VARIABLES - Layout Additions
   ========================================================================== */

:root {
  /* Layout Widths */
  --layout-max: 1200px;
  --layout-wide: 1000px;
  --layout-medium: 800px;
  --layout-narrow: 680px;
  --layout-sidebar: 300px;
  --layout-gutter: 2rem;

  /* Ad Zone Dimensions */
  --ad-banner-height-desktop: 90px;
  --ad-banner-height-mobile: 50px;
  --ad-sidebar-width: 300px;
  --ad-inline-width: 336px;
  --ad-inline-height: 280px;
}


/* ==========================================================================
   2. LAYOUT CONTAINERS
   ========================================================================== */

/* Base layout container - mobile first */
.layout-container {
  width: 100%;
  max-width: var(--layout-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-md);
  padding-right: var(--space-md);
}

@media (min-width: 768px) {
  .layout-container {
    padding-left: var(--space-lg);
    padding-right: var(--space-lg);
  }
}

/* Width modifiers */
.layout-narrow {
  max-width: var(--layout-narrow);
}

.layout-medium {
  max-width: var(--layout-medium);
}

.layout-wide {
  max-width: var(--layout-wide);
}

.layout-full {
  max-width: var(--layout-max);
}


/* ==========================================================================
   3. SIDEBAR LAYOUT
   ========================================================================== */

/* Container for main + sidebar layout */
.layout-with-sidebar {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--layout-gutter);
}

/* Desktop: show sidebar */
@media (min-width: 1024px) {
  .layout-with-sidebar {
    grid-template-columns: 1fr var(--layout-sidebar);
  }
}

/* Main content area */
.layout-main {
  min-width: 0; /* Prevent overflow in grid */
}

/* Sidebar area */
.layout-sidebar {
  display: none;
}

@media (min-width: 1024px) {
  .layout-sidebar {
    display: block;
  }
}

/* Sidebar with sticky behavior */
.layout-sidebar--sticky {
  position: sticky;
  top: calc(64px + var(--space-lg)); /* Below nav */
  align-self: start;
}


/* ==========================================================================
   4. CONTENT BLOCKS
   ========================================================================== */

/* Base content block with bottom margin */
.content-block {
  margin-bottom: var(--space-2xl);
}

/* Last content block - no margin */
.content-block:last-child {
  margin-bottom: 0;
}

/* Narrow width content block */
.content-block--narrow {
  max-width: var(--layout-narrow);
}

/* Featured block with background */
.content-block--featured {
  background: var(--bg-section);
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

/* Card-style block */
.content-block--card {
  background: var(--bg-card);
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}


/* ==========================================================================
   5. SPACING UTILITIES
   ========================================================================== */

/* Margin Top */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-xs); }
.mt-2 { margin-top: var(--space-sm); }
.mt-3 { margin-top: var(--space-md); }
.mt-4 { margin-top: var(--space-lg); }
.mt-5 { margin-top: var(--space-xl); }
.mt-6 { margin-top: var(--space-2xl); }

/* Margin Bottom */
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-xs); }
.mb-2 { margin-bottom: var(--space-sm); }
.mb-3 { margin-bottom: var(--space-md); }
.mb-4 { margin-bottom: var(--space-lg); }
.mb-5 { margin-bottom: var(--space-xl); }
.mb-6 { margin-bottom: var(--space-2xl); }

/* Margin Horizontal */
.mx-auto { margin-left: auto; margin-right: auto; }

/* Padding All */
.p-0 { padding: 0; }
.p-3 { padding: var(--space-md); }
.p-4 { padding: var(--space-lg); }
.p-5 { padding: var(--space-xl); }
.p-6 { padding: var(--space-2xl); }

/* Padding Vertical */
.py-3 { padding-top: var(--space-md); padding-bottom: var(--space-md); }
.py-4 { padding-top: var(--space-lg); padding-bottom: var(--space-lg); }
.py-5 { padding-top: var(--space-xl); padding-bottom: var(--space-xl); }
.py-6 { padding-top: var(--space-2xl); padding-bottom: var(--space-2xl); }

/* Padding Horizontal */
.px-3 { padding-left: var(--space-md); padding-right: var(--space-md); }
.px-4 { padding-left: var(--space-lg); padding-right: var(--space-lg); }
.px-5 { padding-left: var(--space-xl); padding-right: var(--space-xl); }


/* ==========================================================================
   6. GRID UTILITIES
   ========================================================================== */

/* Flexible grid base */
.grid {
  display: grid;
  gap: var(--space-lg);
}

/* Column variants */
.grid--2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid--3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid--4 {
  grid-template-columns: repeat(4, 1fr);
}

/* Auto-fit responsive grid */
.grid--auto {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Mobile: stack all grids */
@media (max-width: 767px) {
  .grid--2,
  .grid--3,
  .grid--4 {
    grid-template-columns: 1fr;
  }
}

/* Tablet: 2 columns for 3+ grids */
@media (min-width: 768px) and (max-width: 1023px) {
  .grid--3,
  .grid--4 {
    grid-template-columns: repeat(2, 1fr);
  }
}


/* ==========================================================================
   7. SECTION UTILITIES
   ========================================================================== */

/* Section with top border */
.section--bordered {
  padding-top: var(--space-xl);
  border-top: 1px solid var(--border);
  margin-top: var(--space-xl);
}

/* Visual section divider */
.section-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-2xl) 0;
}


/* ==========================================================================
   8. AD ZONE PLACEHOLDERS
   All ad zones hidden by default
   Enable by adding 'ads-enabled' class to body
   ========================================================================== */

/* Base ad zone - HIDDEN by default */
.ad-zone {
  display: none;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  text-align: center;
  box-sizing: border-box;
}

/* Enable all ads when body has .ads-enabled */
body.ads-enabled .ad-zone {
  display: block;
}

/* Ad label for transparency (shown when enabled) */
body.ads-enabled .ad-zone::before {
  content: "Advertisement";
  display: block;
  font-size: 0.625rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.25rem;
}

/* ----- Banner Ads (Horizontal) ----- */
.ad-zone--banner {
  width: 100%;
  max-width: 728px;
  min-height: var(--ad-banner-height-desktop);
  margin: var(--space-lg) auto;
  background: var(--bg-section);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* Mobile banner */
@media (max-width: 767px) {
  .ad-zone--banner {
    max-width: 320px;
    min-height: var(--ad-banner-height-mobile);
  }
}

/* Banner position variants */
.ad-zone[data-slot="banner-top"] {
  margin-top: var(--space-md);
  margin-bottom: var(--space-lg);
}

.ad-zone[data-slot="banner-bottom"] {
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
}

/* ----- Sidebar Ads (Vertical) ----- */
.ad-zone--sidebar {
  width: var(--ad-sidebar-width);
  min-height: 250px;
  margin-bottom: var(--space-lg);
  background: var(--bg-section);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* Sticky sidebar ad */
.ad-zone--sidebar-sticky {
  position: sticky;
  top: calc(64px + var(--space-lg));
}

/* ALWAYS hide sidebar ads on mobile/tablet */
@media (max-width: 1023px) {
  .ad-zone--sidebar {
    display: none !important;
  }
}

/* ----- Inline Ads (In-content) ----- */
.ad-zone--inline {
  max-width: var(--ad-inline-width);
  min-height: var(--ad-inline-height);
  margin: var(--space-xl) auto;
  clear: both;
  background: var(--bg-section);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* Mobile inline - smaller */
@media (max-width: 767px) {
  .ad-zone--inline {
    max-width: 300px;
    min-height: 250px;
  }

  /* Only first inline ad on mobile */
  body.ads-enabled .ad-zone--inline:not([data-slot="inline-1"]) {
    display: none !important;
  }
}

/* ----- Native Ads ----- */
.ad-zone--native {
  width: 100%;
  max-width: 100%;
  padding: var(--space-lg);
  background: var(--bg-section);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: var(--space-lg) 0;
}

body.ads-enabled .ad-zone--native::before {
  content: "Sponsored";
}


/* ==========================================================================
   9. VISIBILITY UTILITIES
   ========================================================================== */

/* Hide on specific breakpoints */
.hide-mobile {
  display: block;
}

@media (max-width: 767px) {
  .hide-mobile {
    display: none !important;
  }
}

.hide-desktop {
  display: none;
}

@media (max-width: 767px) {
  .hide-desktop {
    display: block;
  }
}

/* Show only on specific breakpoints */
.show-mobile {
  display: none;
}

@media (max-width: 767px) {
  .show-mobile {
    display: block;
  }
}

.show-desktop {
  display: block;
}

@media (max-width: 767px) {
  .show-desktop {
    display: none;
  }
}


/* ==========================================================================
   10. TEXT UTILITIES
   ========================================================================== */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-muted { color: var(--text-tertiary); }
.text-secondary { color: var(--text-secondary); }


/* ==========================================================================
   11. PRINT STYLES FOR AD ZONES
   ========================================================================== */

@media print {
  .ad-zone {
    display: none !important;
  }
}


/* ==========================================================================
   12. LEGAL DISCLAIMER (LEGAL-001)
   ========================================================================== */

.legal-disclaimer {
  margin: var(--space-xl, 2rem) 0;
  padding: var(--space-md, 1rem);
  background: var(--gray-50, #f9fafb);
  border-left: 4px solid var(--warning, #f59e0b);
  border-radius: var(--radius-sm, 4px);
  font-size: 0.875rem;
  color: var(--text-secondary, #6b7280);
}

.legal-disclaimer strong {
  color: var(--text-primary, #1f2937);
}


/* ==========================================================================
   13. SCREEN READER ONLY (Accessibility)
   ========================================================================== */

.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;
}
