/**
 * Core Styles
 *
 * Base resets, container system, header chrome,
 * site branding, content area, entry defaults,
 * and shared utility styles.
 *
 * @package Mestariteema
 */

/* =WordPress Core
-------------------------------------------------------------- */
body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: var(--fontsize-p, 16px);
    line-height: var(--lineheight-p, 1.6);
    color: var(--scheme-1-text);
}

/* Page wrapper - full width */
.site {
    width: 100%;
    margin: 0;
    padding: 0;
}

/* =Bootstrap-style Container System
-------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 20px;
    padding-right: 20px;
    box-sizing: border-box;
}

.container-fluid {
    width: 100%;
    padding-left: 20px;
    padding-right: 20px;
}

.container-narrow {
    width: 100%;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 20px;
    padding-right: 20px;
}

.container-wide {
    width: 100%;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 20px;
    padding-right: 20px;
}

/* Row and Column basics */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-left: -15px;
    margin-right: -15px;
}

.col {
    flex: 1;
    padding-left: 15px;
    padding-right: 15px;
}

/* Responsive containers */
@media (max-width: 1200px) {
    .container {
        max-width: 960px;
    }
    .container-wide {
        max-width: 1140px;
    }
}

@media (max-width: 992px) {
    .container {
        max-width: 720px;
    }
    .container-wide {
        max-width: 960px;
    }
}

@media (max-width: 768px) {
    .container,
    .container-narrow,
    .container-wide {
        max-width: 100%;
        padding-left: 15px;
        padding-right: 15px;
        width: 100%;
        box-sizing: border-box;
    }
}

/* ============================================
   Header Positioning
   ============================================
   Priority rules:
   - Default:      position: relative (normal document flow)
   - Sticky only:  position: sticky; top: 0
   - Transparent:  position: absolute; overlaps content
   - Both:         starts absolute, transitions to sticky on scroll
   ============================================ */
.site-header {
    position: relative;
    top: 0;
    width: 100%;
    padding: 20px 0;
    border-bottom: none;
    z-index: 1000;
    transition: background-color 0.3s ease;
}

/* Dynamic offsets for overlay/sticky header behavior */
:root {
    --mestari-topbar-height: 0px;
    --mestari-adminbar-offset: 0px;
    --mestari-header-height: 0px;
}

.admin-bar {
    --mestari-adminbar-offset: 32px;
}

@media screen and (max-width: 782px) {
    .admin-bar {
        --mestari-adminbar-offset: 46px;
    }
}

/* Sticky header — enabled via body.header-sticky */
.header-sticky .site-header {
    position: sticky;
    top: var(--mestari-adminbar-offset);
}

/* Transparent header — enabled via body.header-overlay-active */
.header-overlay-active .site-header {
    position: sticky;
    width: 100%;
    top: 0;
}

/* Sticky + Transparent combo */
.header-overlay-active.header-sticky .site-header.header-scrolled {
    position: sticky;
    top: 0;
}

/* Header solid background when scrolled */
.site-header.header-scrolled {
    background-color: var(--scheme-2-bg);
}

/* Content — no padding adjustments needed with sticky */
.site-content {
    padding-top: 0;
}



/* In overlay mode, pull content under the header */
.header-overlay-active .site-content {
    margin-top: calc(var(--mestari-header-height, 0px) * -1) !important;
}

/* Header Inner Container */
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    /* Layout is defined per header-style variant in css/header-styles.css */
}

/* Full Width Header */
.header-full-width {
    background-color: var(--scheme-2-bg);
}

.header-full-width .header-inner {
    max-width: 100%;
}

/* No Header Layout */
.no-header .site-content {
    padding-top: 0;
}

/* Site Branding */
.site-branding {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.site-branding .custom-logo-link {
    display: flex;
    align-items: center;
    line-height: 0;
}

.site-branding .custom-logo-link img {
    display: block;
}

.site-title {
    margin: 0;
    font-size: 1.5em;
    font-weight: 700;
    letter-spacing: 1px;
}

.site-title a {
    color: var(--scheme-1-bg);
    text-decoration: none;
    text-transform: uppercase;
}

.site-title a:hover {
    color: var(--scheme-1-accent);
}

.site-description {
    display: none;
}

/* Header Social Icons */
.header-social {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 15px;
}

.header-social .social-icon {
    color: var(--scheme-1-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.header-social .social-icon:hover {
    color: var(--scheme-1-accent);
}

.header-social svg {
    width: 20px;
    height: 20px;
}

/* Header search */
.header-search {
    position: relative;
    display: flex;
    align-items: center;
}

.header-search-toggle {
    background: none;
    border: none;
    color: var(--scheme-1-bg);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    transition: color 0.2s ease;
}

.header-search-toggle:hover,
.header-search-toggle:focus-visible {
    color: var(--scheme-1-accent);
    outline: none;
}

.header-search-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: var(--scheme-2-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px;
    min-width: 240px;
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1002;
}

.header-search-panel.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.header-search-form {
    display: flex;
    gap: 8px;
}

.header-search-input {
    flex: 1;
    padding: 8px 10px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.08);
    color: var(--scheme-1-bg);
}

.header-search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.header-search-submit {
    background: var(--scheme-1-accent);
    border: none;
    color: var(--scheme-2-bg);
    padding: 8px 12px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
}

/* Language switcher */
.header-language-switcher {
    display: flex;
    align-items: center;
    color: var(--scheme-1-bg);
}

.header-language-switcher a {
    color: var(--scheme-1-bg);
    text-decoration: none;
    margin: 0 6px;
}

.header-language-switcher a:hover {
    color: var(--scheme-1-accent);
}

/* Hello bar - always static, outside header, never sticky */
.hello-bar {
    background: var(--scheme-2-bg);
    color: var(--scheme-1-bg);
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: static;
    z-index: 1001;
    width: 100%;
}

/* Overlay offset is dynamic (set from JS) to match top bar height.
   Avoid hardcoded values because top bar size is customizable. */

.hello-bar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.hello-bar-content {
    font-size: 0.9em;
}

.hello-bar-extras {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hello-bar-cta {
    padding: 8px 20px;
    font-size: 0.85em;
}

@media screen and (max-width: 768px) {
    .hello-bar-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* Header Extras (Social + CTA) */
.header-extras {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 20px;
    grid-column: 3;
}

/* Header CTA Button — uses dedicated CTA variables */
.header-cta {
    display: inline-block;
    padding: var(--header-cta-padding, 12px 32px);
    background: var(--header-cta-bg);
    color: var(--header-cta-color);
    text-decoration: none;
    font-weight: var(--header-cta-font-weight, 600);
    font-size: var(--header-cta-font-size, 14px);
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    border-width: var(--header-cta-border-width, 0);
    border-style: solid;
    border-color: var(--header-cta-border-color);
    border-radius: var(--header-cta-border-radius, 4px);
    white-space: nowrap;
}

.header-cta:hover {
    background: var(--header-cta-hover-bg);
    border-color: var(--header-cta-hover-bg);
    color: var(--header-cta-hover-color);
}

/* ============================================
   Content Area
   ============================================ */
.site-content {
    padding: 0;
    margin: 0;
    min-height: 0;
}

.content-area {
    width: 100%;
}

.site-main {
    width: 100%;
}

/* Full Width Page Template */
.page-full-width {
    padding: 0;
}

.page-full-width .site-main {
    padding: 0;
}

.page-full-width .entry-content {
    padding: 0;
}

.page-full-width .entry-content > *:first-child {
    margin-top: 0;
}

.page-full-width .entry-content > *:last-child {
    margin-bottom: 0;
}

/* Full-width aligned blocks */
.alignfull {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.page-full-width .alignfull {
    margin-top: 0;
    margin-bottom: 0;
}

.page-full-width .wp-block-group.alignfull,
.page-full-width .hero-block,
.page-full-width .split-content-block {
    margin-top: 0;
    margin-bottom: 0;
}

.page-full-width article {
    margin-bottom: 0;
}

article {
    margin-bottom: 40px;
}

/* Ensure no whitespace in content area */
.site-content:empty {
    display: none;
}

.site-main > *:last-child {
    margin-bottom: 0;
}

/* ============================================
   Entry Styles (single/page scope)
   ============================================ */
.single .entry-header,
.page .entry-header {
    margin-bottom: 30px;
}

.single .entry-title,
.page .entry-title {
    margin: 0 0 20px;
    font-size: var(--fontsize-h1, 42px);
    line-height: var(--lineheight-h1, 1.2);
    font-weight: var(--fontweight-h1, 700);
}

.single .entry-title a,
.page .entry-title a {
    color: var(--scheme-1-text);
    text-decoration: none;
}

.single .entry-title a:hover,
.page .entry-title a:hover {
    color: var(--scheme-1-accent);
}

.single .entry-meta,
.page .entry-meta {
    color: var(--scheme-1-text);
    font-size: 0.9em;
    margin-bottom: 20px;
}

.single .entry-footer,
.page .entry-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--scheme-1-border, #eee);
}

.single .edit-link a,
.page .edit-link a {
    color: var(--scheme-1-text);
    text-decoration: none;
    font-size: 0.9em;
}

.single .edit-link a:hover,
.page .edit-link a:hover {
    color: var(--scheme-1-accent);
}

.single .post-thumbnail img,
.page .post-thumbnail img {
    display: block;
    width: 100%;
    height: auto;
}

/* Page Links (pagination for multi-page content) */
.page-links {
    clear: both;
    margin: 20px 0;
    font-weight: 600;
}

.page-links a,
.page-links > span {
    display: inline-block;
    margin: 0 5px;
    padding: 5px 10px;
    border: 1px solid #eee;
    text-decoration: none;
}

.page-links a:hover {
    background: var(--scheme-1-accent);
    color: var(--scheme-1-accent-text, #fff);
    border-color: var(--scheme-1-accent);
}

/* Category and Tag Links */
.cat-links,
.tags-links {
    display: inline-block;
    margin-right: 15px;
    font-size: 0.9em;
}

.cat-links a,
.tags-links a {
    color: var(--scheme-1-text);
    text-decoration: none;
    padding: 2px 8px;
    background: var(--scheme-1-bg);
    border-radius: 3px;
    display: inline-block;
    margin: 2px;
    transition: background 0.3s ease;
}

.cat-links a:hover,
.tags-links a:hover {
    background: var(--scheme-1-bg);
    color: var(--scheme-1-text);
}

/* ============================================
   Search Form
   ============================================ */
.mestari-search-form {
    display: flex;
    align-items: stretch;
    width: 100%;
}

.mestari-search-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-right: none;
    border-radius: 6px 0 0 6px;
    font-family: inherit;
    font-size: 0.95em;
    color: var(--scheme-1-text);
    background: var(--scheme-1-bg);
    transition: border-color 0.2s ease;
    box-sizing: border-box;
    min-width: 0;
}

.mestari-search-input:focus {
    outline: none;
    border-color: var(--scheme-1-accent);
}

.mestari-search-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    background: var(--scheme-1-heading);
    color: var(--scheme-1-bg);
    border: none;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.mestari-search-submit:hover {
    background: var(--scheme-1-accent);
}

/* ============================================
   Responsive — Mobile (content area)
   ============================================ */
@media screen and (max-width: 768px) {
    .site-content {
        padding: 0;
    }
}
