:root {
    --ios-blue: #007AFF;
    --ios-background: #F2F2F7;
    --ios-gray: #8E8E93;
    --ios-border: rgba(60, 60, 67, 0.29);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    background-color: var(--ios-background);
    color: #000;
    height: 100vh;
    display: flex;
    flex-direction: column;
    /* overflow: hidden; */
    max-width: 800px;
    /* Prevents page scrolling */
}

p {
    max-width: 400px;
    text-align: justify;
}

h3 {
    text-align: center;
}

header {
    padding: calc(16px + env(safe-area-inset-top)) 16px 16px;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 100;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(0, 122, 255, 0.1);
    color: var(--ios-blue);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    animation: popIn 0.3s;
}

#description {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #333;
    text-align: justify;
    /* Optional subtle fade-in animation */
    animation: fadeIn 0.3s ease-out;
}

.container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 16px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    max-height: 800px;
    max-height: 90%;
}

#crop-container {
    aspect-ratio: 1/1;
    width: min(90vw, 90vh);
    /* Ensures it fits within viewport width/height */
    height: min(90vw, 90vh);
    /* Ensures it remains a square */
    max-width: 600px;
    /* Prevents it from getting too large on big screens */
    max-height: 600px;
    background: #cfd1dc82;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    touch-action: none;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: auto;
}

.button-wrapper {
    position: relative;
    margin: 0 auto;
    width: 100%;
    max-width: 400px;
    height: 44px;
    min-height: 20px;
    border-radius: 10px;
    background: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    z-index: 1;
}

/* For viewports below 750px, make the button wrappers fixed so they’re always visible */
@media (max-width: 750px) {
    .button-wrapper {
        z-index: 10;
        /* Increase stacking order */
        position: relative;
        /* Ensure it creates its own stacking context */
    }
}

#file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.label {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ios-blue);
    font-size: 17px;
    font-weight: 500;
}

#photo {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: top left;
    transition: opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

#photo.loaded {
    opacity: 1;
}

.button-group {
    display: flex;
    gap: 12px;
    padding: 16px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    position: sticky;
    bottom: 0;
    margin: 0 auto;
    width: 100%;
    max-width: 600px;
    z-index: 1;
}

.btn {
    flex: 1;
    height: 50px;
    border: none;
    border-radius: 12px;
    font-size: 17px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--ios-blue);
    color: white;
}

.btn-secondary {
    background: rgba(0, 122, 255, 0.1);
    color: var(--ios-blue);
}

.btn:disabled {
    opacity: 0.5;
    cursor: default;
}

#support-btn {
    text-decoration: none !important;
}

.btn:hover,
.button-wrapper:hover,
header:hover {
    box-shadow: 0px 6px 15px rgba(0, 0, 0, 0.2);
}


.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.5;
}

.grid-line {
    position: absolute;
    background: white;
}

.grid-line-vertical {
    width: 1px;
    height: 100%;
}

.grid-line-horizontal {
    height: 1px;
    width: 100%;
}

/* Modal popup for Photo Sample */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 12px;
    max-width: 90%;
    max-height: 90%;
    position: relative;
    animation: slideDown 0.3s;
}

.modal-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin-bottom: 10px;
}

.close-btn {
    padding: 8px 12px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    background-color: #ff3a30b9;
    color: white;
    cursor: pointer;
    position: relative;
    width: 100%;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}
