:root {
    /* Color Variables */
    --text: #ecf0f1;
    --text-secondary: #ecf0f166;
    --bg: #1a1a1a;
    --success: #27ae60;
    --error: #e74c3c;
    /* Shadow Variables */
    --shadow-light: rgba(0, 0, 0, 0.2);
    --shadow-medium: rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: light) {
    :root {
        --text: #1a1a1a;
        --text-secondary: #1a1a1a66;
        --bg: #ecf0f1;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background: var(--bg);
}

body {
    font-family: "Georgia", sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: transparent;
    max-width: 800px;
    width: 100%;
}

h1 {
    position: relative;
    text-align: center;
    color: var(--text);
    margin-bottom: 30px;
    font-size: 9em;
}

a, a:visited {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    font-style: oblique;
}

.canvas-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    perspective: 1000px; /* Enable 3D perspective for flip effect */
    height: 400px; /* Fixed height to prevent layout shifts */
}

.canvas-flip-container {
    position: relative;
    width: 320px; /* Accommodate canvas + borders */
    height: 350px;
    transform-style: preserve-3d;
    transition: transform 0.8s ease-in-out;
}

.canvas-flip-container.flipped {
    transform: rotateY(180deg);
}

.canvas-front, .canvas-back {
    position: absolute;
    width: 100%;
    min-height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.canvas-back {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transform: rotateY(180deg);
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    border: 1px dashed var(--accent-primary);
    padding: 20px;
    box-shadow: 0 8px 16px var(--shadow-medium);
    text-align: center;
}

.canvas-back .btn {
    font-size: 18px;
    padding: 15px 30px;
    margin-top: 10px;
}

.canvas-back .message {
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 20px;
    font-size: 16px;
    line-height: 1.4;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 600;
}

input, textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--bg-primary);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    background: var(--canvas-bg);
    color: var(--text-secondary);
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

textarea {
    min-height: 120px;
    resize: vertical;
    /* font-family: monospace; */
}

.btn {
    background: var(--text);
    color: var(--bg);
    border: none;
    padding: 12px 24px;
    margin-top: 10px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: transform 0.2s ease;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.result {
    margin-top: 20px;
    padding: 15px;
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    border-radius: 8px;
    display: none;
    color: var(--text);
}

.result.show {
    display: block;
}

#error-container {
    position: fixed;
    bottom: -100px;
    left: 50%;
    padding: 8px 16px;
    transform: translateX(-50%);
    z-index: 10;
    background: var(--bg);
    border: var(--text) 1px dashed;
    color: var(--error);
    transition: bottom 0.5s ease;
}

#error-container.enabled {
    bottom: 20px;
}

.key-display {
    background: var(--bg);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 15px;
    font-family: monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
    color: var(--text-primary);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.htmx-request .loading {
    display: inline-block;
}

.cards-holder {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 30px;
}

@media (max-width: 768px) {
    .cards-holder {
        flex-direction: column;
        align-items: center;
    }
}

/* Section flip container styles (similar to canvas flip container) */
.section-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    perspective: 1000px; /* Enable 3D perspective for flip effect */
}

.section-flip-container {
    position: relative;
    width: 320px; /* Match canvas container width */
    height: 350px; /* Match canvas container height */
    transform-style: preserve-3d;
    transition: transform 0.8s ease-in-out;
}

.section-flip-container.flipped {
    transform: rotateY(180deg);
}

.section-front, .section-back {
    position: absolute;
    width: 100%;
    min-height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.section-front {
    padding: 20px;
    background: var(--bg);
    border: 1px dashed var(--text);
    box-shadow: 0 8px 16px var(--bg);
}

.section-back {
    position: absolute;
    transform: rotateY(180deg);
    background: var(--bg);
    border: 1px dashed var(--text);
    padding: 20px;
    box-shadow: 0 8px 16px var(--bg);
    text-align: center;
}

.section-back .message {
    color: var(--text);
    text-align: center;
    margin-bottom: 20px;
    font-size: 16px;
    line-height: 1.4;
}

.section-front h2 {
    position: absolute;
    top: 0px;
    left: 0px;
    border-radius: 0 0 0 0;
    color: var(--bg);
    background: var(--text);
    font-size: 3em;
    text-align: left;
    padding: 0px 20px 0px 20px;
}

.section-front h2 span {
    opacity: 0.6;
}

.section-front p {
    text-align: center;
}

.section-front .form-group {
    width: 100%;
}

.section-front form {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.section-back .result {
    background: transparent;
    border: none;
    display: block;
    margin-top: 20px;
    padding: 0;
}

.section-back .result h3 {
    color: var(--text-primary);
    margin-bottom: 15px;
}

.tip {
    margin-top: 20px;
    padding: 16px;
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
}

.footer {
    margin-top: 30px;
    text-align: center;
    color: var(--text-secondary);
}

/* Utility classes to replace inline styles */
.hidden {
    display: none !important;
}

.section-subtitle {
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.copy-encrypted-btn {
    margin-top: 10px;
}
