/**
 * Primal Theme — main stylesheet (single-page design).
 *
 * Contents:
 *   1. Design tokens (:root)
 *   2. Base / reset
 *   3. Fixed background layers
 *   4. Fixed top bar + nav + language dropdown
 *   5. Sections (translucent, scroll over background)
 *   6. Hero
 *   7. Posts grid / infinite scroll
 *   8. Booking modal
 *   9. Buttons & forms
 *  10. Booking plugin (.pb-*) light overrides
 *  11. Footer
 *  12. Accessibility helpers
 *  13. Responsive
 */

/* ------------------------------------------------------------------ *
 * 1. Design tokens
 * ------------------------------------------------------------------ */
:root {
    --pt-color-bg: #fbf9f5;
    --pt-color-surface: #ffffff;
    --pt-color-text: #2f342f;
    --pt-color-muted: #6b706a;
    --pt-color-primary: #5a7d5a;
    --pt-color-primary-dark: #46633f;
    --pt-color-accent: #c98b5e;
    --pt-color-border: #e7e2d8;

    --pt-font-heading: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
    --pt-font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

    --pt-maxwidth: 1100px;
    --pt-bar-height: 64px;
    /* Height of the WordPress admin bar; 0 unless it is present (see body.admin-bar). */
    --pt-admin-offset: 0px;
    --pt-gap: 1.5rem;
    --pt-radius: 14px;
    --pt-shadow: 0 8px 30px rgba(47, 52, 47, 0.12);
    --pt-transition: 160ms ease;
    --pt-z-bg: 0;
    --pt-z-content: 1;
    --pt-z-bar: 100;
    --pt-z-modal: 1000;
}

/* ------------------------------------------------------------------ *
 * 2. Base / reset
 * ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html {
    font-size: 100%;
    scroll-behavior: smooth;
    /* Anchor targets clear the fixed bar (and admin bar) when jumped to directly. */
    scroll-padding-top: calc(var(--pt-bar-height) + var(--pt-admin-offset) + 8px);
}

body {
    margin: 0;
    background: var(--pt-color-text); /* base behind the fixed image */
    color: var(--pt-color-text);
    font-family: var(--pt-font-body);
    font-size: 1.0625rem;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

body.pb-modal-open {
    overflow: hidden; /* scroll lock while modal is open */
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--pt-font-heading);
    line-height: 1.2;
    margin: 0 0 0.6em;
}

h1 { font-size: clamp(2rem, 4vw, 2.75rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.1rem); }
h3 { font-size: 1.35rem; }

p { margin: 0 0 1.2em; }

a {
    color: var(--pt-color-primary-dark);
    text-underline-offset: 2px;
    transition: color var(--pt-transition);
}
a:hover, a:focus { color: var(--pt-color-accent); }

img { max-width: 100%; height: auto; display: block; }

.site-content { position: relative; z-index: var(--pt-z-content); }

/* ------------------------------------------------------------------ *
 * 3. Fixed background layers
 * ------------------------------------------------------------------ */
.site-bg {
    position: fixed;
    inset: 0;
    z-index: var(--pt-z-bg);
    pointer-events: none;
}

.site-bg-image {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    /* Fixed effect: image stays put while content scrolls. */
    background-attachment: fixed;
}

.site-bg-overlay {
    position: absolute;
    inset: 0;
    background: #1c211c; /* dark tint; opacity set inline from Customizer */
}

/* ------------------------------------------------------------------ *
 * 4. Fixed top bar
 * ------------------------------------------------------------------ */
.site-topbar {
    position: fixed;
    top: var(--pt-admin-offset); /* sit below the WP admin bar when present */
    left: 0;
    right: 0;
    height: var(--pt-bar-height);
    z-index: var(--pt-z-bar);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(140%) blur(8px);
    border-bottom: 1px solid var(--pt-color-border);
}

/* When logged in, WordPress adds body.admin-bar and a fixed 32px bar (46px on
   narrow screens). Push our fixed top bar down so it isn't overlapped. */
body.admin-bar {
    --pt-admin-offset: 32px;
}
@media screen and (max-width: 782px) {
    body.admin-bar {
        --pt-admin-offset: 46px;
    }
}

.topbar-inner {
    max-width: var(--pt-maxwidth);
    height: 100%;
    margin-inline: auto;
    padding-inline: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--pt-gap);
}

.site-title {
    font-family: var(--pt-font-heading);
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--pt-color-primary-dark);
    text-decoration: none;
}
.custom-logo { max-height: 44px; width: auto; }

.topbar-nav { display: flex; align-items: center; }

.topbar-menu {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin: 0;
    padding: 0;
}

.topbar-link {
    font-family: var(--pt-font-body);
    font-weight: 500;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--pt-color-text);
    background: none;
    border: 0;
    margin: 0;
    padding: 0.35rem 0;
    cursor: pointer;
    text-decoration: none;
    vertical-align: middle;
    border-bottom: 2px solid transparent;
    transition: color var(--pt-transition), border-color var(--pt-transition);
}

/* Normalize the <button> variant ("Boka Tid") so it aligns like the <a> links. */
button.topbar-link {
    font: inherit;
    font-weight: 500;
    -webkit-appearance: none;
    appearance: none;
}

/* "Boka Tid" — primary action: a subtle pill that stands out but stays inline. */
.topbar-link.pb-open-booking {
    color: #fff;
    background: var(--pt-color-primary);
    font-weight: 600;
    padding: 0.4rem 1.1rem;
    border-radius: 999px;
    border-bottom: 2px solid transparent; /* keep box height identical to links */
}
.topbar-link.pb-open-booking:hover,
.topbar-link.pb-open-booking:focus {
    color: #fff;
    background: var(--pt-color-primary-dark);
    border-bottom-color: transparent;
}
.topbar-link:hover,
.topbar-link:focus {
    color: var(--pt-color-primary-dark);
    border-bottom-color: var(--pt-color-accent);
}



/* Language dropdown */
.topbar-lang { position: relative; }

.lang-switcher { position: relative; }

.lang-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: none;
    border: 1px solid var(--pt-color-border);
    border-radius: 999px;
    padding: 0.3rem 0.75rem;
    font: inherit;
    color: var(--pt-color-text);
    cursor: pointer;
}
.lang-caret { font-size: 0.7em; }

.lang-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 160px;
    list-style: none;
    margin: 0;
    padding: 0.4rem;
    background: var(--pt-color-surface);
    border: 1px solid var(--pt-color-border);
    border-radius: var(--pt-radius);
    box-shadow: var(--pt-shadow);
    display: none;
}
.lang-switcher.open .lang-menu { display: block; }

.lang-option {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--pt-color-text);
}
.lang-option:hover { background: var(--pt-color-hero, #eef2e9); }
.lang-option.is-current { font-weight: 600; color: var(--pt-color-primary-dark); }

/* Mobile menu toggle (hidden on desktop) */
.menu-toggle {
    display: none;
    background: none;
    border: 0;
    padding: 0.6rem;
    cursor: pointer;
}
.menu-toggle-bar,
.menu-toggle-bar::before,
.menu-toggle-bar::after {
    display: block;
    width: 26px;
    height: 2px;
    background: var(--pt-color-text);
    position: relative;
    transition: transform var(--pt-transition), opacity var(--pt-transition);
}
.menu-toggle-bar::before,
.menu-toggle-bar::after { content: ""; position: absolute; left: 0; }
.menu-toggle-bar::before { top: -8px; }
.menu-toggle-bar::after { top: 8px; }
.menu-toggle[aria-expanded="true"] .menu-toggle-bar { background: transparent; }
.menu-toggle[aria-expanded="true"] .menu-toggle-bar::before { transform: translateY(8px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-toggle-bar::after { transform: translateY(-8px) rotate(-45deg); }

/* ------------------------------------------------------------------ *
 * 5. Sections
 * ------------------------------------------------------------------ */
.single-page { padding-top: calc(var(--pt-bar-height) + var(--pt-admin-offset)); }

.section {
    padding-block: clamp(3rem, 7vw, 5.5rem);
}

.section-inner {
    max-width: var(--pt-maxwidth);
    margin-inline: auto;
    padding-inline: 1.25rem;
    background: rgba(251, 249, 245, 0.94);
    border-radius: var(--pt-radius);
    box-shadow: var(--pt-shadow);
    padding-block: clamp(2rem, 4vw, 3rem);
    padding-left: clamp(1.25rem, 4vw, 3rem);
    padding-right: clamp(1.25rem, 4vw, 3rem);
    margin-block: 1.5rem;
}

.section-header { text-align: center; margin-bottom: 2rem; }
.section-subtitle { color: var(--pt-color-muted); margin-top: -0.4em; }
.section-content { max-width: 70ch; margin-inline: auto; }

/* ------------------------------------------------------------------ *
 * 6. Hero
 * ------------------------------------------------------------------ */
.section-hero {
    min-height: calc(100vh - var(--pt-bar-height) - var(--pt-admin-offset));
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding-block: 2rem;
}
.section-hero .hero-inner {
    background: rgba(251, 249, 245, 0.90);
    border-radius: var(--pt-radius);
    box-shadow: var(--pt-shadow);
    padding: clamp(2rem, 5vw, 3.5rem);
    max-width: 760px;
    margin-inline: auto;
}
.hero-title { max-width: 18ch; margin-inline: auto; }
.hero-lead {
    max-width: 52ch;
    margin: 0 auto 1.8rem;
    color: var(--pt-color-muted);
    font-size: 1.15rem;
}

/* ------------------------------------------------------------------ *
 * 7. Posts grid / infinite scroll
 * ------------------------------------------------------------------ */
.posts-grid {
    display: grid;
    gap: 1.75rem;
    grid-template-columns: 1fr;
}

.post-card {
    background: var(--pt-color-surface);
    border: 1px solid var(--pt-color-border);
    border-radius: var(--pt-radius);
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(47, 52, 47, 0.06);
    display: flex;
    flex-direction: column;
}
.post-card-thumb img { width: 100%; object-fit: cover; aspect-ratio: 16 / 9; }
.post-card-body { padding: 1.25rem 1.4rem 1.5rem; }
.post-card-title { margin: 0 0 0.4rem; font-size: 1.2rem; }
.post-card-title a { color: inherit; text-decoration: none; }
.post-card-meta { color: var(--pt-color-muted); font-size: 0.85rem; margin-bottom: 0.6rem; }
.post-card-excerpt { color: var(--pt-color-text); }
.read-more { font-weight: 600; text-decoration: none; }

.posts-sentinel { height: 1px; }
.posts-loading,
.posts-end {
    text-align: center;
    color: var(--pt-color-muted);
    margin-top: 1.5rem;
}

/* ------------------------------------------------------------------ *
 * 8. Booking modal
 * ------------------------------------------------------------------ */
.pb-modal {
    position: fixed;
    inset: 0;
    z-index: var(--pt-z-modal);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: clamp(1rem, 4vw, 3rem) 1rem;
    overflow-y: auto;
}
.pb-modal[hidden] { display: none; }

.pb-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(28, 33, 28, 0.6);
    backdrop-filter: blur(2px);
}

.pb-modal-dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 720px;
    background: var(--pt-color-surface);
    border-radius: var(--pt-radius);
    box-shadow: var(--pt-shadow);
    padding: clamp(1.5rem, 4vw, 2.5rem);
    margin: auto;
}

.pb-modal-close {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    background: none;
    border: 0;
    font-size: 2rem;
    line-height: 1;
    color: var(--pt-color-muted);
    cursor: pointer;
}
.pb-modal-close:hover { color: var(--pt-color-text); }

.pb-modal-title { margin: 0 0 1.25rem; }

/* ------------------------------------------------------------------ *
 * 9. Buttons & forms
 * ------------------------------------------------------------------ */
.button,
button[type="submit"],
input[type="submit"] {
    display: inline-block;
    background: var(--pt-color-primary);
    color: #fff;
    font-family: var(--pt-font-heading);
    font-weight: 600;
    font-size: 1rem;
    padding: 0.7rem 1.6rem;
    border: 2px solid var(--pt-color-primary);
    border-radius: 999px;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--pt-transition), border-color var(--pt-transition), transform var(--pt-transition);
}
.button:hover,
button[type="submit"]:hover,
input[type="submit"]:hover {
    background: var(--pt-color-primary-dark);
    border-color: var(--pt-color-primary-dark);
    color: #fff;
    transform: translateY(-1px);
}
.button-primary { background: var(--pt-color-accent); border-color: var(--pt-color-accent); }
.button-primary:hover { background: #b5794c; border-color: #b5794c; }

/* ------------------------------------------------------------------ *
 * 10. Booking plugin (.pb-*) light overrides
 * ------------------------------------------------------------------ */
.pb-btn-primary,
.pb-book-service-btn {
    background: var(--pt-color-primary);
    border-color: var(--pt-color-primary);
}
.pb-btn-primary:hover,
.pb-book-service-btn:hover {
    background: var(--pt-color-primary-dark);
    border-color: var(--pt-color-primary-dark);
}
.pb-service-card { border-radius: var(--pt-radius); }

/* ------------------------------------------------------------------ *
 * 11. Footer
 * ------------------------------------------------------------------ */
.site-footer {
    position: relative;
    z-index: var(--pt-z-content);
    background: rgba(28, 33, 28, 0.92);
    color: rgba(255, 255, 255, 0.85);
    margin-top: 2rem;
}
.footer-inner {
    max-width: var(--pt-maxwidth);
    margin-inline: auto;
    padding: 1.5rem 1.25rem 2rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.footer-menu { list-style: none; display: flex; gap: 1.2rem; margin: 0; padding: 0; }
.footer-menu a, .site-info { color: rgba(255, 255, 255, 0.8); }
.footer-menu a { text-decoration: none; }
.footer-menu a:hover { color: #fff; }
.site-info { margin: 0; font-size: 0.9rem; }
.footer-widgets {
    max-width: var(--pt-maxwidth);
    margin-inline: auto;
    padding: 2.5rem 1.25rem 1rem;
    display: grid;
    gap: 2rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.footer-widgets .widget-title { color: #fff; }

/* ------------------------------------------------------------------ *
 * 12. Accessibility helpers
 * ------------------------------------------------------------------ */
.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px; width: 1px; margin: -1px;
    overflow: hidden; padding: 0;
    position: absolute !important;
    word-wrap: normal !important;
}
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--pt-color-surface);
    color: var(--pt-color-primary-dark);
    padding: 0.75rem 1.25rem;
    z-index: calc(var(--pt-z-modal) + 1);
    border-radius: 0 0 var(--pt-radius) 0;
}
.skip-link:focus { left: 0; }
:focus-visible { outline: 3px solid var(--pt-color-accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ *
 * 13. Responsive
 * ------------------------------------------------------------------ */
@media (min-width: 700px) {
    .posts-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1000px) {
    .posts-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 860px) {
    .menu-toggle { display: block; order: 2; }

    .topbar-menu {
        display: none;
        position: absolute;
        top: var(--pt-bar-height);
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        background: var(--pt-color-surface);
        border-bottom: 1px solid var(--pt-color-border);
        padding: 0.5rem 1.25rem 1rem;
        box-shadow: var(--pt-shadow);
    }
    .topbar-nav.toggled .topbar-menu { display: flex; }

    .topbar-menu > li { width: 100%; }
    .topbar-link {
        display: block;
        width: 100%;
        padding: 0.85rem 0;
        border-bottom: 1px solid var(--pt-color-border);
    }
    .topbar-lang { padding: 0.75rem 0; }
    .lang-menu { position: static; box-shadow: none; border: 0; padding-left: 0; }

    .footer-inner { flex-direction: column; align-items: flex-start; }
}

/* ------------------------------------------------------------------ *
 * 12. Theme services (Tjänster) — grouped by category + detail popup
 * ------------------------------------------------------------------ */

.pt-services {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.pt-service-group-title {
    font-family: var(--pt-font-heading);
    font-size: 1.3rem;
    margin: 0 0 1rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid rgba(0, 0, 0, 0.08);
    text-align: center;
}

.pt-service-group--uncategorized .pt-service-group-title {
    display: none;
}

.pt-services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

/* Clickable service card (a <button>) */
.pt-service-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    text-align: left;
    width: 100%;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--pt-radius);
    padding: 1.1rem 1.25rem;
    cursor: pointer;
    font-family: inherit;
    color: var(--pt-color-text);
    transition: transform var(--pt-transition), box-shadow var(--pt-transition), border-color var(--pt-transition);
}
.pt-service-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
    border-color: var(--pt-color-primary);
}
.pt-service-card:focus-visible {
    outline: 2px solid var(--pt-color-primary);
    outline-offset: 2px;
}

.pt-service-card-name {
    font-family: var(--pt-font-heading);
    font-weight: 600;
    font-size: 1.08rem;
}
.pt-service-card-meta {
    color: var(--pt-color-muted);
    font-size: 0.9rem;
}
.pt-service-card-more {
    margin-top: 0.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--pt-color-primary);
}

/* Service-detail popup (reuses .pb-modal base; see section 8) */
.pt-service-modal-meta {
    color: var(--pt-color-muted);
    margin: -0.5rem 0 1rem;
    font-size: 0.95rem;
}
.pt-service-modal-meta[hidden] { display: none; }

.pt-service-modal-desc {
    margin-bottom: 1.5rem;
}

.pt-service-modal-actions {
    margin: 0;
}
