@font-face {
    font-family: 'MosesText';
    font-weight: 400;
    src: url('../assets/fonts/MosesText_Inter-Regular.otf?v=9275aca6') format('opentype');
}
@font-face {
    font-family: 'MosesText';
    font-weight: 700;
    src: url('../assets/fonts/MosesText_Inter-Bold.otf?v=770b9b85') format('opentype');
}
@font-face {
    font-family: 'MosesText';
    font-weight: 500;
    src: url('../assets/fonts/MosesText_Inter-Medium.otf?v=22fa8d06') format('opentype');
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
:root {
    --night:        #00182F;
    --blue:         #526BDB;
    --text-dark:    #03122B;
    --text-mid:     #505B73;
    --border:       #E4E8F0;
    --bg-teams:     #EEF2FB;
    --shadow-card:  0 10px 20px rgba(203,203,203,0.4);
    --card-radius:  8px;
    --card-h-mob:   103px;
    --card-w-mob:   334px;
    --card-h-desk:  85px;
    --card-w-desk:  325px;
}
.cal {
    font-family: 'MosesText', Arial, sans-serif;
    direction: rtl;
    background: white;
    height: 100%;
}
/* --- Mobile Main --- */
.cal__mobile-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 7px 0 0;
    background: white;
    border-radius: 0 0 10px 10px;
    box-shadow: inset 0 -2px 4px rgba(0,0,0,0.25);
}
.cal__mobile-header { padding: 5px; width: var(--card-w-mob); }
.cal__mobile-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--night);
    text-align: right;
    line-height: 1.5;
}
.cal__mobile-title--teams {
    padding: 8px 15px 4px;
}
.cal__mobile-cards {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    padding-bottom: 20px;
}
/* --- Cards --- */
.cal__card {
    width: var(--card-w-mob);
    height: var(--card-h-mob);
    border-radius: var(--card-radius);
    border: 1px solid var(--border);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    background-size: cover;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    outline: none;
}
.cal__card-body {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    transform: translateY(0);
    transition: transform 0.2s ease;
}
.cal__card-action-btn {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 3;
    background: var(--night);
    color: white;
    padding: 7px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-family: 'MosesText', Arial, sans-serif;
    font-size: 13px;
    transform: translateY(100%);
    transition: transform 0.2s ease;
}
.cal__card:hover .cal__card-action-btn,
.cal__card:focus-visible .cal__card-action-btn {
    transform: translateY(0);
}
.cal__card:hover .cal__card-body,
.cal__card:focus-visible .cal__card-body {
    transform: translateY(-14px);
}
.cal__card:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.cal__card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.35) 0%, rgba(0,0,0,0.3) 100%);
    z-index: 1;
    pointer-events: none;
}
.cal__card-label {
    position: relative;
    z-index: 2;
    color: white;
    font-family: 'MosesText', Arial, sans-serif;
    font-weight: 700;
    font-size: 20px;
    text-align: center;
    line-height: 1.2;
    white-space: nowrap;
    pointer-events: none;
}
/* Calendar icon pill — mobile only. Half-pill on right edge, navy bg matching Figma */
.cal__card-icon-wrap {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 35px;
    height: 31px;
    background: var(--night); /* #00182f */
    border-radius: 90px 0 0 90px; /* half-pill: rounded left, flush right */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 4px 4px 8px;
    z-index: 2;
    pointer-events: none;
}
.cal__card-icon {
    width: 18px;
    height: 18px;
    display: block;
    object-fit: contain;
    pointer-events: none;
}
/* Each card gets its own background image (place files in assets/) */
.cal__card--all      { background-image: url('assets/card-bg-all.png?v=a8e821c7');      background-size: cover; background-position: center; }
.cal__card--knockout { background-image: url('assets/card-bg-knockout.png?v=db902c4e'); background-size: cover; background-position: center; }
.cal__card--teams    { background-image: url('assets/card-bg-teams.png?v=41fdf987');    background-size: cover; background-position: center; }
/* --- Debug URL overlay (visible only when ?debug in URL) --- */
.cal__debug-url {
    font-size: 10px;
    font-family: monospace;
    color: #fff;
    background: rgba(0,0,0,0.75);
    padding: 2px 6px;
    border-radius: 4px;
    word-break: break-all;
    margin-top: 6px;
    direction: ltr;
    text-align: left;
}
/* --- Mobile teams view --- */
.cal__mobile-teams { display: none; background: white; }
.cal__back {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 5px;
    padding: 12px 15px;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'MosesText', Arial, sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
}
.cal__back:hover { opacity: 0.8; }
.cal__back-icon {
    width: 30px;
    height: 30px;
    background: var(--blue);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
/* --- Teams grid scroll wrapper (forces scrollbar to right in RTL) --- */
.cal__teams-grid-scroll {
    direction: ltr;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}
/* --- Teams grid (mobile base) --- */
.cal__teams-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 10px 15px 15px;
    direction: rtl;
    overflow-y: visible;
    max-height: none;
}
/* --- Team card --- */
.cal__team-card {
    background: linear-gradient(138.814deg, #EBF0F4 0%, #CED4DA 100%);
    border-radius: var(--card-radius);
    overflow: hidden;
    cursor: pointer;
    position: relative;
    box-shadow: 0 2px 5px rgba(0,0,0,0.08);
    display: block;
    text-decoration: none;
    color: inherit;
}
.cal__team-card:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.cal__team-card__body {
    padding: 10px 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 100%;
    transform: translateY(0);
    transition: transform 0.2s ease;
}
.cal__team-card__flag             { width: 36px; height: auto; border-radius: 0; display: block; }
.cal__team-card__flag-placeholder { width: 36px; height: 26px; background: #ccc; border-radius: 0; }
.cal__team-card__name {
    font-family: 'MosesText', Arial, sans-serif;
    font-size: 13px;
    color: var(--text-mid);
    text-align: center;
    line-height: 1.3;
    word-break: break-word;
}
.cal__team-card__btn {
    background: var(--night);
    color: white;
    padding: 7px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-family: 'MosesText', Arial, sans-serif;
    font-size: 12px;
    /* absolute at bottom — hidden below card, slides up on hover */
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    transform: translateY(100%);
    transition: transform 0.2s ease;
}
.cal__team-card:hover .cal__team-card__btn,
.cal__team-card:focus-visible .cal__team-card__btn {
    transform: translateY(0);
}
.cal__team-card:hover .cal__team-card__body,
.cal__team-card:focus-visible .cal__team-card__body {
    transform: translateY(-14px);
}
.cal__team-card__btn-icon { width: 13px; height: 13px; flex-shrink: 0; }
/* --- Mobile team card (horizontal — pill right, name centred) --- */
.cal__team-card--mob {
    background: #F7F9FC;
    height: 55px;
    border-radius: var(--card-radius);
    box-shadow: 0.5px 0.5px 4px 0 rgba(0,0,0,0.18);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    display: block;
    transition: opacity 0.15s ease;
}
.cal__team-card--mob:hover  { opacity: 0.85; }
.cal__team-card--mob:active { opacity: 0.7;  }
.cal__team-card--mob:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
/* Flag image flush with right edge, vertically centred */
.cal__team-card__mob-flag {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 41px;
    height: 31px;
    object-fit: cover;
    border-radius: 0;
    padding-right: 5px;
    display: block;
    pointer-events: none;
}
/* Name: vertically centred, sits to the left of the flag */
.cal__team-card--mob .cal__team-card__name {
    position: absolute;
    right: 47px;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    color: var(--text-dark);
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0;
}
/* Hide desktop elements inside mobile card */
.cal__team-card--mob .cal__team-card__body,
.cal__team-card--mob .cal__team-card__btn { display: none; }
/* --- State: teams active on mobile --- */
.cal--teams-active .cal__mobile-main  { display: none; }
.cal--teams-active .cal__mobile-teams { display: flex; flex-direction: column; height: 100%; }
/* --- Desktop top (hidden on mobile) --- */
.cal__desktop-top { display: none; }
.cal__teams       { display: none; }

/* ===== DESKTOP >= 768px ===== */
@media (min-width: 720px) {
    .cal__mobile-main  { display: none !important; }
    .cal__mobile-teams { display: none !important; }
    .cal__desktop-top {
        display: block;
        background: var(--bg-teams);
        border-radius: var(--card-radius);
    }
    .cal__desktop-container {
        background: white;
        border-radius: var(--card-radius);
        padding: 24px 40px 32px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    .cal__desktop-title {
        width: 100%;
        max-width: 700px;
        font-weight: 700;
        font-size: 26px;
        color: var(--text-dark);
        text-align: right;
        line-height: 1.5;
    }
    .cal__desktop-buttons { display: flex; gap: 20px; justify-content: center; width: 100%; max-width: 700px; }
    .cal__desktop-buttons .cal__card       { width: var(--card-w-desk); height: var(--card-h-desk); flex-shrink: 0; }
    .cal__desktop-buttons .cal__card-label { font-size: 25px; }
    /* Icon wrapper is mobile-only — desktop cards use the hover-reveal btn instead */
    .cal__desktop-buttons .cal__card-icon-wrap { display: none; }
    .cal__teams { display: block; width: 100%; max-width: 700px; }
    .cal__teams-header {
        display: flex;
        align-items: baseline;
        justify-content: flex-start;
        gap: 10px;
        padding-bottom: 12px;
    }
    .cal__teams-title { font-weight: 700; font-size: 16px; color: var(--text-dark); }
    .cal__teams-note  { font-size: 13px; color: var(--text-mid); }
    .cal__teams-grid-scroll {
        direction: ltr;
        overflow-y: auto;
        overflow-x: hidden;
        max-height: 320px;
        width: 100%;
        padding-right: 10px;
    }
    .cal__teams-grid {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 15px;
        padding: 0;
        direction: rtl;
        overflow-y: visible;
        max-height: none;
    }
    .cal__team-card        { width: auto; min-width: 0; height: 105px; direction: rtl; }
    .cal__team-card__flag  { width: 41px; }
    .cal__team-card__name  { font-size: 14px; }
    .cal__team-card__btn   { font-size: 13px; }
    .cal__team-card__btn-icon { width: 15px; height: 15px; }
}

/* ===== NARROW EMBED — 300px wide widget ===== */
@media (max-width: 360px) {
    :root {
        --card-w-mob: 274px;
        --card-h-mob: 85px;
    }
    .cal__mobile-header { width: var(--card-w-mob); }
    .cal__card-label    { font-size: 15px; white-space: normal; padding-inline: 38px; }
    /* Icon pill: slightly smaller to stay proportional */
    .cal__card-icon-wrap { width: 30px; height: 26px; }
    .cal__card-icon      { width: 15px; height: 15px; }
}
