@charset "utf-8";

<?php
/**
 * artwork-page.php — minimal, safe baseline
 * Requires: $title, $image
 */

// ---- Guard: required fields
if (empty($title) || empty($image)) {
  http_response_code(500);
  echo "artwork-page.php: Missing required \$title or \$image.";
  exit;
}

// ---- Normalizer: collapse legacy frame tokens to one spelling
if (!function_exists('g73_normalize_frame_class')) {
  function g73_normalize_frame_class($raw) {
    $raw = trim((string)$raw);
    if ($raw === '') return '';
    $tokens = preg_split('/\s+/', $raw);
    $map = [
      'darkframe'   => 'dark-frame',
      'dark-frame'  => 'dark-frame',
      'lightframe'  => 'light-frame',
      'light-frame' => 'light-frame',
    ];
    $out = [];
    foreach ($tokens as $t) {
      $k = strtolower($t);
      $out[$map[$k] ?? $t] = true; // de-dupe
    }
    return implode(' ', array_keys($out));
  }
}

// ---- Safe defaults
$alt             = $alt             ?? $title;
$caption         = $caption         ?? '';
$body_class      = trim(($body_class ?? '') . ' artwork-page');
$frame_style     = $frame_style     ?? null;   // 'dark' | 'light' (optional hint)

// ---- Final frame class: respect page, else default (dark by default)
$frame_class = isset($frame_class) && $frame_class !== ''
  ? g73_normalize_frame_class($frame_class)
  : (($frame_style === 'light') ? 'light-frame imgw-500' : 'dark-frame imgw-500');

// DEBUG breadcrumb: view page source to verify the computed class
echo "<!-- frame_class=" . htmlspecialchars($frame_class) . " -->\n";

// ---- Page meta (these are consumed by 2024-head.php)
$pageTitle       = $pageTitle       ?? ($title . ' – Dennis R. Ling');
$pageDescription = $pageDescription ?? strip_tags($caption ?: $alt);
$pageKeywords    = $pageKeywords    ?? 'art, photography, painting, Dennis R. Ling, Gallery 73';

require $_SERV_

