/* ============================================================
   Maritime Museum — Wagtail admin theme overrides
   Applies the museum palette (ink / blue / cream / tan / brown)
   to Wagtail's CSS custom properties so the admin matches the
   public-facing site. Loaded via insert_global_admin_css hook.
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Source+Sans+Pro:ital,wght@0,400;0,600;0,700;0,900&family=PT+Serif:ital,wght@0,400;0,700&display=swap");

:root,
.w-theme-light,
:root.w-theme-system {
    /* Brand tokens */
    --ml-ink: #0b2748;
    --ml-blue: #174d7a;
    --ml-cream: #f4f0e6;
    --ml-cream-2: #ece5d4;
    --ml-tan: #d1b48c;
    --ml-brown: #6b5a4b;

    /* Wagtail typography */
    --w-font-sans: "Source Sans Pro", -apple-system, BlinkMacSystemFont,
        "Helvetica Neue", Arial, sans-serif;

    /* Primary (also used for default buttons and links) */
    --w-color-primary: #0b2748;
    --w-color-primary-hue: 213;
    --w-color-primary-saturation: 74%;
    --w-color-primary-lightness: 16%;

    --w-color-primary-200: #174d7a;
    --w-color-primary-200-hue: 209;
    --w-color-primary-200-saturation: 68%;
    --w-color-primary-200-lightness: 28%;

    /* Secondary — call-to-action buttons */
    --w-color-secondary: #174d7a;
    --w-color-secondary-hue: 209;
    --w-color-secondary-saturation: 68%;
    --w-color-secondary-lightness: 28%;
    --w-color-secondary-50: #d1b48c;
    --w-color-secondary-75: #b8966a;
    --w-color-secondary-100: #0b2748;
    --w-color-secondary-400: #174d7a;
    --w-color-secondary-600: #07172c;

    /* Focus accent */
    --w-color-focus: #d1b48c;

    /* Surfaces */
    --w-color-surface-page: var(--ml-cream);
    --w-color-surface-header: var(--ml-cream);
    --w-color-surface-menus: #07172c;
    --w-color-surface-menu-item-active: #112c4f;
    --w-color-surface-dashboard-panel: #ffffff;
    --w-color-surface-field: #ffffff;
    --w-color-surface-field-inactive: var(--ml-cream-2);
    --w-color-surface-button-default: var(--ml-ink);
    --w-color-surface-button-hover: var(--ml-blue);
    --w-color-surface-button-outline-hover: rgba(209, 180, 140, 0.20);
    --w-color-surface-tooltip: #ffffff;
    --w-color-surface-info-panel: var(--ml-cream-2);
    --w-color-surface-status-label: var(--ml-cream-2);

    /* Borders */
    --w-color-border-field-default: var(--ml-tan);
    --w-color-border-field-hover: var(--ml-blue);
    --w-color-border-furniture: var(--ml-tan);
    --w-color-border-furniture-more-contrast: var(--ml-brown);

    /* Icons */
    --w-color-icon-primary: var(--ml-ink);
    --w-color-icon-primary-hover: var(--ml-blue);
    --w-color-icon-secondary: var(--ml-brown);
    --w-color-icon-secondary-hover: var(--ml-ink);

    /* Text — explicit values keep contrast on cream surfaces */
    --w-color-text-context: var(--ml-ink);
    --w-color-text-label: var(--ml-brown);
    --w-color-text-label-default: var(--ml-ink);
    --w-color-text-meta: var(--ml-brown);
    --w-color-text-link-default: var(--ml-blue);
    --w-color-text-link-hover: var(--ml-brown);
    --w-color-text-link-info: var(--ml-blue);
    --w-color-text-button: #ffffff;
    --w-color-text-button-outline-default: var(--ml-ink);
    --w-color-text-button-outline-hover: var(--ml-ink);
    --w-color-text-placeholder: rgba(107, 90, 75, 0.55);
    --w-color-text-highlight: var(--ml-ink);
    --w-color-text-label-menus-default: #e7dec7;
    --w-color-text-label-menus-active: #ffffff;
}

/* ---- Make sure the body and main content use ink-on-cream ---- */
body.wagtail,
.content-wrapper,
.nice-padding,
main,
.tab-content,
.w-tabs__panel,
table.listing,
.listing,
.w-listing {
    color: var(--ml-ink);
}

/* ---- Image grid / listing tiles ---- */
.image-choice {
    display: block;
    color: var(--ml-ink) !important;
    background: #ffffff;
    border: 1px solid var(--ml-tan);
    border-radius: 4px;
    padding: 0.45em;
    transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.image-choice:hover {
    box-shadow: 0 12px 28px rgba(11, 39, 72, 0.12);
    transform: translateY(-2px);
}
.image-choice figure { margin: 0; }
.image-choice figcaption {
    display: block;
    color: var(--ml-ink) !important;
    font-size: 12.5px;
    line-height: 1.35;
    margin-top: 0.55em;
    padding: 0 0.2em 0.2em 0.2em;
    word-break: break-word;
    font-weight: 600;
}
.image-choice .image {
    background: var(--ml-cream-2);
    border-radius: 3px;
    overflow: hidden;
}

/* Listing rows in tables */
table.listing td,
table.listing th { color: var(--ml-ink); }
table.listing a { color: var(--ml-blue); }
table.listing tbody tr:hover { background: rgba(209, 180, 140, 0.12); }

/* Card-style listings (snippets, etc.) */
ul.listing li.listing-item,
.listing__item {
    color: var(--ml-ink);
}

/* ---- Sub-menu / drilldown panel: make sure the popover has a solid bg ---- */
.sidebar-sub-menu-panel,
.w-drilldown__submenu {
    background-color: #07172c !important;
    color: var(--ml-cream);
}

.sidebar-sub-menu-panel > h2,
.sidebar-sub-menu-panel a,
.w-drilldown__submenu a {
    color: #e7dec7;
}

.sidebar-sub-menu-panel a:hover,
.w-drilldown__submenu a:hover {
    color: #ffffff;
    background: rgba(209, 180, 140, 0.18);
}

.sidebar-sub-menu-panel ul li,
.w-drilldown__submenu li {
    color: #e7dec7;
}

/* The page explorer popover (Pages → tree) */
.menu-panel,
[data-explorer-menu],
.sidebar-page-explorer-item,
.explorer__menu {
    background-color: #07172c !important;
    color: var(--ml-cream);
}

.sidebar-page-explorer-item a,
.explorer__menu a {
    color: #e7dec7;
}

.sidebar-page-explorer-item a:hover,
.explorer__menu a:hover {
    color: #ffffff;
    background: rgba(209, 180, 140, 0.16);
}

/* Locale labels and minor tags inside popovers */
.sidebar-sub-menu-panel .indicator,
.sidebar-sub-menu-panel .status-tag,
.sidebar-page-explorer-item .status-tag,
.w-drilldown__submenu .status-tag {
    background: rgba(209, 180, 140, 0.18) !important;
    color: var(--ml-cream) !important;
    border-color: rgba(209, 180, 140, 0.45) !important;
}

/* ---- Action dropdowns (page row "...", header actions, etc.) ---- */
.w-dropdown__content {
    background: #ffffff !important;
    color: var(--ml-ink) !important;
    border: 1px solid var(--ml-tan);
    border-radius: 4px;
    box-shadow: 0 18px 42px rgba(11, 39, 72, 0.18);
}

.w-dropdown__content a,
.w-dropdown__content button,
.w-dropdown__content .button {
    color: var(--ml-ink) !important;
    font-weight: 600;
    background: transparent !important;
    display: flex;
    align-items: center;
    gap: 0.6em;
    padding: 0.55em 1em;
    text-decoration: none;
}

.w-dropdown__content svg,
.w-dropdown__content .icon {
    color: var(--ml-blue) !important;
    fill: currentColor;
}

.w-dropdown__content a:hover,
.w-dropdown__content button:hover {
    background: rgba(209, 180, 140, 0.18) !important;
    color: var(--ml-ink) !important;
}

.tippy-box[data-theme="dropdown-button"] {
    color: var(--ml-ink) !important;
}

.tippy-box[data-theme="dropdown-button"][data-placement^="bottom"] > .tippy-arrow:before {
    border-bottom-color: #ffffff !important;
}
.tippy-box[data-theme="dropdown-button"][data-placement^="top"] > .tippy-arrow:before {
    border-top-color: #ffffff !important;
}

/* ---- Default unthemed tooltip (side panel toggles, hint hovers) ----
   The default `.tippy-box` uses --w-color-surface-tooltip (white in our theme)
   and --w-color-text-button (also white) → invisible. Pin it to ink-on-white
   so hover hints over icon buttons stay readable. */
.tippy-box:not([data-theme]),
.tippy-box[data-theme=""] {
    background-color: var(--ml-ink) !important;
    color: #ffffff !important;
}
.tippy-box:not([data-theme])[data-placement^="top"] > .tippy-arrow:before,
.tippy-box[data-theme=""][data-placement^="top"] > .tippy-arrow:before {
    border-top-color: var(--ml-ink) !important;
}
.tippy-box:not([data-theme])[data-placement^="bottom"] > .tippy-arrow:before,
.tippy-box[data-theme=""][data-placement^="bottom"] > .tippy-arrow:before {
    border-bottom-color: var(--ml-ink) !important;
}
.tippy-box:not([data-theme])[data-placement^="left"] > .tippy-arrow:before,
.tippy-box[data-theme=""][data-placement^="left"] > .tippy-arrow:before {
    border-inline-start-color: var(--ml-ink) !important;
}
.tippy-box:not([data-theme])[data-placement^="right"] > .tippy-arrow:before,
.tippy-box[data-theme=""][data-placement^="right"] > .tippy-arrow:before {
    border-inline-end-color: var(--ml-ink) !important;
}

/* ---- Tippy popup / drilldown menus (the "…" context menu, etc.) ---- */
.tippy-box[data-theme="popup"],
.tippy-box[data-theme="drilldown"] {
    color: var(--ml-ink) !important;
    background-color: #ffffff !important;
    border: 1px solid var(--ml-tan);
}

.tippy-box[data-theme="popup"] a,
.tippy-box[data-theme="popup"] button,
.tippy-box[data-theme="drilldown"] a,
.tippy-box[data-theme="drilldown"] button {
    color: var(--ml-ink) !important;
    font-weight: 600;
}

.tippy-box[data-theme="popup"] svg,
.tippy-box[data-theme="popup"] .icon,
.tippy-box[data-theme="drilldown"] svg,
.tippy-box[data-theme="drilldown"] .icon {
    color: var(--ml-blue) !important;
    fill: currentColor;
}

.tippy-box[data-theme="popup"] a:hover,
.tippy-box[data-theme="popup"] button:hover,
.tippy-box[data-theme="drilldown"] a:hover,
.tippy-box[data-theme="drilldown"] button:hover {
    background: rgba(209, 180, 140, 0.18) !important;
    color: var(--ml-ink) !important;
}

.tippy-box[data-theme="popup"][data-placement^="bottom"] > .tippy-arrow:before,
.tippy-box[data-theme="drilldown"][data-placement^="bottom"] > .tippy-arrow:before {
    border-bottom-color: #ffffff !important;
}
.tippy-box[data-theme="popup"][data-placement^="top"] > .tippy-arrow:before,
.tippy-box[data-theme="drilldown"][data-placement^="top"] > .tippy-arrow:before {
    border-top-color: #ffffff !important;
}

/* ---- Side panel "Checks" (content metrics + a11y) ---- */
[data-side-panel="checks"] h2,
[data-side-panel="checks"] h3 {
    color: var(--ml-ink) !important;
}

[data-side-panel="checks"] .w-text-text-label {
    color: var(--ml-ink) !important;
}

[data-side-panel="checks"] .w-text-text-placeholder {
    color: var(--ml-brown) !important;
}

.w-content-checker__row {
    background: #ffffff !important;
    color: var(--ml-ink) !important;
    border: 1px solid var(--ml-tan) !important;
}

.w-content-checker__name {
    color: var(--ml-ink) !important;
    font-weight: 700;
}

.w-content-checker__help {
    color: var(--ml-brown) !important;
}

.w-content-checker__selector {
    background: var(--ml-cream) !important;
    color: var(--ml-ink) !important;
    border: 1px solid var(--ml-tan) !important;
    font-weight: 600;
}

.w-content-checker__selector:hover,
.w-content-checker__selector:focus {
    background: rgba(209, 180, 140, 0.30) !important;
    color: var(--ml-ink) !important;
}

.w-content-checker__selector-text {
    color: var(--ml-ink) !important;
}

.w-content-checker__icon {
    fill: var(--ml-blue) !important;
    color: var(--ml-blue) !important;
}

.w-content-checker__count {
    background-color: var(--ml-ink) !important;
    color: #ffffff !important;
    border-color: var(--ml-tan) !important;
}

.w-content-checker__count.has-errors {
    background-color: #b32d2e !important;
    color: #ffffff !important;
}

/* ---- Modal header (chooser dialogs etc.) ---- */
.w-header {
    background-color: var(--ml-cream) !important;
    color: var(--ml-ink) !important;
    border-bottom: 1px solid var(--ml-tan);
}
.w-header .w-header__title,
.w-header h1,
.w-header h2 {
    color: var(--ml-ink) !important;
}
.w-header .icon,
.w-header svg {
    color: var(--ml-blue);
}
.w-header .w-header-button {
    color: var(--ml-ink);
    border-color: var(--ml-tan);
}
.w-header .w-header-button:hover {
    color: var(--ml-blue);
    background: rgba(209, 180, 140, 0.18);
}

/* ---- StreamField block picker popover ---- */
.w-combobox-container {
    background: #ffffff !important;
    color: var(--ml-ink) !important;
    border: 1px solid var(--ml-tan);
    box-shadow: 0 18px 42px rgba(11, 39, 72, 0.25);
}

.w-combobox-container input[type="text"],
.w-combobox-container input[type="search"] {
    background: var(--ml-cream) !important;
    color: var(--ml-ink) !important;
    border: 1px solid var(--ml-tan) !important;
}

.w-combobox-container input::placeholder {
    color: rgba(107, 90, 75, 0.65) !important;
}

.w-combobox__optgroup-label {
    color: var(--ml-brown) !important;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 0.78em !important;
}

.w-combobox__option {
    color: var(--ml-ink) !important;
    border: 1px solid var(--ml-tan) !important;
    background: #ffffff;
}

.w-combobox__option:hover,
.w-combobox__option[aria-selected="true"] {
    background: rgba(209, 180, 140, 0.18) !important;
    border-color: var(--ml-blue) !important;
    color: var(--ml-ink) !important;
}

.w-combobox__option-icon {
    color: var(--ml-ink) !important;
}

.w-combobox__option-text {
    color: var(--ml-ink) !important;
}

.w-combobox-preview {
    background: var(--ml-cream) !important;
    color: var(--ml-ink) !important;
    border-color: var(--ml-tan) !important;
}

.w-combobox-preview__label { color: var(--ml-ink) !important; }
.w-combobox-preview__description { color: var(--ml-brown) !important; }

/* ---- Brand mark in sidebar ---- */
.sidebar .sidebar-custom-branding,
.w-sidebar__inner .sidebar-custom-branding {
    display: flex;
    align-items: center;
    gap: 0.7em;
    padding: 14px 16px 12px 16px;
    border-bottom: 1px solid rgba(209, 180, 140, 0.18);
}

.sidebar-custom-branding .mm-brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    background: var(--ml-cream);
    color: var(--ml-ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 14px;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.sidebar-custom-branding .mm-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.sidebar-custom-branding .mm-brand-title {
    color: var(--ml-cream);
    font-weight: 700;
    font-size: 12.5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.sidebar-custom-branding .mm-brand-site {
    color: rgba(231, 222, 199, 0.6);
    font-size: 10.5px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-top: 2px;
}

/* ---- Soften default panels and headers ---- */
.content-wrapper {
    background: var(--w-color-surface-page);
}

.nice-padding > header h1,
header .row h1,
.header > h1 {
    color: var(--ml-ink) !important;
    font-weight: 700;
    letter-spacing: 0.005em;
}

.panel-wrapper,
.dashboard-panel {
    background: var(--w-color-surface-dashboard-panel) !important;
    border: 1px solid var(--ml-tan);
    border-radius: 4px;
    box-shadow: 0 4px 14px rgba(11, 39, 72, 0.06);
}

.panel-wrapper h2,
.dashboard-panel h2 {
    color: var(--ml-ink);
    font-weight: 700;
}

button,
.button,
input[type="submit"],
input[type="button"] {
    font-family: var(--w-font-sans);
    letter-spacing: 0.04em;
}

button.button-secondary,
.button-secondary {
    color: var(--ml-ink) !important;
    border-color: var(--ml-tan) !important;
}

/* Status pill */
.status-tag {
    border-radius: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Sidebar item hover ‒ keep the warm accent line */
.sidebar-menu-item--active > a,
.sidebar-sub-menu-item--active > a {
    background: var(--w-color-surface-menu-item-active);
    position: relative;
}

.sidebar-menu-item--active > a::before,
.sidebar-sub-menu-item--active > a::before {
    content: "";
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 2px 2px 0;
    background: var(--ml-tan);
}

/* Welcome / home panel */
.mm-welcome {
    display: flex;
    flex-direction: column;
    gap: 0.8em;
    padding: 1.6em 1.8em;
    background: linear-gradient(135deg, #07172c 0%, #174d7a 100%);
    color: var(--ml-cream);
    border-radius: 6px;
    box-shadow: 0 14px 32px rgba(11, 39, 72, 0.18);
    margin-bottom: 1.5em;
    border: 1px solid var(--ml-tan);
}

.mm-welcome__eyebrow {
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--ml-tan);
    font-weight: 700;
    margin: 0;
}

.mm-welcome__title {
    font-size: 22px;
    color: var(--ml-cream);
    margin: 0;
    letter-spacing: 0.01em;
    font-weight: 700;
}

.mm-welcome__text {
    color: var(--ml-cream);
    margin: 0;
    opacity: 0.92;
    line-height: 1.55;
    max-width: 56em;
}

.mm-welcome__actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 0.4em;
}

.mm-welcome__actions a {
    display: inline-flex;
    align-items: center;
    gap: 0.45em;
    padding: 0.55em 1.1em;
    background: rgba(244, 240, 230, 0.10);
    color: var(--ml-cream);
    border: 1px solid rgba(209, 180, 140, 0.5);
    border-radius: 2px;
    text-decoration: none;
    font-size: 13px;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.mm-welcome__actions a:hover {
    background: rgba(244, 240, 230, 0.22);
    color: var(--ml-cream);
}

/* ============================================================
   Login screen — restyled in place, no template fork
   ============================================================ */

body.login {
    background:
        linear-gradient(rgba(11, 39, 72, 0.72), rgba(11, 39, 72, 0.92)),
        url("/static/images/homepage.aecc6969809e.png") center/cover no-repeat,
        var(--ml-ink);
    min-height: 100vh;
}

body.login main.content-wrapper {
    max-width: 460px;
    margin: 6vh auto 2em auto;
    padding: 2.6em 2.8em 2em 2.8em;
    background: var(--ml-cream);
    border: 1px solid var(--ml-tan);
    border-radius: 6px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

body.login main.content-wrapper h1 {
    color: var(--ml-ink);
    font-size: 22px;
    margin: 0 0 0.7em 0;
    letter-spacing: 0.01em;
    text-align: center;
}

body.login .login-form input[type="text"],
body.login .login-form input[type="password"],
body.login .login-form input[type="email"] {
    background: #ffffff;
    border: 1px solid var(--ml-tan);
    color: var(--ml-ink);
    border-radius: 3px;
}

body.login .button {
    background: var(--ml-ink);
    color: var(--ml-cream);
    border: 1px solid var(--ml-tan);
    letter-spacing: 0.06em;
}
body.login .button:hover { background: var(--ml-blue); color: var(--ml-cream); }

body.login .login-logo { display: none; }

body.login footer { color: var(--ml-cream); opacity: 0.7; }
body.login footer a { color: var(--ml-tan); }
