/* Blog — inherits landing/app dark theme tokens from site.css */

:root {
  --blog-marker-bg: #ffe34d45;
  --blog-marker-text: #cbb983;
  --blog-marker-skew: -9deg;
}

/* Light themes: dark text on a stronger yellow. The dark-theme pair (pale
   text on a faint yellow) washes out on a light page. data-bs-theme follows
   the kakao theme's colour scheme (Kakao::registerTheme, kakao-theme-switch). */
:root[data-bs-theme="light"] {
  --blog-marker-bg: #ffe066b3;
  --blog-marker-text: var(--kakao-color-text, #18181b);
}

.blog-public__header {
    margin-bottom: 1.75rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--uw-border, rgba(200, 200, 200, 0.14));
}

.blog-public__header h1 {
    font-family: var(--header-font, "Secular One", system-ui, sans-serif);
    font-weight: 400;
    letter-spacing: 0.02em;
}

.blog-post-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.blog-post-card {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1.35rem 0;
    border-bottom: 1px solid var(--uw-border, rgba(200, 200, 200, 0.14));
    align-items: start;
}

.blog-post-card--has-media {
    grid-template-columns: 7.5rem minmax(0, 1fr);
}

@media (min-width: 576px) {
    .blog-post-card--has-media {
        grid-template-columns: 9.5rem minmax(0, 1fr);
        gap: 1.25rem;
    }
}

.blog-post-card__media {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 0.25rem;
    overflow: hidden;
    border: 1px solid var(--uw-border, rgba(200, 200, 200, 0.14));
    background: var(--kakao-color-subtle);
    text-decoration: none;
}

.blog-post-card__media kakao-image {
    display: block;
    width: 100%;
    height: 100%;
    transition: transform 0.25s ease, opacity 0.25s ease;
    opacity: 0.92;
}

.blog-post-card:hover .blog-post-card__media kakao-image {
    transform: scale(1.04);
    opacity: 1;
}

.blog-post-card__body {
    min-width: 0;
}

.blog-post-card__title {
    font-family: var(--header-font, "Secular One", system-ui, sans-serif);
    font-size: 1.35rem;
    font-weight: 400;
    margin: 0 0 0.4rem;
    letter-spacing: 0.01em;
}

.blog-post-card__title a {
    color: var(--uw-text-strong, #f0f0f0);
    text-decoration: none;
}

.blog-post-card__title a:hover {
    color: var(--uw-accent, #4c64b8);
}

.blog-post-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.85rem;
    margin-bottom: 0.55rem;
    color: var(--uw-text-muted, #6a6a6a);
}

/* tag chips: own flex row so they wrap together and keep their spacing */
.blog-post-card__tags {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.blog-post-card__excerpt {
    margin: 0;
    color: var(--uw-text-muted, #6a6a6a);
    line-height: 1.5;
}

.blog-cover-preview {
    max-width: 100%;
    max-height: 10rem;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 0.2rem;
    border: 1px solid var(--uw-border, rgba(200, 200, 200, 0.14));
}

.blog-post {
    max-width: 46rem;
    margin-inline: auto;
    width: 100%;
}

.blog-public {
    max-width: 46rem;
    margin-inline: auto;
    width: 100%;
}

.blog-post__cover {
    margin: 0 0 1.5rem;
    text-align: center;
}

.blog-post__cover kakao-image {
    --kakao-image-radius: 0.25rem;
}
.blog-post__cover kakao-image::part(figure) {
    margin-inline: auto;
}
.blog-post__cover kakao-image::part(frame) {
    border: 1px solid var(--uw-border, rgba(200, 200, 200, 0.14));
}

.blog-manage h1,
.blog-create h1,
.blog-update h1,
.blog-widget-index h1,
.blog-widget-create h1,
.blog-widget-update h1 {
    font-family: var(--header-font, "Secular One", system-ui, sans-serif);
    font-weight: 400;
    letter-spacing: 0.01em;
}

.blog-post__title {
    font-family: var(--header-font, "Secular One", system-ui, sans-serif);
    font-weight: 400;
    margin-bottom: 0.4rem;
    letter-spacing: 0.01em;
}

.blog-post__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    color: var(--uw-text-muted, #6a6a6a);
    font-size: 0.9rem;
}

.blog-post__body {
    font-family: var(--text-font, "Valley Sans", system-ui, sans-serif);
    line-height: 1.7;
    font-size: 1.05rem;
    font-weight: 400;
    color: var(--uw-text, #c8c8c8);
}

.blog-post__body h1,
.blog-post__body h2,
.blog-post__body h3,
.blog-post__body h4 {
    font-family: var(--header-font, "Secular One", system-ui, sans-serif);
    font-weight: 400;
    margin-top: 1.75em;
    margin-bottom: 0.5em;
    color: var(--uw-text-strong, #f0f0f0);
}

.blog-post__body p {
    margin-bottom: 1em;
}

.blog-post__body a {
    color: var(--uw-accent, #4c64b8);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--kakao-color-primary) 40%, transparent);
    text-underline-offset: 0.15em;
}

.blog-post__body a:hover {
    color: var(--uw-accent-hover, #6b82d4);
}

/* Skewed marker highlight for markdown emphasis (*italic* / _italic_) */
.blog-post__body em,
.blog-post__body .em,
.blog-post__body .em-marker {
    font-style: italic;
    font-weight: 500;
    position: relative;
    display: inline-block;
    padding: 0.02em 0.15em 0.02em;
    margin: 0 0.12em;
    color: var(--blog-marker-text, #121013);
    line-height: 1.35;
    vertical-align: baseline;
    z-index: 0;
    text-decoration: none;
    text-shadow: none;
    max-width: 100%;
    word-break: break-word;
}

.blog-post__body em::before,
.blog-post__body .em::before,
.blog-post__body .em-marker::before {
    content: "";
    position: absolute;
    inset: 0.02em 0;
    background: var(--blog-marker-bg, linear-gradient(102deg, #ffe066 0%, #ffd43f 90%, #ffca28 100%));
    transform: skewX(var(--blog-marker-skew, -11deg));
    border-radius: 2px 4px 3px 5px;
    z-index: -1;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.blog-post__body a em,
.blog-post__body a .em,
.blog-post__body a .em-marker {
    text-decoration: none;
}

.blog-post__body a:hover em::before,
.blog-post__body a:hover .em::before,
.blog-post__body a:hover .em-marker::before {
    background: linear-gradient(102deg, #fff085 0%, #ffe066 90%, #ffd43f 100%);
    box-shadow: 0 2px 6px rgba(255, 212, 63, 0.35);
}

.blog-post__body em strong,
.blog-post__body strong em {
    font-weight: 700;
    color: var(--blog-marker-text, #121013);
}

/* Post images are <kakao-image> (CustomParser::imageMarkup): a skeleton of the
   image's size while it loads, then a fade-in; the caption is its figcaption. */
.blog-post__body {
    --kakao-image-radius: 0;
    --kakao-image-caption-align: center;
    --kakao-image-caption-size: 0.8rem;
    --kakao-image-caption-gap: 0.75rem;
    --kakao-image-caption-color: var(--uw-text-muted, #6a6a6a);
}

/* Caption with the temperature badge on its right (slot="caption"). */
.post-image__caption {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.25rem 0.5rem;
}
.post-image__temperature {
    flex: none;
    font-variant-numeric: tabular-nums;
}

.blog-post__body img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1.25rem auto;
}

.blog-post__body .post-figure {
    max-width: 100%;
    margin: 1.5rem auto;
}

.blog-post__body .post-image::part(frame) {
    border: 1px solid var(--uw-border, rgba(200, 200, 200, 0.14));
}

/* Palette derivatives are 480px. Stretched to the text column, they keep the
   pixels hard-edged instead of the browser's smooth upscale. */
.blog-post__body .post-image::part(image) {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.blog-post__body .post-image[data-original] {
    cursor: crosshair;
}

/* Hover lens over palette images (blog-lens.js). Sits on top of the img,
   clipped to its content box; pointer events pass through to the img. */
.post-image-lens {
    position: absolute;
    z-index: 20;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.post-image-lens.is-active {
    opacity: 1;
}

.post-image-lens__view,
.post-image-lens__rim,
.post-image-lens__outline {
    position: absolute;
    inset: 0;
    clip-path: inset(50%);
}

.post-image-lens__view {
    clip-path: none;
    -webkit-mask-image: linear-gradient(transparent, transparent);
    mask-image: linear-gradient(transparent, transparent);
}

.post-image-lens__outline {
    overflow: hidden;
}

/* The originals are scaled around the lens center (blog-lens.js); the
   layer's clip or mask keeps the circle at its screen size. */
.post-image-lens__view,
.post-image-lens__rim {
    overflow: hidden;
}

.post-image-lens__original {
    position: absolute;
    inset: 0;
    will-change: transform;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    border: 0;
    object-fit: fill;
    image-rendering: auto;
}

/* Touch devices: the lens stays pinned on the image and is dragged by the
   circle itself. Only this area takes touches, so the page still scrolls. */
.post-image-lens__grab {
    position: absolute;
    border-radius: 50%;
    pointer-events: auto;
    touch-action: none;
    cursor: grab;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.post-image-lens.is-dragging .post-image-lens__grab {
    cursor: grabbing;
}

/* Grabber badge on the lower right rim: a move icon hinting the lens drags. */
.post-image-lens__grabber {
    position: absolute;
    left: 85.4%;
    top: 85.4%;
    width: 30px;
    height: 30px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v18M3 12h18M9 6l3-3 3 3M9 18l3 3 3-3M6 9l-3 3 3 3M18 9l3 3-3 3'/%3E%3C/svg%3E") center / 18px no-repeat;
    transition: transform 0.15s ease;
}

.post-image-lens.is-dragging .post-image-lens__grabber {
    transform: translate(-50%, -50%) scale(1.15);
}

/* Touch mode keeps the lens closed until its toggle button is tapped. */
.post-image-lens.is-touch:not(.is-open) .post-image-lens__original,
.post-image-lens.is-touch:not(.is-open) .post-image-lens__rim,
.post-image-lens.is-touch:not(.is-open) .post-image-lens__outline,
.post-image-lens.is-touch:not(.is-open) .post-image-lens__grab {
    display: none;
}

.post-image-lens__toggle {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    pointer-events: auto;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    background: rgba(0, 0, 0, 0.7) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5L21 21'/%3E%3C/svg%3E") center / 20px no-repeat;
}

/* Open: the button turns into a close icon. */
.post-image-lens.is-open .post-image-lens__toggle {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E");
}

/* Collage of 3+ consecutive image blocks (CustomParser::galleryMarkup).
   Each row holds the images the server put in it; flex-grow follows each
   image's aspect ratio (--ratio), so a row fills the column and all its images
   share one height without any measuring. */
.blog-post__body .post-gallery {
    --gallery-gap: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: var(--gallery-gap);
    margin: 1.5rem 0;
}

.blog-post__body .post-gallery__row {
    display: flex;
    align-items: flex-start;
    gap: var(--gallery-gap);
}

.blog-post__body .post-gallery__item {
    --kakao-image-caption-gap: 0.35rem;
    --kakao-image-caption-size: 0.75rem;
    flex: var(--ratio) 1 0;
    min-width: 0;
    margin: 0;
}

/* Phones: a row of four becomes two rows of two. */
@media (max-width: 480px) {
    .blog-post__body .post-gallery__row:has(> :nth-child(4)) {
        flex-wrap: wrap;
    }
    .blog-post__body .post-gallery__row:has(> :nth-child(4)) > .post-gallery__item {
        flex-basis: calc(50% - var(--gallery-gap));
    }
}

.blog-post__body .code-pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 0.9rem 1rem;
    border-radius: 0.25rem;
    overflow-x: auto;
    border: 1px solid var(--uw-border, rgba(200, 200, 200, 0.14));
}

.blog-post__body .blockquote {
    border-left: 3px solid var(--uw-accent, #4c64b8);
    padding-left: 1rem;
    color: var(--uw-text-muted, #6a6a6a);
    margin: 1.25rem 0;
}

.blog-post__body .blog-table-wrap,
.blog-post__body .table-responsive {
    margin: 1.35rem 0;
    max-width: 100%;
    overflow-x: auto;
}

.blog-post__body table,
.blog-post__body .blog-table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    color: var(--uw-text, #c8c8c8);
    font-size: 0.95rem;
    line-height: 1.45;
    margin-bottom: 0;
    background: transparent;
}

.blog-post__body table th,
.blog-post__body table td,
.blog-post__body .blog-table th,
.blog-post__body .blog-table td {
    border: 1px solid var(--uw-border, rgba(200, 200, 200, 0.14));
    padding: 0.55rem 0.75rem;
    vertical-align: top;
}

.blog-post__body table thead th,
.blog-post__body .blog-table thead th {
    color: var(--uw-text-strong, #f0f0f0);
    font-weight: 600;
    letter-spacing: normal;
    text-transform: none; /* override site.css admin-grid lowercase */
    white-space: normal;
    background: color-mix(in srgb, var(--kakao-color-text) 4%, transparent);
    border-bottom-width: 2px;
    border-bottom-color: var(--uw-border-strong, rgba(200, 200, 200, 0.28));
}

.blog-post__body table tbody tr:nth-child(even),
.blog-post__body .blog-table tbody tr:nth-child(even) {
    background: color-mix(in srgb, var(--kakao-color-text) 2%, transparent);
}

/* ---------- Sortable tables (Vue transition-group) ---------- */

.blog-table-wrap--sortable {
    position: relative;
}

/* Parent owns the column tracks (col / col-auto / lengths).
   Rows are real boxes that subgrid those tracks, so widths line up and
   transition-group can still FLIP the row. */
.blog-table--sortable {
    display: grid;
    grid-template-columns: var(--blog-table-cols, minmax(0, 1fr));
    width: 100%;
    border: 1px solid var(--uw-border, rgba(200, 200, 200, 0.14));
    border-radius: 0.2rem;
    overflow: hidden;
    position: relative;
}

.blog-table--sortable .blog-table__body {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
}

.blog-table--sortable .blog-table__row {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
    width: 100%;
}

.blog-table--sortable .blog-table__cell {
    border-right: 1px solid var(--uw-border, rgba(200, 200, 200, 0.14));
    border-bottom: 1px solid var(--uw-border, rgba(200, 200, 200, 0.14));
    padding: 0.55rem 0.75rem;
    min-width: 0;
    overflow-wrap: anywhere;
}

.blog-table--sortable .blog-table__cell:last-child {
    border-right: 0;
}

.blog-table--sortable .blog-table__body .blog-table__row:last-child .blog-table__cell {
    border-bottom: 0;
}

.blog-table--sortable .blog-table__row--head .blog-table__cell {
    padding: 0;
    color: var(--uw-text-strong, #f0f0f0);
    font-weight: 600;
    background: color-mix(in srgb, var(--kakao-color-text) 4%, transparent);
    border-bottom-width: 2px;
    border-bottom-color: var(--uw-border-strong, rgba(200, 200, 200, 0.28));
}

.blog-table--sortable .blog-table__row.is-even {
    background: color-mix(in srgb, var(--kakao-color-text) 2%, transparent);
}

.blog-table__th-sortable {
    padding: 0 !important;
    vertical-align: middle;
}

.blog-table__sort-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.55rem;
    width: 100%;
    margin: 0;
    padding: 0.55rem 0.75rem;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 600;
    text-align: inherit;
    cursor: pointer;
    appearance: none;
}

.blog-table__sort-btn:hover,
.blog-table__sort-btn:focus-visible {
    background: color-mix(in srgb, var(--kakao-color-primary) 12%, transparent);
    outline: none;
}

.blog-table__th-label {
    min-width: 0;
    flex: 1 1 auto;
    text-align: inherit;
}

.blog-table__sort-icon {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.12rem;
    flex: 0 0 auto;
    width: 0.7rem;
    opacity: 0.35;
    transition: opacity 0.15s ease;
}

.blog-table__sort-btn:hover .blog-table__sort-icon,
.blog-table__th-sortable.is-asc .blog-table__sort-icon,
.blog-table__th-sortable.is-desc .blog-table__sort-icon {
    opacity: 0.95;
}

.blog-table__sort-caret {
    display: block;
    width: 0;
    height: 0;
    border-left: 0.28rem solid transparent;
    border-right: 0.28rem solid transparent;
    opacity: 0.45;
    transition: opacity 0.15s ease, border-color 0.15s ease;
}

.blog-table__sort-caret--up {
    border-bottom: 0.32rem solid currentColor;
}

.blog-table__sort-caret--down {
    border-top: 0.32rem solid currentColor;
}

.blog-table__th-sortable.is-asc .blog-table__sort-caret--up,
.blog-table__th-sortable.is-desc .blog-table__sort-caret--down {
    opacity: 1;
    color: var(--uw-accent, #4c64b8);
}

.blog-table__th-sortable.is-asc .blog-table__sort-caret--down,
.blog-table__th-sortable.is-desc .blog-table__sort-caret--up {
    opacity: 0.25;
}

/* FLIP move animation for sorted rows */
.blog-table-sort-move {
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.blog-table-sort-enter-active,
.blog-table-sort-leave-active {
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.blog-table-sort-enter-from,
.blog-table-sort-leave-to {
    opacity: 0;
    transform: translateY(0.35rem);
}

.blog-table-sort-leave-active {
    position: absolute;
    width: 100%;
    pointer-events: none;
}

.blog-js-widget {
    margin: 1.35rem 0;
    min-height: 0.5rem;
}

.blog-js-widget--inline {
    display: inline-block;
    margin: 0 0.15em;
    vertical-align: baseline;
}

.blog-js-widget--missing {
    padding: 0.75rem 1rem;
    border: 1px dashed color-mix(in srgb, var(--kakao-color-danger) 50%, transparent);
    color: var(--kakao-color-danger);
    border-radius: 0.25rem;
}

.blog-pagination {
    display: block;
    margin-top: 1.5rem;
}

/* Edit button of a post: right-aligned, also when it wraps under the title on a phone. */
.blog-post__actions {
    margin-left: auto;
}

/* Table of contents (kakao-toc). PC: the post becomes three columns, the toc
   in the left one (its edge in line with the breadcrumb, its top with the
   post's), sticky while the post scrolls; the text column stays centred.
   Below 75rem the toc folds into a bar under the header that shows the
   current section, sticks under the page bar and opens the list on a tap. */
.blog-post__toc {
    margin: 0 0 1.5rem;
    z-index: 5;
}

@media (min-width: 75rem) {
    .blog-post.has-toc {
        max-width: none;
        display: grid;
        grid-template-columns: minmax(10rem, 1fr) minmax(0, 46rem) minmax(0, 1fr);
        column-gap: 2rem;
    }
    .blog-post.has-toc > * {
        grid-column: 2;
        min-width: 0;
    }
    .blog-post.has-toc > .blog-post__toc {
        grid-column: 1;
        grid-row: 1 / span 3;
        align-self: start;
        max-width: 16rem;
        margin: 0;
        /* line the list's text up with the breadcrumb, not its hover padding */
        margin-left: calc(-1 * var(--kakao-toc-padding-x, 0.75rem));
    }
}
