/* Layout fixes for Carlos's portal pages (file added by the APE, not part of
   his export). Injected at build time after his stylesheets (injectNav in
   scripts/build-pages.mjs), so his CSS files stay untouched. */

/* Cards on a portal page share the width of #app (1120 px on desktop).
   portal.css caps two of them below that width, so on /dons/ the
   « Pourquoi soutenir l'APE ? » card (1000 px) was narrower than the
   « À quoi servent les dons ? » card above it, and on /conseils-de-classe/
   the class picker (680 px) was narrower than its about panel. */
.portal-card.donations-card,
.portal-card.class-landing {
  max-width: none;
}

/* The class picker keeps a readable line length inside its full-width card. */
.portal-card.class-landing > * {
  max-width: 680px;
}

/* Home page: less space above the title, so two rows of cards fit in a
   desktop window of about 930 px. Only padding-top changes (styles.css:
   66 px, then 48 / 35 / 28 px at 950 / 720 / 480 px), scaled by about 0.6;
   the space between the title and the cards (padding-bottom) is unchanged. */
#accueil.intro { padding-top: 40px; }
@media (max-width: 950px) { #accueil.intro { padding-top: 30px; } }
@media (max-width: 720px) { #accueil.intro { padding-top: 22px; } }
@media (max-width: 480px) { #accueil.intro { padding-top: 18px; } }

/* Home page, School Council and café cards: the same event block, pinned to
   the bottom of the card like the « Dons » footer note (margin-top: auto in
   the card's flex column), filled by home-portal.js. Three lines, each one
   line high whatever its text (nowrap, ellipsis), served with their final
   height so nothing moves after /api/conseils/config:
   - small muted uppercase label (« Prochaine réunion », « Prochain café »);
   - the date, semibold, in the body font;
   - muted meta line: time · room, or « Comptes rendus disponibles ». */
.home-event { width: 100%; margin-top: auto; padding-top: 20px; }
.home-event > p { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-event-label { font-size: .75rem; font-weight: 600; line-height: 1.5; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.home-event-main { margin-top: 2px; font-size: 1.125rem; font-weight: 600; line-height: 1.4; color: var(--ink); }
.home-event-meta { font-size: .9375rem; line-height: 1.5; color: var(--muted); }
html[lang=zh-Hans] .home-event-label { letter-spacing: 0; }

/* Café description (agenda typed by the APE, or a generic line): two lines
   reserved and at most two shown, like the other cards' descriptions. */
.card > .home-card-desc {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  min-height: 3.2em; /* 2 × line-height 1.6 */
}

/* Mobile: the card is a two-column grid (styles.css); the block spans it. */
@media (max-width: 720px) {
  .home-event { grid-column: 1 / -1; padding-top: 17px; }
}

/* .text-button (« Se déconnecter », « Copier le lien », « Retirer »,
   « Supprimer cette question », « Fermer »...) has no style of its own in
   Carlos's CSS, so it inherited the dark filled .cc-app button. Discreet
   underlined text buttons instead; the destructive ones stay red. The
   keyboard focus keeps the .cc-app button:focus-visible outline (style.css),
   repeated here for a.text-button. */
.cc-app .text-button {
  min-height: 36px;
  padding: 6px 4px;
  border: 0;
  background: transparent;
  color: #365f79;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.cc-app .text-button:hover {
  background: transparent;
  color: #243642;
  text-decoration-thickness: 2px;
}
.cc-app .text-button:focus-visible {
  outline: 3px solid #327ba8;
  outline-offset: 2px;
  border-radius: 4px;
}
.cc-app .text-button:is([data-action^="remove-"], [data-parent-action^="remove-"]) {
  color: #944d45;
}
.cc-app .text-button:is([data-action^="remove-"], [data-parent-action^="remove-"]):hover {
  color: #6f3530;
}

/* « Se déconnecter » (portal.js no. 2) at the right of the top bar
   (‹ Retour · APE · year · Se déconnecter): admin page, and section pages
   for a signed-in representative or administrator. */
.cc-app .portal-top .logout-link {
  min-height: 40px;
  white-space: nowrap;
}
/* Under 600 px portal.css stacks the top bar in a column: keep the link on
   the « ‹ Retour » line, at the right, rather than on a line of its own. */
@media (max-width: 600px) {
  .cc-app .portal-top {
    position: relative;
  }
  .cc-app .portal-top .logout-link {
    position: absolute;
    top: 0;
    right: 0;
  }
}

/* Section pages: skeleton shown under the real back link and title while
   portal.js loads /config and /portal (injectSectionSkeleton in
   scripts/build-pages.mjs). portal.js replaces the whole of #app, so these
   blocks only need to sit roughly where the about panel, the lead, the tabs
   and the first card will appear (portal.css sizes), with nothing above them
   moving. Grey blocks that fill from left to right (a darker band grows over
   the light base, then starts again), only without reduced motion; static
   otherwise. Transform-free background animation: no layout work. */
.ape-skeleton { display: grid; }
.ape-skeleton > span { display: block; border-radius: 12px; background: #edf2f6; }
.ape-skeleton-panel { height: 168px; margin: 16px 0 20px; border-left: 4px solid #d6e6f1; }
.ape-skeleton-line { width: min(560px, 75%); height: 1.5em; border-radius: 7px !important; }
.ape-skeleton-tabs { height: 40px; margin: 22px 0 26px; width: min(520px, 100%); border-radius: 7px !important; }
.ape-skeleton-card { height: 220px; background: #f3f6f9 !important; border: 1px solid #dce5eb; }
@media (prefers-reduced-motion: no-preference) {
  .ape-skeleton > span {
    background-image: linear-gradient(90deg, #dbe5ec 0%, #dbe5ec 45%, rgba(219, 229, 236, 0) 55%);
    background-repeat: no-repeat;
    background-size: 220% 100%;
    background-position: 100% 0;
    animation: ape-skeleton-fill 1.4s ease-in-out infinite;
  }
  .ape-skeleton > span:nth-child(2) { animation-delay: .12s; }
  .ape-skeleton > span:nth-child(3) { animation-delay: .24s; }
  .ape-skeleton > span:nth-child(4) { animation-delay: .36s; }
}
@keyframes ape-skeleton-fill {
  0% { background-position: 100% 0; opacity: 1; }
  80% { background-position: 0 0; opacity: 1; }
  100% { background-position: 0 0; opacity: .6; }
}
.ape-visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
