/* ===== Container ===== */
.ig-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    color: #1a1a1a;
    box-sizing: border-box;
}

/* ===== Theme variables ===== */
.ig-container {
    --ig-accent:        #c7ff7a;
    --ig-cream:         #f5f1e9;
    --ig-black:         #000000;
    --ig-handle-dark:   #c7ff7a;
}

/* ===== Profile header (flexbox) ===== */
.ig-profile {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 0 24px;
    margin-bottom: 24px;
    border-bottom: 1px solid #efefef;
}
.ig-profile-avatar {
    flex: 0 0 120px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    background: #f0f0f0;
}
.ig-profile-avatar img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}
.ig-profile-meta {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
/* Three-row logo block — bare inline stack with <br>, highlighter-cap background. */
.ig-profile-logo-wrapper {
    display: block !important;
    width: max-content !important;
    max-width: 100% !important;
    text-decoration: none !important;
    line-height: normal !important;
    color: inherit;
}
.ig-profile-logo-wrapper:visited {
    color: inherit;
}
.ig-logo-top,
.ig-logo-middle,
.ig-logo-bottom {
    display: inline !important;
    box-decoration-break: clone !important;
    -webkit-box-decoration-break: clone !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    border-radius: 0px !important;
    white-space: pre-wrap !important;
    word-break: break-word !important;
    line-height: 1.4 !important;
    padding: 3px 10px !important;
    font-family: var(--wp--preset--font-family--worksans), sans-serif;
    font-weight: 700;
    font-style: italic;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Row 1: display name (top) — lime default, black on hover. */
.ig-logo-top {
    font-size: 24px;
    background-color: #c7ff7a;
    color: #000000;
}
.ig-profile-logo-wrapper:hover .ig-logo-top,
.ig-profile-logo-wrapper:focus-visible .ig-logo-top {
    background-color: #000000;
    color: #c7ff7a;
}

/* Row 2: @handle (middle) — cream default, lime on hover. */
.ig-logo-middle {
    font-size: 18px;
    background-color: #f5f1e9;
    color: #000000;
}
.ig-profile-logo-wrapper:hover .ig-logo-middle,
.ig-profile-logo-wrapper:focus-visible .ig-logo-middle {
    background-color: #c7ff7a;
    color: #000000;
}

/* Row 3: bio (bottom) — cream default, lime on hover. */
.ig-logo-bottom {
    font-size: 18px;
    background-color: #f5f1e9;
    color: #000000;
}
.ig-profile-logo-wrapper:hover .ig-logo-bottom,
.ig-profile-logo-wrapper:focus-visible .ig-logo-bottom {
    background-color: #c7ff7a;
    color: #000000;
}

/* ===== Grid ===== */
.ig-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}
@media (max-width: 640px) {
    .ig-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Items ===== */
.ig-item {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 12px;
    background: #f0f0f0;
    text-decoration: none;
}
.ig-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .45s ease, filter .45s ease;
    opacity: 1;
}
.ig-item:hover img,
.ig-item:focus-visible img {
    transform: scale(1.05);
    filter: brightness(1.08);
}
.ig-hidden { display: none !important; }

/* ===== Opt-in box (Sunflower pattern: one button gates the whole grid) ===== */
.ig-before-loading {
    margin: 24px auto 28px;
    padding: 28px 20px;
    max-width: 640px;
    text-align: center;
    background: var(--ig-cream);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    box-sizing: border-box;
}
.ig-before-loading-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--ig-black);
}
.ig-before-loading-text {
    font-size: 14px;
    line-height: 1.5;
    margin: 0 0 18px;
    color: var(--ig-black);
}
.ig-before-loading-text a {
    color: var(--ig-black);
    text-decoration: underline;
}
/* "Load Instagram posts" — same look as ig-follow-btn (lime default, black on hover, Sunflower theme radius). */
.ig-load-instagram {
    background-color: var(--ig-accent);
    color: var(--ig-black);
    text-decoration: none;
    border-color: var(--ig-accent);
}
.ig-load-instagram:hover,
.ig-load-instagram:focus-visible {
    background-color: var(--ig-black);
    color: var(--ig-accent);
    border-color: var(--ig-black);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, .18);
}

/* ===== Action row (load posts + follow, side-by-side) ===== */
.ig-before-loading-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 8px;
}
.ig-before-loading-actions .ig-btn-base {
    flex: 0 1 auto;
    min-width: 200px;
}

/* ===== Opt-in checkbox under the notice ===== */
.ig-before-loading-remember {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0 auto 16px;
    max-width: 480px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--ig-black);
    cursor: pointer;
    text-align: left;
}
.ig-before-loading-remember input[type="checkbox"] {
    margin-top: 2px;
    flex: 0 0 auto;
    cursor: pointer;
}
/* ===== Skeleton (fallback) ===== */
.ig-skel {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient( 90deg, #e9e9e9 0%, #f6f6f6 40%, #e9e9e9 80% );
    background-size: 200% 100%;
    animation: ig-shimmer 1.4s linear infinite;
}
.ig-skel--avatar { border-radius: 50%; }
@keyframes ig-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== Reels / video overlay ===== */
.ig-item--video::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 56px;
    height: 56px;
    transform: translate(-50%, -50%);
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 68 68'><circle cx='34' cy='34' r='32' fill='rgba(0,0,0,0.55)' stroke='%23ffffff' stroke-width='2'/><path d='M28 22 L28 46 L48 34 Z' fill='%23ffffff'/></svg>") center / contain no-repeat;
    pointer-events: none;
    opacity: 0.85;
    transition: opacity .2s ease, transform .2s ease;
}
.ig-item--video:hover::after { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }

/* ===== Footer actions (follow + load more) ===== */
.ig-footer-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: stretch;
    gap: 16px;
    margin-top: 28px;
}

/* Shared base class — identical geometry for both buttons.
   Works on both <a> and <button>. border-radius is overridden below
   by the Sunflower theme (formstyle-rounded / formstyle-sharp). */
.ig-btn-base {
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    min-height: 44px;            /* identical height */
    padding: 12px 36px;
    line-height: 1.2;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0;
    text-align: center;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 0;            /* default = square; theme overrides */
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .2s ease, color .2s ease,
        border-color .2s ease, transform .2s ease,
        box-shadow .2s ease, opacity .2s ease, border-radius .2s ease;
}
.ig-btn-base:focus-visible { outline: 2px solid var(--ig-handle-dark); outline-offset: 3px; }
.ig-btn-base:active { transform: translateY(0); }
.ig-btn-base svg { display: block; flex: 0 0 auto; fill: currentColor; }

/* "Follow on Instagram" — lime default, black on hover.
   !important because the Sunflower theme colors <a> tags globally. */
.ig-follow-btn {
    background-color: var(--ig-accent);
    color: var(--ig-black) !important;
    text-decoration: none !important;
    border-color: var(--ig-accent);
}
.ig-follow-btn:hover,
.ig-follow-btn:focus-visible {
    background-color: var(--ig-black);
    color: var(--ig-accent) !important;
    text-decoration: none !important;
    border-color: var(--ig-black);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, .18);
}

/* "Load more" — cream default, lime on hover. */
.ig-load-more {
    background-color: var(--ig-cream);
    color: var(--ig-black);
    border-color: var(--ig-cream);
}
.ig-load-more:hover,
.ig-load-more:focus-visible {
    background-color: var(--ig-accent);
    color: var(--ig-black);
    border-color: var(--ig-accent);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(199, 255, 122, .35);
}
.ig-load-more:disabled {
    opacity: .6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Sunflower-theme button shape — applied to BOTH buttons in sync. */
body.formstyle-rounded .ig-follow-btn,
body.formstyle-rounded .ig-load-more,
body.formstyle-rounded .ig-load-instagram {
    border-radius: 999px;
}

/* Mobile: buttons stacked, full width. */
@media (max-width: 640px) {
    .ig-footer-actions {
        flex-direction: column;
    }
    .ig-btn-base {
        width: 100%;
        justify-content: center;
    }
}

/* ===== Error box ===== */
.ig-error {
    margin: 20px 0;
    padding: 14px 18px;
    text-align: center;
    background: #fff4f4;
    border: 1px solid #f5c6cb;
    color: #842029;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.45;
}

/* ===== "Load more" hidden ===== */
.ig-load-more.is-hidden { display: none; }

/* ===== Reduced-motion opt-out ===== */
@media (prefers-reduced-motion: reduce) {
    .ig-container,
    .ig-container *,
    .ig-container *::before,
    .ig-container *::after {
        transition: none !important;
        animation: none !important;
    }
    .ig-container .ig-item:hover img,
    .ig-container .ig-item:focus-visible img,
    .ig-container .ig-load-instagram:hover,
    .ig-container .ig-load-instagram:focus-visible,
    .ig-container .ig-follow-btn:hover,
    .ig-container .ig-follow-btn:focus-visible,
    .ig-container .ig-load-more:hover,
    .ig-container .ig-load-more:focus-visible,
    .ig-container .ig-item--video:hover::after {
        transform: none !important;
    }
}
