/* ── Notifications ── */

:root {
  --ntf-bg: var(--theme-page-backdrop);
  --ntf-fg: var(--theme-fg);
  --ntf-muted: var(--theme-page-muted);
  --ntf-subtle: var(--theme-page-subtle);
  --ntf-border: var(--theme-page-card-border);
  --ntf-border-strong: var(--theme-page-card-border-strong);
  --ntf-card-bg: var(--theme-page-panel-bg);
  --ntf-item-bg: transparent;
  --ntf-item-unread-bg: var(--theme-page-highlight);
  --ntf-item-unread-border: var(--theme-page-panel-border);
  --ntf-hover-bg: var(--theme-page-hover);
  --ntf-dot: var(--theme-fg);
  --ntf-shadow: var(--theme-page-panel-shadow);
}

body.notifications-page {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--theme-font-transfer-base, Helvetica, Arial, sans-serif);
  font-size: var(--theme-text-size-md, 12px);
  line-height: var(--theme-line-height-body, 1.35);
  background: var(--ntf-bg);
  color: var(--ntf-fg);
}

[data-notifications-host] {
  color: var(--ntf-fg);
  font-family: var(--theme-font-transfer-base, Helvetica, Arial, sans-serif);
  font-size: var(--theme-text-size-md, 12px);
  line-height: var(--theme-line-height-body, 1.35);
}

html[data-notifications-embedded="true"],
html[data-notifications-embedded="true"] body {
  min-height: 100%;
  background: transparent;
}

html[data-notifications-embedded="true"] .sc-header {
  display: none;
}

/* ── Main layout ── */
.notifications-page {
  background: var(--ntf-bg);
}

.notifications-main {
  max-width: 960px;
  margin: 0 auto;
  padding: clamp(80px, 12vh, 124px) clamp(12px, 2.6vw, 24px) clamp(30px, 4vh, 46px);
}

html[data-notifications-embedded="true"] .notifications-main {
  max-width: none;
  margin: 0;
  padding: 0;
}

/* ── Card container ── */
.notifications-card {
  position: relative;
  border: 1px solid var(--theme-page-panel-border);
  border-radius: var(--theme-page-panel-radius);
  background: var(--ntf-card-bg);
  overflow: hidden;
  box-shadow: var(--ntf-shadow);
  backdrop-filter: blur(8px);
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}

html[data-notifications-embedded="true"] .notifications-card {
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.notifications-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid var(--theme-page-panel-inset-border);
  pointer-events: none;
}

html[data-notifications-embedded="true"] .notifications-card::before {
  display: none;
}

.notifications-card:hover {
  border-color: var(--theme-page-panel-border-strong);
  box-shadow: var(--theme-page-panel-shadow-hover);
  transform: translateY(-1px);
}

html[data-notifications-embedded="true"] .notifications-card:hover {
  border-color: transparent;
  box-shadow: none;
  transform: none;
}

/* ── Card header ── */
.notifications-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: clamp(18px, 2.2vw, 24px) clamp(18px, 2.4vw, 26px) 14px;
  border-bottom: 1px solid var(--theme-page-rule);
}

.notifications-card__head h2 {
  margin: 0;
  font-size: var(--theme-text-size-sm, 11px);
  font-weight: 600;
  letter-spacing: var(--theme-tracking-caps-wide, 0.05em);
  text-transform: var(--theme-text-transform-uppercase, uppercase);
}

.notifications-status {
  margin: 0;
  font-size: var(--theme-text-size-xs, 10px);
  letter-spacing: var(--theme-tracking-label, 0.02em);
  text-transform: var(--theme-text-transform-uppercase, uppercase);
  color: var(--ntf-muted);
}

.notifications-toolbar {
  display: grid;
  gap: 12px;
  padding: 14px clamp(18px, 2.4vw, 26px) 0;
}

.notifications-summary {
  margin: 0;
  font-size: var(--theme-text-size-sm, 11px);
  color: var(--ntf-subtle);
  line-height: var(--theme-line-height-copy, 1.45);
}

.notifications-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.notifications-filter-btn {
  appearance: none;
  border: 1px solid var(--ntf-border);
  border-radius: 999px;
  background: transparent;
  color: var(--ntf-muted);
  font: inherit;
  font-size: var(--theme-text-size-xs, 10px);
  font-weight: 600;
  letter-spacing: var(--theme-tracking-label-wide, 0.03em);
  text-transform: var(--theme-text-transform-uppercase, uppercase);
  padding: 7px 11px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.notifications-filter-btn:hover,
.notifications-filter-btn:focus-visible {
  border-color: var(--ntf-border-strong);
  background: var(--ntf-hover-bg);
  color: var(--ntf-fg);
}

.notifications-filter-btn.is-active {
  border-color: var(--ntf-item-unread-border);
  background: var(--ntf-item-unread-bg);
  color: var(--ntf-fg);
}

/* ── Notification list ── */
.notifications-list {
  display: grid;
  gap: 16px;
  padding: 12px clamp(16px, 2.4vw, 24px) clamp(18px, 2.4vw, 24px);
}

.notifications-group {
  display: grid;
  gap: 8px;
}

.notifications-group__title {
  margin: 0;
  padding: 4px 2px 0;
  font-size: var(--theme-text-size-xs, 10px);
  font-weight: 600;
  letter-spacing: var(--theme-tracking-label-wide, 0.03em);
  text-transform: var(--theme-text-transform-uppercase, uppercase);
  color: var(--ntf-muted);
}

.notifications-group__items {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--ntf-border);
}

/* ── Single notification item ── */
.notification-item {
  border: none;
  border-bottom: 1px solid var(--ntf-border);
  border-radius: 0;
  padding: 14px 2px;
  background: var(--ntf-item-bg);
  display: grid;
  gap: 5px;
  text-decoration: none;
  color: inherit;
  transition: background 0.2s ease, color 0.2s ease;
}

button.notification-item {
  width: 100%;
  appearance: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

a.notification-item:hover,
button.notification-item:hover,
button.notification-item:focus-visible {
  background: var(--ntf-hover-bg);
}

a.notification-item:active,
button.notification-item:active {
  background: var(--ntf-hover-bg);
}

.notification-item.is-unread {
  background: var(--ntf-item-unread-bg);
}

/* ── Item header row ── */
.notification-item__header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.notification-dot {
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ntf-dot);
}

.notification-badge {
  flex-shrink: 0;
  border: 1px solid var(--ntf-border);
  border-radius: 999px;
  padding: 2px 7px;
  font-size: var(--theme-text-size-xs, 10px);
  color: var(--ntf-muted);
  letter-spacing: var(--theme-tracking-label, 0.02em);
  text-transform: var(--theme-text-transform-uppercase, uppercase);
}

.notification-item__header h3 {
  margin: 0;
  font-size: var(--theme-text-size-sm, 11px);
  font-weight: 600;
  line-height: var(--theme-line-height-body, 1.3);
  letter-spacing: var(--theme-tracking-ui, 0.01em);
  min-width: 0;
}

.notification-item__header time {
  flex-shrink: 0;
  padding: 2px 6px;
  border: 1px solid var(--ntf-border);
  border-radius: 4px;
  background: var(--ntf-hover-bg);
  font-family: var(--theme-font-mono, "Roboto Mono", monospace);
  font-size: var(--theme-text-size-xs, 10px);
  color: var(--ntf-muted);
  letter-spacing: 0.01em;
  text-transform: none;
}

.notification-badge + time + h3 {
  flex: 1;
}

.notification-item p {
  margin: 0;
  font-size: var(--theme-text-size-sm, 11px);
  color: var(--ntf-subtle);
  line-height: var(--theme-line-height-copy, 1.5);
  white-space: pre-wrap;
  word-break: break-word;
}

.notification-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--theme-text-size-xs, 10px);
  font-weight: 600;
  color: var(--ntf-fg);
  letter-spacing: var(--theme-tracking-label, 0.02em);
  text-transform: var(--theme-text-transform-uppercase, uppercase);
}

.notification-action::after {
  content: "→";
  line-height: 1;
}

/* ── Empty state ── */
.notifications-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 36px 16px;
  text-align: center;
  font-size: var(--theme-text-size-sm, 11px);
  color: var(--ntf-muted);
}

.notifications-empty__icon {
  width: 32px;
  height: 32px;
  opacity: 0.3;
}

.notifications-empty__icon::before {
  content: "";
  display: block;
  width: 32px;
  height: 32px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  position: relative;
}

.notifications-empty__hint {
  font-size: var(--theme-text-size-xs, 10px);
  color: var(--ntf-muted);
  opacity: 0.7;
  text-transform: var(--theme-text-transform-uppercase, uppercase);
  letter-spacing: var(--theme-tracking-label-wide, 0.03em);
}

/* ── Load more ── */
.notifications-load-more-box {
  display: flex;
  justify-content: center;
  padding: 0 clamp(16px, 2.4vw, 24px) clamp(18px, 2.4vw, 24px);
}

.notifications-load-more-btn {
  appearance: none;
  border: 1px solid var(--theme-page-button-ghost-border);
  border-radius: 999px;
  background: var(--theme-page-button-ghost-bg);
  color: var(--theme-page-button-ghost-fg);
  font: inherit;
  font-size: var(--theme-text-size-xs, 10px);
  font-weight: 600;
  text-transform: var(--theme-text-transform-uppercase, uppercase);
  letter-spacing: var(--theme-tracking-label-wide, 0.03em);
  padding: 7px 18px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.notifications-load-more-btn:hover:not(:disabled) {
  border-color: var(--theme-page-card-border-strong);
  background: var(--ntf-hover-bg);
  box-shadow: var(--theme-page-card-shadow-hover);
  transform: translateY(-1px);
}

.notifications-load-more-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

.notifications-load-more-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ── Mobile ── */
@media (max-width: 640px) {
  .notifications-main {
    padding: calc(var(--cell-gap, 14px) + 56px) 12px 28px;
  }

  .notifications-card__head {
    padding: 14px 14px 12px;
  }

  .notifications-toolbar {
    padding: 12px 14px 0;
  }

  .notifications-list {
    padding: 10px 12px 14px;
    gap: 6px;
  }

  .notification-item {
    padding: 10px 12px;
  }

  .notification-item__header h3 {
    font-size: var(--theme-text-size-sm, 11px);
  }
}

/* ── Dark mode: data-theme ── */
body[data-theme="dark"] {
  --ntf-bg: var(--theme-page-backdrop);
  --ntf-fg: var(--theme-fg);
  --ntf-muted: var(--theme-page-muted);
  --ntf-subtle: var(--theme-page-subtle);
  --ntf-border: var(--theme-page-card-border);
  --ntf-border-strong: var(--theme-page-card-border-strong);
  --ntf-card-bg: var(--theme-page-panel-bg);
  --ntf-item-bg: transparent;
  --ntf-item-unread-bg: var(--theme-page-highlight);
  --ntf-item-unread-border: var(--theme-page-panel-border);
  --ntf-hover-bg: var(--theme-page-hover);
  --ntf-dot: var(--theme-fg);
  --ntf-shadow: var(--theme-page-panel-shadow);
}

body[data-theme="dark"] .notifications-card:hover {
  box-shadow: var(--theme-page-panel-shadow-hover);
}

body[data-theme="dark"] a.notification-item:hover {
  box-shadow: var(--theme-page-card-shadow-hover);
}

body[data-theme="dark"] .notifications-load-more-btn:hover:not(:disabled) {
  box-shadow: var(--theme-page-card-shadow-hover);
}

/* ── Dark mode: prefers-color-scheme (for data-theme="system") ── */
@media (prefers-color-scheme: dark) {
  body[data-theme="system"] {
    --ntf-bg: var(--theme-page-backdrop);
    --ntf-fg: var(--theme-fg);
    --ntf-muted: var(--theme-page-muted);
    --ntf-subtle: var(--theme-page-subtle);
    --ntf-border: var(--theme-page-card-border);
    --ntf-border-strong: var(--theme-page-card-border-strong);
    --ntf-card-bg: var(--theme-page-panel-bg);
    --ntf-item-bg: transparent;
    --ntf-item-unread-bg: var(--theme-page-highlight);
    --ntf-item-unread-border: var(--theme-page-panel-border);
    --ntf-hover-bg: var(--theme-page-hover);
    --ntf-dot: var(--theme-fg);
    --ntf-shadow: var(--theme-page-panel-shadow);
  }

  body[data-theme="system"] .notifications-card:hover {
    box-shadow: var(--theme-page-panel-shadow-hover);
  }

  body[data-theme="system"] a.notification-item:hover {
    box-shadow: var(--theme-page-card-shadow-hover);
  }

  body[data-theme="system"] .notifications-load-more-btn:hover:not(:disabled) {
    box-shadow: var(--theme-page-card-shadow-hover);
  }
}
