/* =============================================
   TWIBBON PKKMB 2026 — Stylesheet
   ============================================= */

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

:root {
    --primary:    #2563eb;
    --primary-dk: #1d4ed8;
    --accent:     #f59e0b;
    --accent-dk:  #d97706;
    --bg:         #f0f4ff;
    --card-bg:    #ffffff;
    --text:       #1e293b;
    --muted:      #64748b;
    --border:     #e2e8f0;
    --radius:     16px;
    --shadow:     0 8px 32px rgba(37, 99, 235, 0.12);
}

body {
    font-family: 'Poppins', 'Segoe UI', sans-serif;
    background: linear-gradient(160deg, #0f2c6b 0%, #1a4fa8 40%, #2176d2 70%, #0e7fc2 100%);
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--text);
    padding: 24px 16px 48px;
}

/* ── Page Wrapper ─────────────────────────── */
.page-wrapper {
    max-width: 520px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ── Header ───────────────────────────────── */
.site-header {
    text-align: center;
    padding-top: 8px;
}

.welcome-text {
    font-family: 'Playfair Display', Georgia, serif;
    font-style: italic;
    font-size: 15px;
    color: #fde68a;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 6px;
    opacity: 0.9;
}

.welcome-univ {
    font-family: 'Poppins', sans-serif;
    font-size: 28px;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #ffffff 0%, #fde68a 50%, #ffffff 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 3s linear infinite;
    text-shadow: none;
    position: relative;
}

.welcome-univ::before,
.welcome-univ::after {
    content: '';
    display: block;
    width: 60px;
    height: 2px;
    background: linear-gradient(to right, transparent, #fde68a, transparent);
    margin: 8px auto;
}

@keyframes shimmer {
    0%   { background-position: 0% center; }
    100% { background-position: 200% center; }
}

.header-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 4px 14px;
    border-radius: 100px;
    margin-bottom: 12px;
}

.site-header h1 {
    font-size: 26px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
    margin-bottom: 6px;
}

.header-sub {
    font-size: 14px;
    color: rgb(255, 255, 255);
}

/* ── Visitor Counter ──────────────────────── */
.visitor-counter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    backdrop-filter: blur(8px);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 100px;
}

.visitor-counter svg {
    opacity: 0.85;
    flex-shrink: 0;
}

#visitorCount {
    color: #fde68a;
    font-size: 15px;
    font-weight: 700;
}

/* ── Card ─────────────────────────────────── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border);
}

/* ── Canvas Area ──────────────────────────── */
.canvas-wrapper {
    position: relative;
    width: 100%;
    background: #dde3f0;
    line-height: 0; /* hilangkan gap bawah canvas */
}

canvas {
    width: 100%;
    height: auto;
    display: block;
    cursor: grab;
    touch-action: pan-y; /* izinkan scroll vertikal, JS handle drag di dalam bingkai */
    position: relative;
    z-index: 1;
}

canvas:active {
    cursor: grabbing;
}

/* ── Controls ─────────────────────────────── */
.controls {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ── Upload Button ────────────────────────── */
.upload-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary);
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    user-select: none;
    width: 100%;
}

.upload-btn:hover {
    background: var(--primary-dk);
}

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

.file-name {
    font-size: 13px;
    color: var(--muted);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Tombol Reset Rotasi ─────────────────── */
.reset-rotate-btn {
    align-self: center;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 100px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.reset-rotate-btn:hover {
    background: var(--border);
    color: var(--text);
}

/* ── Tombol Hapus Foto ────────────────────── */
.reset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    background: transparent;
    color: #dc2626;
    border: 1.5px solid #fca5a5;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 9px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    box-shadow: none;
}

.reset-btn:hover {
    background: #fef2f2;
    border-color: #f87171;
    filter: none;
}

/* ── Zoom Slider ──────────────────────────── */
.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slider-header label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.hint {
    font-size: 12px;
    color: var(--muted);
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 100px;
}

.slider-track {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
}

input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: linear-gradient(to right, var(--primary) 0%, var(--border) 0%);
    border-radius: 100px;
    outline: none;
    cursor: pointer;
    transition: background 0.15s;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid #fff;
    box-shadow: 0 1px 6px rgba(37,99,235,0.35);
    cursor: pointer;
    transition: transform 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid #fff;
    box-shadow: 0 1px 6px rgba(37,99,235,0.35);
    cursor: pointer;
}

/* ── Input Nama ───────────────────────────── */
.input-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.nama-input {
    width: 100%;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: #f8fafc;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.nama-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
    background: #fff;
}

.nama-input.error {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220,38,38,0.1);
}

.nama-input::placeholder {
    color: #cbd5e1;
}

.form-fields {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Download Button ──────────────────────── */
.download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    background: linear-gradient(135deg, var(--accent), #fb923c);
    color: #fff;
    border: none;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    padding: 14px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: filter 0.2s, transform 0.1s;
    box-shadow: 0 4px 16px rgba(245,158,11,0.35);
}

.download-btn:hover {
    filter: brightness(1.08);
}

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

/* ── Tips ─────────────────────────────────── */
.tips {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    background: #f8fafc;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    line-height: 1.5;
}

/* ── Footer ───────────────────────────────── */
.site-footer {
    text-align: center;
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.social-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    width: 100%;
}

.follow-text {
    width: 100%;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    text-align: center;
    margin: 0;
}

.footer-bottom {
    width: 100%;
    text-align: center;
    border-top: 1px solid rgba(255,255,255,0.15);
    padding-top: 12px;
    margin-top: 4px;
    font-size: 12px;
    color: rgb(255, 253, 253);
}

.social-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: filter 0.2s, transform 0.1s;
    white-space: nowrap;
}

.social-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.social-btn:active {
    transform: scale(0.97);
}

.social-btn.instagram {
    background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    color: #fff;
}

.social-btn.tiktok {
    background: #010101;
    color: #fff;
}

/* ── Animasi loading spinner ──────────────── */
@keyframes spin {
    to { transform: rotate(360deg); }
}
.spin {
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

/* ── Responsive ──────────────────────────── */
@media (max-width: 360px) {
    .site-header h1 { font-size: 22px; }
    .controls { padding: 18px; }
    .download-btn { font-size: 14px; }
}

/* ── Galeri Section ───────────────────────── */
.gallery-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.gallery-header {
    text-align: center;
}

.gallery-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}

.gallery-header p {
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    margin-bottom: 8px;
}

.gallery-count {
    display: inline-block;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: #fde68a;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 100px;
}

.gallery-header-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
}

.gallery-refresh-btn {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.3s;
    flex-shrink: 0;
}

.gallery-refresh-btn:hover {
    background: rgba(255,255,255,0.25);
}

.gallery-refresh-btn.spinning svg {
    animation: spin 0.6s linear infinite;
}

/* Grid foto galeri */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.gallery-item {
    position: relative;
    aspect-ratio: 3/4;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255,255,255,0.08);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.gallery-item:hover {
    transform: scale(1.04);
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
    z-index: 2;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.3s;
    position: absolute;
    top: 0; left: 0;
}

.gallery-item img.loading {
    opacity: 0;
}

.gallery-item img.loaded {
    opacity: 1;
}

.gallery-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 100%);
    color: #fff;
    font-size: 9px;
    font-weight: 600;
    text-align: left;
    padding: 12px 6px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.gallery-name span {
    display: block;
    font-weight: 400;
    font-size: 8px;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Loading state galeri */
.gallery-loading {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 32px;
    color: rgba(255,255,255,0.6);
    font-size: 13px;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: #fde68a;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* Kosong */
.gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 32px;
    color: rgba(255,255,255,0.5);
    font-size: 13px;
}

/* Tombol load more */
.load-more-btn {
    width: 100%;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25);
    color: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 11px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.load-more-btn:hover {
    background: rgba(255,255,255,0.22);
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.lightbox img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.lightbox-close:hover {
    background: rgba(255,255,255,0.3);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Galeri Collapse/Expand ───────────────── */
.gallery-collapse-wrapper {
    position: relative;
    overflow: hidden;
    transition: max-height 0.5s ease;
    max-height: 520px; /* tampil 2 baris awal */
}

.gallery-collapse-wrapper.expanded {
    max-height: none;
    overflow: visible;
}

.gallery-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(to bottom, transparent, #1a4fa8);
    pointer-events: none;
    transition: opacity 0.3s;
}

.gallery-collapse-wrapper.expanded .gallery-fade {
    opacity: 0;
}

.gallery-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: rgba(255,255,255,0.15);
    border: 1.5px solid rgba(255,255,255,0.3);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.gallery-toggle-btn:hover {
    background: rgba(255,255,255,0.25);
}

.gallery-toggle-btn svg {
    transition: transform 0.3s;
    flex-shrink: 0;
}

.gallery-toggle-btn.expanded svg {
    transform: rotate(180deg);
}

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

/* ── Kontak Bantuan ───────────────────────── */
.bantuan-text {
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    margin-bottom: 8px;
}

.wa-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #25d366;
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 18px;
    border-radius: 100px;
    margin-bottom: 14px;
    transition: filter 0.2s, transform 0.1s;
    box-shadow: 0 2px 10px rgba(37,211,102,0.35);
}

.wa-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}
