/*
 * The public site: what the old theme's stylesheet (theme/theme.css, which dresses the pages written with the old
 * site's HTML) lacks. Written for this application: where the old HTML had a style attribute, a class here (the
 * public pages allow no inline styles); the carousels and the menu without scripts; the events calendar.
 */
:root {
    --orange: #fa940c;
    --peach: #ffc79e;
    --text: #2d2c2b;
    --light: #f6f3f2;
    --border: #d9d4d2;
    --radius: 0.77em;
    --body-font: davis-sans, sans-serif;
    --title-font: finalsix, sans-serif;
}

/* The fonts, as the old site set them in its <head> */
html, body {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-family: davis-sans, sans-serif;
    font-weight: 400;
    font-style: normal;
}
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { font-family: finalsix, sans-serif; font-weight: 800; font-style: normal; }

/* The images have their size (the page does not jump while they load), which the old HTML did not give: their height
   follows their width unless the theme says otherwise (no specificity, so that any rule of the theme wins) */
:where(img[width][height]) { height: auto; }
/* A graphic whose SVG had no size of its own was as wide as its place (Template::themeImage()) */
:where(.theme-fluid) { width: 100%; }
/* On the phone the theme leaves the map's width to the image (width: unset), which for its SVG meant as wide as its
   place, and for the PNG would mean its pixels */
@media screen and (max-width: 799px) {
    .home .map .map-img.theme-fluid { width: calc(100% + 1.5em); }
}

.visually-hidden, .screen-reader-text {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* The colours of the categories (Database\Categories::COLORS): the old HTML had style="--article-color: …" */
.article-color-red { --article-color: var(--color-red); }
.article-color-yellow { --article-color: var(--color-yellow); }
.article-color-teal { --article-color: var(--color-teal); }
.article-color-green { --article-color: var(--color-green); }
.article-color-purple { --article-color: var(--color-purple); }
.article-color-orange { --article-color: var(--color-orange); }

/* The backgrounds the old HTML set with style attributes */
.home .volunteer .volunteer-decoration { background-image: url(theme/volunteer-decoration.png); }
.history-slide-1 { background-image: url(theme/history-slide-1.png); }
.history-slide-2 { background-image: url(theme/history-slide-2.png); }
.history-slide-3 { background-image: url(theme/history-slide-3.png); }
.history-slide-4 { background-image: url(theme/history-slide-4.png); }
.history-slide-5 { background-image: url(theme/history-slide-5.png); }
.history-slide-6 { background-image: url(theme/history-slide-6.png); }
.history-slide-7 { background-image: url(theme/history-slide-7.png); }
.year-entries-grid { grid-template-columns: repeat(1, 1fr); }

/* The 50 of the anniversary, when the number is another one */
.big-number { font-size: 6em; line-height: 1; color: var(--orange); }

/* The carousels before site.js moves them (or without it): they scroll sideways, the buttons hidden */
.swiper:not(.swiper-initialized) > .swiper-wrapper { overflow-x: auto; scroll-snap-type: x mandatory; }
.swiper:not(.swiper-initialized) > .swiper-wrapper > .swiper-slide { scroll-snap-align: start; }
.swiper:not(.swiper-initialized) .swiper-button-prev,
.swiper:not(.swiper-initialized) .swiper-button-next,
.swiper:not(.swiper-initialized) .swiper-pagination { display: none; }
.swiper-pagination-bullet { border: 0; padding: 0; }

/* The moments of the history without scripts: the dialog opens where a decade's button leads */
.history-years-dialog:not([open]):has(:target) { display: block; position: fixed; inset: 5vh 0 0; z-index: 1000; margin: 0 auto; }
/* Its close button needs the script: without it, the browser's back button closes it */
.history-years-dialog:not([open]) .dialog-close { display: none; }

/* The phone's menu without scripts: open while its button or one of its links has the focus */
@media screen and (max-width: 799px) {
    html:not(.menu-script) header#main-header:has([data-menu-button]:focus) .right.desktop-right,
    html:not(.menu-script) header#main-header .right.desktop-right:focus-within { transform: translate(0); }
}

/* The footer's logos are links */
footer#main-footer .footer-logos img { height: auto; }

/* An address written whole in a text (a link to it, or a long e-mail) goes on more lines instead of out of its column */
footer#main-footer .cell, section.map .data { overflow-wrap: anywhere; }

/* The share button of the device's own sharing, until site.js shows it */
.share-btn[hidden] { display: none; }

.no-articles { text-align: center; }

/* The pages of the events and the error page (month.phtml, event.phtml, error.phtml) */
.page-section { padding: 1.5em 1.5em 2.5em; }
.error-page { text-align: center; }

/* Events calendar */
.page-section > h1 { text-align: center; margin-bottom: 0.6em; }
.month-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1em; }
.month-nav h2 { text-align: center; }
.month-step { font-size: 0.7em; font-weight: bold; text-decoration: none; }
.month-step:last-child { text-align: right; }
.month-step:hover { text-decoration: underline; }
.this-month { text-align: center; font-size: 0.7em; }
.month-flyer { text-align: center; margin: 0 0 1em; }

.month-grid { width: 100%; table-layout: fixed; border-collapse: collapse; margin: 1em 0 2em; font-size: 0.6em; }
.month-grid th { padding: 0.5em; text-align: left; font-weight: bold; border-bottom: 2px solid var(--text); }
.month-grid td { height: 7em; padding: 0.4em; vertical-align: top; border: 1px solid var(--border); }
.month-grid td > time { display: block; font-weight: bold; margin-bottom: 0.3em; }
.month-grid td.other-month { background: var(--light); color: #8a8584; }
.month-grid td.past > time { color: #8a8584; }
.month-grid td.today > time {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 1.8em; height: 1.8em; border-radius: 50%; background: var(--orange); color: #fff;
}
.grid-event {
    display: block;
    margin-bottom: 0.3em;
    padding: 0.25em 0.4em;
    border-radius: 0.4em;
    background: var(--peach);
    font-weight: bold;
    line-height: 1.2;
    text-decoration: none;
    overflow-wrap: anywhere;
}
.grid-event:hover { background: var(--orange); }
.grid-time { display: block; font-weight: normal; }

.events-title { text-align: center; margin-bottom: 0.8em; }
/* Month names are lowercase in Italian, but start with a capital letter at the beginning of a title */
.month-name { display: inline-block; }
.events-title::first-letter, .month-name::first-letter { text-transform: uppercase; }
.page-section .event-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 1em; }
.no-events { text-align: center; }
.export { text-align: center; margin-top: 2em; }

/* An event as a card, as on the previous site: the date on orange, the rest on peach */
.page-section .event-card { display: flex; flex-direction: column; background: var(--peach); border-radius: var(--radius); overflow: hidden; }
.page-section .event-card .date { margin: 0; padding: 20px; background: var(--orange); font-weight: bold; line-height: 1; }
.page-section .event-card .date time { display: block; font-family: var(--title-font); font-size: 1.17em; margin-bottom: 0.2em; text-transform: capitalize; }
.page-section .event-card .date span { font-size: 0.76em; }
.page-section .event-card .content { padding: 20px; font-size: 0.76em; line-height: 1.4; }
.page-section .event-card h3 { font-family: var(--body-font); font-weight: 900; text-transform: uppercase; margin-bottom: 0.4em; }
.page-section .event-card h3 a { text-decoration: none; }
.page-section .event-card h3 a:hover { text-decoration: underline; }

/* Notice and facts of an event, on the cards and on the event's page */
.event-notice { display: flex; gap: 0.4em; align-items: flex-start; font-weight: bold; }
.event-facts { list-style: none; margin: 0.8em 0 0; padding: 0; }
.event-facts li { display: flex; gap: 0.4em; align-items: flex-start; margin: 0.3em 0; }
.event-notice img, .event-facts img { width: 1.1em; height: 1.1em; flex: none; margin-top: 0.1em; }
.event-facts a { text-decoration: underline; font-weight: bold; }

/* The page of an event */
.event-page { max-width: 820px; }
.back { font-size: 0.7em; font-weight: bold; }
.back a { text-decoration: none; }
.back a:hover { text-decoration: underline; }
.event-over { display: inline-block; padding: 0.2em 0.8em; border-radius: 1em; background: var(--light); font-size: 0.7em; }
.event-page h1 { margin-top: 0.3em; text-align: left; }
.event-when { font-weight: bold; font-size: 0.9em; }
.event-when::first-letter { text-transform: uppercase; }
.event-body { margin: 1em 0 1.5em; padding: 1em 1.2em; background: var(--peach); border-radius: var(--radius); font-size: 0.85em; }
.event-body > :first-child { margin-top: 0; }
.add-to-calendar h2 { font-size: 0.9em; margin-bottom: 0.5em; }
.add-to-calendar ul { display: flex; flex-wrap: wrap; gap: 0.5em; list-style: none; margin: 0; padding: 0; }
.add-to-calendar a {
    display: inline-flex; align-items: center; padding: 0.3em 0.9em; border-radius: 1em;
    background: var(--light); font-size: 0.65em; font-weight: bold; text-transform: uppercase; text-decoration: none;
}
.add-to-calendar a:hover { background: #000; color: #fff; }
.event-nav { display: flex; justify-content: space-between; gap: 1em; margin-top: 2em; padding-top: 1em; border-top: 1px solid var(--border); font-size: 0.7em; font-weight: bold; }
.event-nav a { text-decoration: none; }
.event-nav a:hover { text-decoration: underline; }
.event-nav a[rel="next"] { text-align: right; margin-left: auto; }

/* Phones: the grid gives way to the cards below it */
@media (max-width: 799px) {
    .page-section { padding: 1em 1em 2em; }
    .month-grid { display: none; }
    .month-nav { margin-bottom: 1em; }
    .month-nav h2 { font-size: 1.1em; }
    /* Only the arrows beside the month: the names of the months around are read by screen readers only */
    .month-step { font-size: 1.4em; }
    .month-step .month-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    /* Without the grid, the month's name is already the title of the cards */
    .events-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}

