/* ==========================================================================
   ALRAHMA AREAS — Shared Design System
   Loaded on: Areas Directory, City Hub, Area pages
   ========================================================================== */

/* --- Design Tokens --- */
:root {
  --al-primary: #ff2714;
  --al-primary-10: rgba(255, 39, 20, .10);
  --al-primary-15: rgba(255, 39, 20, .15);
  --al-primary-ring: 0 0 0 4px rgba(255, 39, 20, .18);
  --al-secondary: #5F656F;
  --al-light: #F5F5F5;
  --al-dark: #02435b;
  --al-dark-04: rgba(2, 67, 91, .04);
  --al-white: #fff;
  --al-border: rgba(2, 67, 91, .12);

  --al-radius-lg: 20px;
  --al-radius: 16px;
  --al-radius-sm: 12px;
  --al-radius-pill: 999px;

  --al-shadow: 0 12px 34px rgba(2, 67, 91, .12);
  --al-shadow-sm: 0 4px 16px rgba(2, 67, 91, .07);
  --al-shadow-hover: 0 16px 40px rgba(2, 67, 91, .16);

  --al-max-w: 1140px;
}

/* --- Base Layout --- */
.al-container {
  width: min(var(--al-max-w), 92%);
  margin-inline: auto;
}

/* --- Topbar --- */
.al-topbar {
  background: var(--al-dark);
  color: var(--al-white);
  padding: 10px 0;
  font-size: 14px;
  line-height: 1.5;
}
.al-topbar__inner {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}
.al-topbar__location {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  opacity: .92;
}
.al-topbar__location svg { flex-shrink: 0; }
.al-topbar__links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.al-topbar__links a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--al-white);
  text-decoration: none;
  font-weight: 700;
  opacity: .92;
  transition: opacity .15s;
}
.al-topbar__links a:hover { opacity: 1; }
.al-topbar__links svg { flex-shrink: 0; }

/* --- Breadcrumbs --- */
.al-breadcrumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 14px;
  color: var(--al-secondary);
  margin-bottom: 6px;
}
.al-breadcrumbs a {
  color: inherit;
  text-decoration: none;
  transition: color .15s;
}
.al-breadcrumbs a:hover { color: var(--al-dark); }
.al-breadcrumbs [aria-current] {
  color: var(--al-dark);
  font-weight: 700;
}

/* --- Buttons --- */
.al-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: var(--al-radius-sm);
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  border: 2px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease, border-color .14s ease;
}
.al-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--al-shadow-sm);
}
.al-btn:active {
  transform: translateY(0);
  box-shadow: none;
}
.al-btn:focus-visible {
  outline: none;
  box-shadow: var(--al-primary-ring);
}
.al-btn--primary {
  background: var(--al-primary);
  color: var(--al-white);
  border-color: var(--al-primary);
}
.al-btn--primary:hover {
  background: #e0220f;
  border-color: #e0220f;
}
.al-btn--outline {
  background: var(--al-white);
  color: var(--al-primary);
  border-color: var(--al-primary);
}
.al-btn--outline:hover {
  background: var(--al-primary-10);
}
.al-btn--soft {
  background: var(--al-dark-04);
  color: var(--al-dark);
  border-color: var(--al-border);
}
.al-btn--soft:hover {
  background: rgba(2, 67, 91, .08);
}

/* --- Cards --- */
.al-card {
  background: var(--al-white);
  border: 1px solid var(--al-border);
  border-radius: var(--al-radius-lg);
  padding: 24px;
  box-shadow: var(--al-shadow-sm);
}
.al-card--glass {
  background: linear-gradient(180deg, rgba(255,255,255,.88), rgba(255,255,255,.94));
  backdrop-filter: saturate(140%) blur(10px);
}
.al-card__title {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--al-dark);
}

/* --- Pill / Badge --- */
.al-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--al-radius-pill);
  background: var(--al-primary-10);
  color: var(--al-primary);
  font-weight: 700;
  font-size: 13px;
}

/* --- Thumbnails --- */
.al-thumb {
  border-radius: var(--al-radius);
  overflow: hidden;
  border: 1px solid var(--al-border);
  box-shadow: var(--al-shadow-sm);
  background: var(--al-dark-04);
  margin-bottom: 14px;
}
.al-thumb img {
  width: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  object-fit: cover;
  display: block;
}
.al-thumb--placeholder {
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: flex-end;
  padding: 16px;
  background:
    radial-gradient(500px 200px at 80% 10%, rgba(255,39,20,.22), transparent 60%),
    linear-gradient(180deg, rgba(2,67,91,.10), rgba(2,67,91,.02));
  color: var(--al-dark);
  font-weight: 700;
  font-size: 18px;
}

/* --- Hero (shared base) --- */
.al-hero {
  padding: 28px 0 24px;
  border-bottom: 1px solid var(--al-border);
}
.al-hero h1 {
  margin: 12px 0 10px;
  font-size: clamp(24px, 3.2vw, 42px);
  line-height: 1.22;
  color: var(--al-dark);
}
.al-hero__grid {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 16px;
  align-items: start;
  margin-top: 14px;
}

/* --- Sections --- */
.al-section {
  padding: 52px 0;
}
.al-section + .al-section {
  border-top: 1px solid rgba(2, 67, 91, .06);
}
.al-section__header {
  margin-bottom: 20px;
}
.al-section__header h2 {
  margin: 0 0 6px;
  font-size: clamp(20px, 2.5vw, 28px);
  color: var(--al-dark);
  line-height: 1.3;
}

/* --- Grids --- */
.al-grid--2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
.al-grid--3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* --- Actions wrapper --- */
.al-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.al-actions--center {
  justify-content: center;
}

/* --- Utilities --- */
.al-text-muted {
  color: var(--al-secondary);
}
.al-note {
  font-size: 12px;
  color: var(--al-secondary);
  margin: 14px 0 0;
}
.al-list {
  margin: 0;
  padding-inline-start: 22px;
  color: var(--al-secondary);
  line-height: 1.8;
}
.al-list li { margin: 6px 0; }
.al-list li::marker { color: var(--al-primary); }
.al-list strong { color: var(--al-dark); }

/* --- CTA Block --- */
.al-cta {
  padding: 32px 28px;
  border-radius: var(--al-radius-lg);
  border: 1px solid var(--al-border);
  background:
    radial-gradient(500px 200px at 80% 10%, rgba(255,39,20,.12), transparent 60%),
    linear-gradient(180deg, var(--al-dark-04), rgba(255,255,255,.94));
  box-shadow: var(--al-shadow-sm);
  text-align: center;
}
.al-cta h2 {
  margin: 0 0 10px;
  color: var(--al-dark);
  font-size: clamp(20px, 2.4vw, 28px);
}

/* --- Pagination (Prev/Next) --- */
.al-pagination {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
}
.al-pagination__link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: var(--al-radius);
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  background: var(--al-white);
  color: var(--al-dark);
  border: 1px solid var(--al-border);
  box-shadow: var(--al-shadow-sm);
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.al-pagination__link:hover {
  transform: translateY(-2px);
  box-shadow: var(--al-shadow);
  border-color: var(--al-primary-15);
}
.al-pagination__link--disabled {
  opacity: .45;
  pointer-events: none;
}

/* ==========================================================================
   CONTENT RENDERING — Gutenberg / Custom HTML output
   Applied to .al-content wrapper around the_content()
   ========================================================================== */
.al-content {
  line-height: 1.85;
  color: var(--al-secondary);
  font-size: 15px;
}
.al-content > *:first-child { margin-top: 0; }
.al-content > *:last-child  { margin-bottom: 0; }

/* Headings */
.al-content h2 {
  font-size: clamp(20px, 2.4vw, 26px);
  color: var(--al-dark);
  margin: 44px 0 14px;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--al-primary);
  line-height: 1.3;
}
.al-content h3 {
  font-size: clamp(17px, 1.8vw, 21px);
  color: var(--al-dark);
  margin: 36px 0 12px;
  line-height: 1.35;
}
.al-content h4 {
  font-size: 17px;
  color: var(--al-dark);
  margin: 28px 0 10px;
}

/* Paragraphs */
.al-content p {
  margin: 0 0 18px;
}

/* Strong */
.al-content strong {
  color: var(--al-dark);
  font-weight: 700;
}

/* Links */
.al-content a {
  color: var(--al-primary);
  text-decoration: none;
  font-weight: 700;
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.al-content a:hover {
  border-bottom-color: currentColor;
}

/* Lists */
.al-content ul,
.al-content ol {
  margin: 18px 0;
  padding-inline-start: 24px;
  line-height: 1.8;
}
.al-content li {
  margin: 8px 0;
}
.al-content li::marker {
  color: var(--al-primary);
}

/* Images */
.al-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--al-radius);
  border: 1px solid var(--al-border);
  box-shadow: var(--al-shadow-sm);
  margin: 16px 0;
  display: block;
}
.al-content figure {
  margin: 24px 0;
}
.al-content figcaption {
  font-size: 13px;
  color: var(--al-secondary);
  text-align: center;
  margin-top: 8px;
}
/* Fix Gutenberg figure images within al-content */
.al-content .wp-block-image img {
  margin: 0;
}

/* HR / Separator */
.al-content hr,
.al-content .wp-block-separator {
  border: none;
  border-top: 2px solid rgba(2, 67, 91, .08);
  margin: 36px 0;
}

/* Blockquote */
.al-content blockquote,
.al-content .wp-block-quote {
  border-inline-start: 4px solid var(--al-primary);
  margin: 24px 0;
  padding: 16px 24px;
  background: rgba(255, 39, 20, .04);
  border-radius: 0 var(--al-radius-sm) var(--al-radius-sm) 0;
  color: var(--al-dark);
}
[dir="rtl"] .al-content blockquote,
[dir="rtl"] .al-content .wp-block-quote {
  border-radius: var(--al-radius-sm) 0 0 var(--al-radius-sm);
}
.al-content blockquote p:last-child { margin-bottom: 0; }

/* Tables */
.al-content table,
.al-content .wp-block-table table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  border: 1px solid var(--al-border);
  border-radius: var(--al-radius-sm);
  overflow: hidden;
}
.al-content th,
.al-content td {
  padding: 12px 16px;
  text-align: inherit;
  border-bottom: 1px solid var(--al-border);
}
.al-content th {
  background: var(--al-dark-04);
  font-weight: 700;
  color: var(--al-dark);
}

/* FAQ — details/summary */
.al-content details {
  margin: 10px 0;
  border: 1px solid var(--al-border);
  border-radius: var(--al-radius-sm);
  overflow: hidden;
  background: var(--al-white);
  transition: box-shadow .25s;
}
.al-content details + details {
  margin-top: 0;
  border-top: none;
  border-radius: 0;
}
.al-content details:first-of-type { border-radius: var(--al-radius-sm) var(--al-radius-sm) 0 0; }
.al-content details:last-of-type  { border-radius: 0 0 var(--al-radius-sm) var(--al-radius-sm); }
.al-content details:only-of-type  { border-radius: var(--al-radius-sm); }
.al-content details[open] {
  box-shadow: var(--al-shadow-sm);
}
.al-content summary {
  padding: 16px 20px;
  font-weight: 700;
  font-size: 15px;
  color: var(--al-dark);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: background .2s;
}
.al-content summary::-webkit-details-marker { display: none; }
.al-content summary::after {
  content: '+';
  font-size: 20px;
  font-weight: 400;
  color: var(--al-primary);
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  transition: transform .25s;
}
.al-content details[open] summary::after {
  content: '−';
}
.al-content summary:hover {
  background: rgba(2, 67, 91, .03);
}
.al-content details > *:not(summary) {
  padding: 0 20px 16px;
}
.al-content details > p:not(summary) {
  margin-top: 0;
}

/* Sections from editor (Custom HTML blocks) */
.al-content > section {
  margin: 40px 0;
  padding: 28px 24px;
  border-radius: var(--al-radius-lg);
  border: 1px solid var(--al-border);
  background: linear-gradient(180deg, rgba(2, 67, 91, .02), transparent);
  box-shadow: var(--al-shadow-sm);
}
.al-content > section > *:first-child { margin-top: 0; }
.al-content > section > *:last-child  { margin-bottom: 0; }

/* Gutenberg Buttons */
.al-content .wp-block-buttons {
  margin: 20px 0;
}
.al-content .wp-block-button__link {
  padding: 12px 24px;
  border-radius: var(--al-radius-sm);
  font-weight: 700;
  transition: transform .14s ease, box-shadow .14s ease;
}
.al-content .wp-block-button__link:hover {
  transform: translateY(-1px);
  box-shadow: var(--al-shadow-sm);
}

/* Gutenberg Columns */
.al-content .wp-block-columns {
  margin: 24px 0;
  gap: 16px;
}

/* ==========================================================================
   ANIMATION SYSTEM — Fail-safe, JS-gated
   CSS default: everything visible. JS adds .al-anim to <html> to enable.
   ========================================================================== */
/* Baseline: always visible */
[data-anim] {
  opacity: 1;
  transform: none;
}
/* JS-gated: only animate when JS confirms it can handle it */
html.al-anim [data-anim] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .55s cubic-bezier(.4, 0, .2, 1), transform .55s cubic-bezier(.4, 0, .2, 1);
  will-change: opacity, transform;
}
html.al-anim [data-anim].al-visible {
  opacity: 1;
  transform: none;
}
/* Grid stagger */
html.al-anim .al-grid--3 [data-anim]:nth-child(2),
html.al-anim .al-grid--2 [data-anim]:nth-child(2) { transition-delay: .07s; }
html.al-anim .al-grid--3 [data-anim]:nth-child(3) { transition-delay: .14s; }
html.al-anim .al-grid--3 [data-anim]:nth-child(4) { transition-delay: .21s; }
html.al-anim .al-grid--3 [data-anim]:nth-child(5) { transition-delay: .28s; }
html.al-anim .al-grid--3 [data-anim]:nth-child(6) { transition-delay: .35s; }
html.al-anim .al-grid--3 [data-anim]:nth-child(n+7) { transition-delay: .4s; }
/* Reduced motion: disable all transitions */
@media (prefers-reduced-motion: reduce) {
  html.al-anim [data-anim] {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 980px) {
  .al-hero__grid   { grid-template-columns: 1fr; }
  .al-grid--2      { grid-template-columns: 1fr; }
  .al-grid--3      { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .al-grid--3      { grid-template-columns: 1fr; }
  .al-section      { padding: 40px 0; }
  .al-card         { padding: 18px; }
  .al-cta          { padding: 24px 18px; }
  .al-topbar__location { font-size: 13px; }
}
@media (max-width: 480px) {
  .al-btn { width: 100%; }
  .al-pagination { flex-direction: column; }
  .al-pagination__link { width: 100%; justify-content: center; }
}
