:root {
    /* Backgrounds */
    --color-bg: #222222;
    --color-bg-alt: #333333;

    /* Typography */
    --color-text: #D4D4D4;
    --color-text-alt: #505050;

    /* Brand & accents */
    --color-primary: #A06DC2;         /* AA-safe purple */
    --color-primary-hover: #8F5AB4;   /* darker for hover */
    --color-secondary: #89A158;       /* AA-safe olive for links */
    --color-accent: #D75B33;          /* lively mauve-orange */
    --color-accent-light: #E0AA2F;    /* warm amber-gold */
    --color-tertiary: #0F5E73;        /* deep teal */
    --radius: 4px;
    --spacing: 1rem;
    --font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    /* Footer/Sidebar background uses palette colors */
    --color-bg-footer: #222222;  /* anthracite */
    --color-bg-sidebar: #333333; /* light anthracite */
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--color-bg);
    color: var(--color-text);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center; /* keep header centered; main will stretch */
    text-align: center; /* default; override with .content/.content-inner */
    line-height: 1.5;
    padding: var(--spacing);
}

/* Ensure main stretches full width so grid sidebars can align left */
main { width: 100%; margin: 0; flex: 1; }

h1 {
    color: var(--color-primary);
    margin-bottom: var(--spacing);
    font-size: 2rem;
}

form {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 360px;
    gap: var(--spacing);
    margin-bottom: var(--spacing);
}

label {
    text-align: left;
    color: var(--color-text);
    font-weight: bold;
}

input[type="text"], input[type="email"], input[type="password"] {
    padding: 0.5rem;
    border: 1px solid var(--color-text-alt);
    border-radius: var(--radius);
    background-color: var(--color-bg-alt);
    color: var(--color-text);
}

button {
    padding: 0.75rem;
    border: none;
    border-radius: var(--radius);
    background-color: var(--color-primary);
    color: var(--color-text);
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s ease;
}

button:hover {
    background-color: var(--color-primary-hover);
}

a {
    color: var(--color-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
}

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

p {
    margin: var(--spacing) 0;
}

img {
    max-width: 100%;
    height: auto;
    margin-bottom: var(--spacing);
}

/* Default logo rendered via CSS mask */
.logo {
    width: 64px;
    height: 64px;
    background-color: var(--color-secondary);  /* default tint, overridden in context */
    -webkit-mask: url('/main/static/images/triggerpointed_logo_traced.svg') no-repeat center / contain;
            mask: url('/main/static/images/triggerpointed_logo_traced.svg') no-repeat center / contain;
}

/* Brand container in global header */
.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    /* Default: auto width; becomes fixed on sidebar pages */
}

.brand-text {
    display: inline-block; /* always show brand text */
    color: var(--color-text-alt); /* match footer link tone */
    font-weight: 600;
    letter-spacing: 0.2px;
    font-size: 1.3rem;
}

/* Default header brand logo size */
header .brand .logo {
    width: 48px;
    height: 48px;
}

/* Home page header: center logo with brand text */
.home-header { display: flex; flex-direction: column; align-items: center; margin: 0.5rem 0 1rem; }



.home-header .logo { margin: 0.5rem 0; width: 48px; height: 48px; }

/* Stack brand title and subtitle under the logo */
.logo-text {
    display: flex;
    flex-direction: column;
    align-items: center;   /* keep them centred */
    text-align: center;    /* ensure multiline text is centred */
}


.home-header .brand-title { margin: 0.5rem 0 0; font-size: 1.6rem; color: var(--color-primary); }

.home-header .brand-subtitle { margin: 0; font-size: 0.95rem; color: var(--color-text-alt); }

/* Hero ribbon image (cropped strip) */
.hero-ribbon { width: 100%; max-width: 1200px; margin: 0 auto 1.25rem; overflow: hidden; border-radius: 8px; }
.hero-ribbon img { width: 100%; height: 140px; object-fit: cover; display: block; filter: saturate(1.05); }

/* Small icon images on cards */
.card .icon { width: 64px; height: 64px; display: block; margin-bottom: 0.5rem; }
.icon { width: 64px; height: 64px; display: block; margin-bottom: 0.5rem; }
.date-tag { font-size: 0.85rem; color: var(--color-text-alt); font-weight: 500; margin-left: 0.5rem; }
.trust-line { color: var(--color-text-alt); font-size: 0.85rem; margin-top: 0.6rem; display: inline-flex; align-items: center; gap: 0.35rem; }
.trust-line svg { width: 14px; height: 14px; fill: currentColor; opacity: 0.85; }
.trust-line img.lock-icon { width: 14px; height: 14px; opacity: 0.85; display: inline-block; }

.whatsnew { line-height: 1.8; }

/* Vertical notices */
.error, #error {
    color: var(--color-accent);
}

/* Feedback messages */
.success, #success {
    color: var(--color-secondary);
}

/* Site-wide header/navigation */
header {
    display: grid;
    grid-template-columns: calc(220px + 1rem) 1fr; /* align with sidebar layout even on pages without sidebar */
    align-items: center;
    gap: 0; /* spacing handled inside columns */
    padding: var(--spacing) 0;
    position: sticky;
    top: 0;
    width: 100%;
    background-color: var(--color-bg);
    z-index: 100;
}

header nav ul {
    list-style: none;
    display: flex;
    gap: var(--spacing);
    margin: 0;
    padding: 0;
}

/* Make nav a flex row holding both menus */
header nav {
    display: flex;
    align-items: center;
    width: 100%;
}

/* Keep menu items on one line by default */
header nav ul { /* reinforce nowrap for both lists */
    flex-wrap: nowrap;
}

/* Push auth menu to the right and align horizontally */
#auth-nav {
    margin-left: auto;
    display: flex;
    gap: var(--spacing);
}

header nav a {
    color: var(--color-secondary);
    text-decoration: none;
}

header nav a:hover {
    color: var(--color-accent-light);
}

/* When a page has a left sidebar, align header with content */
.has-sidebar header {
    display: grid;
    grid-template-columns: calc(220px + 1rem) 1fr; /* sidebar + grid gap | content */
    gap: 0; /* spacing handled inside columns */
}

.has-sidebar header .brand { /* sits in first column; no fixed width needed */ }

.has-sidebar header .brand .brand-text {
    font-size: 1.3rem;
}

.has-sidebar header .header-right {
    /* mirror .content-inner sizing */
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem; /* same as .content-inner */
}

.has-sidebar header .header-right nav {
    display: flex;
    align-items: center;
}

/* Also align header-right to content width on non-sidebar pages */
header .header-right {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Focus visibility for accessibility */
:focus-visible {
    outline: 2px solid var(--color-accent-light);
    outline-offset: 2px;
}

/* Dropdown menus */
/* (Dropdown styles retained if needed later) */

/* Utility */
.hidden { display: none; }

/* Page layout with left sidebar for subcategories */
.page-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 1rem;
    width: 100%;
    align-items: start;
}
.sidebar {
    text-align: left;
    position: sticky;
    top: 60px;
    background-color: var(--color-bg-sidebar);
    border: 1px solid #2b2b2b;
    border-radius: 8px;
    padding: 0.5rem 0.75rem 0.75rem;
}
.sidebar h3 { margin: 0.25rem 0 0.5rem; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li { margin: 0; }
.sidebar a { display: block; padding: 0.5rem 0.5rem; color: var(--color-text); }
.sidebar a:hover { color: var(--color-accent-light); }
.sidebar a.active { color: var(--color-accent-light); font-weight: 600; border-left: 2px solid var(--color-primary); padding-left: calc(0.5rem - 2px); }
.content { text-align: left; }
.content-inner { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }

/* Admin/content tables and forms theme */
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; color: var(--color-text); border-bottom: 1px solid #2b2b2b; padding: 0.5rem; }
tbody td { border-bottom: 1px solid #2a2a2a; padding: 0.5rem; }
tbody tr:hover { background: #1b1b1b; }

/* Inputs inside table should be readable and sized */
td input[type="text"], td input[type="number"], td input[type="email"] {
  width: 100%;
}

/* Narrow forms in content for better focus */
.content form { max-width: 800px; margin-left: auto; margin-right: auto; }

/* Responsive: stack sidebar on small screens */
@media (max-width: 900px) {
  .page-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
}

/* Card layout for product summaries */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 2rem;
}
.card {
    border: 1px solid var(--color-bg-alt);
    border-radius: 8px;
    padding: 1rem;
    background: #1e1e1e;
    text-align: left;
}
.card h3 { margin-top: 0.25rem; }
.card .thumb {
    width: 100%;
    aspect-ratio: 1.6 / 1;
    background: #2a2a2a;
    border-radius: 6px;
    margin-bottom: 0.75rem;
}
.btn { display: inline-block; padding: 0.5rem 0.8rem; border-radius: 6px; cursor: pointer; vertical-align: middle; }
.cards .btn { margin: 0.25rem 0.25rem 0 0; }
.btn-primary { background: var(--color-primary); color: #fff; border: none; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-link { background: transparent; color: var(--color-secondary); border: 1px solid var(--color-bg-alt); }
.btn-link:hover { color: var(--color-accent-light); }

/* Mobile subnav chips */
.mobile-subnav { display: none; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip { display: inline-block; padding: 0.25rem 0.6rem; border: 1px solid var(--color-bg-alt); border-radius: 999px; }
@media (max-width: 900px) {
  .mobile-subnav { display: flex; }
}

/* Footer links horizontal */
footer {
    margin-top: var(--spacing);
    text-align: center;
    background-color: var(--color-bg-footer);
    width: 100%;
    padding: var(--spacing);
    border-top: 1px solid #2b2b2b;
    /* Make footer text smaller for lower visual weight */
    font-size: 0.8rem; /* ~12.8px */
}

/* Footer grid layout */
.footer-grid {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    text-align: left;
}
.footer-col h4 {
    margin: 0 0 0.5rem 0;
    color: var(--color-text);
    font-size: 0.9rem; /* slightly larger than body inside footer */
}
.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin: 0.25rem 0; }
.footer-col a { color: var(--color-text-alt); text-decoration: none; }
.footer-col a:hover { color: var(--color-text); }

@media (max-width: 900px) {
  .footer-grid { grid-template-columns: 1fr; }
}

/* Skip link */
.skip-link {
    position: absolute;
    left: 1rem;
    top: -40px;
    background: var(--color-primary);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
}
.skip-link:focus { top: 1rem; }
