/* =======================================================
   Profile Page Specific Styles
   - Contains all styles exclusive to the profile page.
   - General styles are in a separate CSS file.
   ======================================================= */

/* -------------------------------------------------------
   1. Profile Layout
------------------------------------------------------- */
.profile-container {
    width: 100%;
    margin: 0;
    padding: 0;
}
.profile-main {
    margin-top:2rem;
    margin-bottom:4rem;
}
/* -------------------------------------------------------
   2. Header Section
------------------------------------------------------- */
/* Header picture background */
.header-picture {
    width: 100%;
    height: 20rem;
    background-size: cover;
    background-position: center center;
    background-color: #eee;
    background-image: url('https://touchgrass.network/cdn/img/profile-header/placeholder.jpg');
    opacity: 1;
    position: relative;
    z-index: 1;
}
/* Dark overlay on header picture */
.header-picture::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.2); /* Darken by 30% */
    z-index: 2;
}

/* -------------------------------------------------------
   3. Profile Picture & Username
------------------------------------------------------- */
/* Profile picture with drop shadow and brightness */
.profile-picture {
    width: 14rem;
    height: 14rem;
    position: absolute;
    top: 13rem;
    left: calc(50% - 7rem - 4px);
    border: none;
    border-radius: 50%;
    background-size: cover;
    background-position: center center;
    background-color: #ccc;
    background-image: url('https://touchgrass.network/cdn/img/pfp/placeholder.jpg');
    filter: brightness(120%);
    filter: drop-shadow(0px 0px 40px rgba(0,0,0,0.3));
    z-index: 1800;
}
/* Overlay effect on profile picture */
.profile-picture::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.1); /* Darken by 10% */
    z-index: 1;
    border-radius: 100%;
    cursor: pointer;
}
/* Username overlay on header */
.header-username {
    position: absolute;
    width: 100%;
    text-align: center;
    top: 8rem;
    color: #fff;
    font-size: 3rem;
    z-index: 2000; 
    font-weight: 200;
}

/* Edit icon for header picture */
.header-picture-edit-icon {
    top: 18.5rem !important;
    right: 1rem !important;
    left: auto !important;
    z-index: 1000; /* Ensure the edit icon is above the overlay */
    cursor: pointer;
}

/* Generic edit icon (used for profile picture or elsewhere) */
.edit-icon {
    text-decoration: none;
    display: block;
    background-color: #fff;
    width: 2.8rem;
    height: 2.8rem;
    border-radius: 50%;
    position: absolute;
    opacity: 1;
    top: 10.5rem;
    left: 10.5rem;
    z-index: 1000;
    text-align: center;
    line-height: 2.3rem;
    font-size: 3rem;
    cursor: pointer;
    box-shadow: 1px 3px 4px rgba(0, 0, 0, 0.1); /* Shadow pointing south-east */
}
.edit-icon i {
    font-size: 1.5rem;
    line-height: 2.8rem;
    color:#000;
}

/* -------------------------------------------------------
   4. Popups & Modal Overlays
------------------------------------------------------- */
/* General popup overlay */
.popup {
    position: fixed;
    width: 100%;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    font-family: 'Arial', sans-serif;
}
/* Popup content container */
.popup-content {
    background-color: #f9f9f9;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    position: relative;
    width: 40rem;
    top: 15rem;
    left: calc(50% - 20rem);
    animation: popupIn 0.3s ease forwards;
}
/* Popup animation */
@keyframes popupIn {
    from {
        opacity: 0;
        transform: translateY(0);
    }
    to {
        opacity: 1;
        transform: translateY(-10%);
    }
}
/* Close button for popups */
.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 20px;
    cursor: pointer;
    color: #333;
}

/* Profile popup overlay */
.profile-popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    min-height: 100vh;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 9000;
    cursor: pointer;
    overflow: hidden;
    left: 0;
    right: 0;
}
/* Profile popup content */
.profile-popup-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: min(800px, 90vw);
    max-height: 90vh;
    width: auto;
    height: auto;
    padding: 10px;
    box-sizing: border-box;
    overflow: hidden;
}
/* Responsive image in profile popup */
.profile-popup-content img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    max-width: 100%;
    max-height: 85vh;
    display: block;
    margin: auto;
}
/* Profile picture cropper overlay */
.profile-cropper-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 5, 0.75);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 9500;
}
.profile-cropper-overlay.profile-cropper-visible {
    display: flex;
}
.profile-cropper-content {
    width: min(480px, 92vw);
    max-width: 520px;
    border-radius: 18px;
    background: #fff;
    padding: 1.5rem;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
    position: relative;
    text-align: center;
}
.profile-cropper-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #444;
}
.profile-cropper-subtitle {
    margin: 0.25rem 0 1rem;
    color: #555;
    font-size: 0.95rem;
}
.profile-cropper-box {
    width: min(360px, 80vw);
    aspect-ratio: 1 / 1;
    margin: 0 auto 1rem;
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background-color: #f6f6f6;
    overflow: hidden;
    position: relative;
    cursor: grab;
    touch-action: none;
}
.profile-cropper-box.dragging {
    cursor: grabbing;
}
.profile-cropper-box img {
    position: absolute;
    top: 0;
    left: 0;
    user-select: none;
    pointer-events: none;
    will-change: transform;
}
.profile-cropper-guides {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(0deg, rgba(255, 255, 255, 0.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.3) 1px, transparent 1px);
    background-size: calc(100% / 3) calc(100% / 3);
    mix-blend-mode: lighten;
}
.profile-cropper-zoom {
    display: block;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #666;
    margin-bottom: 0.4rem;
}
.profile-cropper-zoom input[type="range"] {
    width: 100%;
    margin-top: 0.35rem;
    accent-color: #111;
}
.profile-cropper-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}
.profile-cropper-button {
    border-radius: 999px;
    padding: 0.65rem 1.5rem;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.profile-cropper-button:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
}
.profile-cropper-cancel:hover {
    background: #f5f5f5;
}
.profile-cropper-confirm {
    background: #111;
    color: #fff;
    border-color: #111;
}
.profile-cropper-confirm:hover {
    background: #000;
}
@media (max-width: 480px) {
    .profile-cropper-content {
        padding: 1.25rem;
    }
    .profile-cropper-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .profile-cropper-button {
        width: 100%;
        text-align: center;
    }
}
/* Close button for profile popup */
.profile-popup-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 44px;  /* Larger touch target */
    height: 44px; /* Larger touch target */
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #333;
    transition: background-color 0.2s;
    z-index: 9001; /* Ensure it's always on top */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

/* -------------------------------------------------------
   5. Form Elements & Error Messages
------------------------------------------------------- */
form {
    display: flex;
    flex-direction: column;
}
form label {
    margin-bottom: 10px;
    color: #333;
}
form input[type="file"] {
    margin-bottom: 20px;
}
.error-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #ff4444;
    color: white;
    padding: 1rem 2rem;
    border-radius: 4px;
    z-index: 10000;
    max-width: 80%;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    white-space: pre-line;
}

/* -------------------------------------------------------
   6. Profile Introduction & Editing
------------------------------------------------------- */
#intro-textarea {
    width: calc(100% - 10rem);
    border-radius: 0;
    float: left;
    font-family: inherit;
    font-size: 1rem;
    border: none;
    border-bottom: 2px solid rgba(200,100,100,.3);
    background-color: transparent;
    padding: 5px;
    resize: none;
    margin: 0;
    display: block;
    margin-top: 3rem;
}
#save-intro-button {
    float: left;
    width: 1rem;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    display: block;
    margin-top: 3rem;
    margin-left: .5rem;
    cursor: pointer;
}
#edit-intro-button {
    float: left;
    width: 1rem;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    display: block;
    margin-top: 3rem;
    margin-left: .5rem;
    cursor: pointer;
}
#intro-display {
    width: calc(100% - 10rem);
    border-radius: 0;
    cursor: pointer;
    float: left;
    font-family: inherit;
    font-size: 1rem;
    border: none;
    border-bottom: 1px solid rgba(0,0,0,.3);
    background-color: transparent;
    padding: 5px;
    resize: none;
    min-height: 40px;
    margin: 0;
    display: block;
    margin-top: 3rem;
    padding-top: 5px;
    line-height: 1.4rem;
}
.intro-pencil {
    float: right;
    display: block;
    margin-right: -40px;
    margin-top: -5px;
    font-size: 1.5rem;
}

/* -------------------------------------------------------
   7. Profile Links
------------------------------------------------------- */
.profile-links {
    margin-top: 2.5rem;
}
#links-form {
    margin-left: 10rem;
    width: calc(100% - 10rem);
}
#links-container {
    display: inline;
}
.add-link-button {
    border: none;
    background: none;
    cursor: pointer;
    display: inline-block;
    vertical-align: .5rem; /* less is more */
}
.add-link-button i {
    font-size: 1.5rem;
    line-height: 2.8rem;
}
.link-input {
    background: none;
    border: none;
    border-radius: 0;
    padding-top: .3rem;
    padding-left: 1rem;
    font-family: Montserrat, 'Segoe UI', sans-serif;
    float: left;
}
.save-link-button,
.edit-link-button,
.remove-link-button {
    background: none;
    border: none;
    cursor: pointer;
    margin-left: .5rem;
    float: left;
}
.save-link-button {
    margin-top: -.3rem;
}
.edit-link-button,
.remove-link-button {
    margin-top: -.4rem;
    margin-left: 0;
    padding-right: 0;
}
.remove-link-button {
    padding-left: 0;
    color: rgb(200,100,0);
    margin-right: 1rem;
}
.saved-link {
    float: left;
    width: auto;
    padding: .5rem 5rem .5rem 1rem;
    margin-right: -4rem;
    text-decoration: none;
    font-weight: bold;
}
.saved-link:link,
.saved-link:visited {
    color: rgba(0,50,150,1);
}
.saved-link:hover,
.saved-link:active {
    color: rgba(0,50,150,.8);
}
.link-item {
    width: auto;
    display: inline-block;
    height: 30px;
    border-radius: 2rem;
    background-color: rgba(0,0,0,.05);
    clear: both;
    margin-right: .5rem;
    margin-bottom: .4rem;
}
.link-item:hover {
    background-color: rgba(0,0,0,.08);
}

/* -------------------------------------------------------
   8. "What I'm Upto" Block
------------------------------------------------------- */
.profile-upto {
    width: 100%;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 32px;
    padding-bottom: 80px;
    position: relative;
    background-color: rgba(0,0,0,.02);
    padding-top: 3.5rem;
}
.upto-title {
    border-bottom: 1px solid rgba(0,0,0,.1);
    background-color: rgba(0,0,0,.05);
    padding: 1rem 0 1rem 0;
    margin: 0 !important;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    text-align: center;
    border-radius: 32px 32px 0 0;
}
.upto-options {
    padding-bottom:3rem;
}

/* -------------------------------------------------------
   Book Cover & Tooltip Styles
------------------------------------------------------- */
#upto-section {
    position: relative;
}
/* Upto list container */
.upto-book-list {
    position: relative;
    height: auto;
    width: auto;
    height: 220px;
    margin: 0;
    padding: 0;
    overflow: visible;
    left: -2rem;
}
.upto-book-cover {
    width: 120px;
    height: 190px;
    background-size: cover;
    background-position: center;
    background-color: #e0e0e0;
    border-radius: 8px;
    border: 1px solid #777;
    position: absolute !important;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center left;
    box-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 10px;
    overflow: visible;
    background-image: none;
    left: 0;
    cursor: pointer;
    z-index: 1;
}
.upto-book-cover.has-cover {
    background-image: var(--cover-url);
}
.upto-book-cover .upto-book-fallback-title {
    font-family: "Times New Roman", serif;
    font-size: 14px;
    text-align: center;
    color: #333;
    margin: 0;
    line-height: 1.2;
}
.upto-book-cover .upto-book-fallback-author {
    font-family: "Times New Roman", serif;
    font-size: 12px;
    font-style: italic;
    text-align: center;
    color: #666;
    margin: 10px 0 0 0;
}
/* Hide fallback content when cover is loaded */
.upto-book-cover.has-cover .upto-book-fallback-title,
.upto-book-cover.has-cover .upto-book-fallback-author {
    display: none;
}
.upto-book-cover:hover {
    filter: brightness(100%); /* Remove whitewash on hover */
    z-index: 10; /* Bring to front on hover */
}
.upto-book-cover:hover .tooltip {
    display: block;
}

.tooltip .tooltip-title {
    font-size: 15px;
    margin: 0;
    line-height: 1.2;
}
.tooltip .tooltip-author {
    font-size: 13px;
    font-style: italic;
    margin: 0.3rem 0 0 0;
    opacity: 0.9;
}

/* -------------------------------------------------------
   9. Media Queries
------------------------------------------------------- */
/* Mobile styles (max-width: 768px) */
@media (max-width: 768px) {
    .profile-popup-content {
        width: 95vw;
        max-width: 100%;
        z-index: 50000000;
        padding: 5px;
    }
    .profile-popup-close {
        top: 10px;
        right: 10px;
        z-index: 50000001;
    }
    html, body {
        max-width: 100%;
        overflow-x: hidden;
    }
    #intro-textarea,
    #intro-display {
        width: 100%;
        margin-top: 8rem;
    }
    #save-intro-button,
    #edit-intro-button {
        margin-top: 1rem;
    }
    #links-form {
        margin-left: 0;
        width: 100%;
    }
}

/* Additional mobile styles for "What I'm Upto" & book covers */
@media (max-width: 768px) {
    .upto-book-cover {
        width:90px;
        height:145px;
    }
    .upto-options {
        padding: 0rem .5rem 2rem .5rem;
    }
    .upto-book-list {
        position: relative;
        width: 160px;
        overflow: visible;
        height:200px;
        scrollbar-width: thin;
    }
    .upto-book-list.expanded {
        overflow-x: scroll;
        position: relative;
        padding-right: -100px;
        width: calc(100% + 4rem);
    }
    /* Initial stacked state for mobile */
    .upto-book-list:not(.expanded) .upto-book-cover {
        position: absolute !important;
        transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    }
    /* Expanded state for mobile */
    .upto-book-list.expanded .upto-book-cover {
        transform: scale(1) translateZ(0) !important;
        filter: brightness(100%) contrast(100%) !important;
        top: 0 !important;
        box-shadow: 0 5px 15px rgba(0,0,0,0.2) !important;
        transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    }
    /* Position books when expanded */
    .upto-book-list.expanded > div:nth-child(1) .upto-book-cover {
        left: calc(0px + 2rem) !important;
    }
    .upto-book-list.expanded > div:nth-child(2) .upto-book-cover {
        left: calc(120px + 2rem) !important;
    }
    .upto-book-list.expanded > div:nth-child(3) .upto-book-cover {
        left: calc(240px + 2rem) !important;
    }
    .upto-book-list.expanded > div:nth-child(4) .upto-book-cover {
        left: calc(360px + 2rem) !important;
    }
    .upto-book-list.expanded > div:nth-child(5) .upto-book-cover {
        left: calc(480px + 2rem) !important;
    }
    .upto-book-list.expanded > div:last-child .upto-book-cover {
        margin-right: 140px; /* Add space after last book */
    }
    /* Book hover/active state on mobile */
    .upto-book-list.expanded .upto-book-cover:active {
        transform: scale(1.1) translateX(-5px) !important;
        z-index: 100 !important;
        box-shadow: 0 10px 40px rgba(0,0,0,0.3) !important;
    }
}

/* Desktop specific styles (min-width: 769px) */
@media (min-width: 769px) {
    .upto-book-cover.expanded .tooltip {
        display: block;
    }
    .upto-book-list.expanded .upto-book-cover.expanded .tooltip {
        display: block;
        opacity: 1;
    }
    .upto-book-cover {
        cursor: pointer;
    }
    .upto-book-cover.expanded {
        z-index: 100;
    }
    .upto-book-cover.expanded .tooltip {
        display: block;
        opacity: 1;
    }
    .upto-book-list.expanded .upto-book-cover {
        transform: scale(1) translateZ(0) !important;
        filter: brightness(100%) contrast(100%) !important;
        top: 0 !important;
        box-shadow: 0 5px 15px rgba(0,0,0,0.2) !important;
    }
    .upto-book-list.expanded > div:nth-child(1) .upto-book-cover {
        left: calc(0px + 2rem) !important;
    }
    .upto-book-list.expanded > div:nth-child(2) .upto-book-cover {
        left: calc(160px + 2rem) !important;
    }
    .upto-book-list.expanded > div:nth-child(3) .upto-book-cover {
        left: calc(320px + 2rem) !important;
    }
    .upto-book-list.expanded > div:nth-child(4) .upto-book-cover {
        left: calc(480px + 2rem) !important;
    }
    .upto-book-list.expanded > div:nth-child(5) .upto-book-cover {
        left: calc(640px + 2rem) !important;
    }
    .upto-book-list.expanded .upto-book-cover.expanded {
        transform: scale(1.1) translateX(-5px) !important;
        z-index: 100 !important;
        box-shadow: 0 10px 40px rgba(0,0,0,0.3) !important;
    }
}

/* -------------------------------------------------------
   10. Overrides & Additional Styles
------------------------------------------------------- */
/* Remove outline on intro textarea and link inputs */
#intro-textarea,
#intro-textarea:focus,
.link-input,
.link-input:focus {
    outline: none !important;
}

/* -------------------------------------------------------
   12. Global Add Button, Book Details & Review Section
------------------------------------------------------- */
/* Global position for add button */
#global-add-upto {
    position: absolute;
    bottom: 15px !important;
    top: auto !important;
    right: 15px !important;
    left: auto !important;
    margin: 0 !important;
}
/* Global add button (duplicate definition with updated values) */
.add-upto-item-global {
    background: #007ACC;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1rem;
    transition: transform 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.add-upto-item-global:hover {
    transform: scale(1.1);
}
.add-upto-item-global .material-symbols-outlined {
    color: #fff;
    font-size: 24px;
}
.add-upto-item-global i {
    font-size: 1.5rem;
    line-height: 2.8rem;
}
/* Book details header */
.upto-book-details-header {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}
.upto-book-details-header img {
    width: 150px;
    height: 225px;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
.upto-book-info {
    flex: 1;
}
/* Book review section */
.upto-book-review-section {
    margin-top: 20px;
}
#upto-book-review-textarea {
    width: 100%;
    min-height: 150px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 10px;
    font-family: inherit;
}
#upto-book-review-display {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 4px;
    position: relative;
}
#edit-upto-book-review-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
}
