/* ==========================================================================
   home.css - the home page
   --------------------------------------------------------------------------
   Purpose:     Layout, prayer table, Jumu'ah card, photo, social links, message bar.
   Used by:     index.html only.
   ========================================================================== */

/* ---------- Page layout ---------- */
.app-container {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    padding: 20px 20px 100px 20px; /* bottom padding for ticker */
    min-height: 0;
}

/* Computer: left = logo, prayer table, Jumu'ah, Connect With Us; right = photo, announcements, Visit Us.
   Phone: one column. The column wrappers dissolve (display: contents) and "order" places each block. */
.home-layout {
    display: flex;
    flex-direction: column;
}

.home-col {
    display: contents;
}

@media (min-width: 768px) {
    .app-container {
        max-width: 700px;
        padding: 32px 32px 110px 32px;
    }
}

@media (min-width: 1024px) {
    .app-container {
        max-width: 1180px;
        padding: 48px 40px 120px 40px;
    }

    .home-layout-page .app-container {
        display: block;
    }

    .home-layout {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); /* 50 / 50 */
        column-gap: 40px;
        align-items: start;
    }

    .home-col {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }
}

@media (min-width: 1440px) {
    .app-container {
        max-width: 1320px;
    }
}

@media (max-width: 1023px) {
    .app-container {
        padding-left: max(20px, env(safe-area-inset-left, 0px));
        padding-right: max(20px, env(safe-area-inset-right, 0px));
    }

    .home-layout {
        gap: 24px;
    }

    /* The layout gap alone sets the space between cards */
    .home-layout > .home-col > * {
        margin-top: 0;
        margin-bottom: 0;
    }
}

/* ---------- Logo and date bar ---------- */
.app-header {
    animation: fadeInDown 0.6s ease-out;
}

.datetime-section {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.8s ease-out;
}

/* Date on the left, Next Jama'at on the right, the same width as the prayer table */
.home-hero .datetime-section {
    width: 100%;
    align-items: stretch;
}

.date-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    column-gap: 1rem;
    row-gap: 0.25rem;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    font-family: var(--font-heading);
    font-size: 1.4rem;
    line-height: 1.2;
    color: var(--text-primary);
    text-align: left;
}

.date-bar .gregorian-date {
    font-size: inherit;
    font-weight: 400;
    color: inherit;
    white-space: nowrap;
}

.next-jamaat {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 0.35em;
}

.next-jamaat-label {
    font-weight: 400;
    white-space: nowrap;
}

.next-jamaat-value {
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.app-logo-primary {
    width: min(340px, 82vw);
    height: auto;
    display: block;
}

.home-hero {
    order: 1;
}

.home-hero .app-header {
    padding-top: 8px;
    margin-bottom: var(--logo-clear);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.home-hero .app-logo-primary {
    margin-left: auto;
    margin-right: auto;
    max-width: 100%;
}

@media (min-width: 1024px) {
    .app-header {
        gap: 28px;
    }

    .datetime-section {
        display: flex;
        justify-content: center;
        gap: 40px;
    }

    .home-hero {
        order: 0;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: var(--logo-clear);
        margin-bottom: var(--logo-clear);
    }

    .home-hero .app-header {
        flex: none;
        margin-bottom: 0;
    }

    .app-logo-primary {
        width: 380px;
    }

    .home-hero .datetime-section {
        margin-bottom: 0;
    }
}

@media (min-width: 1440px) {
    .app-logo-primary {
        width: 420px;
    }
}

@media (max-width: 1023px) {
    .home-hero {
        text-align: center;
    }

    .home-hero .datetime-section {
        margin-bottom: 0;
    }
}

@media (max-width: 600px) {
    .date-bar {
        font-size: clamp(0.85rem, 3.75vw, 1.15rem);
        padding: 12px 14px;
        column-gap: 0.6rem;
    }
}

@media (max-height: 500px) and (orientation: landscape) and (max-width: 1023px) {
    .home-hero {
        display: flex;
        justify-content: center;
        text-align: left;
        flex-direction: column;
        align-items: stretch;
        gap: var(--logo-clear);
    }

    .app-logo-primary {
        width: 200px;
    }

    .home-hero .app-header {
        margin-bottom: 0;
    }

    .home-hero .datetime-section {
        flex: none;
    }
}

/* ---------- Prayer table ---------- */
.timetable-section {
    width: 100%;
    animation: fadeInUp 0.8s ease-out;
    order: 2;
}

.timetable-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

/* Names and start times are regular; Iqamah, header and current row are bold */
.timetable-header {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr;
    padding: 16px 20px;
    background: rgba(0,0,0,0.02);
    border-bottom: 2px solid var(--border-color);
    font-family: var(--font-heading);
    font-size: 1.3rem;
    color: var(--text-primary);
    font-weight: 700;
}

.prayer-row {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    transition: background-color 0.3s;
}

.prayer-row:last-child {
    border-bottom: none;
}

.prayer-row.active {
    background-color: var(--row-highlight-bg);
    border-left: 4px solid var(--accent);
    padding-left: 16px;
}

.prayer-row.active .salah-en {
    color: var(--accent);
    font-weight: 700;
}

.prayer-row.active .time-val {
    color: var(--accent);
}

.col-name {
    display: flex;
    flex-direction: column;
}

.salah-en {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    color: var(--text-primary);
    line-height: 1.2;
    font-weight: 400;
}

.salah-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.time-val {
    font-size: 1.2rem;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.sunrise-row {
    background: rgba(38, 79, 39, 0.03);
}

.timetable-card .col-start.time-val {
    font-weight: 400;
}

.timetable-card .col-iqamah.time-val {
    font-weight: 700;
}

.timetable-card .prayer-row.active .time-val {
    font-weight: 700;
}

@media (min-width: 1024px) {
    .timetable-section {
        break-inside: avoid;
        order: 0;
    }
}

@media (max-width: 360px) {
    .timetable-header {
        font-size: 1.1rem;
        padding: 12px 16px;
    }

    .prayer-row {
        padding: 12px 16px;
    }

    .salah-en {
        font-size: 1.2rem;
    }

    .time-val {
        font-size: 1.1rem;
    }
}

/* ---------- Jumu'ah card ---------- */
.jumuah-section {
    width: 100%;
    margin-top: 24px;
    animation: fadeInUp 0.8s ease-out;
    order: 3;
}

.jumuah-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    padding: 24px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.jumuah-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.jumuah-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 14px;
    margin-bottom: 20px;
}

.jumuah-title-wrap {
    display: flex;
    flex-direction: column;
}

.jumuah-title {
    font-size: 1.8rem;
    color: var(--text-primary);
    line-height: 1.1;
    font-family: var(--font-heading);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}

.jumuah-title-sub {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.jumuah-day-badge {
    background: var(--accent);
    color: var(--bg-main);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.jumuah-times-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.khutbah-time-card {
    background: rgba(38, 79, 39, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.jumuah-card:hover .khutbah-time-card {
    background: rgba(38, 79, 39, 0.05);
    border-color: rgba(38, 79, 39, 0.2);
}

.khutbah-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.khutbah-time {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    font-variant-numeric: tabular-nums;
    margin-bottom: 6px;
    text-shadow: 0 0 10px var(--accent-glow);
}

.khutbah-lang-labels {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

@media (min-width: 1024px) {
    .jumuah-section {
        break-inside: avoid;
        order: 0;
    }
}

@media (max-width: 767px) {
    .jumuah-card-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 8px;
    }

    /* Lets the Friday badge sit between the title and the Arabic */
    .jumuah-title-wrap {
        display: contents;
    }

    .jumuah-title {
        order: 1;
        white-space: nowrap;
    }

    .jumuah-day-badge {
        order: 2;
    }

    .jumuah-title-sub {
        order: 3;
        margin-top: 0;
    }
}

@media (max-width: 520px) {
    .khutbah-label {
        font-size: 0.85rem;
        white-space: nowrap;
        letter-spacing: 0.2px;
    }
}

@media (max-width: 360px) {
    .jumuah-title {
        font-size: 1.5rem;
    }
}

@media (hover: none) {
    .jumuah-card:hover {
        transform: none;
    }
}

/* ---------- Mosque photo ---------- */
.mosque-photo-card {
    position: relative;
    margin: 0 0 1rem;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

.photo-welcome {
    position: absolute;
    inset: 0 0 auto 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 22px 20px 56px;
    text-align: center;
    color: #fff;
    background: linear-gradient(to bottom, rgba(23, 50, 24, 0.78) 0%, rgba(23, 50, 24, 0.45) 55%, rgba(23, 50, 24, 0) 100%);
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
    pointer-events: none;
}

.photo-welcome-salaam {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(1.5rem, 4.5vw, 2.1rem);
    line-height: 1.15;
}

.photo-welcome-line {
    font-family: var(--font-heading);
    font-weight: 400;
    font-size: clamp(1.05rem, 3vw, 1.35rem);
    line-height: 1.3;
}

.home-photo-wrap {
    order: 5;
    margin-bottom: 1.5rem;
}

.mosque-photo-card img {
    width: 100%;
    height: 260px;
    object-fit: cover;
    object-position: 50% 62%;
    display: block;
}

.home-photo-wrap .mosque-photo-card {
    margin-bottom: 0;
}

@media (min-width: 1024px) {
    .home-photo-wrap {
        order: 0;
    }

    .mosque-photo-card img {
        height: 440px;
    }
}

@media (min-width: 1440px) {
    .mosque-photo-card img {
        height: 500px;
    }
}

@media (max-width: 520px) {
    .mosque-photo-card img {
        height: 240px;
    }
}

/* ---------- Connect With Us ---------- */
.socials-section {
    margin-top: 35px;
    margin-bottom: 20px;
    animation: fadeInUp 1s ease-out;
    order: 8;
}

.socials-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.social-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.25s ease, background-color 0.25s ease;
}

.social-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.03);
    padding: 8px;
    color: var(--text-secondary);
    transition: background-color 0.25s ease, color 0.25s ease, transform 0.25s ease;
}

.social-icon svg {
    width: 100%;
    height: 100%;
}

.social-name {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.social-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-md);
}

.social-card:hover .social-icon {
    transform: scale(1.1);
}

.social-card.facebook:hover {
    border-color: rgba(24, 119, 242, 0.3);
    background: rgba(24, 119, 242, 0.04);
}

.social-card.facebook:hover .social-icon {
    background: #1877F2;
    color: #ffffff;
}

.social-card.instagram:hover {
    border-color: rgba(225, 48, 108, 0.3);
    background: rgba(225, 48, 108, 0.04);
}

.social-card.instagram:hover .social-icon {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    color: #ffffff;
}

.social-card.youtube:hover {
    border-color: rgba(255, 0, 0, 0.3);
    background: rgba(255, 0, 0, 0.04);
}

.social-card.youtube:hover .social-icon {
    background: #FF0000;
    color: #ffffff;
}

.social-card.twitter-x:hover {
    border-color: var(--text-primary);
    background: rgba(0, 0, 0, 0.04);
}

.social-card.twitter-x:hover .social-icon {
    background: var(--text-primary);
    color: var(--bg-card);
}

@media (min-width: 768px) {
    .socials-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .social-card {
        flex-direction: column;
        text-align: center;
        gap: 10px;
        padding: 20px 12px;
    }
}

@media (min-width: 1024px) {
    .socials-section {
        break-inside: avoid;
        order: 0;
    }

    .socials-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 480px) {
    .socials-grid {
        grid-template-columns: 1fr;
    }

    .social-card {
        padding: 14px 16px;
    }
}

@media (hover: none) {
    /* Touch screens: no "stuck" lift after tapping */
    .social-card:hover {
        transform: none;
    }
}

/* ---------- Message bar (ticker) ---------- */
.ticker-section {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(28, 58, 31, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #F2E8D7;
    padding: 16px 20px;
    text-align: center;
    box-shadow: 0 -4px 15px rgba(0,0,0,0.1);
    z-index: 100;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    padding-left: max(20px, env(safe-area-inset-left, 0px));
    padding-right: max(20px, env(safe-area-inset-right, 0px));
}

.ticker-content {
    font-size: 1rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    animation: fadeIn 1s;
}

@media (min-width: 768px) {
    .ticker-content {
        max-width: 700px;
        margin: 0 auto;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .ticker-section {
        padding-top: 8px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    }
}

@media (min-width: 1024px) {
    .ticker-content {
        max-width: 1180px;
    }
}

@media (min-width: 1440px) {
    .ticker-content {
        max-width: 1320px;
    }
}

@media (max-width: 767px) {
    .ticker-section {
        padding-top: 10px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }

    /* The whole message, on up to two lines, in a bar of fixed height */
    .ticker-content {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        font-size: 0.95rem;
        line-height: 1.35;
        min-height: 2.7em; /* always room for two lines */
        display: flex;
        align-items: center;
        justify-content: center;
    }
}
