/* ============================================
   CSS Variables from Bricks Theme
   (extracted from bricks-css-variables.json)
   ============================================ */
:root {
    /* --- Base Colors --- */
    --white: #FFFFFF;
    --black: #000000;

    /* --- Brand Primary --- */
    --primary-50: #f0fff8;
    --primary-100: #dbffee;
    --primary-200: #bdffe0;
    --primary-300: #8fffcb;
    --primary-400: #5cffb3;
    --primary-500: #24e58b;
    --primary-600: #1dc979;
    --primary-700: #1ea465;
    --primary-800: #1c8252;
    --primary-900: #196240;
    --primary-950: #13432d;

    /* --- Grey Primitives --- */
    --grey-1000: #141414;
    --grey-950: #1a1919;
    --grey-900: #212020;
    --grey-850: #292929;
    --grey-800: #323131;
    --grey-750: #3c3b3b;
    --grey-700: #474746;
    --grey-650: #545353;
    --grey-600: #616160;
    --grey-550: #6f6e6e;
    --grey-500: #7c7c7b;
    --grey-450: #8b8a89;
    --grey-400: #999898;
    --grey-350: #a8a7a6;
    --grey-300: #b7b6b5;
    --grey-250: #c6c5c4;
    --grey-200: #d4d3d2;
    --grey-150: #e0dfde;
    --grey-100: #edeceb;
    --grey-50: #f7f6f5;

    /* --- Text Tokens --- */
    --text-primary-light: var(--grey-1000);
    --text-secondary-light: var(--grey-700);
    --text-muted-light: var(--grey-350);

    /* --- Spacing (Fixed) --- */
    --space-none: 0rem;
    --space-2: 0.1250rem;
    --space-4: 0.2500rem;
    --space-6: 0.3750rem;
    --space-8: 0.5000rem;
    --space-10: 0.6250rem;
    --space-12: 0.7500rem;
    --space-14: 0.8750rem;
    --space-16: 1.0000rem;
    --space-18: 1.1250rem;
    --space-20: 1.2500rem;
    --space-24: 1.5000rem;
    --space-28: 1.7500rem;
    --space-32: 2.0000rem;
    --space-36: 2.2500rem;
    --space-40: 2.5000rem;
    --space-48: 3.0000rem;
    --space-56: 3.5000rem;
    --space-64: 4.0000rem;
    --space-80: 5.0000rem;
    --space-96: 6.0000rem;
    --space-112: 7.0000rem;
    --space-128: 8.0000rem;

    /* --- Typography --- */
    --h1: clamp(2.25rem, 1.8214rem + 2.1429vw, 3.75rem);
    --h2: clamp(1.875rem, 1.5536rem + 1.6071vw, 3rem);
    --h3: clamp(1.5rem, 1.2857rem + 1.0714vw, 2.25rem);
    --h4: clamp(1.25rem, 1.0714rem + 0.8929vw, 1.875rem);
    --text-12: 0.7500rem;
    --text-14: 0.8750rem;
    --text-16: 1.0000rem;
    --text-18: 1.1250rem;
    --text-20: 1.2500rem;

    /* --- Line Heights --- */
    --lh-h1: clamp(2.5875rem, 2.1482rem + 2.1964vw, 4.125rem);
    --lh-h2: clamp(2.1563rem, 1.8295rem + 1.6339vw, 3.3rem);
    --lh-h3: clamp(1.725rem, 1.5107rem + 1.0714vw, 2.475rem);
    --lh-h4: clamp(1.4375rem, 1.2589rem + 0.8929vw, 2.0625rem);
    --lh-body-12: 1.1250rem;
    --lh-body-14: 1.3125rem;
    --lh-body-16: 1.5000rem;
    --lh-body-18: 1.6875rem;
    --lh-body-20: 1.8750rem;
    --heading-line-height: calc(4px + 2ex);

    /* --- Layout --- */
    --sctn-inline-padding: clamp(1.0000rem, 0.2143rem + 3.9286vw, 3.7500rem);
    --sctn-block-padding: clamp(3.0000rem, 2.2500rem + 3.7500vw, 5.6250rem);
    --content-width: 85.3750rem;

    /* --- Grid --- */
    --grid-gap: var(--space-24);
    --grid-1: repeat(1, minmax(0, 1fr));
    --grid-2: repeat(2, minmax(0, 1fr));
    --grid-3: repeat(3, minmax(0, 1fr));

    /* --- Page Shell --- */
    --header-height: 52px;
    --shell-bg: #FAFAFA;
    --header-bg: #FFFFFF;
    --header-border: #E8E8E8;

    /* --- Action Buttons --- */
    --action-btn-bg: #FFFFFF;
    --action-btn-border: #E0E0E0;
    --action-btn-text: #444444;
    --popup-bg: #FFFFFF;
    --popup-hover-bg: #F5F5F5;
    --popup-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    --loader-color: #1ea465;

    /* --- Toast --- */
    --toast-bg: #2D3748;
    --toast-text: #FFFFFF;
    --toast-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}


/* ============================================
   Reset & Base
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: var(--text-16);
    color: var(--text-secondary-light);
    background: var(--shell-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}


/* ============================================
   Site Header
   ============================================ */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding-inline: 16px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
}

.site-header__left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.site-header__logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-primary-light);
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}

.site-header__sep {
    color: var(--grey-300);
    font-size: 14px;
}

.site-header__page-name {
    font-size: 13px;
    color: var(--text-secondary-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-header__center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.site-header__right {
    display: flex;
    align-items: center;
    gap: 8px;
}


/* ============================================
   Viewport Switcher
   ============================================ */
.viewport-switcher {
    display: flex;
    align-items: center;
    background: var(--grey-50);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
    border: 1px solid var(--grey-100);
}

.viewport-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--grey-500);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.viewport-btn:hover {
    color: var(--text-primary-light);
}

.viewport-btn.active {
    background: var(--white);
    color: var(--text-primary-light);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.viewport-btn svg {
    flex-shrink: 0;
}


/* ============================================
   Copy Button & Popup
   ============================================ */
.copy-wrapper {
    position: relative;
}

.copy-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--action-btn-bg);
    border: 1px solid var(--action-btn-border);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--action-btn-text);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.copy-btn:hover {
    background: #f9f9f9;
    border-color: #d0d0d0;
}

.copy-chevron {
    margin-left: 2px;
}

.copy-popup {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: var(--popup-bg);
    border-radius: 10px;
    box-shadow: var(--popup-shadow);
    padding: 6px;
    z-index: 110;
}

.copy-popup.show {
    display: block;
}

.popup-option {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 9px 12px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    border-radius: 7px;
    color: #333;
    transition: background 0.12s ease;
}

.popup-option:hover {
    background: var(--popup-hover-bg);
}

.popup-option .icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-right: 10px;
    flex-shrink: 0;
}

.loader {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--loader-color);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-left: auto;
}

.popup-option.loading .loader {
    display: block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}


/* ============================================
   Preview Area
   ============================================ */
.preview-area {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 24px;
    overflow: auto;
}

.preview-frame {
    width: 100%;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.04);
    overflow: hidden;
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.preview-frame.tablet {
    width: 991px;
    max-width: 100%;
}

.preview-frame.mobile {
    width: 390px;
    max-width: 100%;
}


/* ============================================
   Iframe Preview
   ============================================ */
#preview-iframe {
    width: 100%;
    border: none;
    display: block;
    min-height: 400px;
}


/* ============================================
   Toast Notification
   ============================================ */
#toast {
    visibility: hidden;
    position: fixed;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    background: var(--toast-bg);
    color: var(--toast-text);
    padding: 12px 22px;
    border-radius: 8px;
    box-shadow: var(--toast-shadow);
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s, bottom 0.3s;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

#toast.show {
    visibility: visible;
    opacity: 1;
    bottom: 40px;
}


/* ============================================
   Responsive: Hide text labels on small screens
   ============================================ */
@media (max-width: 720px) {
    .viewport-btn span {
        display: none;
    }
    .viewport-btn {
        padding: 6px 8px;
    }
    .site-header__logo span {
        display: none;
    }
    .copy-btn .copy-chevron {
        display: none;
    }
}

@media (max-width: 520px) {
    .site-header__sep,
    .site-header__page-name {
        display: none;
    }
    .preview-area {
        padding: 12px;
    }
}
