/* Shared responsive identity system for the public login and applicant portal. */

html[data-portal-font="modern"] { --portal-font-body: 'Cairo', system-ui, sans-serif; --portal-font-heading: 'Tajawal', 'Cairo', sans-serif; }
html[data-portal-font="friendly"] { --portal-font-body: 'Tajawal', 'Cairo', sans-serif; --portal-font-heading: 'Tajawal', sans-serif; }
html[data-portal-font="formal"] { --portal-font-body: 'Noto Kufi Arabic', 'Cairo', sans-serif; --portal-font-heading: 'Noto Kufi Arabic', 'Cairo', sans-serif; }

html[data-portal-density="compact"] { --portal-section-gap: 10px; --portal-card-pad: 14px; --portal-shell-pad: 18px; }
html[data-portal-density="balanced"] { --portal-section-gap: 14px; --portal-card-pad: 18px; --portal-shell-pad: 26px; }
html[data-portal-density="airy"] { --portal-section-gap: 22px; --portal-card-pad: 24px; --portal-shell-pad: 38px; }

body.public-portal-page,
body.applicant-portal-page {
  font-family: var(--portal-font-body, 'Cairo', sans-serif);
  background-attachment: fixed;
}

body.public-portal-page h1,
body.public-portal-page h2,
body.public-portal-page h3,
body.applicant-portal-page h1,
body.applicant-portal-page h2,
body.applicant-portal-page h3,
body.applicant-portal-page .hero-name,
body.applicant-portal-page .tl-name {
  font-family: var(--portal-font-heading, 'Tajawal', sans-serif);
}

html[data-portal-background="soft"] body.public-portal-page,
html[data-portal-background="soft"] body.applicant-portal-page {
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 88%, #fff), var(--bg));
}

html[data-portal-background="mesh"] body.public-portal-page,
html[data-portal-background="mesh"] body.applicant-portal-page {
  background:
    radial-gradient(circle at 12% 8%, rgba(var(--primary-rgb, 21,101,192), .18), transparent 30rem),
    radial-gradient(circle at 88% 34%, color-mix(in srgb, var(--primary-h) 15%, transparent), transparent 34rem),
    var(--bg);
}

html[data-portal-background="plain"] body.public-portal-page,
html[data-portal-background="plain"] body.applicant-portal-page { background: var(--surface); }

html[data-portal-background="contrast"] body.public-portal-page,
html[data-portal-background="contrast"] body.applicant-portal-page {
  background:
    linear-gradient(120deg, color-mix(in srgb, var(--primary) 26%, #111827), color-mix(in srgb, var(--primary-h) 16%, #020617)) fixed;
}

/* Public portal login: one DOM, multiple responsive arrangements. */
.public-portal-page .shell {
  width: min(100%, 1240px);
  max-width: none;
  padding: var(--portal-shell-pad, 26px) clamp(16px, 3vw, 34px) 54px;
}

.public-portal-page .hero { gap: var(--portal-section-gap, 14px); }
.public-portal-page .hero-panel,
.public-portal-page .login-card,
.public-portal-page .hero-card { transition: border-radius .2s, box-shadow .2s, background .2s; }

html[data-portal-density="compact"] .public-portal-page .hero-panel,
html[data-portal-density="compact"] .public-portal-page .login-card { padding: 22px; }
html[data-portal-density="airy"] .public-portal-page .hero-panel,
html[data-portal-density="airy"] .public-portal-page .login-card { padding: clamp(30px, 4vw, 44px); }

html[data-portal-template="dashboard"] .public-portal-page .hero {
  grid-template-columns: minmax(310px, .72fr) minmax(0, 1.45fr);
  align-items: stretch;
}
html[data-portal-template="dashboard"] .public-portal-page .hero-panel { grid-column: 2; grid-row: 1; }
html[data-portal-template="dashboard"] .public-portal-page .login-card { grid-column: 1; grid-row: 1; }
html[data-portal-template="dashboard"] .public-portal-page .hero-panel,
html[data-portal-template="dashboard"] .public-portal-page .login-card { border-radius: 18px; }
html[data-portal-template="dashboard"] .public-portal-page .hero-grid { grid-template-columns: repeat(var(--portal-card-count, 3), minmax(0, 1fr)); }
html[data-portal-template="dashboard"] .public-portal-page .hero-card { min-height: 170px; }

html[data-portal-template="journey"] .public-portal-page .shell { width: min(100%, 980px); }
html[data-portal-template="journey"] .public-portal-page .hero { grid-template-columns: 1fr; }
html[data-portal-template="journey"] .public-portal-page .hero-panel {
  position: relative;
  overflow: hidden;
  border-radius: 34px 10px 34px 10px;
}
html[data-portal-template="journey"] .public-portal-page .hero-panel::after {
  content: '';
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 8px;
  background: linear-gradient(var(--primary), var(--primary-h));
}
html[data-portal-template="journey"] .public-portal-page .login-card { width: min(100%, 620px); justify-self: center; border-radius: 28px; border-inline-start: 7px solid var(--primary); }

html[data-portal-template="editorial"] .public-portal-page .shell { width: min(100%, 1320px); }
html[data-portal-template="editorial"] .public-portal-page .hero { grid-template-columns: minmax(330px, .65fr) minmax(0, 1.6fr); gap: clamp(20px, 4vw, 58px); }
html[data-portal-template="editorial"] .public-portal-page .hero-panel,
html[data-portal-template="editorial"] .public-portal-page .login-card,
html[data-portal-template="editorial"] .public-portal-page .hero-card { border-radius: 3px; box-shadow: 10px 14px 0 color-mix(in srgb, var(--primary) 12%, transparent); }
html[data-portal-template="editorial"] .public-portal-page .hero-panel { border-top: 7px solid var(--primary); }
html[data-portal-template="editorial"] .public-portal-page h1 { font-size: clamp(2.5rem, 5vw, 4.8rem); letter-spacing: -.04em; }

html[data-portal-template="minimal"] .public-portal-page .shell { width: min(100%, 760px); }
html[data-portal-template="minimal"] .public-portal-page .topbar { justify-content: center; }
html[data-portal-template="minimal"] .public-portal-page .hero { grid-template-columns: minmax(0, 1fr); }
html[data-portal-template="minimal"] .public-portal-page .hero-panel,
html[data-portal-template="minimal"] .public-portal-page .login-card,
html[data-portal-template="minimal"] .public-portal-page .hero-card { border-radius: 10px; box-shadow: none; background: var(--surface); }
html[data-portal-template="minimal"] .public-portal-page .login-card { grid-column: 1; grid-row: 1; width: min(100%, 520px); justify-self: center; border-top: 5px solid var(--primary); }
html[data-portal-template="minimal"] .public-portal-page .hero-panel { grid-column: 1; grid-row: 2; padding-block: 18px; background: transparent; border-color: transparent; text-align: center; }
html[data-portal-template="minimal"] .public-portal-page .logo-wrap { justify-content: center; }
html[data-portal-template="minimal"] .public-portal-page .hero-panel > p { max-width: 560px; margin-inline: auto; }
html[data-portal-template="minimal"] .public-portal-page .hero-grid { display: none; }
html[data-portal-template="minimal"] .public-portal-page .hero-foot { border: 0; padding-top: 0; }

/* Authenticated applicant portal. */
.applicant-portal-page .portal-shell { --portal-max-width: 900px; --portal-shape: var(--radius, 16px); }
.applicant-portal-page .portal-container {
  width: min(calc(100% - clamp(20px, 4vw, 48px)), var(--portal-max-width));
  max-width: none;
  margin-inline: auto;
  padding-bottom: 48px;
}
.applicant-portal-page .portal-content { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--portal-section-gap, 14px); }
.applicant-portal-page .portal-section { min-width: 0; order: var(--portal-order, 1); }
.applicant-portal-page .portal-section > :first-child { margin-top: 0; }
.applicant-portal-page .portal-section > :last-child { margin-bottom: 0; }

html[data-portal-density="compact"] .applicant-portal-page .card:not(.hero-card),
html[data-portal-density="compact"] .applicant-portal-page .tl-card,
html[data-portal-density="compact"] .applicant-portal-page .appointment-card { padding: 11px 13px; }
html[data-portal-density="airy"] .applicant-portal-page .card:not(.hero-card),
html[data-portal-density="airy"] .applicant-portal-page .tl-card,
html[data-portal-density="airy"] .applicant-portal-page .appointment-card { padding: 20px 22px; }

html[data-portal-template="dashboard"] .applicant-portal-page .portal-shell { --portal-max-width: 1180px; }
html[data-portal-template="dashboard"] .applicant-portal-page .portal-container {
  display: grid;
  grid-template-columns: minmax(250px, 330px) minmax(0, 1fr);
  gap: clamp(14px, 2vw, 22px);
  align-items: start;
}
html[data-portal-template="dashboard"] .applicant-portal-page .hero-card {
  grid-column: 1;
  grid-row: 1;
  position: sticky;
  top: 18px;
  min-height: min(620px, calc(100vh - 36px));
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
html[data-portal-template="dashboard"] .applicant-portal-page .hero-top,
html[data-portal-template="dashboard"] .applicant-portal-page .hero-meta { flex-direction: column; align-items: stretch; }
html[data-portal-template="dashboard"] .applicant-portal-page .hero-actions { order: -1; justify-content: flex-start; }
html[data-portal-template="dashboard"] .applicant-portal-page .hero-badges { flex-direction: column; align-items: stretch; }
html[data-portal-template="dashboard"] .applicant-portal-page .hero-badge { justify-content: flex-start; border-radius: 10px; }
html[data-portal-template="dashboard"] .applicant-portal-page .hero-brand { width: 100%; min-width: 0; }
html[data-portal-template="dashboard"] .applicant-portal-page .portal-content {
  grid-column: 2;
  grid-row: 1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  margin: 0;
}
html[data-portal-template="dashboard"] .applicant-portal-page .portal-section--timeline { grid-column: 1 / -1; }
html[data-portal-template="dashboard"] .applicant-portal-page .hero-card { border-radius: 18px; }
html[data-portal-template="dashboard"] .applicant-portal-page .portal-notifications,
html[data-portal-template="dashboard"] .applicant-portal-page .appointment-card { height: 100%; }

html[data-portal-template="journey"] .applicant-portal-page .portal-shell { --portal-max-width: 980px; }
html[data-portal-template="journey"] .applicant-portal-page .hero-card { border-radius: 32px 10px 32px 10px; }
html[data-portal-template="journey"] .applicant-portal-page .timeline-progress { border-radius: 999px; padding-inline: 22px; }
html[data-portal-template="journey"] .applicant-portal-page .tl-card { border-radius: 22px 8px 22px 8px; }

html[data-portal-template="editorial"] .applicant-portal-page .portal-shell { --portal-max-width: 1040px; }
html[data-portal-template="editorial"] .applicant-portal-page .portal-content {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-flow: dense;
  align-items: start;
}
html[data-portal-template="editorial"] .applicant-portal-page .portal-section--system { grid-column: 1 / -1; }
html[data-portal-template="editorial"] .applicant-portal-page .portal-section--notifications,
html[data-portal-template="editorial"] .applicant-portal-page .portal-section--appointment { grid-column: span 4; }
html[data-portal-template="editorial"] .applicant-portal-page .portal-section--timeline { grid-column: span 8; }
html[data-portal-template="editorial"] .applicant-portal-page .hero-card {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-top: 7px solid var(--primary);
  border-radius: 3px;
  box-shadow: 10px 12px 0 color-mix(in srgb, var(--primary) 11%, transparent);
}
html[data-portal-template="editorial"] .applicant-portal-page .hero-card::before,
html[data-portal-template="editorial"] .applicant-portal-page .hero-card::after { display: none; }
html[data-portal-template="editorial"] .applicant-portal-page .hero-name,
html[data-portal-template="editorial"] .applicant-portal-page .hero-sub { color: var(--text); }
html[data-portal-template="editorial"] .applicant-portal-page .hero-sub { opacity: .68; }
html[data-portal-template="editorial"] .applicant-portal-page .hero-btn-outline { color: var(--primary); border-color: var(--border); background: var(--bg); }
html[data-portal-template="editorial"] .applicant-portal-page .hero-btn-danger { color: #b91c1c; }
html[data-portal-template="editorial"] .applicant-portal-page .hero-badge { color: var(--text); background: var(--bg); border-color: var(--border); }
html[data-portal-template="editorial"] .applicant-portal-page .hero-badge-current { color: #fff; background: var(--primary); }
html[data-portal-template="editorial"] .applicant-portal-page .card:not(.hero-card),
html[data-portal-template="editorial"] .applicant-portal-page .tl-card,
html[data-portal-template="editorial"] .applicant-portal-page .appointment-card,
html[data-portal-template="editorial"] .applicant-portal-page .timeline-progress { border-radius: 3px; box-shadow: 8px 8px 0 color-mix(in srgb, var(--primary) 8%, transparent); }

html[data-portal-template="minimal"] .applicant-portal-page .portal-shell { --portal-max-width: 860px; }
html[data-portal-template="minimal"] .applicant-portal-page .portal-content { gap: 0; border-top: 1px solid var(--border); }
html[data-portal-template="minimal"] .applicant-portal-page .portal-section { padding-block: 12px; border-bottom: 1px solid var(--border); }
html[data-portal-template="minimal"] .applicant-portal-page .hero-card {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-inline-start: 6px solid var(--primary);
  border-radius: 10px;
}
html[data-portal-template="minimal"] .applicant-portal-page .hero-card::before,
html[data-portal-template="minimal"] .applicant-portal-page .hero-card::after { display: none; }
html[data-portal-template="minimal"] .applicant-portal-page .hero-card { padding: 14px 16px; margin-bottom: 18px; }
html[data-portal-template="minimal"] .applicant-portal-page .hero-name { font-size: 18px; }
html[data-portal-template="minimal"] .applicant-portal-page .hero-meta { margin-top: 10px; }
html[data-portal-template="minimal"] .applicant-portal-page .hero-name,
html[data-portal-template="minimal"] .applicant-portal-page .hero-sub { color: var(--text); }
html[data-portal-template="minimal"] .applicant-portal-page .hero-sub { opacity: .65; }
html[data-portal-template="minimal"] .applicant-portal-page .hero-btn-outline { color: var(--primary); background: transparent; border-color: var(--border); }
html[data-portal-template="minimal"] .applicant-portal-page .hero-btn-danger { color: #b91c1c; background: transparent; }
html[data-portal-template="minimal"] .applicant-portal-page .hero-badge { color: var(--text); background: transparent; border-color: var(--border); }
html[data-portal-template="minimal"] .applicant-portal-page .hero-badge-current { color: #fff; background: var(--primary); }
html[data-portal-template="minimal"] .applicant-portal-page .card:not(.hero-card),
html[data-portal-template="minimal"] .applicant-portal-page .tl-card,
html[data-portal-template="minimal"] .applicant-portal-page .appointment-card,
html[data-portal-template="minimal"] .applicant-portal-page .timeline-progress { border-radius: 10px; box-shadow: none; background: transparent; }
html[data-portal-template="minimal"] .applicant-portal-page .timeline-progress { display: none; }
html[data-portal-template="minimal"] .applicant-portal-page .portal-notification-item { padding-inline: 0; }

/* Timeline modes now change the actual presentation. */
.applicant-portal-page .portal-shell[data-timeline-style="stream"] .timeline {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(280px, 1fr);
  gap: 14px;
  padding: 8px 4px 16px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
}
.applicant-portal-page .portal-shell[data-timeline-style="stream"] .timeline::before { display: none; }
.applicant-portal-page .portal-shell[data-timeline-style="stream"] .tl-item {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
  margin: 0;
  scroll-snap-align: start;
}
.applicant-portal-page .portal-shell[data-timeline-style="stream"] .tl-dot { margin-inline-start: 12px; }
.applicant-portal-page .portal-shell[data-timeline-style="stream"] .tl-card { height: 100%; }

.applicant-portal-page .portal-shell[data-timeline-style="compact"] .timeline { padding: 0; }
.applicant-portal-page .portal-shell[data-timeline-style="compact"] .timeline::before { display: none; }
.applicant-portal-page .portal-shell[data-timeline-style="compact"] .tl-item { gap: 8px; margin-bottom: 8px; align-items: stretch; }
.applicant-portal-page .portal-shell[data-timeline-style="compact"] .tl-dot {
  width: 28px !important;
  height: 28px !important;
  flex-basis: 28px;
  font-size: 10px !important;
  margin-top: 8px;
}
.applicant-portal-page .portal-shell[data-timeline-style="compact"] .tl-card { padding: 10px 12px; box-shadow: none; }
.applicant-portal-page .portal-shell[data-timeline-style="compact"] .tl-header { margin-bottom: 3px; }

html[dir="ltr"] .applicant-portal-page .timeline::before { left: 19px; right: auto; }

@media (max-width: 900px) {
  html[data-portal-template] .public-portal-page .hero {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--portal-section-gap, 14px);
  }
  html[data-portal-template] .public-portal-page .hero-panel,
  html[data-portal-template] .public-portal-page .login-card { grid-column: 1; width: 100%; }
  html[data-portal-template] .public-portal-page .hero-panel { grid-row: 2; }
  html[data-portal-template] .public-portal-page .login-card { grid-row: 1; max-width: none; border-radius: 18px; }
  html[data-portal-template="dashboard"] .public-portal-page .hero-grid { grid-template-columns: 1fr; }
  html[data-portal-template="dashboard"] .public-portal-page .hero-card { min-height: 0; }
  html[data-portal-template="editorial"] .public-portal-page .hero-panel,
  html[data-portal-template="editorial"] .public-portal-page .login-card { box-shadow: 6px 7px 0 color-mix(in srgb, var(--primary) 10%, transparent); }
  html[data-portal-template="minimal"] .public-portal-page .hero-panel { border-color: transparent; }
  html[data-portal-template="dashboard"] .applicant-portal-page .portal-content { grid-template-columns: minmax(0, 1fr); }
  html[data-portal-template="dashboard"] .applicant-portal-page .portal-section--timeline { grid-column: auto; }
  html[data-portal-template="dashboard"] .applicant-portal-page .portal-container { display: block; }
  html[data-portal-template="dashboard"] .applicant-portal-page .hero-card {
    position: relative;
    top: auto;
    min-height: 0;
    margin-bottom: var(--portal-section-gap, 14px);
  }
  html[data-portal-template="dashboard"] .applicant-portal-page .hero-top { flex-direction: row; }
  html[data-portal-template="dashboard"] .applicant-portal-page .hero-actions { order: 0; }
  html[data-portal-template="dashboard"] .applicant-portal-page .hero-badges { flex-direction: row; }
  html[data-portal-template="dashboard"] .applicant-portal-page .portal-content { margin-top: 0; }
  html[data-portal-template="editorial"] .applicant-portal-page .portal-content { grid-template-columns: minmax(0, 1fr); }
  html[data-portal-template="editorial"] .applicant-portal-page .portal-section--system,
  html[data-portal-template="editorial"] .applicant-portal-page .portal-section--notifications,
  html[data-portal-template="editorial"] .applicant-portal-page .portal-section--appointment,
  html[data-portal-template="editorial"] .applicant-portal-page .portal-section--timeline { grid-column: auto; }
}

@media (max-width: 600px) {
  html[data-portal-density="airy"] { --portal-section-gap: 16px; --portal-card-pad: 18px; --portal-shell-pad: 20px; }
  .public-portal-page .shell { padding-inline: 14px; }
  .applicant-portal-page .portal-container { width: min(calc(100% - 20px), var(--portal-max-width)); }
  html[data-portal-template="journey"] .public-portal-page .hero-panel,
  html[data-portal-template="journey"] .applicant-portal-page .hero-card { border-radius: 22px 8px 22px 8px; }
  html[data-portal-template="editorial"] .public-portal-page h1 { font-size: clamp(2rem, 12vw, 3.1rem); }
  .applicant-portal-page .portal-shell[data-timeline-style="stream"] .timeline { grid-auto-columns: minmax(250px, 88vw); }
  html[data-portal-template="dashboard"] .applicant-portal-page .hero-top { flex-direction: column; }
  html[data-portal-template="dashboard"] .applicant-portal-page .hero-actions { order: -1; }
  html[data-portal-template="dashboard"] .applicant-portal-page .hero-badges { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .public-portal-page *, .applicant-portal-page * { scroll-behavior: auto !important; }
  .public-portal-page .hero-panel, .public-portal-page .login-card, .applicant-portal-page .hero-badge-current { animation: none !important; transition: none !important; }
}
