@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

/* 
   Classless & ID-less CSS for Socio BSC
   Colour Palette: 
   Primary: #897baa, #45335e
   Header/Footer: #2a1e3d
   Accent: #b2a1c7
   Background: #F3F4F6 
*/

:root {
    --primary: #897baa;
    --primary-dark: #45335e;
    --header-footer-bg: #2a1e3d;
    --accent: #b2a1c7;
    --bg-light: #F3F4F6;
    --text-dark: #1F2937;
    --text-light: #4B5563;
    --white: #FFFFFF;
}

/* Global Reset */
html, body {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: 'Roboto', sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--bg-light);
}

/* Typography */
h1, h2, h3 {
    line-height: 1.2;
    color: var(--primary-dark);
}

/* Normalise hierarchy visually so SEO promotions don't change the design */
main h1 { font-size: 2rem; margin-bottom: 1.5rem; }
main h2 { font-size: 1.5rem; margin-top: 2rem; margin-bottom: 1rem; }
main h3 { font-size: 1.17rem; margin-top: 1.5rem; margin-bottom: 0.5rem; }


p {
    margin-bottom: 1rem;
}

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

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

/* Header & Navigation */
header {
    background-color: var(--header-footer-bg);
    color: var(--white);
    padding: 1rem max(1rem, calc(50% - 600px + 1rem));
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Semantic Logo Styling */
header > a:first-of-type {
    display: flex;
    align-items: center; /* Fixes any vertical alignment 'ghost gaps' */
    text-decoration: none;
}

header > a:first-of-type img {
    max-height: 75px;
    width: auto;
    aspect-ratio: auto;
    border-radius: 0;
    box-shadow: none;
    object-fit: contain;
    margin: 0; /* Reset global image margins if any */
}

header a {
    color: var(--white);
}

header:has(> address) {
    padding: 0;
}

header > address {
    order: -1;
    flex: 0 0 100%;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem 1.5rem;
    background-color: #1c1429;
    margin: 0;
    padding: 0.45rem max(1rem, calc(50% - 600px + 1rem));
    font-style: normal;
    font-size: 0.8rem;
    letter-spacing: 0.01em;
    color: rgba(255, 255, 255, 0.85);
}

header > address p {
    margin: 0;
}

header:has(> address) > a:first-of-type {
    margin: 1rem 0 1rem max(1rem, calc(50% - 600px + 1rem));
}

header:has(> address) > nav {
    margin: 1rem max(1rem, calc(50% - 600px + 1rem)) 1rem 0;
}

header > address a {
    color: var(--accent);
    font-weight: 500;
}

header > address a:hover {
    color: var(--white);
    text-decoration: underline;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--white);
}

nav > ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

nav > ul > li {
    position: relative;
}

/* Semantic Nested Navigation Dropdown */
nav > ul > li > button {
    background: none;
    border: none;
    color: var(--white);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
    transition: color 0.3s ease;
}

nav > ul > li > button::after {
    content: " ▾";
}

nav > ul > li:hover > button,
nav > ul > li > button[aria-expanded="true"] {
    color: var(--accent);
}

nav > ul > li > ul {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--header-footer-bg);
    list-style: none;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
    min-width: 300px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    z-index: 10;
}

/* Invisible hover bridge so cursor movement across the 0.5rem gap doesn't close the menu */
nav > ul > li > ul::before {
    content: "";
    position: absolute;
    top: -0.5rem;
    left: 0;
    right: 0;
    height: 0.5rem;
}

@media (hover: hover) {
    nav > ul > li:hover > ul {
        display: block;
    }
}

nav > ul > li > button[aria-expanded="true"] + ul {
    display: block;
}

nav > ul > li > ul li a {
    padding: 0.5rem 1rem;
    display: block;
}

nav > ul > li > ul li a:hover {
    background-color: var(--accent);
    color: var(--white);
}

/* Main Content */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

section {
    margin-bottom: 3rem;
}

section > h1, section > h2 {
    border-bottom: 2px solid var(--accent);
    padding-bottom: 0.5rem;
}

/* Semantic Slider - Targets the first section's figure */
main > figure {
    margin: 0;
    padding: 0;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

main > figure ul {
    display: flex;
    margin: 0;
    padding: 0;
    list-style: none;
    transition: transform 0.5s ease-in-out;
}

main > figure ul li {
    min-width: 100%;
    flex: 0 0 100%;
    backface-visibility: hidden;
    transform: translateZ(0);
    overflow: hidden;
}

/* Global Figures */
figure {
    margin: 0 0 1.5rem 0;
    padding: 0;
    overflow: hidden;
    border-radius: 8px;
}

/* Global Images */
img {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    object-position: center;
    border-radius: 8px;
}

/* Full Width Hero (Used on Homepage) */
figure[data-type="full-width-hero"] {
    margin: 0;
    padding: 0;
    width: 100%;
    position: relative;
    border-radius: 0;
}

figure[data-type="full-width-hero"] img {
    border-radius: 0;
    aspect-ratio: auto;
    max-height: 80vh;
    object-fit: cover;
    object-position: center;
}

figure[data-type="full-width-hero"] figcaption {
    position: absolute;
    bottom: 2rem;
    left: max(1rem, calc(50% - 600px + 1rem));
    background-color: rgba(42, 30, 61, 0.85); /* Semi-transparent header purple */
    color: var(--white);
    padding: 1rem 1.5rem;
    font-size: 1.2rem;
    font-weight: 500;
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    z-index: 10;
}

main > figure > figcaption {
    position: absolute;
    bottom: 1.5rem;
    left: 1.5rem;
    background-color: rgba(42, 30, 61, 0.85);
    color: var(--white);
    padding: 0.75rem 1.25rem;
    font-size: 1.15rem;
    font-weight: 500;
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    z-index: 10;
    pointer-events: none;
}

@media (max-width: 768px) {
    figure[data-type="full-width-hero"] figcaption,
    main > figure > figcaption {
        bottom: 1rem;
        left: 1rem;
        right: 1rem; /* Allow it to span across on small screens if needed */
        font-size: 1rem;
        text-align: center;
    }
}



/* Allow inline images in articles (like from the WYSIWYG editor) to retain their natural sizes and aspect ratios */
article img {
    width: auto;
    max-width: 100%;
    aspect-ratio: auto;
    object-fit: contain;
    margin: 1rem 0; /* Add some spacing around inline images */
}

/* Force featured images inside figures to retain the strict cinematic hero styling */
article figure img, section > figure img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    margin: 0;
}
main > figure nav {
    position: absolute;
    top: 50%;
    width: 100%;
    display: flex;
    justify-content: space-between;
    transform: translateY(-50%);
    pointer-events: none; /* Let clicks pass through empty space */
}

main > figure nav button {
    pointer-events: auto;
    background-color: rgba(42, 30, 61, 0.7);
    color: var(--white);
    border: none;
    padding: 1rem;
    cursor: pointer;
    font-size: 1.5rem;
    transition: background-color 0.3s;
}

main > figure nav button:hover {
    background-color: var(--accent);
}

/* Footer */
footer {
    background-color: var(--header-footer-bg);
    color: var(--white);
    text-align: center;
    padding: 1.5rem;
    margin-top: 2rem;
}

footer > a {
    display: inline-block;
    margin: 0.5rem 1rem 1rem 1rem;
    vertical-align: middle;
}

footer p {
    margin: 0.35rem 0;
}

footer small {
    font-size: 0.85rem;
    opacity: 0.85;
}

footer p a {
    color: var(--accent);
    text-decoration: underline;
    font-weight: 500;
}

footer p a:hover {
    color: var(--white);
}

footer > a img {
    aspect-ratio: auto;
    object-fit: contain;
    height: 110px;
    width: auto;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    display: block;
}

footer > a[href*="cbuilde"] img {
    height: 75px;
    filter: brightness(0) invert(1);
}

/* Responsive Design */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }

    header:has(> address) {
        padding: 0 0 1rem 0;
    }

    header:has(> address) > a:first-of-type {
        margin: 0 1rem;
    }

    header:has(> address) > nav {
        margin: 0;
        padding: 0 1rem;
        box-sizing: border-box;
    }

    header > address {
        align-self: stretch;
        justify-content: center;
        text-align: center;
        margin: 0;
        font-size: 0.75rem;
        line-height: 1.4;
    }
    
    header h1 {
        text-align: center;
    }
    
    nav {
        width: 100%;
    }
    
    nav > ul {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
    }
}


/* Form Styling */
form {
    max-width: 600px;
    background-color: var(--white);
    padding: 2.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}
fieldset {
    border: none;
    padding: 0;
    margin: 0;
}
legend {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent);
    width: 100%;
}
label {
    font-weight: 500;
    color: var(--primary-dark);
}
input, textarea, select {
    width: 100%;
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
    border: 1px solid #D1D5DB;
    background-color: var(--bg-light);
    border-radius: 4px;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-dark);
    transition: all 0.3s ease;
    box-sizing: border-box;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(137, 123, 170, 0.25);
    background-color: var(--white);
}
button[type="submit"] {
    background-color: var(--primary-dark);
    color: var(--white);
    border: none;
    padding: 1rem 2rem;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 500;
    border-radius: 4px;
    transition: background-color 0.3s;
    margin-top: 1rem;
}
button[type="submit"]:hover {
    background-color: var(--primary);
}

/* Footer Address Styling */
footer address {
    font-style: normal;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    opacity: 0.9;
}
footer address a {
    color: var(--white);
    text-decoration: underline;
    font-weight: 500;
}
footer address a:hover {
    color: var(--accent);
}

/* Call to Action Links */
a[role="button"] {
    display: block;
    width: fit-content;
    margin: 4rem auto 2rem;
    background-color: var(--primary-dark);
    color: var(--white);
    padding: 1rem 2rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    font-size: 1.1rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: background-color 0.3s, transform 0.2s;
    text-align: center;
}
a[role="button"]:hover {
    background-color: var(--primary);
    transform: translateY(-2px);
    color: var(--white);
}

/* Specific Google Review Button Override */
a[data-type="google-review"] {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background-color: var(--white);
    color: var(--text-dark);
    border: 1px solid #D1D5DB;
    margin: 1rem 0 0 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

a[data-type="google-review"]:hover {
    background-color: var(--bg-light);
    color: var(--primary);
}

a[data-type="google-review"] img {
    width: 24px;
    height: 24px;
    margin: 0;
    aspect-ratio: auto;
    object-fit: contain;
    transform: none;
}


/* Form Status Messages */
output[data-status]:not([hidden]),
output#form-message:not([hidden]) {
    display: block;
    max-width: 600px;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    font-weight: bold;
}
output[data-status="success"] {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
output[data-status="error"] {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}


/* Semantic Split Layout: Any section that has a direct child <aside> will automatically split */
main > section:has(> aside) {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    align-items: flex-start;
}

main > section:has(> aside) > h1,
main > section:has(> aside) > h2 {
    flex: 1 1 100%;
    margin-bottom: 0;
}

main > section:has(> aside) > article {
    flex: 1 1 500px;
}

main > section:has(> aside) > aside {
    flex: 1 1 300px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Ensure text on the right aligns with the top of the content inside the white form box on the left */
main > section:has(> aside) > article > h2:first-child,
main > section:has(> aside) > aside > article:first-child > h2:first-child {
    margin-top: 0;
}

main > section:has(> article > form) > aside > article:first-child > h2:first-child {
    margin-top: 2.5rem;
}

/* Semantic styling for heading links, RICS accreditation logo, and horizontal rules in articles */
article h2 a {
    color: inherit;
    text-decoration: underline;
}

article > a:has(> img[src*="rics-logo"]) {
    display: inline-block;
}

article > a > img[src*="rics-logo"] {
    aspect-ratio: auto;
    object-fit: contain;
    max-width: 250px;
    border-radius: 0;
    box-shadow: none;
    margin-bottom: 1rem;
}

article hr {
    margin: 2rem 0;
    border: none;
    border-top: 1px solid #D1D5DB;
}

section > figure {
    margin: 0 0 2rem 0;
    padding: 0;
}

article iframe {
    border: 0;
    border-radius: 8px;
    width: 100%;
    display: block;
}

/* News Post Cards */
article[data-type="news-post"] {
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    background: var(--white);
}

article[data-type="news-post"] h2 {
    margin-top: 0;
}

article[data-type="news-post"] img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin-bottom: 1rem;
}

article[data-type="news-post"] time {
    color: var(--primary-dark);
    font-size: 0.9em;
    display: block;
    margin-bottom: 1rem;
}

article[data-type="news-post"] > :last-child {
    margin-bottom: 0;
}

/* Admin Dashboard & Form Refinements */
input[type="checkbox"] {
    width: auto;
    margin: 0 0.4rem 0 0;
}

fieldset figure {
    margin: 0.5rem 0 0.75rem 0;
}

fieldset figure img {
    max-width: 200px;
    display: block;
    margin-bottom: 0.75rem;
    border-radius: 8px;
}

fieldset figcaption label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: normal;
}

fieldset figcaption small {
    display: block;
    font-size: 0.9em;
    color: #666;
}

fieldset p > button[type="submit"] + a {
    margin-left: 1rem;
    color: var(--primary);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 2rem;
    background: var(--white);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background: var(--primary-dark);
    color: var(--white);
}

td a {
    padding: 0.5rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9rem;
    margin-right: 0.5rem;
}

td a[data-type="edit"] {
    background: var(--primary);
    color: var(--white);
}

td a[data-type="edit"]:hover {
    background: var(--accent);
}

td a[data-type="delete"] {
    background: #e11d48;
    color: var(--white);
}

td a[data-type="delete"]:hover {
    background: #be123c;
}

#editor-container {
    height: 400px;
    min-height: 200px;
    resize: vertical;
    overflow-y: hidden;
    background: var(--white);
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

.ql-toolbar {
    background: #f3f4f6;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    margin-top: 0.5rem;
}

.ql-editor p {
    margin-bottom: 0.5rem;
}

[hidden] {
    display: none !important;
}
