/* ========================================
   SQUARE OVERLAY (desktop)
   ======================================== */
.square-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 120ms ease;
}
.square-overlay:not(.is-hidden) {
    pointer-events: auto;
    opacity: 1;
}
.square-overlay__backdrop {
    position: absolute;
    inset: 0;
    background: var(--black-overlay);
}
.square-overlay__dialog {
    position: relative;
    width: 90vw;
    max-height: 90vh;
    background: var(--bg-surface);
    overflow: auto;
    box-shadow: var(--shadow-xl);
}
.square-overlay__close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--black-60);
    color: var(--white);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 20px;
    cursor: pointer;
}
.square-overlay__close:focus-visible {
    outline: 2px solid var(--white);
    outline-offset: 2px;
}
.square-overlay__cta {
    padding: 12px;
    text-align: right;
    border-top: 1px solid var(--c-border);
}
.square-overlay__cta-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}
.square-overlay__cta-link:hover,
.square-overlay__cta-link:focus-visible {
    text-decoration: underline;
}
.square-overlay-open #grid-container {
    pointer-events: none;
}

.square-view__copy-icon {
    width: 1rem;
    height: 1rem;
}

/* ========================================
   SQUARE VIEW PAGE - Fullscreen Layout
   ======================================== */

.square-view-page--fullscreen {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--c-surface);
}

.square-view-page--overlay {
    display: flex;
    height: 100%;
    min-height: 80vh;
    background: var(--c-surface);
    overflow: hidden;
    align-items: flex-start;
}

/* ----------------------------------------
   Image Section
   ---------------------------------------- */

.square-view__image-section {
    flex: 1 1 60%;
    position: sticky;
    top: 0;
    overflow: hidden;
    background: var(--c-text);
}

.square-view-page--overlay .square-view__image-section {
    aspect-ratio: 1 / 1;
    align-self: flex-start;
}

.square-view__hero-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.square-view__image-section .square-view__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--c-text-muted);
    font-family: var(--font-body);
    font-size: var(--fs-2);
}

.square-view__image-section .square-view__blur-banner {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--sp-4);
    background: var(--black-70);
    color: var(--white);
    text-align: center;
    font-family: var(--font-body);
    font-size: var(--fs-2);
}

/* ----------------------------------------
   Content Section
   ---------------------------------------- */

.square-view__content-section {
    flex: 0 0 420px;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    background: var(--c-surface);
    border-left: 1px solid var(--c-border);
    height: 100%;
    overflow: hidden;
}

/* ----------------------------------------
   Header (Meta Row)
   ---------------------------------------- */

.square-view__header {
    display: flex;
    flex-direction: column;
    /* align-items: center; */
    /* justify-content: space-between; */
    gap: var(--space-s);
    padding: var(--space-s);
    border-bottom: 1px solid var(--c-border);
}

.square-view__badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
}

.square-view__badges .square-meta-badge {
    padding: var(--sp-1) var(--sp-2);
    font-size: var(--fs-1);
}

.square-view__report-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: var(--sp-1) var(--sp-2);
    background: transparent;
    border: none;
    font-family: var(--font-body);
    font-size: var(--fs-1);
    color: var(--c-text-muted);
    cursor: pointer;
    transition: color 0.2s ease;
}

.square-view__report-btn:hover {
    color: var(--c-text);
}

.square-view__report-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
}

.square-view__report-btn--disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* ----------------------------------------
   Main Content
   ---------------------------------------- */

.square-view__main {
    flex: 1;
    padding-block: var(--space-l);
    padding-inline: var(--space-l);
    overflow-y: auto;
    min-height: 0;
}

.square-view__author {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
}

.square-view__author-avatar {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    overflow: hidden;
    background: var(--c-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.square-view__author-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.square-view__author-avatar svg {
    width: 24px;
    height: 24px;
}

.square-view__title {
    font-family: var(--font-body);
    font-size: var(--fs-3);
    font-weight: var(--fw-bold);
    color: var(--c-text);
    margin: 0;
}

.square-view__story {
    font-family: var(--font-body);
    font-size: var(--fs-2);
    font-weight: var(--fw-regular);
    color: var(--c-text);
    height: auto;
    line-height: 1.6;
    margin-bottom: var(--sp-5);
    padding-block: var(--space-s);
    padding-inline: unset;
}

.square-view__timestamp {
    font-family: var(--font-body);
    font-size: var(--fs-1);
    color: var(--c-text-muted);
    margin-block: var(--space-s);
}

.square-view__notice {
    margin-top: var(--sp-4);
    padding: var(--sp-3);
    background: var(--c-surface-alt);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: var(--fs-1);
    color: var(--c-text-muted);
    text-align: center;
}

/* ----------------------------------------
   Footer Actions
   ---------------------------------------- */

.square-view__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4);
    border-top: 1px solid var(--c-border);
}

.square-view__visit-link {
    font-family: var(--font-body);
    font-size: var(--fs-2);
    font-weight: var(--fw-medium);
    color: var(--c-text);
    text-decoration: none;
    transition: color 0.2s ease;
}

.square-view__visit-link:hover {
    color: var(--c-primary);
}

.square-view__share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-2) var(--sp-4);
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: var(--fs-2);
    font-weight: var(--fw-medium);
    color: var(--c-text);
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.square-view__share-btn:hover {
    background: var(--c-surface-hover);
    border-color: var(--c-border-dark);
}

.square-view__share-btn:focus {
    outline: none;
}

.square-view__share-btn:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}

/* ----------------------------------------
   Share Dropdown (Tippy)
   ---------------------------------------- */

.share-dropdown__content {
    display: flex;
    flex-direction: column;
    padding: var(--sp-2) 0;
}

.share-dropdown__item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: transparent;
    border: none;
    font-family: var(--font-body);
    font-size: var(--fs-2);
    font-weight: var(--fw-regular);
    color: var(--c-text);
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease;
    text-align: left;
    width: 100%;
}

.share-dropdown__item:hover {
    background: var(--c-surface-alt);
}

.share-dropdown__item svg {
    flex-shrink: 0;
    color: var(--c-text-muted);
}

.share-dropdown__item:hover svg {
    color: var(--c-text);
}

/* Tippy theme override */
.tippy-box[data-theme~='light-border'] {
    background-color: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card-lg);
}

.tippy-box[data-theme~='light-border'] .tippy-content {
    padding: 0;
}

.tippy-box[data-theme~='light-border'] .tippy-arrow {
    color: var(--c-surface);
}

/* ----------------------------------------
   Blurred States
   ---------------------------------------- */

.square-view__image-section.is-blurred .square-view__hero-image,
.square-view__hero-image.is-blurred {
    filter: blur(20px);
}

.is-blurred-text {
    filter: blur(8px);
    user-select: none;
}

/* ----------------------------------------
   Responsive
   ---------------------------------------- */

@media (max-width: 767px) {
    .square-view-page--fullscreen,
    .square-view-page--overlay {
        flex-direction: column;
        min-height: auto;
    }

    .square-view-page--overlay {
        height: auto;
        overflow: visible;
    }

    .square-view__image-section {
        flex: none;
        height: 50vh;
        height: 50dvh;
        min-height: 300px;
    }

    .square-view__content-section {
        flex: none;
        max-width: 100%;
        min-height: 50vh;
    }

    .square-view__header {
        flex-wrap: wrap;
    }

    .square-view__badges {
        order: 1;
        width: 100%;
    }

    .square-view__report-btn {
        order: 2;
        margin-left: auto;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .square-view__content-section {
        flex: 0 0 360px;
        max-width: 360px;
    }
}

@media (min-width: 1440px) {
    .square-view__content-section {
        flex: 0 0 480px;
        max-width: 480px;
    }
}
