/* ============================================================================
   AliothPress Design System — Core
   
   This file defines ALL CSS custom properties (design tokens) and the 
   minimal reset. Themes override these variables to change the look.
   
   Architecture:
     core.css        → tokens + reset (this file)
     typography.css  → fonts, headings, prose
     components.css  → header, footer, cards, nav, buttons
     responsive.css  → media queries, mobile layout
     themes/xxx.css  → theme overrides (colors, fonts, radii)
   
   Naming convention: --ap-{category}-{property}
   ap = AliothPress
   ============================================================================ */


/* ============================================================================
   1. DESIGN TOKENS (CSS Custom Properties)
   
   All visual decisions live here. Themes override ONLY these variables.
   Components reference these — never hardcode colors/sizes.
   ============================================================================ */

:root {
  /* --- Colors: Neutral palette --- */
  --ap-color-white: #ffffff;
  --ap-color-black: #0f172a;
  
  --ap-color-gray-50:  #f8fafc;
  --ap-color-gray-100: #f1f5f9;
  --ap-color-gray-200: #e2e8f0;
  --ap-color-gray-300: #cbd5e1;
  --ap-color-gray-400: #94a3b8;
  --ap-color-gray-500: #64748b;
  --ap-color-gray-600: #475569;
  --ap-color-gray-700: #334155;
  --ap-color-gray-800: #1e293b;
  --ap-color-gray-900: #0f172a;
  
  /* --- Colors: Semantic (themes override these) --- */
  --ap-color-primary:     #2563eb;
  --ap-color-primary-hover:#1d4ed8;
  --ap-color-primary-light:#dbeafe;
  --ap-color-primary-subtle:#eff6ff;
  
  --ap-color-accent:       #7c3aed;
  --ap-color-accent-hover: #6d28d9;
  
  --ap-color-success:  #16a34a;
  --ap-color-warning:  #d97706;
  --ap-color-error:    #dc2626;
  --ap-color-info:     #0891b2;
  
  /* --- Surfaces & Text --- */
  --ap-color-bg:           var(--ap-color-white);
  --ap-color-surface:      var(--ap-color-gray-50);
  --ap-color-surface-alt:  var(--ap-color-gray-100);
  --ap-color-border:       var(--ap-color-gray-200);
  --ap-color-border-strong:var(--ap-color-gray-300);
  
  --ap-color-text:         var(--ap-color-gray-900);
  --ap-color-text-secondary:var(--ap-color-gray-600);
  --ap-color-text-muted:   var(--ap-color-gray-400);
  --ap-color-text-inverse: var(--ap-color-white);
  --ap-color-link:         var(--ap-color-primary);
  --ap-color-link-hover:   var(--ap-color-primary-hover);
  
  /* --- Header --- */
  --ap-header-bg:          var(--ap-color-gray-900);
  --ap-header-text:        var(--ap-color-white);
  --ap-header-link:        rgba(255, 255, 255, 0.85);
  --ap-header-link-hover:  var(--ap-color-white);
  --ap-header-height:      64px;
  
  /* --- Footer --- */
  --ap-footer-bg:          var(--ap-color-gray-50);
  --ap-footer-text:        var(--ap-color-gray-600);
  --ap-footer-link:        var(--ap-color-gray-600);
  --ap-footer-link-hover:  var(--ap-color-gray-900);
  --ap-footer-border:      var(--ap-color-border);
  
  /* --- Typography scale (modular, 1.25 ratio) --- */
  --ap-font-heading:  system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ap-font-body:     system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ap-font-mono:     'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  
  --ap-text-xs:    0.75rem;    /* 12px */
  --ap-text-sm:    0.875rem;   /* 14px */
  --ap-text-base:  1rem;       /* 16px */
  --ap-text-lg:    1.125rem;   /* 18px */
  --ap-text-xl:    1.25rem;    /* 20px */
  --ap-text-2xl:   1.5rem;     /* 24px */
  --ap-text-3xl:   1.875rem;   /* 30px */
  --ap-text-4xl:   2.25rem;    /* 36px */
  --ap-text-5xl:   3rem;       /* 48px */
  
  --ap-leading-tight:  1.25;
  --ap-leading-normal: 1.6;
  --ap-leading-relaxed:1.75;
  
  --ap-font-weight-normal:  400;
  --ap-font-weight-medium:  500;
  --ap-font-weight-semibold:600;
  --ap-font-weight-bold:    700;
  
  /* --- Spacing (8px base grid) --- */
  --ap-space-1:  0.25rem;   /* 4px */
  --ap-space-2:  0.5rem;    /* 8px */
  --ap-space-3:  0.75rem;   /* 12px */
  --ap-space-4:  1rem;      /* 16px */
  --ap-space-5:  1.25rem;   /* 20px */
  --ap-space-6:  1.5rem;    /* 24px */
  --ap-space-8:  2rem;      /* 32px */
  --ap-space-10: 2.5rem;    /* 40px */
  --ap-space-12: 3rem;      /* 48px */
  --ap-space-16: 4rem;      /* 64px */
  --ap-space-20: 5rem;      /* 80px */
  --ap-space-24: 6rem;      /* 96px */
  
  /* --- Layout --- */
  --ap-container-max:   1200px;
  --ap-container-narrow: 768px;
  --ap-container-wide:  1400px;
  --ap-container-pad:   var(--ap-space-5);  /* Side padding */
  
  /* --- Borders & Shapes --- */
  --ap-radius-sm:  4px;
  --ap-radius-md:  8px;
  --ap-radius-lg:  12px;
  --ap-radius-xl:  16px;
  --ap-radius-full:9999px;
  
  --ap-border-width: 1px;
  
  /* --- Shadows --- */
  --ap-shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.05);
  --ap-shadow-md:   0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --ap-shadow-lg:   0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --ap-shadow-xl:   0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  
  /* --- Transitions --- */
  --ap-transition-fast:   150ms ease;
  --ap-transition-normal: 250ms ease;
  --ap-transition-slow:   350ms ease;
  
  /* --- Z-index scale --- */
  --ap-z-dropdown:  100;
  --ap-z-sticky:    200;
  --ap-z-overlay:   300;
  --ap-z-modal:     400;
  --ap-z-toast:     500;
}


/* ============================================================================
   2. CSS RESET (minimal, modern)
   
   Only what's needed — no bloat.
   ============================================================================ */

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

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

body {
  font-family: var(--ap-font-body);
  font-size: var(--ap-text-base);
  line-height: var(--ap-leading-normal);
  color: var(--ap-color-text);
  background-color: var(--ap-color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

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

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

.ap-prose a:not(.ap-btn):not(.ap-slideshow__btn):not(.ap-form__submit),
.ap-table a:not(.ap-btn):not(.ap-slideshow__btn):not(.ap-form__submit) {
  text-decoration: underline;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

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

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

ul,
ol {
  list-style: none;
}

/* 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;
}


/* ============================================================================
   3. LAYOUT UTILITIES
   ============================================================================ */

.ap-container {
  width: 100%;
  max-width: var(--ap-container-max);
  margin-inline: auto;
  padding-inline: var(--ap-container-pad);
}

.ap-container--narrow {
  max-width: var(--ap-container-narrow);
}

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


/* ============================================================================
   4. PAGE TEMPLATE LAYOUTS
   
   Activated by class on <article>:
     .ap-page--default     → centered content, max-width 768px
     .ap-page--full-width  → content spans full container (1200px)
     .ap-page--landing     → no header/meta, full-width, hero-ready
   
   Pages with template='sidebar' in DB gracefully fall back to default.
   ============================================================================ */

/* --- Base page styles (all templates) --- */
.ap-page {
  padding: var(--ap-space-10) 0 var(--ap-space-16);
}

.ap-page__header {
  text-align: center;
  margin-bottom: var(--ap-space-10);
}

.ap-page__title {
  font-family: var(--ap-font-heading);
  font-size: var(--ap-text-4xl);
  font-weight: var(--ap-font-weight-bold);
  line-height: var(--ap-leading-tight);
  color: var(--ap-color-text);
}

.ap-page__meta {
  color: var(--ap-color-text-muted);
  font-size: var(--ap-text-sm);
  margin-top: var(--ap-space-3);
}

.ap-page__featured-image {
  margin-bottom: var(--ap-space-10);
  border-radius: var(--ap-radius-lg);
  overflow: hidden;
}

.ap-page__featured-image img {
  width: 100%;
  height: auto;
  display: block;
}

.ap-page__featured-image figcaption {
  text-align: center;
  font-size: var(--ap-text-sm);
  color: var(--ap-color-text-muted);
  margin-top: var(--ap-space-2);
}

/* --- Default: centered, readable width --- */
.ap-page--default .ap-page__content {
  max-width: var(--ap-container-narrow);
  margin-inline: auto;
  font-size: var(--ap-text-lg);
  line-height: var(--ap-leading-relaxed);
}

/* --- Full Width: content spans full container --- */
.ap-page--full-width .ap-page__content {
  max-width: var(--ap-container-max);
  margin-inline: auto;
  font-size: var(--ap-text-lg);
  line-height: var(--ap-leading-relaxed);
}

.ap-page--full-width .ap-page__featured-image {
  border-radius: 0;
  margin-left: calc(-1 * var(--ap-container-pad));
  margin-right: calc(-1 * var(--ap-container-pad));
}

/* --- Landing Page: no header, full-width, hero-ready --- */
.ap-page--landing {
  padding-top: 0;
  padding-bottom: 0;
}

.ap-page--landing .ap-page__header {
  display: none;
}

/*
  Landing uses the same wide container as Full Width for non-section content.
  Section blocks break out to full viewport on their own via .ap-section--full
  (using left:50% + transform), so no 100vw breakout needed here.
*/
.ap-page--landing .ap-page__content {
  max-width: var(--ap-container-max);
  margin-inline: auto;
  font-size: var(--ap-text-lg);
  line-height: var(--ap-leading-relaxed);
}

.ap-page--landing .ap-page__featured-image {
  border-radius: 0;
  margin-bottom: 0;
}

/* --- Landing Narrow: like Default reading width, but no title, sections break out --- */
.ap-page--landing-narrow {
  padding-top: 0;
  padding-bottom: 0;
}

.ap-page--landing-narrow .ap-page__header {
  display: none;
}

.ap-page--landing-narrow .ap-page__content {
  max-width: var(--ap-container-narrow);
  margin-inline: auto;
  font-size: var(--ap-text-lg);
  line-height: var(--ap-leading-relaxed);
}

.ap-page--landing-narrow .ap-page__featured-image {
  border-radius: 0;
  margin-bottom: 0;
}

/* --- Sidebar fallback: gracefully degrade to default --- */
.ap-page--sidebar .ap-page__content {
  max-width: var(--ap-container-narrow);
  margin-inline: auto;
  font-size: var(--ap-text-lg);
  line-height: var(--ap-leading-relaxed);
}

/* --- Responsive: page templates --- */
@media (max-width: 768px) {
  .ap-page__title {
    font-size: var(--ap-text-3xl);
  }

  .ap-page__header {
    margin-bottom: var(--ap-space-6);
  }

  .ap-page {
    padding: var(--ap-space-6) 0 var(--ap-space-10);
  }
}
