/* Scoop Calendar event tiles on Wara El Mazzika (front-page rail, /events/, artist hubs' Upcoming gigs). Loaded only on
   pages that render tiles (event-tiles.php: wem_tiles_wanted()).
   1. Fonts the tile asks for, self-hosted (OFL, Latin subsets from @fontsource): Fira Sans 400/700/800, Poppins 800.
   2. The calendar's standalone tile stylesheet, copied unchanged from scoop-events-api/tile-contract.css.
      Re-copy it when the calendar's tile rules change.
   3. WEM additions: Arabic glyphs fall back to the site's Almarai instead of a system font. */

@font-face { font-family: "Fira Sans"; src: url("fonts/firasans-400-latin.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Fira Sans"; src: url("fonts/firasans-700-latin.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Fira Sans"; src: url("fonts/firasans-800-latin.woff2") format("woff2"); font-weight: 800; font-style: normal; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Poppins; src: url("fonts/poppins-800-latin.woff2") format("woff2"); font-weight: 800; font-style: normal; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---- 2. tile-contract.css (unchanged) ---------------------------------------------------------------------------- */
/* Scoop Calendar event tile: standalone copy for consumers of /scoop-events/v1/upcoming (waraelmazzika.com).
   Extracted from scoop-events-widget/assets/scoop-events.css (tile layout, image tiles, start time, uniform
   grid, status, tags) with its later overrides folded in. Class names are the calendar's own, so the markup in
   tools/events-api-tiles-contract.md renders the same tile. Copy it; do not hotlink the calendar's stylesheet.
   Re-copy when that file's tile rules change. Fonts: Poppins (title) and Fira Sans (date/city/venue); load them
   or the system fallbacks apply. */

/* The calendar sizes everything border-box (theme-wide). */
.sew-events--tile,
.sew-events--tile * {
    box-sizing: border-box;
}

/* Grid: 3-up, 2-up under 900px, 1-up under 600px. Replace with your own grid if you need to. */
.sew-events--tile .sew-events__list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.sew-events--tile .sew-events__tile {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* The tile. --tile-ink and background-color come inline from tile.ink / tile.colour, placement from tile.vars. */
.sew-events__tile-link {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 26px;
    height: 240px;
    padding: 30px;
    border-radius: 20px;
    overflow: hidden;
    text-decoration: none;
    color: var(--tile-ink, #fff);
    background-color: #444;
}

.sew-events__tile-link:hover,
.sew-events__tile-link:focus-visible {
    text-decoration: none;
    color: var(--tile-ink, #fff);
    filter: brightness(0.94);
}

/* Date column: weekday (or Tonight / Today / Tomorrow) / day / month / time. */
.sew-events__tile-date {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    align-items: flex-start;
    color: var(--tile-ink, #fff);
}

.sew-events__tile-weekday,
.sew-events__tile-month {
    font-family: "Fira Sans", system-ui, arial, sans-serif;
    font-size: 11px;
    font-weight: 400;
    text-transform: uppercase;
    line-height: 1.2;
}

.sew-events__tile-weekday {
    line-height: 19.2px;
}

.sew-events__tile-date.is-imminent .sew-events__tile-weekday {
    font-weight: 800;
    letter-spacing: 0.04em;
}

.sew-events__tile-day {
    font-family: "Fira Sans", system-ui, arial, sans-serif;
    font-size: 30px;
    font-weight: 700;
    line-height: 33px;
}

.sew-events__tile-time {
    font-family: "Fira Sans", system-ui, arial, sans-serif;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    margin-block-start: 6px;
    white-space: nowrap;
}

/* Body: [status/tag labels] / "City · Category" / TITLE / pin + venue. */
.sew-events__tile-body {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
    overflow: hidden;
}

.sew-events__tile-city,
.sew-events__tile-venue {
    font-family: "Fira Sans", system-ui, arial, sans-serif;
    font-size: 12px;
    font-weight: 400;
    text-transform: none;
    color: var(--tile-ink, #fff);
}

.sew-events__tile-city {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sew-events__tile-dot { opacity: .7; margin: 0 2px; }

.sew-events__tile-title {
    font-family: Poppins, sans-serif;
    font-size: 24px;
    font-weight: 800;
    text-transform: uppercase;
    line-height: 28.8px;
    color: var(--tile-ink, #fff);
    overflow-wrap: break-word;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
}

.sew-events__tile-venue {
    gap: 5px;
    min-width: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
}

.sew-events__pin {
    display: inline-block;
    width: 9px;
    height: 12px;
    vertical-align: -1px;
    margin-inline-end: 4px;
}

/* Image tiles (tile.kind = image). tile.vars sets --sd/--xd/--yd/--ed (desktop) and --sm/--xm/--ym/--em (phone):
   the <img> box is the tile times --s, shifted by (1 - s) x position; object-position is the same x / y. Physical
   left/top on purpose: the crop must not mirror on an RTL page. The event colour stays underneath while it loads. */
.sew-events__tile-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    z-index: 0;
}

.sew-events__tile-link--has-image {
    --s: var(--sd, 1);
    --x: var(--xd, .5);
    --y: var(--yd, .5);
    --e: var(--ed, .58);
    color: #fff;
}

.sew-events__tile-link--has-image .sew-events__tile-img {
    inset: auto;
    left: calc((1 - var(--s)) * var(--x) * 100%);
    top: calc((1 - var(--s)) * var(--y) * 100%);
    width: calc(var(--s) * 100%);
    height: calc(var(--s) * 100%);
    max-width: none;
    object-position: calc(var(--x) * 100%) calc(var(--y) * 100%);
    border-radius: 0;
}

/* Editor flip: the picture is mirrored, never the text. */
.sew-events__tile-link--has-image.sew-events__tile-link--flip .sew-events__tile-img {
    left: calc((1 - var(--s)) * (1 - var(--x)) * 100%);
    transform: scaleX(-1);
}

.sew-events__tile-link--has-image .sew-events__tile-date,
.sew-events__tile-link--has-image .sew-events__tile-body {
    position: relative;
    z-index: 2;
}

/* No scrim: white text on a shadow. */
.sew-events__tile-link--has-image .sew-events__tile-date,
.sew-events__tile-link--has-image .sew-events__tile-weekday,
.sew-events__tile-link--has-image .sew-events__tile-day,
.sew-events__tile-link--has-image .sew-events__tile-month,
.sew-events__tile-link--has-image .sew-events__tile-time,
.sew-events__tile-link--has-image .sew-events__tile-title,
.sew-events__tile-link--has-image .sew-events__tile-city,
.sew-events__tile-link--has-image .sew-events__tile-venue {
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,.75), 0 0 10px rgba(0,0,0,.55), 0 0 22px rgba(0,0,0,.35);
}

/* A light, even photo: dark ink on a light halo. */
.sew-events__tile-link--ink-dark .sew-events__tile-date,
.sew-events__tile-link--ink-dark .sew-events__tile-weekday,
.sew-events__tile-link--ink-dark .sew-events__tile-day,
.sew-events__tile-link--ink-dark .sew-events__tile-month,
.sew-events__tile-link--ink-dark .sew-events__tile-time,
.sew-events__tile-link--ink-dark .sew-events__tile-title,
.sew-events__tile-link--ink-dark .sew-events__tile-city,
.sew-events__tile-link--ink-dark .sew-events__tile-venue {
    color: #0d0d0d;
    text-shadow: 0 1px 2px rgba(255,255,255,.7), 0 0 10px rgba(255,255,255,.5), 0 0 22px rgba(255,255,255,.3);
}

/* Status label (cancelled / postponed) and editor tags ("ADE"), above the city line. */
.sew-events__tile-status,
.sew-events__tile-tag {
    align-self: flex-start;
    max-width: 100%;
    margin-bottom: 4px;
    border: 1px solid rgba(0, 0, 0, .35);
    font-family: "Fira Sans", system-ui, arial, sans-serif;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.sew-events__tile-status {
    padding: 3px 10px;
    border-radius: 999px;
    background: #fff;
    color: #9b1c1c;
}

.sew-events__tile-status--postponed {
    background: #ffe28a;
    color: #6b3f00;
}

.sew-events__tile-tag {
    padding: 3px 8px;
    border-radius: 4px;
    background: #e39d1c;
    color: #0d0d0d;
}

.sew-events__tile.is-cancelled .sew-events__tile-link {
    filter: grayscale(.9) brightness(.97);
}

.sew-events__tile.is-cancelled .sew-events__tile-link:hover,
.sew-events__tile.is-cancelled .sew-events__tile-link:focus-visible {
    filter: grayscale(.9) brightness(.9);
}

.sew-events__tile.is-cancelled .sew-events__tile-title {
    text-decoration: line-through;
    text-decoration-thickness: 2px;
}

@media (max-width: 900px) {
    .sew-events--tile .sew-events__list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .sew-events--tile .sew-events__list {
        grid-template-columns: minmax(0, 1fr);
    }
    .sew-events__tile-link {
        height: 200px;
        padding: 20px;
    }
    .sew-events__tile-title {
        font-size: 20px;
        line-height: 24px;
        -webkit-line-clamp: 3;
    }
    .sew-events__tile-link--has-image {
        --s: var(--sm, 1);
        --x: var(--xm, .5);
        --y: var(--ym, .5);
        --e: var(--em, .58);
    }
}

@media (max-width: 400px) {
    .sew-events__tile-title {
        font-size: 17px;
        line-height: 21px;
        hyphens: manual;
    }
}

/* ---- 3. WEM additions ---------------------------------------------------------------------------------------------- */
/* The Latin faces above carry a Latin unicode-range, so Arabic text (Arabic-site labels, Arabic titles) falls through to
   Almarai, the site's Arabic face, instead of a system font. */
.sew-events--tile .sew-events__tile-link { font-family: "Fira Sans", Almarai, "IBM Plex Sans Arabic", system-ui, arial, sans-serif; }
.sew-events--tile :is(.sew-events__tile-weekday, .sew-events__tile-day, .sew-events__tile-month, .sew-events__tile-time, .sew-events__tile-city, .sew-events__tile-venue, .sew-events__tile-tag, .sew-events__tile-status) { font-family: "Fira Sans", Almarai, "IBM Plex Sans Arabic", system-ui, arial, sans-serif; }
.sew-events--tile .sew-events__tile-title { font-family: Poppins, Almarai, "IBM Plex Sans Arabic", sans-serif; }
/* Artist hubs: a gig the API did not return keeps its text row, under the tiles. */
.sew-events--tile + .eventlist { margin-block-start: var(--s4); }
