/* ============================================================
   CMS Content Styles
   Typography and layout styles for content rendered from CMS
   ============================================================ */

.cms-content {
    padding: var(--s-7) 0;
}

.cms-content .container {
    max-width: 1200px;
    /* Long unbroken strings (URLs, emails) in CMS copy must wrap, not widen the page */
    overflow-wrap: anywhere;
}

/* CMS embeds carry fixed width attributes; keep them inside the container */
.cms-content iframe,
.cms-content video,
.cms-content embed {
    max-width: 100%;
}

/* Typography for CMS content */
.cms-content h1 {
    font-family: var(--font-display);
    font-size: 40px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin: 0 0 var(--s-4);
    color: var(--sam-dark);
}

.cms-content h2 {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.2;
    margin: var(--s-6) 0 var(--s-3);
    color: var(--sam-dark);
}

.cms-content h3 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.25;
    margin: var(--s-5) 0 var(--s-2);
    color: var(--sam-dark);
}

.cms-content h4 {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    margin: var(--s-4) 0 var(--s-2);
    color: var(--sam-dark);
}

.cms-content p {
    font-size: 16px;
    line-height: 1.7;
    margin: 0 0 var(--s-3);
    color: var(--sam-brown-dark);
}

.cms-content a {
    color: var(--sam-red-ink);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 160ms ease;
}

.cms-content a:hover {
    color: var(--sam-dark);
}

/* Linked headings (post titles, guide header) read as headings, not inline links */
.cms-content :is(h1, h2, h3, h4, h5, h6) a {
    color: inherit;
    text-decoration: none;
}

.cms-content :is(h1, h2, h3, h4, h5, h6) a:hover {
    color: var(--sam-red-ink);
}

/* Editors set an inline font-size (often 12pt) on spans inside headings; the heading size must win.
   On single posts the guide description is parsed into the header's h2; it keeps its own 16px. */
.cms-content :is(h1, h2, h3, h4, h5, h6) [style*="font-size"]:not(.descriptP) {
    font-size: inherit !important;
}

/* Owl Carousel's script is not loaded in the new layout, so its slides would
   stack at full width. Show them as a horizontally scrollable row instead. */
.cms-content .owl-carousel:not(.owl-loaded) {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(220px, calc((100% - 2 * var(--s-4)) / 3));
    gap: var(--s-4);
    padding-bottom: var(--s-2);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
}

.cms-content .owl-carousel:not(.owl-loaded) > * {
    scroll-snap-align: start;
}

/* Lists */
.cms-content ul,
.cms-content ol {
    margin: 0 0 var(--s-4);
    padding-left: var(--s-4);
}

.cms-content li {
    font-size: 16px;
    line-height: 1.7;
    margin-bottom: var(--s-2);
    color: var(--sam-brown-dark);
}

.cms-content ul li::marker {
    color: var(--sam-red-ink);
}

/* Images */
.cms-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin: var(--s-4) 0;
}

/* Images editors place in an article. Their width attribute is kept, so object-fit
   stops a tall image from being squashed once max-height applies. Theme images
   (.postItem-img) are excluded: they size themselves with object-fit: cover. */
.cms-content article img:not(.postItem-img) {
    max-height: 480px;
    object-fit: contain;
}

/* WordPress alignment classes */
.cms-content .aligncenter {
    display: block;
    margin-inline: auto;
}

.cms-content .alignleft {
    float: left;
    margin: var(--s-2) var(--s-4) var(--s-3) 0;
}

.cms-content .alignright {
    float: right;
    margin: var(--s-2) 0 var(--s-3) var(--s-4);
}

/* WordPress writes the caption's width inline, often wider than the text column */
.cms-content .wp-caption {
    max-width: 100%;
}

/* Blockquotes */
.cms-content blockquote {
    margin: var(--s-5) 0;
    padding: var(--s-4) var(--s-5);
    border-left: 4px solid var(--sam-red);
    background: var(--sam-brown-light);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.cms-content blockquote p {
    margin: 0;
    font-style: italic;
    color: var(--sam-brown-dark);
}

/* Tables */
.cms-content table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--s-4) 0;
}

.cms-content th,
.cms-content td {
    padding: var(--s-2) var(--s-3);
    text-align: left;
    border-bottom: 1px solid var(--sam-light);
}

.cms-content th {
    font-weight: 600;
    color: var(--sam-dark);
    background: var(--sam-brown-light);
}

/* Code blocks */
.cms-content code {
    font-family: var(--font-mono);
    font-size: 14px;
    background: var(--sam-brown-light);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.cms-content pre {
    background: var(--sam-dark);
    color: var(--sam-white);
    padding: var(--s-4);
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: var(--s-4) 0;
}

.cms-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* Horizontal rule */
.cms-content hr {
    border: none;
    border-top: 1px solid var(--sam-light);
    margin: var(--s-6) 0;
}

/* First element should have no top margin */
.cms-content > :first-child,
.cms-content .container > :first-child {
    margin-top: 0;
}

/* ============================================================
   CMS Guide Template (Hyresguiden)
   The WordPress guide template ships its own markup for the guide
   header, the category lists and single posts, styled for the old
   site by guide_min.css. Every rule below is scoped to a class of
   that template, so other CMS pages only get the generic styles above.

   Markup:
     .headerGuide, .descriptP, .categories-header   Guide header (category lists + posts)
     .Single-Post-Outer                             Single post: article + sidebar
       .Single-Post-Inner > section#content > article.post
         .singleImg                                 Hero image
         .postItem-contentOuter                     Category, title and body
       .Single-Post-Inner > .owl-carousel           Related posts
       .Single-Post-Sidebar                         Search, table of contents, recent posts, categories

   guide_min.css switches to its mobile layout at 849px (sidebar and
   carousel hidden via .viewDesktop), so the guide breakpoint matches.
   ============================================================ */

/* ---------- Guide header ---------- */

/* The CMS wraps the description in <strong>; it is body copy, not a heading */
.cms-content .descriptP {
    max-width: 68ch;
    margin: 0 auto var(--s-5);
    font-weight: 400;
    letter-spacing: normal;
    text-align: center;
}

.cms-content .categories-header {
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--s-2);
    padding: 0 0 var(--s-6);
}

.cms-content .categories-header br {
    display: none;
}

.cms-content .categories-header a {
    padding: var(--s-2) var(--s-4);
    border-radius: var(--radius-pill);
    background: var(--sam-white);
    color: var(--sam-dark);
    font-weight: 600;
    text-decoration: none;
    transition: background 160ms ease;
}

.cms-content .categories-header a:hover {
    background: var(--sam-brown-light);
    color: var(--sam-dark);
}

/* ---------- Post list ---------- */

/* The whole card is one link, so the generic .cms-content a rule would
   underline and colour the category and title inside it */
.cms-content .post-item > a {
    display: block;
    color: var(--sam-dark);
    text-decoration: none;
}

.cms-content .post-item > a:hover .postItem-title {
    color: var(--sam-red-ink);
}

.cms-content .post-item .postItem-category {
    margin: var(--s-2) 0;
    font-size: var(--text-sm);
}

/* ---------- Single post layout ---------- */

.cms-content .Single-Post-Outer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: var(--s-6);
    align-items: start;
}

/* .clearfix pseudo-elements would become empty grid cells */
.cms-content .Single-Post-Outer::before,
.cms-content .Single-Post-Outer::after {
    content: none;
}

.cms-content .Single-Post-Inner,
.cms-content .Single-Post-Sidebar {
    width: auto;
    float: none;
    padding: 0;
}

/* ---------- Article ---------- */

.cms-content .Single-Post-Inner article.post {
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-1);
}

/* Hero images are uploaded in any shape; crop them all to the same frame.
   The generic img rule's height: auto would otherwise show a portrait image in full. */
.cms-content .Single-Post-Inner .singleImg {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 480px;
    margin: 0;
    border-radius: 0;
    object-fit: cover;
}

/* Related posts inside the article, only shown below the guide breakpoint */
.cms-content .post-item .singleImg {
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.cms-content .postItem-contentOuter {
    padding: var(--s-6) var(--s-7);
}

.cms-content .postItem-contentOuter p {
    text-align: left;
}

/* Category label, styled like .section-overline */
.cms-content .postItem-contentOuter .postItem-category {
    margin: 0 0 var(--s-2);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--sam-red-ink);
}

.cms-content .Single-Post-Inner :is(h1, h4).postItem-title {
    margin: 0 0 var(--s-5);
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
    text-align: left;
}

/* Editors use h5 for section headings */
.cms-content .postItem-contentOuter h5 {
    margin: var(--s-6) 0 var(--s-3);
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.25;
    color: var(--sam-dark);
}

/* ---------- Related posts ---------- */

/* The scrollable row itself comes from the Owl Carousel rule above. The id selector
   outweighs guide_min.css' #tenantCarousel { width: 90%; margin: 0 auto }. */
.cms-content #tenantCarousel:not(.owl-loaded) {
    width: auto;
    margin: var(--s-6) 0 0;
}

.cms-content .tenant-carousel-item {
    display: flex;
    flex-direction: column;
    background: var(--sam-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
    overflow: hidden;
    text-align: left;
}

.cms-content .tenant-carousel-item > a {
    display: block;
    color: inherit;
    text-decoration: none;
}

.cms-content .tenant-carousel-img {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    margin: 0;
    border-radius: 0;
}

/* guide_min.css' fixed heights showed a sliver of the line after the clamp */
.cms-content .tenant-carousel-title {
    height: auto;
    margin: var(--s-3) var(--s-4) var(--s-2);
    font-size: 17px;
    line-height: 1.3;
}

.cms-content .tenant-carousel-item .block-ellipsis {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    height: auto;
    padding: 0 var(--s-4);
    font-size: 14px;
    line-height: 1.5;
    color: var(--sam-brown-dark);
}

/* "Read more" row; the CMS centers it inline */
.cms-content .tenant-carousel-item > div {
    margin-top: auto;
    padding: var(--s-3) var(--s-4) var(--s-4);
    text-align: left !important;
}

/* "Läs mer" carries the CMS's .btn, so it already takes the design-system button.
   Make it .btn--secondary.btn--sm, and restore what guide_min.css (blue border,
   square corners) and the generic .cms-content a rule (underline) override. */
.cms-content a.btn-carousel {
    --btn-bg: var(--surface-raised);
    --btn-fg: var(--text-primary);
    --btn-border: var(--border-strong);
    --btn-height: 36px;
    --btn-px: 14px;
    --btn-fs: var(--text-sm);

    padding: 0 var(--btn-px);
    border: 1.5px solid var(--btn-border);
    border-radius: var(--radius-pill);
    color: var(--btn-fg);
    font-size: var(--btn-fs) !important;
    text-decoration: none;
}

.cms-content a.btn-carousel:hover {
    background: var(--surface-warm);
    color: var(--btn-fg);
}

/* ---------- Sidebar ---------- */

.cms-content .Single-Post-Sidebar > div {
    margin: 0 0 var(--s-4);
    padding: var(--s-5);
    background: var(--sam-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
}

.cms-content .recentPosts-div-title {
    margin: 0 0 var(--s-3);
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    color: var(--sam-dark);
}

.cms-content .Single-Post-Sidebar ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.cms-content .Single-Post-Sidebar li {
    margin: 0;
    padding: var(--s-2) 0;
    border-bottom: 1px solid var(--sam-light);
    font-size: 15px;
    line-height: 1.5;
}

.cms-content .Single-Post-Sidebar li:last-child {
    border-bottom: 0;
}

.cms-content .Single-Post-Sidebar a {
    color: var(--sam-dark);
    text-decoration: none;
}

.cms-content .Single-Post-Sidebar a:hover {
    color: var(--sam-red-ink);
}

/* Recent post thumbnail: the CMS wraps it in a 150px grey box */
.cms-content .recent-postItem-title > a > div {
    margin-bottom: var(--s-2);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.cms-content .recent-postItem-title img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    margin: 0;
    border-radius: 0;
}

/* Search */
.cms-content #searchPost-div {
    display: flex;
}

.cms-content #searchPost {
    flex: 1;
    min-width: 0;
    height: 44px;
    padding: 0 var(--s-3);
    border: 1px solid var(--sam-light);
    border-right: 0;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    background: var(--sam-white);
    color: var(--sam-dark);
    font: inherit;
    font-size: 16px;
}

.cms-content #searchPost:focus-visible {
    outline: 2px solid var(--color-action);
    outline-offset: -2px;
}

.cms-content #searchsubmit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    padding: 0;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    background: var(--sam-red-action);
    color: var(--sam-white);
    cursor: pointer;
}

.footer-box img{
    width: 55px !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .cms-content {
        padding: var(--s-5) 0;
    }

    .cms-content h1 {
        font-size: 32px;
    }

    .cms-content h2 {
        font-size: 24px;
    }

    .cms-content h3 {
        font-size: 20px;
    }
}

/* Guide template */
@media (max-width: 849px) {
    .cms-content :is(.alignleft, .alignright) {
        display: block;
        float: none;
        margin-inline: auto;
    }

    .cms-content .Single-Post-Outer {
        grid-template-columns: minmax(0, 1fr);
    }

    .cms-content .postItem-contentOuter {
        padding: var(--s-5) var(--s-4);
    }

    .cms-content .Single-Post-Inner :is(h1, h4).postItem-title {
        font-size: 26px;
    }

    .cms-content .postItem-contentOuter h5 {
        font-size: 20px;
    }
}
