/* ===========================================================================
   theme.css — the C3 look, driven entirely by colour tokens.

   Loaded only for libraries that have a `colour_brand` row in Athenaeum's
   theme table (see _application/helpers/theme_helper.php). Order in
   template.php:

     bootstrap.min.css → colcade.css → effects.css → overrides.css
       → theme.css (this file)
       → inline <style>: :root colours from Athenaeum, then the library's
         own `style` CSS, then its `banner` CSS

   so a library can still override anything here from Athenaeum.

   THE RULE THAT KEEPS EVERYTHING READABLE
   Every background is used with its matching text colour, never another:

     background            text on it
     --surface / -alt      --ink, --muted, --brand-text
     --brand               --on-brand
     --accent              --on-accent

   --on-brand, --on-accent, --brand-text and --muted are contrast-checked in
   PHP, so any four input colours give a readable site.
   =========================================================================== */


/* ---------------------------------------------------------------------------
   1. TOKENS

   The values below are defaults only. template.php prints the library's
   colours in a later :root block, which wins.
   --------------------------------------------------------------------------- */

:root
{
	/* Inputs: set from Athenaeum colour_* rows */
	--brand:      #027f0e;
	--accent:     #ff6347;
	--surface:    #ffffff;
	--ink:        #212529;

	/* Contrast-checked: worked out in PHP */
	--on-brand:   #ffffff;
	--on-accent:  #000000;
	--brand-text: #027f0e;
	--muted:      #6c757d;
	--brand-close-filter: invert(1) grayscale(100%) brightness(200%);

	/* Decorative: derived here, never edited */
	--surface-alt: color-mix(in oklch, var(--surface), var(--brand) 6%);
	--border:      color-mix(in oklch, var(--ink), var(--surface) 80%);
	--focus-ring:  color-mix(in srgb, var(--accent) 60%, transparent);

	/* Shape */
	--radius:      18px;
	--btn-radius:  8px;
	--shadow:      2px 4px 12px #00000014;
	--shadow-soft: 2px 4px 4px #00000014;

	--thumb-image-height: 120px;
	--banner-height: 160px;

	/* Pass to Bootstrap so its own components follow */
	--bs-body-bg:         var(--surface);
	--bs-body-color:      var(--ink);
	--bs-border-color:    var(--border);
	--bs-secondary-color: var(--muted);
}


/* ---------------------------------------------------------------------------
   2. BASE
   --------------------------------------------------------------------------- */

html,
body,
.main-content,
.container,
.container-fluid,
.page_content
{
	background-color: var(--surface);
	color: var(--ink);
}

.blog_content
{
	margin: 4px;
}

a
{
	color: inherit;
	text-decoration: none;
}

a:hover
{
	color: var(--brand-text);
	text-decoration: underline;
}

/* On brand-coloured blocks, brand-coloured hover text would vanish:
   keep the block's own text colour and rely on the underline. */
/* Buttons and dropdown items set their own hover colours, so leave them out. */
:is(.navbar, .banner, .big_message, .big_footer, .card-header, .modal-header) a:not(.btn, .dropdown-item):hover
{
	color: inherit;
}

/* Keyboard users must always see where they are. */
:focus-visible
{
	outline: 3px solid var(--focus-ring);
	outline-offset: 2px;
}

img
{
	max-width: 100%;
}


/* ---------------------------------------------------------------------------
   3. BRAND BLOCKS: navbar, banner, callouts, headers
   --------------------------------------------------------------------------- */

/* .navbar[data-bs-theme] is needed to outrank Bootstrap's dark-navbar rule. */
.navbar,
.navbar[data-bs-theme]
{
	background-color: var(--brand);
	color: var(--on-brand);
	border-radius: var(--radius);
	box-shadow: var(--shadow-soft);

	--bs-navbar-color:               var(--on-brand);
	--bs-navbar-hover-color:         var(--on-brand);
	--bs-navbar-active-color:        var(--on-brand);
	--bs-navbar-brand-color:         var(--on-brand);
	--bs-navbar-brand-hover-color:   var(--on-brand);
	--bs-navbar-toggler-border-color: color-mix(in srgb, var(--on-brand) 40%, transparent);
}

.navbar-brand
{
	margin-left: 8px;
}

.navbar-toggler
{
	margin-right: 8px;
}

.navbar .nav-item > a
{
	color: inherit;
}

.navbar .nav-item:hover
{
	background-color: var(--accent);
	color: var(--on-accent);
	border-radius: var(--btn-radius);
}

.navbar .nav-item:hover > a
{
	text-decoration: none;
}

.dropdown-menu
{
	--bs-dropdown-bg:                var(--surface);
	--bs-dropdown-color:             var(--ink);
	--bs-dropdown-border-color:      var(--border);
	--bs-dropdown-link-color:        var(--ink);
	--bs-dropdown-link-hover-bg:     var(--accent);
	--bs-dropdown-link-hover-color:  var(--on-accent);
	--bs-dropdown-link-active-bg:    var(--accent);
	--bs-dropdown-link-active-color: var(--on-accent);
}

/* Banner: plain brand block by default. With a banner_image row it becomes
   "logo" (image beside the text) or "wide" (image fills, text on top).
   The `banner` CSS row in Athenaeum is printed after this and can override. */
.banner
{
	display: flex;
	flex-wrap: nowrap;
	justify-content: center;
	align-items: center;
	gap: 1.5rem;
	height: var(--banner-height);
	padding: 18px 24px;
	margin: 18px 0;
	font-size: clamp(1.25rem, 4vw, 2rem);
	color: var(--on-brand);
	background-color: var(--brand);
	background-position: center;
	background-size: cover;
	background-repeat: no-repeat;
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}

/* .banner is also a Bootstrap .row, which makes every child full width. */
.banner > .banner_text
{
	width: auto;
	max-width: 100%;
	padding: 0;
	text-align: center;
	text-wrap: balance;
	text-shadow: 0 1px 4px color-mix(in srgb, var(--brand) 85%, transparent);
}

/* LOGO: image sits beside the text and can never overlap it. */
.banner--logo
{
	justify-content: flex-start;
}

.banner--logo > .banner_logo
{
	flex: none;
	width: auto;
	max-width: 40%;
	height: 100%;
	padding: 0;
	object-fit: contain;
}

.banner--logo > .banner_text
{
	flex: 1 1 0;
}

/* WIDE: image fills the banner; the text gets a brand-coloured panel so it
   reads on any picture. */
.banner--wide
{
	background-image: var(--banner-image);
}

.banner--wide > .banner_text
{
	padding: 0.2em 0.8em;
	background-color: color-mix(in srgb, var(--brand) 80%, transparent);
	border-radius: var(--btn-radius);
}

/* Phones: logo above the text. */
@media (max-width: 575.98px)
{
	.banner--logo
	{
		flex-direction: column;
		justify-content: center;
		height: auto;
		gap: 0.75rem;
	}

	.banner--logo > .banner_logo
	{
		height: 80px;
		max-width: 80%;
	}
}

.big_message,
.big_footer
{
	width: 100%;
	text-align: center;
	font-size: 200%;
	padding: 18px 0;
	margin: 18px 0;
	color: var(--on-brand);
	background-color: var(--brand);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}

.card-header,
.modal-header
{
	background-color: var(--brand);
	color: var(--on-brand);
}

.card-header :is(h1, h2, h3, h4, h5, h6),
.modal-header :is(h1, h2, h3, h4, h5, h6)
{
	color: inherit;
	margin: 0;
}

.card-header .btn-close,
.modal-header .btn-close
{
	--bs-btn-close-filter: var(--brand-close-filter);
}


/* ---------------------------------------------------------------------------
   4. CARDS (search results, blog posts)
   --------------------------------------------------------------------------- */

.card-grid
{
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
	gap: 1em;
}

.card
{
	break-inside: avoid;
	padding: 0;
	background-color: var(--surface);
	color: var(--ink);
	border-color: var(--border);
	border-radius: var(--radius);
	box-shadow: inset 0 -2px 4px #00000014;
	overflow: hidden;
	white-space: normal;
	transition: all 0.3s cubic-bezier(0, 0, 0.5, 1);
}

/* Search results and My issues/reserves/history: each card is header, body,
   footer, and subgrid lines those up across a row so every header in the
   row is the same height. Only inside .card-grid: outside a grid (the home
   page's Colcade columns) subgrid squashes the header and clips its text. */
.card-grid > .card
{
	display: grid;
	grid-template-rows: subgrid;
	grid-row: span 3;
	gap: 0;
}

.card-header
{
	overflow: hidden;
	padding: 1em;
}

.blog-page .card-header
{
	height: auto;
	text-align: center;
}

.card-body
{
	background-color: var(--surface);
	color: var(--ink);
}

.card-text
{
	text-align: center;
}

.card-footer
{
	padding: 1em;
	background-color: var(--surface);
	color: var(--muted);
	font-size: 0.7em;
	font-style: italic;
}


/* ---------------------------------------------------------------------------
   5. TITLE DETAIL, MODALS, TABLES
   --------------------------------------------------------------------------- */

.title,
.title_detail,
.title_content
{
	background-color: var(--surface);
	margin: 0;
}

.title_notes
{
	text-align: start;
}

.title_notes_block,
.table-responsive
{
	background-color: var(--surface);
}

.modal-content
{
	background-color: var(--surface);
	color: var(--ink);
}

.table
{
	--bs-table-bg:           var(--surface);
	--bs-table-color:        var(--ink);
	--bs-table-border-color: var(--border);
	--bs-table-striped-bg:   var(--surface-alt);
	--bs-table-hover-bg:     var(--surface-alt);
}


/* ---------------------------------------------------------------------------
   6. FORMS AND BUTTONS
   --------------------------------------------------------------------------- */

.form-control,
.form-select
{
	background-color: var(--surface);
	color: var(--ink);
	border-color: var(--border);
}

.form-control::placeholder
{
	color: var(--muted);
}

.form-control:focus,
.form-select:focus
{
	background-color: var(--surface);
	color: var(--ink);
	border-color: var(--accent);
	box-shadow: 0 0 0 0.25rem var(--focus-ring);
}

.btn
{
	border-radius: var(--btn-radius);
	margin: 8px;
	--bs-btn-focus-box-shadow: 0 0 0 0.25rem var(--focus-ring);
}

/* Main action: brand at rest, accent on hover. */
.btn-primary
{
	--bs-btn-bg:                  var(--brand);
	--bs-btn-color:               var(--on-brand);
	--bs-btn-border-color:        var(--brand);
	--bs-btn-hover-bg:            var(--accent);
	--bs-btn-hover-color:         var(--on-accent);
	--bs-btn-hover-border-color:  var(--accent);
	--bs-btn-active-bg:           var(--accent);
	--bs-btn-active-color:        var(--on-accent);
	--bs-btn-active-border-color: var(--accent);
	--bs-btn-disabled-bg:         var(--brand);
	--bs-btn-disabled-color:      var(--on-brand);
	--bs-btn-disabled-border-color: var(--brand);
}

.btn-outline-primary
{
	--bs-btn-color:               var(--brand-text);
	--bs-btn-border-color:        var(--brand-text);
	--bs-btn-hover-bg:            var(--accent);
	--bs-btn-hover-color:         var(--on-accent);
	--bs-btn-hover-border-color:  var(--accent);
	--bs-btn-active-bg:           var(--accent);
	--bs-btn-active-color:        var(--on-accent);
	--bs-btn-active-border-color: var(--accent);
}

/* Buttons that sit on a brand block (navbar "Find", modal "cancel"):
   take the colour of whatever they sit on. */
.btn-outline,
.btn.close
{
	--bs-btn-color:               currentColor;
	--bs-btn-border-color:        currentColor;
	--bs-btn-hover-bg:            var(--accent);
	--bs-btn-hover-color:         var(--on-accent);
	--bs-btn-hover-border-color:  var(--accent);
	--bs-btn-active-bg:           var(--accent);
	--bs-btn-active-color:        var(--on-accent);
	--bs-btn-active-border-color: var(--accent);
}

/* Reserve stays yellow in every theme so it is recognisable. */
.btn-reserve
{
	--bs-btn-bg:                 #ffc107;
	--bs-btn-color:              #000000;
	--bs-btn-border-color:       #ffc107;
	--bs-btn-hover-bg:           #e0a800;
	--bs-btn-hover-color:        #000000;
	--bs-btn-hover-border-color: #d39e00;
}


/* ---------------------------------------------------------------------------
   7. PAGINATION
   --------------------------------------------------------------------------- */

.pagination
{
	margin: 4px;

	--bs-pagination-bg:                 var(--surface);
	--bs-pagination-color:              var(--brand-text);
	--bs-pagination-border-color:       var(--border);
	--bs-pagination-hover-bg:           var(--brand);
	--bs-pagination-hover-color:        var(--on-brand);
	--bs-pagination-hover-border-color: var(--brand);
	--bs-pagination-focus-bg:           var(--surface-alt);
	--bs-pagination-focus-color:        var(--brand-text);
	--bs-pagination-focus-box-shadow:   0 0 0 0.25rem var(--focus-ring);
	--bs-pagination-active-bg:          var(--accent);
	--bs-pagination-active-color:       var(--on-accent);
	--bs-pagination-active-border-color: var(--accent);
	--bs-pagination-disabled-bg:        var(--surface-alt);
	--bs-pagination-disabled-color:     var(--muted);
	--bs-pagination-disabled-border-color: var(--border);
}


/* ---------------------------------------------------------------------------
   8. CAROUSELS
   --------------------------------------------------------------------------- */

/* Hide arrows and captions on carousels. */
.carousel-control-prev,
.carousel-control-next,
.carousel-caption
{
	display: none;
}

.carousel-item
{
	height: var(--thumb-image-height);
	min-height: var(--thumb-image-height);
	line-height: var(--thumb-image-height);
	text-align: center;
}

.carousel-item img
{
	max-height: var(--thumb-image-height);
	max-width: 100%;
	vertical-align: middle;
}

.img-thumbnail
{
	height: var(--thumb-image-height);
	max-width: calc(var(--thumb-image-height) * 0.75);
}


/* ---------------------------------------------------------------------------
   9. FOOTER AND UTILITIES
   --------------------------------------------------------------------------- */

.footer
{
	background-color: var(--surface);
	color: var(--muted);
	font-size: 0.75rem;
}

.centred
{
	display: flex;
	justify-content: center;
}

.urlbuttons
{
	background-color: var(--surface);
	padding: 4px 0;
}

.circle
{
	width: 1.6em;
	height: 1.6em;
	background: var(--accent);
	border-radius: 50%;
}

.fa-bookmark::before
{
	content: "🔖";
}
