/* Ruth 18 Photo Gallery - Styles */
/* Based on .pen design */

/* Fonts */
@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Instrument+Serif:ital@0;1&family=Inter:wght@400;500;600;700&display=swap');

/* CSS Variables */
:root {
    --bg-primary: #0A0A0B;
    --bg-secondary: #111113;
    --bg-tertiary: #1A1A1D;
    --bg-quaternary: #2A2A2E;

    --gold-start: #D4AF37;
    --gold-end: #F4D03F;
    --gold-gradient: linear-gradient(135deg, var(--gold-start) 0%, var(--gold-end) 100%);
    --gold-transparent: rgba(212, 175, 55, 0.09);

    --text-primary: #FFFFFF;
    --text-secondary: #CDCDCF;
    --text-tertiary: #A0A0A5;
    --text-quaternary: #808085;
    --text-white-80: rgba(255, 255, 255, 0.8);

    --font-mono: 'DM Mono', monospace;
    --font-serif: 'Instrument Serif', serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input {
    font-family: inherit;
    border: none;
    background: none;
}

/* App Container */
.app {
    max-width: 390px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    background-color: var(--bg-primary);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background-color: var(--bg-secondary);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--gold-gradient);
    border-radius: var(--radius-md);
}

.logo-text {
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--text-primary);
}

.qr-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-full);
}

.qr-hint i {
    color: var(--gold-start);
    font-size: 14px;
}

.qr-hint span {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Header with back button */
.header-back {
    padding: 16px 20px;
    background-color: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: background-color 0.2s;
}

.back-btn:active {
    background-color: var(--bg-quaternary);
}

.back-btn i {
    font-size: 18px;
}

.back-btn span {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.header-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-spacer {
    width: 85px;
}

.gallery-count {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background-color: var(--gold-transparent);
    border-radius: var(--radius-full);
}

.gallery-count i {
    color: var(--gold-start);
    font-size: 12px;
}

.gallery-count span {
    font-size: 12px;
    font-weight: 600;
    color: var(--gold-start);
}

/* Hero Section */
.hero {
    position: relative;
    height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: 40px 24px;
    gap: 16px;
    background-size: cover;
    background-position: center;
}

.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
        rgba(10, 10, 11, 0) 0%,
        rgba(10, 10, 11, 0.87) 30%,
        #0A0A0B 60%
    );
}

.hero > * {
    position: relative;
    z-index: 1;
}

.hero-title {
    font-family: var(--font-serif);
    font-size: 32px;
    font-weight: normal;
    text-align: center;
    color: var(--text-primary);
    width: 100%;
}

.hero-subtitle {
    font-size: 18px;
    font-weight: 500;
    text-align: center;
    color: var(--text-primary);
}

.hero-desc {
    font-size: 14px;
    font-weight: 400;
    text-align: center;
    color: var(--text-white-80);
    width: 100%;
}

/* Actions Section */
.actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px 20px;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 18px 24px;
    border-radius: var(--radius-lg);
    font-size: 16px;
    font-weight: 600;
    transition: transform 0.1s, opacity 0.2s;
    width: 100%;
}

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

.btn-primary {
    background: var(--gold-gradient);
    color: var(--text-primary);
}

.btn-primary i {
    font-size: 24px;
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--bg-quaternary);
}

.btn-secondary i {
    font-size: 24px;
    color: var(--gold-start);
}

.btn-disabled {
    background-color: var(--bg-quaternary);
    color: var(--text-tertiary);
    pointer-events: none;
}

.btn-disabled i {
    color: var(--text-tertiary);
}

/* Recent Photos Section */
.recent-photos {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px 20px;
    background-color: var(--bg-secondary);
}

.recent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.recent-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.recent-count {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-full);
}

.recent-count i {
    color: var(--gold-start);
    font-size: 12px;
}

.recent-count span {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.recent-count-link {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background-color: var(--gold-transparent);
    border-radius: var(--radius-full);
    transition: background-color 0.2s;
}

.recent-count-link:active {
    background-color: rgba(212, 175, 55, 0.2);
}

.recent-count-link i {
    color: var(--gold-start);
    font-size: 12px;
}

.recent-count-link span {
    font-size: 12px;
    font-weight: 600;
    color: var(--gold-start);
}

.photo-grid-home {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
}

.photo-grid-home img {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    border-radius: var(--radius-md);
}

.no-photos {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
}

.no-photos i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.no-photos p {
    font-size: 14px;
}

/* Footer */
.footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px 20px;
    background-color: var(--bg-secondary);
    margin-top: auto;
}

.footer-divider {
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--gold-start) 0%, var(--gold-end) 100%);
    border-radius: 2px;
}

.footer-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-align: center;
}

.footer-date {
    font-size: 12px;
    color: var(--text-quaternary);
    text-align: center;
}

/* Upload Page */
.upload-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 32px 20px;
}

.preview-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    height: 350px;
    background-color: var(--bg-secondary);
    border: 2px dashed var(--bg-quaternary);
    border-radius: var(--radius-xl);
    overflow: hidden;
    position: relative;
}

.preview-area.has-image {
    border-style: solid;
    border-color: var(--gold-start);
}

.preview-area img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.preview-placeholder i {
    font-size: 64px;
    color: var(--text-quaternary);
}

.preview-placeholder .text-main {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-align: center;
}

.preview-placeholder .text-hint {
    font-size: 14px;
    color: var(--text-quaternary);
    text-align: center;
}

.remove-preview {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    color: var(--text-primary);
}

.remove-preview i {
    font-size: 20px;
}

.action-buttons {
    display: flex;
    gap: 12px;
    width: 100%;
}

.action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    border-radius: var(--radius-lg);
    transition: transform 0.1s;
}

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

.action-btn-primary {
    background: var(--gold-gradient);
}

.action-btn-primary i {
    font-size: 28px;
    color: var(--text-primary);
}

.action-btn-primary span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.action-btn-secondary {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--bg-quaternary);
}

.action-btn-secondary i {
    font-size: 28px;
    color: var(--gold-start);
}

.action-btn-secondary span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.name-input {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.name-input label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-tertiary);
}

.name-field {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--bg-quaternary);
    border-radius: 10px;
}

.name-field i {
    font-size: 18px;
    color: var(--text-quaternary);
}

.name-field input {
    flex: 1;
    font-size: 15px;
    color: var(--text-primary);
    outline: none;
}

.name-field input::placeholder {
    color: var(--text-quaternary);
}

.submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 24px;
    border-radius: var(--radius-lg);
    width: 100%;
    font-size: 16px;
    font-weight: 600;
    transition: transform 0.1s, opacity 0.2s;
}

.submit-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.submit-btn:disabled {
    background-color: var(--bg-quaternary);
    color: var(--text-tertiary);
    cursor: not-allowed;
}

.submit-btn:disabled i {
    color: var(--text-tertiary);
}

.submit-btn:not(:disabled) {
    background: var(--gold-gradient);
    color: var(--text-primary);
}

.submit-btn i {
    font-size: 20px;
}

.hint-text {
    font-size: 12px;
    color: var(--text-quaternary);
    text-align: center;
    width: 100%;
}

/* Upload Progress */
.upload-progress {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 24px;
}

.upload-progress.visible {
    display: flex;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background-color: var(--bg-quaternary);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--gold-gradient);
    width: 0%;
    transition: width 0.3s;
}

.progress-text {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Gallery Page */
.gallery-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
    gap: 4px;
}

.gallery-row {
    display: flex;
    gap: 4px;
    height: 120px;
}

.gallery-row img {
    flex: 1;
    min-width: 0;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.gallery-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px;
}

.gallery-empty i {
    font-size: 64px;
    color: var(--text-quaternary);
    opacity: 0.5;
}

.gallery-empty p {
    font-size: 16px;
    color: var(--text-tertiary);
    text-align: center;
}

/* FAB */
.fab-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
}

.fab {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gold-gradient);
    border-radius: 28px;
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.fab:active {
    transform: scale(0.95);
}

.fab i {
    font-size: 28px;
    color: var(--text-primary);
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 14px 24px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    z-index: 1000;
    max-width: 90%;
    text-align: center;
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    border: 1px solid var(--gold-start);
}

.toast.error {
    border: 1px solid #ef4444;
}

/* Loading spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--bg-quaternary);
    border-top-color: var(--gold-start);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Image modal */
.modal {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.visible {
    display: flex;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: var(--text-primary);
}

.modal-close i {
    font-size: 24px;
}

#modalImageContainer {
    width: calc(100vw - 40px);
    height: 70vh;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: var(--radius-md);
}

.modal-info {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Hidden file input */
.hidden-input {
    display: none;
}

/* Responsive adjustments */
@media (min-width: 391px) {
    .app {
        border-left: 1px solid var(--bg-quaternary);
        border-right: 1px solid var(--bg-quaternary);
    }
}

/* Safe area for iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .footer,
    .upload-content,
    .fab-container {
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }
}
