/* ============================================
   NEWSPAPER CUTOUT WIDGET FOR NOTION v1.0.0
   ============================================ */

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

body {
    min-height: 100vh;
    background: #d4c9a8;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 28px, rgba(0,0,0,0.03) 28px, rgba(0,0,0,0.03) 29px),
        repeating-linear-gradient(90deg, transparent, transparent 28px, rgba(0,0,0,0.02) 28px, rgba(0,0,0,0.02) 29px);
    font-family: 'EB Garamond', Georgia, serif;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* ============================================
   SETTINGS BUTTON
   ============================================ */

.settings-btn {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

body:hover .settings-btn {
    opacity: 1;
}

.settings-btn:hover {
    background: #ffffff;
    color: #374151;
    transform: rotate(45deg);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.settings-btn:active {
    transform: rotate(45deg) scale(0.95);
}

/* ============================================
   CUTOUT BOARD
   ============================================ */

.cutout-board {
    width: 100%;
    min-height: 100vh;
    padding: 50px 30px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    align-content: center;
    gap: 0;
    position: relative;
}

.cutout-board::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='200' height='200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    pointer-events: none;
}

/* ============================================
   LETTER PIECES
   ============================================ */

.letter-piece {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: default;
    transition: transform 0.15s ease;
    transform-origin: var(--pivot-x, 50%) var(--pivot-y, 14%);
    transform: translate3d(0, var(--ty, 0px), 0) rotate(var(--rot, 0deg));
}

.cutout-board:not(.no-animation) .letter-piece {
    animation: ransomSway var(--sway-dur, 4.8s) steps(1, end) infinite;
    animation-delay: var(--sway-delay, 0s);
}

.cutout-board.no-animation .letter-piece {
    animation: none;
}

.letter-piece:hover {
    transform: translate3d(0, var(--ty, 0px), 0) rotate(var(--rot, 0deg)) scale(1.18) !important;
    z-index: 50 !important;
}

.letter-piece .paper {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.letter-piece .char {
    position: relative;
    z-index: 2;
    line-height: 1;
}

.letter-piece.space {
    width: 18px;
    margin: 0 2px !important;
}

.letter-piece.space .paper {
    display: none;
}

.letter-piece.line-break {
    flex-basis: 100%;
    height: 6px;
}

.letter-piece.line-break .paper {
    display: none;
}

.has-tape::after {
    content: '';
    position: absolute;
    width: 115%;
    height: 9px;
    top: -4px;
    left: -7%;
    background: rgba(255, 235, 150, 0.5);
    transform: rotate(var(--tape-angle, 0deg));
    z-index: 3;
    border-radius: 1px;
    filter: blur(0.2px);
}

@keyframes ransomSway {
    0%,
    8%,
    100% {
        transform: translate3d(0, var(--ty, 0px), 0) rotate(var(--rot, 0deg));
    }
    18%,
    28% {
        transform:
            translate3d(var(--sway-x-right, 2px), calc(var(--ty, 0px) + var(--sway-y-up, -2px)), 0)
            rotate(calc(var(--rot, 0deg) + var(--sway-rot-right, 4deg)));
    }
    40%,
    52% {
        transform:
            translate3d(var(--sway-x-left, -2px), calc(var(--ty, 0px) + var(--sway-y-down, 2px)), 0)
            rotate(calc(var(--rot, 0deg) + var(--sway-rot-left, -4deg)));
    }
    64%,
    74% {
        transform:
            translate3d(var(--sway-x-right-soft, 1px), calc(var(--ty, 0px) + var(--sway-y-up-soft, -1px)), 0)
            rotate(calc(var(--rot, 0deg) + var(--sway-rot-right-soft, 2deg)));
    }
    84%,
    92% {
        transform:
            translate3d(var(--sway-x-left-soft, -1px), calc(var(--ty, 0px) + var(--sway-y-down-soft, 1px)), 0)
            rotate(calc(var(--rot, 0deg) + var(--sway-rot-left-soft, -2deg)));
    }
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
    color: #9a8e7a;
    font-family: 'Special Elite', monospace;
    font-size: 1rem;
    text-align: center;
    padding: 40px 20px;
    letter-spacing: 1px;
    line-height: 1.6;
}

/* ============================================
   SIDEBAR PANEL
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100vh;
    background: #ffffff;
    overflow-y: auto;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.show .modal-container {
    transform: translateX(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 24px 18px;
    border-bottom: 1px solid #f0f0f0;
    position: sticky;
    top: 0;
    background: #ffffff;
    z-index: 10;
}

.modal-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: #1a1a1a;
    font-family: 'Special Elite', monospace;
    letter-spacing: 0.5px;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #374151;
}

.modal-body {
    padding: 8px 0 16px;
}

/* ============================================
   CONFIG SECTIONS
   ============================================ */

.config-section {
    padding: 18px 24px;
    border-bottom: 1px solid #f0f0f0;
}

.config-section:last-child {
    border-bottom: none;
}

.config-section h3 {
    font-size: 0.72rem;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.section-description {
    font-size: 0.8rem;
    color: #9ca3af;
    margin-bottom: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.config-item {
    margin-bottom: 14px;
}

.config-item:last-child {
    margin-bottom: 0;
}

.config-item label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ============================================
   TEXT INPUT
   ============================================ */

.text-input {
    width: 100%;
    padding: 10px 14px;
    font-family: 'Special Elite', monospace;
    font-size: 0.95rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    background: #fafafa;
    color: #1a1a1a;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.5;
}

.text-input:focus {
    border-color: #6b5d4a;
    background: #ffffff;
}

.text-input::placeholder {
    color: #b0a48e;
    font-style: italic;
}

/* ============================================
   SHUFFLE BUTTON
   ============================================ */

.btn-shuffle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Special Elite', monospace;
    font-size: 0.85rem;
    padding: 9px 18px;
    border: 1.5px solid #8a7d6b;
    background: rgba(255, 252, 240, 0.8);
    color: #4a3f32;
    cursor: pointer;
    border-radius: 8px;
    letter-spacing: 0.5px;
    transition: all 0.2s;
    width: 100%;
    justify-content: center;
}

.btn-shuffle:hover {
    background: #4a3f32;
    color: #f5f0e1;
    border-color: #4a3f32;
}

.btn-shuffle:active {
    transform: scale(0.98);
}

.btn-shuffle svg {
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.btn-shuffle:hover svg {
    transform: rotate(180deg);
}

.config-hint {
    margin-top: 8px;
    font-size: 0.75rem;
    color: #9ca3af;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.4;
}

/* ============================================
   PAGE BACKGROUND PRESETS
   ============================================ */

.bg-presets {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.bg-preset {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    background: none;
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.bg-preset:hover {
    border-color: #d1d5db;
    background: #f9fafb;
}

.bg-preset.active {
    border-color: #6b5d4a;
    background: #fef9f0;
}

.preset-preview {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.1);
    display: block;
}

.transparent-bg {
    background-image: repeating-conic-gradient(#d1d5db 0% 25%, #ffffff 0% 50%);
    background-size: 12px 12px;
}

.preset-label {
    font-size: 0.68rem;
    color: #6b7280;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    white-space: nowrap;
}

.custom-color-section {
    margin-top: 4px;
}

.custom-color-label {
    font-size: 0.78rem;
    color: #6b7280;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    margin-bottom: 8px;
    display: block;
}

.custom-color-input-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.custom-color-picker {
    width: 40px;
    height: 38px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    padding: 2px;
    background: white;
}

.custom-color-text {
    flex: 1;
    padding: 8px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.82rem;
    font-family: 'Courier Prime', monospace;
    color: #374151;
    outline: none;
    transition: border-color 0.2s;
}

.custom-color-text:focus {
    border-color: #6b5d4a;
}

.apply-custom-btn {
    padding: 8px 14px;
    border: 1.5px solid #8a7d6b;
    background: transparent;
    color: #4a3f32;
    font-size: 0.82rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.apply-custom-btn:hover {
    background: #4a3f32;
    color: white;
    border-color: #4a3f32;
}

/* ============================================
   URL SECTION
   ============================================ */

.url-container {
    display: flex;
    gap: 8px;
}

.url-input {
    flex: 1;
    padding: 9px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.78rem;
    font-family: 'Courier Prime', monospace;
    color: #6b7280;
    background: #f9fafb;
    outline: none;
    min-width: 0;
}

.copy-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    border: 1.5px solid #8a7d6b;
    background: transparent;
    color: #4a3f32;
    font-size: 0.82rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.copy-btn:hover {
    background: #4a3f32;
    color: white;
    border-color: #4a3f32;
}

.copy-feedback {
    font-size: 0.78rem;
    color: #22c55e;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.3s;
    height: 16px;
}

.copy-feedback.show {
    opacity: 1;
}

/* ============================================
   INSTRUCTIONS
   ============================================ */

.instructions-section {
    background: #fafaf8;
}

.instructions-list {
    list-style: none;
    counter-reset: steps;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.instructions-list li {
    counter-increment: steps;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.82rem;
    color: #4b5563;
    line-height: 1.5;
    margin-bottom: 8px;
}

.instructions-list li:last-child {
    margin-bottom: 0;
}

.instructions-list li::before {
    content: counter(steps);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    min-width: 20px;
    background: #4a3f32;
    color: white;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    margin-top: 1px;
}

.instructions-list code {
    background: #f3f4f6;
    padding: 1px 6px;
    border-radius: 4px;
    font-family: 'Courier Prime', monospace;
    font-size: 0.8rem;
    color: #6b5d4a;
}

/* ============================================
   SCROLLBAR
   ============================================ */

.modal-container::-webkit-scrollbar {
    width: 6px;
}

.modal-container::-webkit-scrollbar-track {
    background: transparent;
}

.modal-container::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.modal-container::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ============================================
   TOGGLE SWITCH
   ============================================ */

.toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toggle-item > label:first-child {
    margin-bottom: 0;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #d1d5db;
    border-radius: 22px;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: #6b5d4a;
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 600px) {
    .modal-container {
        width: 100%;
    }

    .cutout-board {
        padding: 40px 16px;
    }

    .bg-presets {
        gap: 6px;
    }
}
