@import url("./fonts.css");



/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
    --bg: #ffffff;
    --fg: #05546a;
    --primary: #0c6b82;
    --accent: #e12323;
    --border: #b8d4da;
    --muted: #5a8a96;
    --light: #f0f0f0;
    --radius: 10px;
    --gap: 19px;
    --sidebar-w: 385px;
    --sidebar-min-h: 580px;
    --sidebar-section-min-h: 120px;
    --sidebar-section-extra-min-h: 130px;
    --confetti-red: #af0101;
    --confetti-teal: #0a8d92;
    --confetti-cream: #f3efe4;
    --font-base: "Almoni", sans-serif;
}

/* ── Reset / Base ─────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
}

body {
    font-family: var(--font-base);
    background: var(--bg);
    color: var(--fg);
    direction: rtl;
    line-height: 1.6;
    font-size: 20px;
    height: 100%;
    overflow: hidden;
}

button,
input,
select,
textarea {
    font-family: var(--font-base);
}

#confetti-canvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 20;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}
a {
    color: inherit;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.site-header {
    position: relative;
    padding: 0.75rem var(--gap);
    background: var(--bg);
    background-image: url("../assets/banner-top.jpg?v=19");
    background-size: cover;
    background-position: center;
    height: 30vh;
    z-index: 100;
}

.site-header-logo {
    position: absolute;
    top: 1rem;
    left: 1rem;
    width: clamp(92px, 11vw, 136px);
    height: auto;
    z-index: 1;
}

#share-btn {
    padding: 1rem 0.8rem;
    grid-area: share;
    direction: rtl;
    display: block;
    width: 20%;
    margin: 0 auto;
    border-radius: 50px; /* completely rounded ends but straight on the long sides */
    color: #ffffff;
    border: none;
    cursor: pointer;
    background-color: #0C6B82;
    font-size: 2.1rem;
    font-weight: 700;
    box-shadow: 0 4px 6px #688B94;
    line-height: 1;
    transform-origin: center;
    scale: 1;
    rotate: 0deg;
    animation:
        share-btn-scale 2.85s ease-in-out infinite,
        share-btn-rotate 3.65s ease-in-out infinite;
}

#share-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    background-color: #7aa8b4;
    animation: none;
    scale: 1;
    rotate: 0deg;
}



@keyframes share-btn-scale {
    0%,
    100% {
        scale: 1;
    }

    20% {
        scale: 0.96;
    }

    48% {
        scale: 1.085;
    }

    72% {
        scale: 0.975;
    }
}

@keyframes share-btn-rotate {
    0%,
    100% {
        rotate: 0deg;
    }

    26% {
        rotate: -3deg;
    }

    58% {
        rotate: 3deg;
    }

    82% {
        rotate: -2deg;
    }
}

@media (prefers-reduced-motion: reduce) {
    #share-btn {
        animation: none;
    }
}

/* ── Board Layout (2 columns) ─────────────────────────────────────────────── */
.board-layout {
    display: grid;
    direction: ltr;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: 15px auto 65px minmax(0, 6fr);
    grid-template-areas:
        ". ."
        "share   share"
        "sidebar sort"
        "sidebar feed";
    gap: var(--gap);
    max-width: 1600px;
    margin: 0 auto;
    padding: var(--gap) var(--gap) 0;
    height: calc(100vh - 30vh);
    overflow: hidden;
}

#left-sidebar {
    grid-area: sidebar;
    direction: rtl;
    min-height: 0;
    display: flex;
    justify-content: center;
    overflow: visible;
    scrollbar-width: none;
}
#feed-section {
    grid-area: feed;
    direction: rtl;
    min-height: 0;
    overflow-y: auto;
}

.mobile-cheer-row {
    display: none;
}

#sort-bar {
    grid-area: sort;
    direction: rtl;
}

/* ── Sort Bar ────────────────────────────────────────────────────────────── */
#sort-bar {
    display: flex;
    align-items: center;
    justify-self: left;
    gap: 0.4rem;
    height: 34px;
}

@media (min-width: 901px) {
    #sort-bar {
        align-self: end;
        margin-left: 20px;
    }
}

.sort-label {
    font-size: 19px;
    font-weight: 400;
    color: #9C9C9C;
    white-space: nowrap;
    margin-left: 4px;
}

.sort-buttons {
    display: flex;
}

.sort-btn {
    padding: 3px 18px;
    border: none;
    background: transparent;
    border-radius: 6px;
    color: #0C6B82;
    cursor: pointer;
    font-size: 19px;
    font-family: inherit;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
}

.sort-btn.active {
    background: #10DDEE;
    box-shadow: 0 10px 12px rgba(0,0,0,0.2);
}

.sort-dir-btn {
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--fg);
    cursor: pointer;
    font-size: 1rem;
    font-family: inherit;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sort-dir-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#left-sidebar {
    overflow: visible;
}
.sidebar-shell {
    position: relative;
    width: 100%;
    max-width: 385px;
    height: 100%;
    min-height: min(100%, var(--sidebar-min-h));
    overflow: visible;
}
.sidebar {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    min-height: min(100%, var(--sidebar-min-h));
    background: #05546a;
    box-shadow: 0px 5px 3.4px -4px rgba(0, 0, 0, 0.2);
    border-radius: 10px 10px 0 0;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    padding: 60px 0 0.75rem;
    scrollbar-width: none;
    overflow-x: hidden;
    overflow-y: auto;
}

.sidebar::-webkit-scrollbar {
    display: none;
}

#confetti-static {
    position: absolute;
    /* Shifts up by exactly 81px, scaling proportionally with the width */
    top: 0;
    margin-top: -21.04%;
    /* Shifts left by exactly 72px (when parent is 385px) */
    left: -18.7%;
    width: 146.42%; 
    max-width: none; /* <--- This unlocks the width */
    z-index: 999;
    pointer-events: none;
}

.sidebar-section {
    position: relative;
    width: 328px;
    border-bottom: none;
    border-radius: var(--radius);
    margin: 0;
    padding: 1.5rem 0 0 0;
    text-align: center;
    flex: 1 0 var(--sidebar-section-min-h);
    min-height: var(--sidebar-section-min-h);
}

.sidebar-section-daily {
    background: #0F6982;
    max-height: 120px;
    min-height: 120px;
}
.sidebar-section-weekly {
    background: #1a7f9b;
    max-height: 120px;
    min-height: 120px;
}
.sidebar-section-progress {
    background: #00a9b7;
    min-height: 126px;
    max-height: 126px;
}

.sidebar-section-records {
    background: #e12323;
    min-height: 132px;
    max-height: 132px;
}

.sidebar-section::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 1;
}
.sidebar-section-daily::before {
    background-image: url("../assets/favorites-icon.png?v=19");
}
.sidebar-section-weekly::before {
    background-image: url("../assets/favorites-icon.png?v=19");
}
.sidebar-section-progress::before {
    background-image: url("../assets/reached-goal-icon.png?v=19");
}

.sidebar-section-records::before {
    background-image: url("../assets/stats-icon.png?v=19");
}

.sidebar-section-title {
    font-size: 22px;
    line-height: 1;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 0;
    margin-top: -1px;
    text-align: center;
}

.sidebar-section-daily .sidebar-section-title {
    color: #00EBFF;
 }
.sidebar-section-weekly .sidebar-section-title { 
    color: #00EBFF; 
}
.sidebar-section-progress .sidebar-section-title { 
    color: #05546A; 
}

.sidebar-section-records .sidebar-section-title {
    color: #A3F8FF;
}

.sidebar-item {
    margin-bottom: 0.65rem;
}

/* Side-by-side sub-items in sections 1 & 2 */
.sidebar-section dl {
    display: flex;
    gap: 0;
    margin-bottom: 0;
}
.sidebar-section-daily dl {
    margin-top: 10px;
}
.sidebar-section-weekly dl {
    margin-top: 10px;
}

.sidebar-section-progress dl {
    margin-top: 5px;
}

.sidebar-section dl .sidebar-item {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
    padding: 0 0.75rem;
}
.sidebar-section dl .sidebar-item + .sidebar-item {
    border-right: 1px solid rgba(255, 255, 255);
}
.sidebar-item-label {
    font-size: 19px;
    font-weight: 600;
    line-height: 19px;
    color: rgba(255, 255, 255, 1);
}
.sidebar-item-value {
    font-size: 19px;
    margin-top: 0;
    font-weight: 400;
    line-height: 21.5px;
    color: #fff;
}
.sidebar-section-weekly .sidebar-item-label,
.sidebar-section-progress .sidebar-item-label { line-height: 17px;}


/* Record holders inside sidebar section 4 */
.sidebar-feature-list {
    margin-top: 4px;
}

.sidebar-feature-item {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.1rem;
    flex-wrap: wrap;
    white-space: normal;
    margin-bottom: 0
}

.sidebar-feature-item:last-child {
    margin-bottom: 0;
}

.sidebar-feature-label {
    font-size: 19px;
    color: #ffffff;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 21px;
    flex-shrink: 0;
}

.sidebar-feature-value {
    font-size: 19px;
    font-weight: 400;
    word-break: break-word;
    color: #fff;
    line-height: 21px;
}

.sidebar-empty {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    font-style: italic;
    padding: 0.5rem 0;
}

/* ── Experience Cards ────────────────────────────────────────────────────── */
#cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, 363px);
    gap: var(--gap);
}

.card {
    position: relative;
    width: 363px;
    height: 238px;
    background: #f0f0f0;
    border-radius: var(--radius);
    border: none;
    border-top: 8px solid #fc0000;
    overflow: visible;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}

.card-title-bar {
    position: absolute;
    top: -8px;
    left: 0;
    width: 140px;
    height: 25px;
    background: #fc0000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.5rem;
    z-index: 1;
    border-radius: var(--radius) 0 6px 0;
}

.card-exp-title {
    position: absolute;
    top: -8px;
    left: 0;
    width: min-content;
    min-width: 150px;
    height: 25px;
    background: #fc0000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    z-index: 1;
    border-radius: var(--radius) 0 6px 0;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    direction: rtl;
}

.card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 39px 1rem 0;
    max-height: 168px;
}

.card-story {
    width: 100%;
    max-width: 100%;
    height: 77%;
    max-height: 77%;
    min-height: 0;
    font-size: 20px;
    color: #05546a;
    line-height: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    white-space: pre-line;
    margin-bottom: 0.25rem;
    margin-inline: auto;
    font-weight: 400;
}

.card-read-more {
    font-size: 16;
    color: #80A5AE;
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
    padding: 0;
    display: block;
    text-align: center;
}
.card-read-more:hover { color: #c00; }

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0px 30px 0px 23px;
    margin-top: 13px;
    direction: rtl;
}

.card-author {
    display: flex;
    flex-direction: column;
    text-align: right;
}
.card-author-name,
.card-author-branch {
    font-size: 1rem;
    color: #05546a;
    line-height: 1.1;
}

.card-author-name {
    font-weight: 400;
}

.card-author-prefix {
    font-weight: 600;
}

.card-author-value {
    font-weight: 400;
}

.card-author-branch {
    font-weight: 500;
}

.card-like-btn {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.15rem;
    direction: ltr;
    line-height: 1;
}
.card-like-btn:hover .card-like-icon { transform: scale(1.2); }
.card-like-btn:disabled,
.card-like-btn.liked { cursor: default; opacity: 0.45; }
.card-like-btn:disabled:hover .card-like-icon,
.card-like-btn.liked:hover .card-like-icon { transform: none; }

.card-like-icon {
    font-size: 30px;
    color: #fc0000;
    transition: transform 0.15s;
}

.card-like-count {
    font-size: 16px;
    font-weight: 500;
    color: #05546a;
}

/* ── Share Modal ─────────────────────────────────────────────────────────── */
#share-modal {
    background: rgba(0, 0, 0, 0.52);
}

#share-modal .modal-box {
    width: min(82vw, 42rem);
    max-width: 42rem;
    max-height: min(90vh, 46rem);
    padding: 0;
    border: none;
    border-radius: 10px;
    background: #efefef;
    box-shadow: 4px 7px 10px rgba(0, 0, 0, 0.3);
    overflow: hidden auto;
}

#share-modal #modal-title {
    margin: 0;
    min-height: 4.3rem;
    padding: 1.7rem 4rem 0.2rem;
    background: #fc0000;
    color: #ffffff;
    font-size: 26px;
    font-weight: 600;
    line-height: 1;
    text-align: center;
}

#share-modal .modal-close {
    top: 0;
    left: 0.95rem;
    color: #ffffff;
    font-size: 40px;
    z-index: 2;
}

#share-modal .modal-close:hover {
    color: #ffffff;
    opacity: 0.82;
}

#share-modal #share-form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 1.55rem 2.25rem 2rem;
    direction: rtl;
}

#share-modal .form-group {
    display: grid;
    grid-template-columns: clamp(6.75rem, 24%, 9.5rem) minmax(0, 1fr);
    align-items: center;
    gap: 0.7rem 1rem;
    width: 100%;
    margin-bottom: 0;
}

#share-modal .form-group label {
    margin: 0;
    color: #7d9da8;
    font-size: 1rem;
    font-weight: 600;
    text-align: right;
    line-height: 1.2;
    align-self: center;
}

#share-modal .form-group label[for="f-story"] {
    grid-column: 1 / -1;
    justify-self: start;
    align-self: start;
}

#share-modal .form-group input[type="text"],
#share-modal .form-group input[type="number"],
#share-modal .form-group input[type="file"],
#share-modal .form-group select,
#share-modal .form-group textarea {
    width: 100%;
    min-width: 0;
    padding: 0.75rem 0.9rem;
    border: 1px solid rgba(5, 84, 106, 0.14);
    border-radius: 10px;
    background: #ffffff;
    color: #05546a;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

#share-modal .form-group input[type="text"],
#share-modal .form-group input[type="number"],
#share-modal .form-group input[type="file"],
#share-modal .form-group select {
    grid-column: 2;
}

#share-modal .form-group textarea {
    grid-column: 1 / -1;
    min-height: 10.5rem;
    line-height: 1.45;
}

#share-modal .form-group input:focus,
#share-modal .form-group select:focus,
#share-modal .form-group textarea:focus {
    outline: none;
    border-color: rgba(12, 107, 130, 0.45);
    box-shadow:
        inset 0 0 0 1px rgba(12, 107, 130, 0.18),
        0 0 0 3px rgba(12, 107, 130, 0.12);
}

#share-modal .progress-wrap span {
    display: block;
    font-size: 0.8rem;
    color: #7d9da8;
}

#share-modal .progress-wrap {
    grid-column: 2;
    width: 100%;
    margin-top: 0.1rem;
}

#share-modal .progress-wrap progress {
    width: 100%;
    height: 10px;
    accent-color: #05546a;
}

#share-modal .form-error {
    border-color: rgba(225, 35, 35, 0.28);
    background: #fff4f4;
    color: #b11b1b;
}

#share-modal .form-actions {
    justify-content: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(5, 84, 106, 0.12);
    display: inline-flex;
    flex-direction: row;
}

#share-modal .form-actions .btn {
    min-width: 8rem;
    padding: 0.65rem 1.45rem;
    border-radius: 999px;
    font-weight: 600;
}

#share-modal .btn-primary {
    background: #fc0000;
    border-color: #fc0000;
    color: #ffffff;
}

#share-modal .btn-primary:hover {
    background: #d10000;
    border-color: #d10000;
}

#share-modal .btn-secondary {
    background: #ffffff;
    border-color: rgba(5, 84, 106, 0.18);
    color: #05546a;
}

#share-modal .btn-secondary:hover {
    background: #05546a;
    border-color: #05546a;
    color: #ffffff;
}

/* ── Card Full View Modal ────────────────────────────────────────────────── */
.card-view-meta {
    display: flex;
    gap: 1rem;
    font-size: 1em;
    color: var(--muted);
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.card-view-story {
    font-size: 1em;
    color: var(--fg);
    white-space: pre-wrap;
    margin-bottom: 1rem;
}
.card-view-photo {
    width: 100%;
    border-radius: var(--radius);
    margin-top: 1rem;
    border: 1px solid var(--border);
}

#card-view-modal {
    background: rgba(0, 0, 0, 0.52);
}

#card-view-modal .modal-box {
    width: min(82vw, 42rem);
    max-width: 42rem;
    min-height: 26rem;
    max-height: min(88vh, 40rem);
    padding: 0;
    border: none;
    border-radius: 10px;
    background: #efefef;
    box-shadow: 4px 7px 10px rgba(0, 0, 0, 0.3);
    overflow: hidden auto;
    display: flex;
    flex-direction: column;
}

#card-view-title {
    order: 1;
    margin: 0;
    min-height: 4.3rem;
    padding: 1.7rem 4rem 0.2rem;
    background: #fc0000;
    color: #ffffff;
    font-size: 26px;
    font-weight: 600;
    line-height: 1;
    text-align: center;
}

#card-view-modal .modal-close {
    top: 0;
    left: 0.95rem;
    color: #ffffff;
    font-size: 40px;
    z-index: 2;
}

#card-view-modal .modal-close:hover {
    color: #ffffff;
    opacity: 0.82;
}

#card-view-modal .card-view-story {
    order: 2;
    width: min(78%, 544px);
    margin: 4.35rem auto 0;
    font-size: clamp(1.12rem, 1.55vw, 1.38rem);
    line-height: 1;
    color: #05546a;
    text-align: right;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

#card-view-modal .card-view-photo {
    order: 3;
    width: min(78%, 24rem);
    margin: 1.5rem auto 0;
    border: none;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

#card-view-modal .card-view-meta {
    order: 4;
    width: 100%;
    margin-top: auto;
    padding: 2.2rem 4.25rem 2.35rem;
    display: grid;
    grid-template-columns: auto auto auto 1fr auto;
    align-items: center;
    gap: 0.75rem 1.5rem;
    direction: ltr;
    color: #7d9da8;
    font-size: 0.92rem;
    line-height: 1;
}

#card-view-modal .card-view-meta > span {
    direction: rtl;
    white-space: nowrap;
}

#card-view-date {
    grid-column: 1;
    justify-self: start;
}

#card-view-branch {
    grid-column: 2;
}

#card-view-name {
    grid-column: 3;
}

#card-view-modal .card-view-likes {
    grid-column: 5;
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    color: #05546a;
    direction: ltr;
}

#card-view-modal .card-view-likes:disabled,
#card-view-modal .card-view-likes.liked {
    cursor: default;
    opacity: 0.45;
}

#card-view-modal .card-view-likes:not(:disabled):hover .card-view-like-icon {
    transform: scale(1.12);
}

#card-view-modal .card-view-like-icon {
    color: #ff4d4d;
    font-size: 1.7rem;
    line-height: 1;
    transition: transform 0.15s;
}

#card-view-modal .card-view-like-count {
    font-size: 0.92rem;
    font-weight: 600;
}

/* ── Empty States ────────────────────────────────────────────────────────── */
.empty-state {
    color: var(--muted);
    text-align: center;
    padding: 2rem 0;
    font-style: italic;
}
.empty-state-sm {
    color: var(--muted);
    font-style: italic;
    font-size: 0.85rem;
    padding: 0.3rem 0;
}

/* ── Load More ───────────────────────────────────────────────────────────── */
.load-more-wrap {
    text-align: center;
    margin: 1.25rem 0;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 0.45rem 1.2rem;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--primary);
    cursor: pointer;
    font-size: 1em;
    font-family: inherit;
    transition:
        background 0.15s,
        color 0.15s;
    white-space: nowrap;
    text-align: center;
}
.btn:hover {
    background: var(--primary);
    color: #fff;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover {
    background: #c01010;
    border-color: #c01010;
}
.btn-secondary {
    background: var(--bg);
    color: var(--primary);
}
.btn-danger {
    border-color: #aaa;
    color: #888;
}
.btn-danger:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-sm {
    padding: 0.2rem 0.55rem;
    font-size: 0.78rem;
}
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 1rem;
    padding: 0.1rem 0.3rem;
    line-height: 1;
}
.btn-icon:hover {
    color: var(--primary);
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}
.modal-overlay.open {
    display: flex;
}

.modal-box {
    background: var(--bg);
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 40vw;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}
.modal-box h2 {
    margin-bottom: 1.25rem;
    font-size: 1.5em;
    /*center the title*/
    text-align: center;
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    background: none;
    border: none;
    font-size: 40px;
    cursor: pointer;
    color: var(--muted);
    line-height: 1;
}
.modal-close:hover {
    color: var(--fg);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    html,
    body {
        height: auto;
        min-height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .board-layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "share"
            "sort"
            "feed"
            "cheer"
            "sidebar";
        height: auto;
        overflow: visible;
    }

    .mobile-cheer-row {
        display: block;
        grid-area: cheer;
        direction: rtl;
        padding: 1rem;
        text-align: center;
        font-size: 20px;
        font-weight: 600;
        color: #05546A;
        line-height: 21px;
    }

    #left-sidebar,
    #feed-section {
        min-height: auto;
    }

    #left-sidebar {
        justify-content: stretch;
    }

    
}

@media (max-width: 768px) {
    :root {
        --mobile-header-h: clamp(116px, 22vh, 148px);
        --mobile-share-h: 46px;
        --mobile-share-overlap: 18px;
        --mobile-card-width: 262px;
        --mobile-card-height: 274px;
        --sidebar-section-min-h: 118px;
        --sidebar-section-extra-min-h: 168px;
    }

    body {
        background: linear-gradient(180deg, #e7fbff 0%, #ffffff 42%, #edf8fb 100%);
    }

    .site-header {
        position: sticky;
        top: 0;
        height: var(--mobile-header-h);
        padding: 0;
        z-index: 50;
        box-shadow: 0 8px 18px rgba(5, 84, 106, 0.12);
        background-position: center top;
    }

    .site-header-logo {
        top: 0.7rem;
        left: 0.7rem;
        width: clamp(45px, 13vw, 70px);
    }

    .board-layout {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.35rem;
        width: 100%;
        max-width: none;
        min-height: auto;
        margin-top: calc(-1 * var(--mobile-share-overlap));
        padding: 0 0 0.75rem;
    }
    
    #share-btn {
        width: min(70vw, 230px);
        height: var(--mobile-share-h);
        margin: 0 auto 0.2rem;
        align-self: center;
        display: flex;
        align-items: center;
        justify-content: center;
        position: sticky;
        top: calc(var(--mobile-header-h) - 24px);
        z-index: 60;
        font-size: 1.7rem;
        font-weight: 600;
        box-shadow: 0 10px 20px rgba(5, 84, 106, 0.2);
    }

    #sort-bar {
        position: relative;
        top: auto;
        z-index: 40;
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
        justify-content: center;
        gap: 0.2rem;
        height: auto;
        padding: 0.5rem 0.85rem 0.45rem;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        background: transparent;
        backdrop-filter: none;
        border-bottom: none;
        box-sizing: border-box;
        align-items: center;
        align-content: center;
        
    }

    #sort-bar::-webkit-scrollbar {
        display: none;
    }

    .sort-label {
        flex: 0 0 auto;
        font-size: 0.8rem;
        color: #9C9C9C;
        line-height: 1.2;
    }

    .sort-buttons {
        flex-wrap: nowrap;
        gap: 0.2rem;
    }

    .sort-btn.active {
        box-shadow: none;
    }

    .sort-btn,
    .sort-dir-btn {
        flex: 0 0 auto;
        padding: 0.1rem 0.5rem;
        border-radius: var(--radius);
        font-size: 0.8rem;
    }

    #feed-section {
        width: 100%;
        overflow: visible;
        /* padding: 0 0 0.5rem; */
    }

    #cards-container {
        display: flex;
        direction: rtl;
        gap: 2rem;
        overflow-x: auto;
        overflow-y: hidden;
        align-items: stretch;
        padding: 0 calc((100vw - var(--mobile-card-width)) / 2) 0.35rem;
        scroll-snap-type: x mandatory;
        scroll-padding-inline: calc((100vw - var(--mobile-card-width)) / 2);
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    #cards-container::-webkit-scrollbar {
        display: none;
    }

    .card {
        flex: 0 0 var(--mobile-card-width);
        width: var(--mobile-card-width);
        height: var(--mobile-card-height);
        min-height: 262px;
        max-width: 260px;
        direction: rtl;
        scroll-snap-align: center;
        scroll-snap-stop: always;
        border-radius: 16px;
        overflow: visible;
        box-shadow: 0 2px 2px rgba(5, 84, 106, 0.14);
        justify-content: space-between;
    }

    .card-exp-title {
        font-size: 13px;
        line-height: 12px;
        padding: 8px 13px 3px 13px;
        min-width: 0;
        height: fit-content;
    }

    .card-body {
        padding-top: 27px;
        max-height: 190px;
    }

    .card-story {
        font-size: 15px;
        line-height: 14px;
    }

    .card-read-more {
        margin-top: -8px;
        margin-bottom: 4px;
        font-size: 12px;
    }

    .card-footer {
        position: relative;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        gap: 0.18rem;
        padding: 3px 0.85rem 0.8rem;
        text-align: center;
        margin-top: 0.75rem;
    }

    .card-footer::before {
        content: "";
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - 1.6rem);
        height: 1px;
        background: rgba(5, 84, 106, 0.2);
    }

    .card-author {
        align-items: center;
        text-align: center;
        gap: 0.02rem;
    }

    .card-author-name,
    .card-author-branch {
        font-size: 12px;
        line-height: 10px;
    }

    .card-like-count {
        font-size: 13px;
    }

    .card-like-btn {
        justify-content: center;
        gap: 0.25rem;
        padding: 0;
    }

    .card-like-icon {
        font-size: 1.55rem;
    }

    #left-sidebar {
        position: relative;
        width: 100%;
        z-index: 10;
        overflow: visible;
        padding: 0; /* 0.75rem calc(0.5rem + env(safe-area-inset-bottom)); */
        margin-top: 0.2rem;
    }

    .sidebar-shell {
        width: 100%;
        max-width: 100%;
        height: auto;
        min-height: 0;
    }

    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        min-height: auto;
        max-height: none;
        overflow: visible;
        gap: 0.65rem;
        padding: calc(1.35rem + 50px) 2rem 0.5rem;
        border-radius: 24px 24px 0 0;
        box-shadow: 0 -10px 24px rgba(5, 84, 106, 0.18);
        max-width: 100%;
    }

    .sidebar::before {
        content: "";
        position: absolute;
        top: 0.55rem;
        left: 50%;
        transform: translateX(-50%);
        width: 56px;
        height: 5px;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.45);
    }

    .sidebar-section {
        width: 100%;
        min-height: fit-content;
        padding: 1.1rem 1.4rem 0.8rem;
        border-radius: 7px;
    }
    .sidebar-section-daily {
        max-height: 85px;
        min-height: 85px;
    }
    .sidebar-section-weekly {
        max-height: 85px;
        min-height: 85px;
    }
    .sidebar-section-progress {
        max-height: 102px;
        min-height: 102px;
    }
    .sidebar-section-records {
        max-height: 118px;
        min-height: 118px;
    }

    .sidebar-section::before {
        width: 32px;
        height: 32px;
    }

    .sidebar-section-title {
        margin-top: 1px;
        font-size: 15px;
    }
    .sidebar-section-daily dl {
        margin-top: 5px;
    }
    .sidebar-section-weekly dl {
        margin-top: 5px;
    }
    .sidebar-section-progress dl {
        margin-top: 2px;
    }

    .sidebar-section dl .sidebar-item {
        padding: 0 0.4rem;
    }

    .sidebar-item-label,
    .sidebar-feature-label {
        font-size: 15px;
        line-height: 14px;
    }

    .sidebar-item-value,
    .sidebar-feature-value {
        font-size: 15px;
        line-height: 16px;
    }

    .modal-overlay {
        align-items: flex-start;
        overflow-y: auto;
        padding: 0.75rem;
    }

    .modal-box {
        width: min(100%, 34rem);
        max-width: calc(100vw - 1.5rem);
        max-height: calc(100vh - 1.5rem);
        margin: auto;
        padding: 1rem 1rem 1.25rem;
        border-width: 1px;
        border-radius: 18px;
    }

    .modal-box h2 {
        margin-bottom: 1rem;
        padding-inline: 1.75rem;
        font-size: 1.2rem;
        line-height: 1.25;
    }

    .modal-close {
        top: 0.55rem;
        left: 0.55rem;
        font-size: 2rem;
    }

    #share-modal .modal-box {
        width: 100%;
        max-width: calc(100vw - 1.5rem);
        max-height: calc(100vh - 1.5rem);
        padding: 0;
        border-radius: 12px;
    }

    #share-modal #modal-title {
        min-height: auto;
        padding: 0.95rem 3.15rem 0.9rem;
        font-size: 1.35rem;
    }

    #share-modal .modal-close {
        top: 0.5rem;
        left: 0.7rem;
        font-size: 1.85rem;
    }

    #share-modal #share-form {
        gap: 0.75rem;
        padding: 1rem 1rem 1.15rem;
    }

    #share-modal .form-group {
        grid-template-columns: 5.75rem minmax(0, 1fr);
        gap: 0.65rem 0.85rem;
    }

    #share-modal .form-group label {
        font-size: 0.95rem;
    }

    #share-modal .form-group input[type="text"],
    #share-modal .form-group input[type="number"],
    #share-modal .form-group input[type="file"],
    #share-modal .form-group select,
    #share-modal .form-group textarea {
        padding: 0.7rem 0.8rem;
        font-size: 16px;
        line-height: 1.35;
    }

    #share-modal .form-group textarea {
        min-height: 8.5rem;
    }

    #share-modal .form-actions {
        width: 100%;
        gap: 0.5rem;
        padding-top: 0.85rem;
    }

    #share-modal .form-actions .btn {
        flex: 1 1 0;
        min-height: 44px;
    }

    #card-view-modal {
        padding: 0.75rem;
    }

    #card-view-modal .modal-box {
        width: 100%;
        max-width: calc(100vw - 1.5rem);
        min-height: auto;
        max-height: calc(100vh - 1.5rem);
        border-radius: 12px;
    }

    #card-view-title {
        min-height: auto;
        padding: 0.95rem 3.15rem 0.9rem;
        font-size: 1.35rem;
    }

    #card-view-modal .modal-close {
        top: 0.5rem;
        left: 0.7rem;
        font-size: 1.85rem;
    }

    #card-view-modal .card-view-story {
        width: min(84%, 22rem);
        margin-top: 2.4rem;
        font-size: 1.05rem;
    }

    #card-view-modal .card-view-photo {
        width: min(86%, 20rem);
    }

    #card-view-modal .card-view-meta {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.45rem 1rem;
        padding: 1.5rem 1.2rem 1.3rem;
        direction: rtl;
        font-size: 0.82rem;
    }

    #card-view-modal .card-view-meta > span {
        direction: rtl;
    }

    #card-view-date,
    #card-view-branch,
    #card-view-name,
    #card-view-modal .card-view-likes {
        grid-column: auto;
        justify-self: auto;
    }

    #card-view-modal .card-view-likes {
        width: 100%;
        justify-content: center;
        margin-top: 0.15rem;
    }

    .empty-state {
        padding: 1rem 1rem 1.5rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    :root {
        --mobile-card-width: clamp(260px, 80vw, 260px);
    }

    .modal-overlay {
        padding: 0.5rem;
    }

    .modal-box {
        max-width: calc(100vw - 1rem);
        padding: 0.95rem;
    }

    #share-modal .modal-box {
        max-width: calc(100vw - 1rem);
        padding: 0;
    }

    #share-modal #share-form {
        padding: 0.95rem;
    }

    #card-view-modal .modal-box {
        max-width: calc(100vw - 1rem);
        padding: 0;
    }

    #share-btn {
        width: min(74vw, 228px);
    }

    .card {
        flex-basis: var(--mobile-card-width);
        width: var(--mobile-card-width);
    }

    .card-story {
        font-size: 0.9rem;
    }
}
