<?php
/**
 * Ready made looks for the bottom bar.
 *
 * Kept out of `schema.php` for two reasons: the schema is long enough already,
 * and this block is only ever read by the dashboard. `schema.php` therefore
 * includes it only on admin and REST requests, so a frontend page view does not
 * pay for translating a few hundred strings it will never show.
 *
 * ## Every look sets the same things
 *
 * A preset is a look: background, icon and label colour, the current page
 * marker, the shape of the bar, and whether there is wording under the icons.
 * Nothing else. That list is fixed, and it is fixed *structurally* — every
 * entry below is built by `$menuverse_bottom_look()`, so a preset cannot
 * declare a key its neighbours leave out.
 *
 * This is the whole point of the helper. The gallery used to be two kinds of
 * preset wearing one card: the first three set shape, wording and the marker
 * but no colours, while the rest set colours and replaced the items but left
 * shape, wording and the marker alone. Applying "Icons only" and then "Onyx"
 * gave a dark bar with the wording still switched off, because nothing in Onyx
 * ever mentioned wording. The bar someone got was not the bar on the card they
 * pressed, and which parts carried over depended on the order they had clicked
 * in. Leaving a key out is not a way to say "keep what is there".
 *
 * The background keys are the one exception, and only the ones a look cannot
 * use: a flat colour look states `bar_background`, a gradient states its two
 * stops, a frosted one its tint and blur. `bg_type` is always stated, so the
 * unused keys are never read and a stale one cannot show through.
 *
 * ## No look brings its own items
 *
 * Seven of these once replaced the contents of the bar. A look is picked by
 * eye, halfway through setting the bar up, and having the wording someone had
 * just typed thrown away by a card that looked nice was the single most
 * destructive thing on the screen — and it made those seven behave unlike the
 * other three again. What is in the bar is step two's decision; this step only
 * restyles it. That also keeps every swatch a picture of *this* site's bar.
 *
 * `category` groups the gallery's filter row. The chips follow the order the
 * categories first appear in below, so the list is kept in that order rather
 * than sorted by name.
 *
 * @package MenuVerse
 */

defined( 'ABSPATH' ) || exit;

/**
 * Builds the settings for one look.
 *
 * Returns the same keys every time, which is what stops one preset from
 * quietly inheriting part of the last one. See the note above.
 *
 * @param string|array $background Hex colour, or `array( from, to )` for a blend.
 * @param string       $foreground Icon and label colour.
 * @param string       $active     Colour for the item matching the current page.
 * @param string       $marker     One of `color`, `pill`, `line`, `underline`.
 * @param int          $radius     Corner rounding in pixels. Anything above 0
 *                                 lifts the bar off the screen edge.
 * @param int          $blur       Frosting in pixels. Above 0 makes it glass.
 * @param bool         $labels     Whether wording sits under the icons.
 * @param string       $height     Height of the bar.
 * @param string       $icon_size  Icon size.
 * @return array
 */
$menuverse_bottom_look = function ( $background, $foreground, $active, $marker, $radius = 0, $blur = 0, $labels = true, $height = '58px', $icon_size = '24px' ) {
	$gradient = is_array( $background );
	$values   = array(
		'bg_type' => $gradient ? 'gradient' : ( $blur > 0 ? 'glass' : 'color' ),
	);

	if ( $gradient ) {
		$values['bg_gradient_start'] = $background[0];
		$values['bg_gradient_end']   = $background[1];
	} elseif ( $blur > 0 ) {
		// The bar is meant to read as tinted glass, not as a pane of colour, so
		// the tint carries the alpha rather than asking every look to spell out
		// the same suffix.
		$values['glass_tint']   = $background . 'd9';
		$values['glass_blur']   = $blur;
		$values['glass_border'] = true;
	} else {
		$values['bar_background'] = $background;
	}

	$values['bar_color']        = $foreground;
	$values['bar_active_color'] = $active;
	$values['show_labels']      = $labels;
	$values['active_indicator'] = $marker;
	$values['bar_radius']       = $radius;
	$values['bar_height']       = $height;
	$values['icon_size']        = $icon_size;
	// A bar sitting flush against the bottom of the screen needs a hairline to
	// separate it from the page behind it. One that floats already has its own
	// edge all the way round, and the extra line reads as a seam across it.
	$values['show_border'] = 0 === $radius;

	return $values;
};

/*
 * `max_visible` is deliberately absent from every look. How many buttons fit is
 * a decision about the contents of the bar, taken in the previous step against
 * the items someone actually has — a look reaching back to overwrite it would
 * undo that from a screen that says it only changes appearance.
 */

return array(

	/* Light. */

	array(
		'id'          => 'app',
		'category'    => __( 'Light', 'menuverse' ),
		'label'       => __( 'App style', 'menuverse' ),
		'description' => __( 'Icons with wording beneath and a pill on the current page, the way a phone app looks.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( '#ffffff', '#3c4250', '#2f4fe0', 'pill' ),
	),

	array(
		'id'          => 'minimal',
		'category'    => __( 'Light', 'menuverse' ),
		'label'       => __( 'Icons only', 'menuverse' ),
		'description' => __( 'No wording at all. Takes less room, and is best with five or six items.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( '#ffffff', '#3c4250', '#2f4fe0', 'color', 0, 0, false, '52px', '26px' ),
	),

	array(
		'id'          => 'compact',
		'category'    => __( 'Light', 'menuverse' ),
		'label'       => __( 'Compact', 'menuverse' ),
		'description' => __( 'A shorter bar with a line marking the current page. Good on small phones.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( '#ffffff', '#4a5060', '#2f4fe0', 'line', 0, 0, true, '50px', '20px' ),
	),

	array(
		'id'          => 'paper',
		'category'    => __( 'Light', 'menuverse' ),
		'label'       => __( 'Paper', 'menuverse' ),
		'description' => __( 'Warm off white with a hairline edge. Understated and quiet.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( '#faf8f4', '#5b5750', '#1c1a17', 'underline' ),
	),

	array(
		'id'          => 'linen',
		'category'    => __( 'Light', 'menuverse' ),
		'label'       => __( 'Linen', 'menuverse' ),
		'description' => __( 'Soft sand with a clay highlight. Reads well on editorial sites.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( '#f3ece2', '#6b5f52', '#b4530a', 'pill', 14 ),
	),

	array(
		'id'          => 'mint',
		'category'    => __( 'Light', 'menuverse' ),
		'label'       => __( 'Mint', 'menuverse' ),
		'description' => __( 'Pale green with a deep teal highlight. Calm, and at home on a clinic site.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( '#eef7f2', '#4c6259', '#0f766e', 'line' ),
	),

	array(
		'id'          => 'floating',
		'category'    => __( 'Light', 'menuverse' ),
		'label'       => __( 'Floating', 'menuverse' ),
		'description' => __( 'A rounded island lifted off the edge of the page with a soft shadow.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( '#ffffff', '#4a5060', '#2f4fe0', 'pill', 22 ),
	),

	/* Dark. */

	array(
		'id'          => 'onyx',
		'category'    => __( 'Dark', 'menuverse' ),
		'label'       => __( 'Onyx', 'menuverse' ),
		'description' => __( 'Near black, with the current page picked out in white.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( '#111318', '#8f96a3', '#ffffff', 'line' ),
	),

	array(
		'id'          => 'slate',
		'category'    => __( 'Dark', 'menuverse' ),
		'label'       => __( 'Slate', 'menuverse' ),
		'description' => __( 'Cool grey blue with a sky blue highlight. Quiet and businesslike.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( '#1f2a3c', '#9fb0c6', '#5cc4ff', 'line' ),
	),

	array(
		'id'          => 'espresso',
		'category'    => __( 'Dark', 'menuverse' ),
		'label'       => __( 'Espresso', 'menuverse' ),
		'description' => __( 'Deep brown with a caramel highlight. Suits cafés and food shops.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( '#241c17', '#c4b3a4', '#e0a35c', 'pill', 16 ),
	),

	array(
		'id'          => 'forest',
		'category'    => __( 'Dark', 'menuverse' ),
		'label'       => __( 'Forest', 'menuverse' ),
		'description' => __( 'Dark green with a lime highlight. Outdoors and sustainability.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( '#14261d', '#a7bfae', '#8fe388', 'underline' ),
	),

	array(
		'id'          => 'ink',
		'category'    => __( 'Dark', 'menuverse' ),
		'label'       => __( 'Ink', 'menuverse' ),
		'description' => __( 'Navy with a warm gold highlight. Formal and trustworthy.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( '#12203f', '#9fb0cc', '#f0c274', 'pill', 14 ),
	),

	/* Glass. */

	array(
		'id'          => 'frost',
		'category'    => __( 'Glass', 'menuverse' ),
		'label'       => __( 'Frost', 'menuverse' ),
		'description' => __( 'Frosted charcoal glass with a bright cyan highlight.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( '#0f172a', '#e2e8f0', '#16e2f5', 'line', 0, 20 ),
	),

	array(
		'id'          => 'aurora',
		'category'    => __( 'Glass', 'menuverse' ),
		'label'       => __( 'Aurora', 'menuverse' ),
		'description' => __( 'Frosted violet glass with a bright cyan highlight on the current page.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( '#8b6ff0', '#ece9ff', '#5ef2ff', 'pill', 18, 18 ),
	),

	array(
		'id'          => 'tide',
		'category'    => __( 'Glass', 'menuverse' ),
		'label'       => __( 'Tide', 'menuverse' ),
		'description' => __( 'Frosted blue glass. Suits a services or contact led site.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( '#3f8fd6', '#e6f2fb', '#ffffff', 'underline', 18, 16 ),
	),

	array(
		'id'          => 'sage',
		'category'    => __( 'Glass', 'menuverse' ),
		'label'       => __( 'Sage', 'menuverse' ),
		'description' => __( 'Frosted green glass with an amber highlight. Suits food and shops.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( '#5fae86', '#eaf7ef', '#ffc451', 'pill', 18, 16 ),
	),

	array(
		'id'          => 'mist',
		'category'    => __( 'Glass', 'menuverse' ),
		'label'       => __( 'Mist', 'menuverse' ),
		'description' => __( 'Almost clear white glass. The page shows through underneath.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( '#ffffff', '#3c4250', '#2f4fe0', 'pill', 20, 24 ),
	),

	array(
		'id'          => 'obsidian',
		'category'    => __( 'Glass', 'menuverse' ),
		'label'       => __( 'Obsidian', 'menuverse' ),
		'description' => __( 'Heavy black glass with a magenta highlight. Bold at night.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( '#0a0a0c', '#c9c9d1', '#ff4d9d', 'line', 0, 26 ),
	),

	/* Gradient. */

	array(
		'id'          => 'blaze',
		'category'    => __( 'Gradient', 'menuverse' ),
		'label'       => __( 'Blaze', 'menuverse' ),
		'description' => __( 'A warm orange to red blend with a yellow highlight.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( array( '#ff7a2f', '#ef3b3b' ), '#ffe9dd', '#ffd83d', 'pill', 16 ),
	),

	array(
		'id'          => 'bloom',
		'category'    => __( 'Gradient', 'menuverse' ),
		'label'       => __( 'Bloom', 'menuverse' ),
		'description' => __( 'Magenta into violet, with a yellow highlight. Good for bookings.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( array( '#d02fd0', '#7d3ce8' ), '#f7e6ff', '#ffe14d', 'pill', 16 ),
	),

	array(
		'id'          => 'lagoon',
		'category'    => __( 'Gradient', 'menuverse' ),
		'label'       => __( 'Lagoon', 'menuverse' ),
		'description' => __( 'Teal into deep blue with a pale mint highlight.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( array( '#0e9f9f', '#1d4ed8' ), '#dff5f3', '#b8ffe4', 'line', 18 ),
	),

	array(
		'id'          => 'dusk',
		'category'    => __( 'Gradient', 'menuverse' ),
		'label'       => __( 'Dusk', 'menuverse' ),
		'description' => __( 'Indigo into plum with a peach highlight. Soft and premium.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( array( '#3b3f8f', '#7a3b6b' ), '#e4dff0', '#ffc4a3', 'underline', 20 ),
	),

	array(
		'id'          => 'citrus',
		'category'    => __( 'Gradient', 'menuverse' ),
		'label'       => __( 'Citrus', 'menuverse' ),
		'description' => __( 'Lime into amber with a dark ink highlight. Loud and friendly.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( array( '#a3e635', '#f59e0b' ), '#2c2a12', '#111318', 'pill', 16 ),
	),

	array(
		'id'          => 'noir',
		'category'    => __( 'Gradient', 'menuverse' ),
		'label'       => __( 'Noir', 'menuverse' ),
		'description' => __( 'Charcoal into black with a silver highlight. A luxury feel.', 'menuverse' ),
		'values'      => $menuverse_bottom_look( array( '#2b2b31', '#0a0a0c' ), '#9a9aa4', '#e8e8ee', 'line' ),
	),
);
