/* =========================================================
   Tata letak: splash, halaman autentikasi, kerangka aplikasi
   ========================================================= */

.app {
  min-height: 100vh;
  min-height: 100dvh;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: 200;
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

.skip-link:focus {
  top: calc(var(--space-2) + var(--safe-top));
}

/* ---------- Splash (Layar 1) ---------- */
.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  background: #e9c995;
  transition: opacity var(--duration-normal) var(--ease-out), visibility var(--duration-normal);
}

.splash.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Latar ruang perpustakaan (berbagi gambar dengan Masuk & Daftar) */
.splash__bg,
.auth-page__bg {
  position: absolute;
  inset: 0;
  background: #e9c995 url('/assets/images/auth-bg-portrait.jpg') center bottom / cover no-repeat;
}

@media (min-aspect-ratio: 1/1) {
  .splash__bg,
  .auth-page__bg {
    background-image: url('/assets/images/auth-bg-landscape.jpg');
  }
}

/* Cahaya lembut di belakang logo agar logo tetap jelas di atas latar */
.splash__bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 40% at 50% 38%, rgba(255, 250, 238, 0.82) 0%, rgba(255, 250, 238, 0.45) 45%, rgba(255, 250, 238, 0) 75%);
}

.splash__brand {
  position: relative;
  z-index: 1;
  margin-top: calc(22vh + var(--safe-top));
  display: flex;
  justify-content: center;
  animation: splash-rise 700ms var(--ease-out) both;
}

.splash__logo {
  width: min(64vw, 300px);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 18px rgba(120, 60, 10, 0.18));
}

.splash__progress {
  position: absolute;
  left: 50%;
  bottom: calc(var(--space-12) + var(--safe-bottom));
  z-index: 1;
  width: min(56vw, 240px);
  height: 4px;
  overflow: hidden;
  transform: translateX(-50%);
  border-radius: var(--radius-full);
  background: rgba(255, 248, 232, 0.45);
  opacity: 0;
  animation: splash-fade-in 300ms 500ms forwards;
}

.splash__progress span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: rgba(255, 252, 244, 0.95);
  animation: splash-load 1.2s ease-in-out infinite;
}

.splash__status {
  position: absolute;
  bottom: calc(var(--space-6) + var(--safe-bottom));
  z-index: 1;
  min-height: 1.5em;
  padding: 0 var(--space-6);
  text-align: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-surface);
  text-shadow: 0 1px 2px rgba(40, 20, 6, 0.7);
}

@keyframes splash-rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes splash-fade-in {
  to { opacity: 1; }
}

@keyframes splash-load {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

/* ---------- Wordmark ---------- */
.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.brand__wordmark {
  font-size: var(--text-4xl);
  font-weight: var(--weight-extrabold);
  letter-spacing: 0.04em;
  line-height: 1;
  color: var(--color-primary-dark);
}

.brand__tagline {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.02em;
  color: var(--color-primary);
}

.brand--lg .brand__wordmark { font-size: 2.75rem; }
.brand--lg .brand__tagline { font-size: var(--text-xs); }
.brand--sm .brand__wordmark { font-size: var(--text-2xl); }
.brand--sm .brand__tagline { font-size: 0.6875rem; }

/* Logo resmi (gambar asli, proporsi dijaga) */
.logo {
  display: block;
  height: auto;
  object-fit: contain;
}

.logo--symbol { width: 104px; }
.logo--full { width: 220px; }

/* ---------- Halaman autentikasi ---------- */
.auth-page {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  padding: calc(var(--space-6) + var(--safe-top)) var(--space-5) calc(var(--space-8) + var(--safe-bottom));
  overflow: hidden;
  background: var(--color-cream);
}

.auth-page__form {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--form-max);
  display: flex;
  flex-direction: column;
}

.auth-card__top {
  display: flex;
  align-items: center;
  min-height: var(--touch-min);
  margin-bottom: var(--space-2);
}

.auth-card__brand {
  margin: var(--space-4) 0 var(--space-6);
}

.auth-card__title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  color: var(--color-text);
}

.auth-card__title--center {
  text-align: center;
  font-weight: var(--weight-regular);
}

.auth-card__title strong {
  display: block;
  font-weight: var(--weight-extrabold);
  color: var(--color-primary-dark);
}

.auth-card__subtitle {
  margin-top: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.auth-card__subtitle--center {
  text-align: center;
  max-width: 300px;
  margin-inline: auto;
}

.auth-card__form {
  margin-top: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.auth-card__footer {
  margin-top: var(--space-6);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text);
}

.auth-card__footer a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-weight: var(--weight-semibold);
}

.auth-card__footer a .icon {
  width: 16px;
  height: 16px;
}

.auth-deco {
  position: absolute;
  z-index: 0;
  pointer-events: none;
  width: 140px;
  height: auto;
  opacity: 0.9;
}

.auth-deco--bl { left: -36px; bottom: -18px; }
.auth-deco--br { right: -36px; bottom: -18px; transform: scaleX(-1); }

/* ---------- Masuk & Daftar dengan latar perpustakaan (gambar 2 referensi) ---------- */
.auth-page--scene {
  padding: 0;
  background: #e9c995;
}

.auth-page--scene .auth-page__bg {
  position: fixed;
  z-index: 0;
}

/* Selubung krem: bagian atas memperlihatkan ruang baca, bagian formulir mudah dibaca */
.auth-page--scene .auth-page__bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(248, 243, 232, 0.00) 0%,
    rgba(248, 243, 232, 0.10) 12%,
    rgba(248, 243, 232, 0.55) 26%,
    rgba(248, 243, 232, 0.84) 40%,
    rgba(248, 243, 232, 0.90) 70%,
    rgba(248, 243, 232, 0.82) 100%);
}

.auth-page--scene .auth-page__form {
  position: relative;
  z-index: 1;
  padding: calc(var(--space-12) + var(--safe-top)) var(--space-5) calc(var(--space-8) + var(--safe-bottom));
}

.auth-page--scene .auth-card {
  max-width: 420px;
}

.auth-hero {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-4);
}

.auth-hero .logo--symbol {
  width: 112px;
  filter: drop-shadow(0 6px 14px rgba(120, 60, 10, 0.16));
}

.auth-hero--sm .logo--symbol {
  width: 92px;
}

.auth-page--scene .auth-card__title {
  font-size: 1.75rem;
  color: var(--color-text);
}

.auth-page--scene .auth-card__title strong {
  font-size: 2rem;
  color: var(--color-primary-dark);
}

.auth-card__title--strong {
  font-weight: var(--weight-extrabold) !important;
  color: var(--color-primary-dark) !important;
}

.auth-page--scene .auth-card__subtitle {
  max-width: 320px;
  color: #3e4f49;
  font-size: var(--text-base);
}

.auth-page--scene .auth-card__form {
  margin-top: var(--space-6);
}

/* Kolom isian berbentuk kapsul krem */
.auth-page--scene .field__control {
  min-height: 56px;
  border-radius: var(--radius-full);
  background: var(--auth-field);
  border-color: var(--auth-field-border);
  box-shadow: 0 2px 10px rgba(90, 55, 20, 0.06);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.auth-page--scene .field__control:focus-within {
  background: #fffdf8;
  border-color: var(--color-button);
}

.auth-page--scene .field__icon {
  padding-left: var(--space-5);
  color: #3e4f49;
}

.auth-page--scene .field__input {
  min-height: 53px;
}

.auth-page--scene .btn--primary {
  min-height: 56px;
  border-radius: var(--radius-full);
  font-size: var(--text-lg);
}

/* Tautan pindah Masuk ⇄ Daftar, berbentuk kapsul seperti referensi */
.auth-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  flex-wrap: wrap;
  min-height: 52px;
  margin-top: var(--space-5);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-full);
  background: rgba(255, 251, 243, 0.72);
  border: 1px solid var(--auth-field-border);
  color: var(--color-text);
  font-size: var(--text-base);
  text-align: center;
  text-decoration: none;
}

.auth-switch:hover {
  text-decoration: none;
  background: rgba(255, 251, 243, 0.92);
}

.auth-switch strong {
  color: var(--color-primary-dark);
}

.auth-switch .icon {
  width: 18px;
  height: 18px;
  color: var(--color-primary-dark);
}

/* ---------- Kerangka aplikasi (setelah login) ---------- */
.shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.shell__main {
  flex: 1;
  width: 100%;
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + var(--space-6));
}

.page {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-6);
}

.page--narrow {
  max-width: 560px;
}

.page__title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
}

.page__lead {
  margin-top: var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.section {
  margin-top: var(--space-6);
}

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.section__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

/* Header standar (judul + tombol kembali) */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: calc(var(--header-height) + var(--safe-top));
  padding: var(--safe-top) var(--space-2) 0;
  background: rgba(248, 243, 232, 0.94);
  backdrop-filter: saturate(1.2) blur(8px);
  -webkit-backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--color-border);
}

.app-header__title {
  flex: 1;
  min-width: 0;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header__spacer {
  width: var(--touch-min);
}

/* Halaman utama tanpa tombol kembali: judul rata kiri sejajar isi halaman */
.app-header > .app-header__spacer:first-child {
  width: 0;
}

/* Header beranda (hijau) */
.home-header {
  position: relative;
  padding: calc(var(--space-4) + var(--safe-top)) var(--space-4) var(--space-8);
  background: var(--gradient-header);
  color: var(--color-surface);
  border-bottom-left-radius: var(--radius-xl);
  border-bottom-right-radius: var(--radius-xl);
}

.home-header__inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

.home-header__row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.home-header__mark {
  width: 40px;
  height: auto;
  flex-shrink: 0;
  padding: 4px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-md);
}

.home-header__greeting {
  flex: 1;
  min-width: 0;
}

.home-header__salam {
  font-size: var(--text-sm);
  opacity: 0.9;
}

.home-header__name {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-header__actions {
  display: flex;
  gap: var(--space-1);
}

/* Navigasi bawah */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  height: calc(var(--bottom-nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -4px 16px rgba(6, 68, 55, 0.06);
}

.bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--touch-min);
  font-size: 0.6875rem;
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  text-decoration: none;
}

.bottom-nav__item:hover {
  text-decoration: none;
  color: var(--color-primary);
}

.bottom-nav__item svg {
  width: 22px;
  height: 22px;
}

.bottom-nav__item[aria-current='page'] {
  color: var(--color-primary);
  font-weight: var(--weight-bold);
}

.bottom-nav__item[aria-current='page'] svg {
  stroke-width: 2.4;
}

.bottom-nav__brand {
  display: none;
}

/* Banner offline */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: calc(var(--space-2) + var(--safe-top)) var(--space-4) var(--space-2);
  background: var(--color-text);
  color: var(--color-surface);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.offline-banner svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
