/* ==========================================================================
   SmartAGM v2 — To be announced
   Markup: templates/home/v2/partials/announced.html
   Heading + muted "Dates pending" badge, then a grid of dashed cards
   (4 → 3 → 2 → 1 columns). Each card: logo, name, type and note, and a
   "Notify me when it opens" button pinned to the bottom. Dashed and
   translucent so these read as placeholders next to the open meetings above.
   The button opens the notify dialog (bottom of this file), which fades and
   rises in with CSS only (@starting-style).
   Logical properties mirror in RTL.
   ========================================================================== */

.announced {
  padding-block: var(--space-18) var(--space-2);
}

/* ---- Heading ------------------------------------------------------------ */

.announced__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4) var(--space-8);
  margin-bottom: var(--space-7);
}

.announced__title {
  margin: 0 0 10px;
  /* 28px on phones → 40px from ~1100px wide, like the other section headings. */
  font-size: clamp(28px, 1.6vw + 22px, var(--text-4xl));
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-snug);
  text-wrap: balance;
}

.announced__lead {
  max-width: 62ch;
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-lg);
  line-height: var(--leading-normal);
  text-wrap: pretty;
}

/* Arabic: letter-spacing breaks the joined letters. */
.announced:lang(ar),
.announced :lang(ar) {
  letter-spacing: 0;
}

/* ---- Grid --------------------------------------------------------------- */

.announced__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ---- Card --------------------------------------------------------------- */

.announced-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: 22px;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-surface-translucent);
  transition:
    border-color var(--duration-fast) var(--ease-standard),
    background-color var(--duration-fast) var(--ease-standard);
}

.announced-card:hover {
  border-color: var(--color-accent);
  background: var(--color-surface);
}

.announced-card__logo {
  position: relative;
  display: flex;
  flex: none;
  width: 46px;
  height: 46px;
  padding: 3px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-subtle);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.02em;
}

/* Behind the logo; shows when there is none, or when it fails to load (the img removes itself). */
.announced-card__mark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.announced-card__logo img {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 3px;
  background: var(--color-surface);
  object-fit: contain;
}

.announced-card__name {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-snug);
  overflow-wrap: anywhere;
}

.announced-card__meta {
  margin: 0;
  color: var(--color-text-subtle);
  font-size: var(--text-md);
}

.announced-card__type::after {
  content: " · ";
}

.announced-card__link {
  align-self: flex-start;
  margin-top: auto; /* keeps the links aligned across a row */
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-accent-text);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  text-align: start;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-standard);
}

.announced-card__link[hidden] {
  display: none;
}

.announced-card__link:hover {
  color: var(--color-text);
}

/* ---- Notify dialog ------------------------------------------------------ */

/* Opened with show(), not showModal() (password managers won't autofill next to another
   top-layer element; see announced.js), so the centring, layer and backdrop are ours. */
.notify-dialog {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-header) + 2);
  width: min(440px, calc(100% - 2 * var(--gutter)));
  height: fit-content;
  margin: auto;
  max-width: none;
  /* Scrolls inside rather than being cut off when little height is left (an iPad keyboard). */
  max-height: calc(100% - 2 * var(--space-4));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-8);
  border: 0;
  border-radius: var(--radius-2xl);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 30px 70px -30px rgba(3, 11, 26, 0.6);
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  transition:
    opacity 220ms var(--ease-standard),
    transform 220ms var(--ease-standard),
    display 220ms allow-discrete;
}

.notify-dialog[open] {
  opacity: 1;
  transform: none;
}

@starting-style {
  .notify-dialog[open] {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
}

/* Unhidden on open, faded by .is-open, hidden again by announced.js after the fade. */
.notify-backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-header) + 1);
  background: rgba(3, 11, 26, 0);
  -webkit-backdrop-filter: blur(0);
  backdrop-filter: blur(0);
  transition:
    background-color 220ms var(--ease-standard),
    -webkit-backdrop-filter 220ms var(--ease-standard),
    backdrop-filter 220ms var(--ease-standard);
}

.notify-backdrop[hidden] {
  display: none;
}

.notify-backdrop.is-open {
  background: rgba(3, 11, 26, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

@media (prefers-reduced-motion: reduce) {
  .notify-dialog,
  .notify-backdrop {
    transition: none;
  }

  .notify-dialog {
    transform: none;
  }

  @starting-style {
    .notify-dialog[open] {
      transform: none;
    }
  }
}

.notify-dialog__close {
  position: absolute;
  inset-block-start: var(--space-4);
  inset-inline-end: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: none;
  color: var(--color-text-subtle);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard);
}

.notify-dialog__close:hover {
  background: var(--color-surface-muted);
  color: var(--color-text);
}

.notify-dialog__step {
  display: flex;
  flex-direction: column;
  margin: 0;
}

.notify-dialog__step[hidden] {
  display: none;
}

.notify-dialog__done {
  align-items: center;
  text-align: center;
}

.notify-dialog__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-accent-tint);
  color: var(--color-accent-text);
}

.notify-dialog__icon--done {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-pill);
  background: var(--color-status-open-bg);
  color: var(--color-status-open-text);
}

.notify-dialog__company {
  margin: 0 0 var(--space-1);
  color: var(--color-accent-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  overflow-wrap: anywhere;
}

.notify-dialog__company:empty {
  display: none;
}

.notify-dialog__title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-snug);
  text-wrap: balance;
}

.notify-dialog__title:focus {
  outline: none;
}

.notify-dialog__text {
  margin: 0 0 var(--space-6);
  color: var(--color-text-muted);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  text-wrap: pretty;
}

.notify-dialog__label {
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.notify-dialog__input {
  width: 100%;
  min-height: 50px;
  padding: 13px var(--space-4);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  /* 16px or more, or iPhone/iPad Safari zooms the whole page into the field when it's tapped. */
  font-size: 16px;
  line-height: 1.4;
  text-align: start;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--duration-fast) var(--ease-standard);
}

.notify-dialog__input:focus {
  border-color: var(--color-accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--color-accent-tint);
}

.notify-dialog__input[aria-invalid="true"] {
  border-color: var(--color-status-closing-dot);
}

.notify-dialog__error {
  min-height: 1.5em;
  margin: var(--space-2) 0 var(--space-3);
  color: var(--color-status-closing-text);
  font-size: var(--text-sm);
}

.notify-dialog__submit {
  width: 100%;
}

.notify-dialog__submit:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* ---- Smaller screens ---------------------------------------------------- */

@media (max-width: 1024px) {
  .announced__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 800px) {
  .announced__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .announced {
    padding-block: var(--space-12) 0;
  }

  .announced__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
  }

  .announced-card {
    padding: var(--space-5);
  }

  .notify-dialog {
    padding: var(--space-6) var(--space-5);
  }
}

/* Short screens, e.g. an iPad in landscape with the keyboard up (~400px left): drop the
   bell and tighten the spacing so the field and the button still fit without scrolling. */
@media (max-height: 560px) {
  .notify-dialog {
    padding: var(--space-5) var(--space-6);
  }

  .notify-dialog__step:not(.notify-dialog__done) .notify-dialog__icon {
    display: none;
  }

  .notify-dialog__text {
    margin-bottom: var(--space-4);
  }

  .notify-dialog__error {
    margin-bottom: var(--space-2);
  }
}
