/* =========================================================
   BASE ENGINE
========================================================= */

.screen-engine {
    width: 100%;
    box-sizing: border-box;
    padding: 14px;
}

/* =========================================================
   PREVIEW MODE
========================================================= */

.screen-engine__preview {
    width: 100%;
    aspect-ratio: 16 / 9;

    border-radius: 16px;

    position: relative;
    overflow: hidden;

    cursor: pointer;

    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: rgba(50, 50, 93, 0.25) 0px 6px 12px -2px, rgba(0, 0, 0, 0.3) 0px 3px 7px -3px;

    transition: none;
}

/* =========================================================
   PREVIEW CONTROLS LAYOUT (SAFE ZONE)
========================================================= */

.screen-engine__controls {
    display: grid;
    gap: 16px;
    margin-top: 16px;

    width: 100%;
    box-sizing: border-box;
}

/* =========================================================
   CARD BASE
========================================================= */

.screen-engine__card {
    background: #fff;
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 16px;
    
    box-shadow: rgba(50, 50, 93, 0.25) 0px 6px 12px -2px, rgba(0, 0, 0, 0.3) 0px 3px 7px -3px;
  
    padding: 16px;

    display: flex;
    flex-direction: column;
    gap: 12px;

    text-align: left;

    width: 100%;
    box-sizing: border-box;
}

/* =========================================================
   CARD TITLE
========================================================= */

.screen-engine__card-title {
    font-size: 1rem;
    font-weight: 700;
    color: #111;

    letter-spacing: 0.2px;
}

/* =========================================================
   CARD INTERNAL LAYOUT
========================================================= */

.screen-engine__control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;

    width: 100%;
    box-sizing: border-box;
}

.screen-engine__control-group label {
    font-size: 0.85rem;
    color: rgba(0,0,0,0.65);
}

/* =========================================================
   COLOR PICKER
========================================================= */

.screen-engine__color-picker-wrapper {
    width: 100%;
}

.screen-engine__color-picker {
    width: 100%;
    height: 56px;

    display: block;

    padding: 0;
    margin: 0;

    background: transparent;
    border: 1px solid rgba(0,0,0,0.06);
    outline: none;

    cursor: pointer;

    appearance: none;
    -webkit-appearance: none;

    box-sizing: border-box;
}

.screen-engine__color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
    border-radius:0px;
    overflow: hidden;
}

.screen-engine__color-picker::-webkit-color-swatch {
    border: none;
    border-radius:0px;
}

/* =========================================================
   HEX INPUT + COPY
========================================================= */

.screen-engine__hex-wrapper {
    width: 100%;
    max-width: 100%;

    display: flex;
    align-items: center;
    gap: 6px;

    box-sizing: border-box;
}

.screen-engine__hex-input {
    flex: 1;
    min-width: 0;
  
    height: 38px;
    padding: 0 6px;

    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.12);

    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 16px;

    outline: none;
    box-sizing: border-box;
}

.screen-engine__hex-input:focus {
    border-color: rgba(0,0,0,0.3);
}

.screen-engine__copy-hex {
    height: 38px;
    padding: 0 6px;

    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.08);

    background: #fafafa;
    color: rgba(0,0,0,0.7);

    cursor: pointer;

    font-size: 12px;
    font-weight: 500;
}

/* =========================================================
   SELECT + NUMBER INPUTS
========================================================= */

.screen-engine__select,
.screen-engine__number-input {
    width: 100%;
    height: 42px;

    padding: 0 6px;

    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.12);

    font-size: 16px;
    background: #fff;

    box-sizing: border-box;
}

.screen-engine__select {
    max-width: 100%;
}

/* =========================================================
   DIMENSIONS ROW
========================================================= */

.screen-engine__dimensions-row {
    display: flex;
    align-items: center;
    gap: 10px;

    width: 100%;
}

.screen-engine__dimension-separator {
    flex-shrink: 0;

    font-size: 1rem;
    font-weight: 600;

    color: rgba(0,0,0,0.45);
}

.screen-engine__input-wrapper {
    flex: 1;
    min-width: 0;
    position: relative;
    box-sizing: border-box;
}

.screen-engine__input-wrapper .screen-engine__number-input {
    padding-right: 42px;
}

.screen-engine__input-suffix {
    position: absolute;
    top: 50%;
    right: 12px;

    transform: translateY(-50%);

    font-size: 0.85rem;
    color: rgba(0,0,0,0.5);

    pointer-events: none;
    user-select: none;
}

/* =========================================================
   DOWNLOAD BUTTON
========================================================= */

.screen-engine__download-button {
    width: 100%;
    max-width: 100%;

    height: 46px;

    border: none;
    border-radius: 12px;

    background: #111;
    color: #fff;

    font-weight: 600;
    font-size: 0.95rem;

    letter-spacing: 0.2px;

    cursor: pointer;
}

.screen-engine__download-button:hover {
    opacity: 0.92;
}

/* =========================================================
   FULLSCREEN BASE STATE (shared)
========================================================= */

.screen-engine--fullscreen {
    position: fixed;
    inset: 0;

    width: 100vw;
    height: 100vh;

    z-index: 999999;

    background: var(--screen-color, #000);

    margin: 0;
    padding: 0;

    overflow: hidden;
}

/* =========================================================
   DESKTOP NATIVE FULLSCREEN MODE
========================================================= */

.screen-engine--native-fullscreen {
    height: 100vh;
}

.screen-engine--native-fullscreen .screen-engine__preview {
    width: 100%;
    height: 100vh;

    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;

    overflow: hidden;
}

/* =========================================================
   iOS FULLSCREEN MODE
========================================================= */

.screen-engine--ios-fullscreen {
    height: 100vh;
    height: 100dvh;
    height: var(--vh, 100dvh);

    background: var(--screen-color, #000);
}

.screen-engine--ios-fullscreen .screen-engine__preview {
    width: 100%;
    height: 100%;

    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;

    overflow: hidden;
}

/* =========================================================
   CONTROLS ALWAYS HIDDEN IN FULLSCREEN
========================================================= */

.screen-engine--fullscreen .screen-engine__controls {
    display: none !important;
}

/* =========================================================
   UI ELEMENTS
========================================================= */

.screen-engine__hover-text,
.screen-engine__fullscreen-icon {
    position: absolute;
    color: white;
    text-shadow:1px 1px 0 #000,-1px -1px 0 #000,1px -1px 0 #000,-1px 1px 0 #000,1px 1px 0 #000;
    z-index: 2;
    transition: opacity 0.2s ease;
}

.screen-engine__hover-text {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.screen-engine__fullscreen-icon {
    right: 16px;
    bottom: 16px;
}

.screen-engine--ui-hidden .screen-engine__hover-text,
.screen-engine--ui-hidden .screen-engine__fullscreen-icon {
    opacity: 0;
    pointer-events: none;
}

.screen-engine--cursor-hidden,
.screen-engine--cursor-hidden * {
    cursor: none !important;
}

/* =========================================================
   SAFETY OVERRIDE
========================================================= */

.screen-engine--fullscreen .screen-engine__preview {
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

/* =========================================================
   iOS FULLSCREEN HARD RESET FIX
========================================================= */

.screen-engine--ios-fullscreen {
    position: fixed;
    inset: 0;

    width: 100vw;
    height: 100vh;
    height: 100dvh;
    height: var(--vh, 100dvh);

    overflow: hidden;
    display: block;

    touch-action: none;
}

.screen-engine--ios-fullscreen .screen-engine__preview {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    margin: 0;
    padding: 0;

    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;

    transform: none !important;
    -webkit-transform: translateZ(0);
}

.screen-engine__hover-text,
.screen-engine__fullscreen-icon {
    z-index: 10;
}

.screen-engine__shortcuts {
    width: 100%;
    box-sizing: border-box;

    margin-top: 10px;
    margin-bottom: 6px;

    display: flex;
    justify-content: center;
    align-items: center;
}

/* inner content */
.screen-engine__shortcuts-content {
    font-size: 0.8rem;
    line-height: 1.4;

    color: rgba(0, 0, 0, 0.55);
    text-align: center;

    max-width: 100%;
    padding: 0 6px;

    letter-spacing: 0.1px;

    /* keeps it readable but light */
    font-weight: 500;
}

/* optional visual grouping helper (if we use separators like ·) */
.screen-engine__shortcuts-content span {
    display: inline-block;
}

/* subtle emphasis for key labels (optional JS can wrap keys in <strong>) */
.screen-engine__shortcuts-content strong {
    font-weight: 600;
    color: rgba(0, 0, 0, 0.75);
}

/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 480px) {

    .screen-engine__dimensions-row {
        flex-direction: column;
        align-items: stretch;
    }

    .screen-engine__dimension-separator {
        text-align: center;
    }
}

/* MOBILE OPTIMIZATION */
@media (max-width: 480px) {

    .screen-engine__shortcuts {
        margin-top: 8px;
        margin-bottom: 4px;
    }

    .screen-engine__shortcuts-content {
        font-size: 0.75rem;
        line-height: 1.35;
        padding: 0 4px;
    }
}

/* iOS Safari fix */

@supports (-webkit-touch-callout: none) {
    .screen-engine--ios-fullscreen {
        height: -webkit-fill-available;
    }
}