/*
Theme Name: TML
Theme URI: https://tmlstory.com/
Author: TML
Description: Lightweight Gutenberg-first automotive information theme for TML.
Version: 0.6.0
Requires at least: 6.6
Requires PHP: 8.2
Text Domain: tml
*/

/* =========================================================
   TML DESIGN SYSTEM
   ========================================================= */

:root {
    --tml-ink: #172033;
    --tml-text: #344054;
    --tml-muted: #667085;
    --tml-line: #e4e7ec;
    --tml-soft: #f7f8fa;
    --tml-soft-blue: #f2f6ff;

    --tml-blue: #155eef;
    --tml-blue-dark: #1249b8;

    --tml-white: #ffffff;

    --tml-wrap: 1180px;
    --tml-reading: 780px;

    --tml-radius-sm: 8px;
    --tml-radius: 12px;
    --tml-radius-lg: 18px;

    --tml-shadow:
        0 1px 3px rgba(16, 24, 40, 0.06),
        0 1px 2px rgba(16, 24, 40, 0.04);
}

/* =========================================================
   BASE
   ========================================================= */

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

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--tml-ink);
    background: var(--tml-white);
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Noto Sans KR",
        "Apple SD Gothic Neo",
        Arial,
        sans-serif;
    font-size: 16px;
    line-height: 1.7;
    word-break: keep-all;
    overflow-wrap: break-word;
}

img {
    display: block;
    max-width: 100%;
    height: auto;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea,
select {
    font: inherit;
}

.tml-wrap {
    width: min(
        calc(100% - 40px),
        var(--tml-wrap)
    );
    margin-inline: auto;
}

/* =========================================================
   HEADER
   ========================================================= */

.tml-header {
    position: sticky;
    top: 0;
    z-index: 1000;

    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--tml-line);

    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.tml-header__inner {
    min-height: 68px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 28px;
}

.tml-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;

    flex-shrink: 0;
}

.tml-brand__name {
    color: var(--tml-ink);

    font-size: 1.3rem;
    font-weight: 850;
    line-height: 1;
    letter-spacing: -0.045em;
}

.tml-brand__dot {
    width: 7px;
    height: 7px;

    display: inline-block;

    border-radius: 50%;
    background: var(--tml-blue);
}

/* Desktop nav */

.tml-nav {
    margin-left: auto;
}

.tml-nav__list {
    display: flex;
    align-items: center;

    gap: 25px;

    margin: 0;
    padding: 0;

    list-style: none;
}

.tml-nav__list a {
    display: block;

    color: #344054;

    font-size: 0.93rem;
    font-weight: 650;
    line-height: 1.4;

    transition:
        color 0.16s ease,
        transform 0.16s ease;
}

.tml-nav__list a:hover,
.tml-nav__list a:focus-visible {
    color: var(--tml-blue);
}

/* =========================================================
   MOBILE MENU
   ========================================================= */

.tml-menu {
    display: none;
    position: relative;
}

.tml-menu summary {
    min-width: 44px;
    min-height: 44px;

    display: grid;
    place-items: center;

    padding: 0;

    cursor: pointer;

    border: 1px solid var(--tml-line);
    border-radius: 9px;

    background: var(--tml-white);

    color: var(--tml-ink);
    font-size: 0;

    list-style: none;
}

.tml-menu summary::-webkit-details-marker {
    display: none;
}

.tml-menu summary::before {
    content: "☰";

    font-size: 20px;
    line-height: 1;
}

.tml-menu[open] summary::before {
    content: "×";

    font-size: 26px;
}

.tml-menu__panel {
    position: absolute;
    top: calc(100% + 9px);
    right: 0;

    width: min(300px, calc(100vw - 28px));

    padding: 8px;

    border: 1px solid var(--tml-line);
    border-radius: 12px;

    background: var(--tml-white);
    box-shadow:
        0 14px 34px rgba(16, 24, 40, 0.12);
}

.tml-menu__panel a {
    display: block;

    padding: 11px 12px;

    border-radius: 8px;

    color: var(--tml-text);

    font-size: 0.95rem;
    font-weight: 650;
}

.tml-menu__panel a + a {
    margin-top: 2px;
}

.tml-menu__panel a:hover,
.tml-menu__panel a:focus-visible {
    color: var(--tml-blue);
    background: var(--tml-soft-blue);
}

/* =========================================================
   GENERIC CONTENT
   ========================================================= */

.tml-main {
    min-height: 60vh;
    padding: 48px 0 72px;
}

.tml-post-list {
    display: grid;
    gap: 20px;
}

.tml-post-card {
    padding: 24px;

    border: 1px solid var(--tml-line);
    border-radius: var(--tml-radius);

    background: var(--tml-white);
}

.tml-post-card h2 {
    margin: 0 0 8px;

    font-size: clamp(1.2rem, 2vw, 1.45rem);
    line-height: 1.4;
    letter-spacing: -0.03em;
}

.tml-post-card time {
    color: var(--tml-muted);
    font-size: 0.875rem;
}

/* =========================================================
   FOOTER
   ========================================================= */

.tml-footer {
    border-top: 1px solid var(--tml-line);
    background: var(--tml-soft);
}

.tml-footer__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;

    padding: 34px 0;

    color: var(--tml-muted);
    font-size: 0.88rem;
}

.tml-footer__brand strong {
    display: block;

    margin-bottom: 3px;

    color: var(--tml-ink);
    font-size: 0.95rem;
}

.tml-footer__copy {
    text-align: right;
}

/* =========================================================
   ACCESSIBILITY
   ========================================================= */

a:focus-visible,
summary:focus-visible {
    outline: 3px solid rgba(21, 94, 239, 0.25);
    outline-offset: 3px;
}

/* =========================================================
   WORDPRESS ADMIN BAR
   ========================================================= */

body.admin-bar .tml-header {
    top: 32px;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 960px) {
    .tml-nav__list {
        gap: 18px;
    }

    .tml-nav__list a {
        font-size: 0.88rem;
    }
}

@media (max-width: 820px) {
    .tml-nav {
        display: none;
    }

    .tml-menu {
        display: block;
    }
}

@media (max-width: 760px) {
    .tml-wrap {
        width: min(
            calc(100% - 28px),
            var(--tml-wrap)
        );
    }

    .tml-header__inner {
        min-height: 60px;
    }

    .tml-brand__name {
        font-size: 1.18rem;
    }

    .tml-main {
        padding-top: 32px;
        padding-bottom: 52px;
    }

    .tml-post-card {
        padding: 20px;
    }

    .tml-footer__inner {
        display: block;
    }

    .tml-footer__copy {
        margin-top: 14px;
        text-align: left;
    }
}

@media (max-width: 782px) {
    body.admin-bar .tml-header {
        top: 46px;
    }
}

/* =========================================================
   TML V0.5 HEADER REFINEMENT
   ========================================================= */

/*
 * Desktop keeps the convenient sticky navigation.
 * Mobile releases the header to maximize reading space.
 */
@media (max-width: 820px) {

    .tml-header,
    body.admin-bar .tml-header {
        position: static;
        top: auto;
    }
}

/* === /TML V0.5 HEADER REFINEMENT === */


/* ==========================================================
   TML STANDARD CTA — DIRECT PORT FROM TMS
   Core Button style: TML 링크 버튼
   Lightweight internal-link card
   ========================================================== */

.wp-block-button.is-style-tml-cta {
    width: 100%;
    margin: 1.6rem 0;
}

.wp-block-button.is-style-tml-cta .wp-block-button__link,
.wp-block-button.is-style-tml-cta .wp-element-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    width: 100%;
    min-height: 58px;

    padding: 15px 18px;

    box-sizing: border-box;

    border: 1px solid #dfe3e8;
    border-radius: 14px;

    background: #f8f9fa;
    color: #20242a !important;

    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);

    font-size: 1rem;
    font-weight: 650;
    line-height: 1.45;
    text-align: left;
    text-decoration: none !important;

    transition:
        background-color .18s ease,
        border-color .18s ease,
        box-shadow .18s ease,
        transform .18s ease;
}

.wp-block-button.is-style-tml-cta .wp-block-button__link::after,
.wp-block-button.is-style-tml-cta .wp-element-button::after {
    content: "→";

    flex: 0 0 auto;

    color: #6b7280;

    font-size: 1.2em;
    font-weight: 500;
    line-height: 1;
}

.wp-block-button.is-style-tml-cta .wp-block-button__link:visited,
.wp-block-button.is-style-tml-cta .wp-element-button:visited {
    color: #20242a !important;
}

.wp-block-button.is-style-tml-cta .wp-block-button__link:hover,
.wp-block-button.is-style-tml-cta .wp-block-button__link:focus,
.wp-block-button.is-style-tml-cta .wp-element-button:hover,
.wp-block-button.is-style-tml-cta .wp-element-button:focus {
    background: #f2f4f6;
    border-color: #c8ced6;

    color: #111827 !important;

    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);

    text-decoration: none !important;

    transform: translateY(-1px);
}

@media (max-width: 768px) {

    .wp-block-button.is-style-tml-cta {
        margin: 1.35rem 0;
    }

    .wp-block-button.is-style-tml-cta .wp-block-button__link,
    .wp-block-button.is-style-tml-cta .wp-element-button {
        min-height: 54px;

        padding: 14px 15px;

        border-radius: 12px;

        font-size: .97rem;
    }
}


/* ==========================================================
   TML CTA V2 - ACCENT CARD
   ========================================================== */

.wp-block-button.is-style-tml-cta .wp-block-button__link,
.wp-block-button.is-style-tml-cta .wp-element-button {
    min-height: 62px;

    padding: 16px 18px 16px 20px;

    border: 1px solid #bfd4f7;
    border-radius: 14px;

    background: #f3f7fd;
    color: #14233b !important;

    box-shadow: 0 2px 6px rgba(24, 78, 160, 0.06);

    font-weight: 700;
}

.wp-block-button.is-style-tml-cta .wp-block-button__link::after,
.wp-block-button.is-style-tml-cta .wp-element-button::after {
    content: "→";

    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 32px;
    height: 32px;

    border-radius: 50%;

    background: #e1ecff;
    color: #1769d2;

    font-size: 18px;
    font-weight: 700;
}

.wp-block-button.is-style-tml-cta .wp-block-button__link:hover,
.wp-block-button.is-style-tml-cta .wp-block-button__link:focus,
.wp-block-button.is-style-tml-cta .wp-element-button:hover,
.wp-block-button.is-style-tml-cta .wp-element-button:focus {
    background: #eaf2ff;
    border-color: #8fb7ef;

    color: #0f1f36 !important;

    box-shadow: 0 5px 14px rgba(24, 78, 160, 0.10);

    transform: translateY(-1px);
}

@media (max-width: 768px) {

    .wp-block-button.is-style-tml-cta .wp-block-button__link,
    .wp-block-button.is-style-tml-cta .wp-element-button {
        min-height: 58px;
        padding: 14px 15px;
    }

    .wp-block-button.is-style-tml-cta .wp-block-button__link::after,
    .wp-block-button.is-style-tml-cta .wp-element-button::after {
        width: 29px;
        height: 29px;
        font-size: 16px;
    }
}


/* ==========================================================
   TML CTA V3 - CENTERED CONTENT
   ========================================================== */

.wp-block-button.is-style-tml-cta .wp-block-button__link,
.wp-block-button.is-style-tml-cta .wp-element-button {
    justify-content: center;
    gap: 12px;
    text-align: center;
}

.wp-block-button.is-style-tml-cta .wp-block-button__link::after,
.wp-block-button.is-style-tml-cta .wp-element-button::after {
    margin-left: 2px;
}


/* ==================================================
 * TML Lightweight Native Search — DIRECT PORT FROM TMS
 * ================================================== */

.tml-header__inner {
    position: relative;
}

.tml-search {
    position: relative;
    flex: 0 0 auto;
}

.tml-search > summary {
    list-style: none;
}

.tml-search > summary::-webkit-details-marker {
    display: none;
}

.tml-search__toggle {
    display: grid;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    place-items: center;
    border-radius: 50%;
    cursor: pointer;
    color: inherit;
    font-size: 25px;
    line-height: 1;
    user-select: none;
}

.tml-search__toggle:hover,
.tml-search__toggle:focus-visible {
    background: rgba(127, 127, 127, 0.10);
    outline: none;
}

.tml-search__panel {
    position: absolute;
    z-index: 1000;
    top: calc(100% + 12px);
    right: 0;
    width: min(360px, calc(100vw - 32px));
    padding: 10px;
    border: 1px solid #dcdcde;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.10);
}

.tml-search__form {
    display: flex;
    gap: 7px;
}

.tml-search__field {
    flex: 1 1 auto;
    min-width: 0;
    height: 40px;
    padding: 0 12px;
    border: 1px solid #c3c4c7;
    border-radius: 5px;
    background: #fff;
    color: #1d2327;
    font: inherit;
}

.tml-search__field:focus {
    border-color: #646970;
    outline: 1px solid #646970;
}

.tml-search__submit {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 0 14px;
    border: 0;
    border-radius: 5px;
    cursor: pointer;
    background: #1d2327;
    color: #fff;
    font: inherit;
    font-weight: 600;
}


/* Search results */

.tml-search-page {
    padding-top: 48px;
    padding-bottom: 64px;
}

.tml-search-page__header {
    margin-bottom: 30px;
}

.tml-search-page__eyebrow {
    margin: 0 0 6px;
    color: #646970;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
}

.tml-search-page__header h1 {
    margin: 0 0 22px;
    font-size: clamp(26px, 4vw, 38px);
    line-height: 1.25;
}

.tml-search-page__form {
    display: flex;
    max-width: 620px;
    gap: 8px;
}

.tml-search-page__form input[type="search"] {
    flex: 1 1 auto;
    min-width: 0;
    height: 44px;
    padding: 0 13px;
    border: 1px solid #c3c4c7;
    border-radius: 5px;
    font: inherit;
}

.tml-search-page__form button {
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 5px;
    cursor: pointer;
    background: #1d2327;
    color: #fff;
    font: inherit;
    font-weight: 600;
}

.tml-search-results {
    border-top: 1px solid #dcdcde;
}

.tml-search-result {
    padding: 24px 0;
    border-bottom: 1px solid #dcdcde;
}

.tml-search-result__meta {
    display: flex;
    gap: 7px;
    margin-bottom: 7px;
    color: #646970;
    font-size: 12px;
}

.tml-search-result__title {
    margin: 0 0 8px;
    font-size: clamp(18px, 2.5vw, 23px);
    line-height: 1.4;
}

.tml-search-result__title a {
    color: inherit;
    text-decoration: none;
}

.tml-search-result__title a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.tml-search-result__excerpt {
    max-width: 760px;
    color: #50575e;
    font-size: 14px;
    line-height: 1.7;
}

.tml-search-pagination {
    margin-top: 32px;
}

.tml-search-pagination .nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tml-search-pagination .page-numbers {
    display: inline-flex;
    min-width: 36px;
    min-height: 36px;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    color: inherit;
    text-decoration: none;
}

.tml-search-pagination .current {
    background: #1d2327;
    border-color: #1d2327;
    color: #fff;
}

.tml-search-empty {
    padding: 28px 0;
    border-top: 1px solid #dcdcde;
}

@media (max-width: 720px) {

    .tml-search__panel {
        position: fixed;
        top: 70px;
        right: 16px;
        left: 16px;
        width: auto;
    }

    .tml-search-page {
        padding-top: 32px;
    }

    .tml-search-page__form {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
    }
}

/* ==================================================
 * TML HEADER TOOLS REFINEMENT
 * Search + menu grouping
 * ================================================== */

.tml-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.tml-primary-nav {
    margin-left: auto;
}

.tml-header__tools {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.tml-search,
.tml-menu {
    flex: 0 0 auto;
}

.tml-search__toggle {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    background: transparent;
}

.tml-search__toggle span {
    display: inline-block;
    line-height: 1;
    transform: translateY(-1px);
}

@media (min-width: 769px) {
    .tml-header__tools {
        gap: 12px;
        margin-left: 8px;
    }

    .tml-search__toggle {
        width: 34px;
        height: 34px;
    }
}

@media (max-width: 768px) {
    .tml-header__inner {
        gap: 12px;
    }

    .tml-primary-nav {
        display: none;
    }

    .tml-header__tools {
        margin-left: auto;
        gap: 10px;
    }

    .tml-search__toggle {
        width: 38px;
        height: 38px;
        border: 1px solid #d7dce4;
        border-radius: 12px;
        background: #fff;
    }

    .tml-search__panel {
        right: 0;
        left: auto;
    }
}
