/* =================================================================
   KALENDER JAWA — Stylesheet: Massimo Vignelli 
   Palet: Vibrant Solid Color (Merah, Hitam, Putih Murni)
   Tipografi: Helvetica / Arial
   Grid: Border 2px Hitam Pekat di sekeliling sel
   ================================================================= */

:root {
  /* Skala Warna Material Design 2 Palette */
  --bg-canvas: #FAFAFA;       /* Grey 50 */
  --bg-card: #FFFFFF;         
  --bg-hover: #EEEEEE;        /* Grey 200 */
  
  --bg-today: #2196F3;        /* Biru Material 500 */
  --bg-selected: #212121;     /* Hitam Gelap */
  
  --text-main: #212121;       /* Grey 900 (Hitam Material) */
  --text-secondary: #424242;  /* Grey 800 */
  --text-muted: #757575;      /* Grey 600 */
  --text-inverse: #FFFFFF;
  
  --accent-primary: #2196F3;  /* Biru Material 500 */
  --accent-secondary: #FF9800;/* Orange 500 */
  --holiday-alert: #F44336;   /* Red 500 */
  
  /* Garis Batas Tabular */
  --border-color: #212121;    /* Grey 900 */
  --border-hairline: 1px solid var(--border-color);

  /* Gap Grid yang menghasilkan border 2px berkat background kontainer */
  --grid-gap: 2px; 

  --radius-none: 0px;
  --shadow-none: none;

  /* Transisi Kaku Instan */
  --ease-flat: ease-in-out;
  --duration-fast: 100ms;
  --duration-normal: 200ms;

  /* Hierarki Tipografi — Inter: Alternatif modern terbaik untuk Helvetica di Web */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-size-xs: 0.70rem;    /* Label kecil (Neptu & Pasaran) */
  --font-size-sm: 0.85rem;    
  --font-size-base: 1rem;     
  --font-size-md: 1.25rem;    
  --font-size-lg: 1.5rem;     
  --font-size-xl: 2rem;       
  --font-size-2xl: 3rem;      /* Angka kalender grid besar */
  --font-size-3xl: 4.5rem;
}

/* -----------------------------------------------------------------
   § RESET & BASE 
   ----------------------------------------------------------------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 15px; 
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-canvas);
  color: var(--text-main);
  line-height: 1.3;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px;
}

/* -----------------------------------------------------------------
   § APP HEADER
   ----------------------------------------------------------------- */
.app-header {
  width: 100%;
  max-width: 960px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: center;
  padding: 16px 0 16px;
  margin-bottom: 8px;
}

.header-brand {
  grid-column: 1 / span 2;
  display: flex;
  align-items: center;
}

.header-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.04em;
  line-height: 40px;
  height: 40px;
  display: flex;
  align-items: center;
}

.month-nav {
  grid-column: 3 / 6;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* KEMINTAAN USER: "button solid black color white" */
.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--text-main); /* Hitam */
  color: var(--text-inverse);   /* Putih */
  border: none;                 /* Tidak perlu border karena solid */
  cursor: pointer;
  transition: all var(--duration-fast);
  flex-shrink: 0;
}

.nav-btn:hover {
  background: var(--accent-primary); /* Hover Merah Vignelli */
  color: var(--text-inverse);
}

.nav-btn:active {
  background: var(--text-muted);
}

.month-label {
  flex: 1; /* Mengisi sisa ruang di tengah */
  text-align: center; 
  align-items: center;
  user-select: none;
  display: flex;
  flex-direction: column;
}

.month-label__text {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.month-label__jawa {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  margin-top: 2px;
}

.today-btn {
  grid-column: 6 / 8;
  justify-self: end;
  flex-shrink: 0;
  padding: 0 16px;
  height: 40px;
  background: var(--text-main); 
  color: var(--text-inverse);   
  border: none;
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.today-btn:hover {
  background: var(--accent-primary); /* Hover Merah */
  color: var(--text-inverse);
}
.today-btn:active {
  background: var(--text-muted);
}

/* -----------------------------------------------------------------
   § CALENDAR MATRIKS CONTAINER
   ----------------------------------------------------------------- */
.calendar-container {
  width: 100%;
  max-width: 960px;
  background: transparent;
  margin-bottom: 24px;
}

/* -----------------------------------------------------------------
   § WEEKDAY HEADER 
   Garis 2px black hasil background bleed
   ----------------------------------------------------------------- */
.weekday-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  border-left: 1px solid var(--border-color);
}

.weekday-name {
  background: var(--text-main); 
  text-align: left; /* Flush Left */
  font-size: var(--font-size-xs);
  font-weight: 700; /* Inter Bold */
  color: var(--text-inverse);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 12px;
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.weekday-name--weekend {
  background: var(--holiday-alert);
  color: var(--text-inverse);
  border-right-color: var(--holiday-alert);
  border-bottom-color: var(--holiday-alert);
}

/* -----------------------------------------------------------------
   § CALENDAR GRID
   Berubah jadi Solid Grid berkat background border dan gap
   ----------------------------------------------------------------- */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0; 
  border-left: 1px solid var(--border-color); 
  transition: opacity var(--duration-normal) var(--ease-flat);
}

.calendar-grid--fading {
  opacity: 0;
}

/* -----------------------------------------------------------------
   § DAY CELL
   ----------------------------------------------------------------- */
.day-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;  
  align-items: flex-start;      
  aspect-ratio: 1.1;           
  background: var(--bg-card);
  cursor: pointer;
  padding: 10px 12px;
  user-select: none;
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  transition: background var(--duration-fast);
}

.day-cell:hover {
  background: var(--bg-hover);
}

/* Angka Tanggal (Besar, Bold Helvetica) */
.day-cell__date {
  font-size: var(--font-size-2xl);
  font-weight: 700;             
  line-height: 0.8;
  letter-spacing: -0.04em;
  color: var(--text-main);
  margin-bottom: auto;          
}

/* Info Pasaran */
.day-cell__pasaran {
  font-size: var(--font-size-xs);
  font-weight: 700;             
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Info Tambahan Neptu (Bawah Kanan, Kecil) */
.day-cell__neptu {
  position: absolute;
  bottom: 10px;
  right: 12px;
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--text-muted); /* Abu-abu agar menempel estetis seperti anotasi */
}

/* --- STATE SEL --- */
.day-cell--outside {
  background: #E0E0E0; /* Grey 300 (Darker Grey Canvas) */
}
.day-cell--outside .day-cell__date,
.day-cell--outside .day-cell__pasaran,
.day-cell--outside .day-cell__neptu {
  opacity: 0.4;
}
.day-cell--outside:hover {
  background: var(--bg-hover);
}

/* HARI INI — Vibrant Red dengan teks putih */
.day-cell--today {
  background: var(--bg-today);
}
.day-cell--today .day-cell__date {
  color: var(--text-inverse);
}
.day-cell--today .day-cell__pasaran,
.day-cell--today .day-cell__neptu {
  color: rgba(255, 255, 255, 0.85);
}
.day-cell--today:hover {
  background: #1976D2; /* Biru Gelap Hover */
}

/* HARI LIBUR / MINGGU — Merah Solid */
.day-cell--holiday .day-cell__date,
.day-cell--sunday .day-cell__date {
  color: var(--holiday-alert);
}
.day-cell--holiday .day-cell__pasaran,
.day-cell--sunday .day-cell__pasaran {
  color: var(--holiday-alert);
}

/* NAAS & GEBLAK — Background kuning dengan label kecil */
.day-cell--naas,
.day-cell--geblak {
  background: #FFF59D !important; /* Yellow 200 */
}
.day-cell--naas:hover,
.day-cell--geblak:hover {
  background: #FFF176 !important; /* Yellow 300 hover */
}
.day-cell--naas .day-cell__pasaran,
.day-cell--geblak .day-cell__pasaran {
  color: var(--text-main);
}
/* Naas menang jika tumpang tindih */
.day-cell--naas.day-cell--geblak {
  background: #FFF59D !important;
}
/* Label kecil N/G di pojok kanan atas */
.day-cell__naas-label {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.6rem;
  font-weight: 700;
  color: #F57F17; /* Yellow 900 */
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1;
}
/* Hari libur/minggu tetap merah di atas kuning */
.day-cell--naas.day-cell--holiday .day-cell__date,
.day-cell--naas.day-cell--sunday .day-cell__date,
.day-cell--geblak.day-cell--holiday .day-cell__date,
.day-cell--geblak.day-cell--sunday .day-cell__date {
  color: var(--holiday-alert);
}
.day-cell--naas.day-cell--holiday .day-cell__pasaran,
.day-cell--naas.day-cell--sunday .day-cell__pasaran,
.day-cell--geblak.day-cell--holiday .day-cell__pasaran,
.day-cell--geblak.day-cell--sunday .day-cell__pasaran {
  color: var(--holiday-alert);
}

/* SEL DIPILIH — Hitam (Teks Putih) — !important untuk menang dari naas/geblak */
.day-cell--selected {
  background: var(--bg-selected) !important;
}
.day-cell--selected .day-cell__date {
  color: var(--text-inverse) !important;
}
.day-cell--selected .day-cell__pasaran,
.day-cell--selected .day-cell__neptu {
  color: rgba(255, 255, 255, 0.7) !important;
}
.day-cell--selected .day-cell__naas-label {
  color: rgba(255, 255, 255, 0.7);
}
.day-cell--today.day-cell--selected {
  background: var(--bg-selected); 
  border: 4px solid var(--bg-today); 
  box-shadow: inset 0 0 0 2px var(--bg-today);
}


/* -----------------------------------------------------------------
   § DETAIL PANEL
   ----------------------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-normal) var(--ease-flat);
  z-index: 90;
}

.overlay--visible {
  opacity: 1;
  visibility: visible;
}

.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 440px;
  max-width: 100vw;
  height: 100vh;
  background: var(--bg-canvas); 
  z-index: 100;
  overflow-y: auto;
  padding: 0; 

  transform: translateX(100%);
  visibility: hidden;
  transition: transform var(--duration-normal) cubic-bezier(0.16, 1, 0.3, 1);
}

.detail-panel--open {
  transform: translateX(0);
  visibility: visible;
}

.detail-panel__close {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--text-main);
  color: var(--text-inverse);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.detail-panel__close:hover {
  background: var(--accent-primary);
}

.detail-section {
  padding: 16px 24px;
}

.detail-section--masehi {
  padding-top: 64px;
  padding-bottom: 40px;
}

.detail-date-number {
  display: block;
  font-size: var(--font-size-3xl);
  font-weight: 700; 
  color: var(--text-main);
  line-height: 0.9;
  letter-spacing: -0.04em;
  margin-bottom: 8px;
}

.detail-date-full {
  display: block;
  font-size: var(--font-size-base);
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.detail-holiday-name {
  display: none;
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--holiday-alert);
  margin-top: 8px;
}
.detail-holiday-name--visible {
  display: block;
}

.detail-label {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-main);
  margin-bottom: 8px;
}

.detail-value {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.detail-value--holiday {
  color: var(--holiday-alert);
}

.detail-value--highlight {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--accent-secondary);
}

.btn-naas-geblak {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--text-main);
  color: var(--text-inverse);
  border: none;
  font-family: var(--font-sans);
  font-size: var(--font-size-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  cursor: pointer;
  transition: all var(--duration-fast);
}
.btn-naas-geblak:hover {
  background: #FFF59D;
  color: #F57F17;
}
.btn-naas-geblak--active {
  background: #FFF59D;
  color: #F57F17;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 24px;
}

.detail-meta__item {
  display: flex;
  flex-direction: column;
}

.detail-meta__key {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.detail-meta__val {
  font-size: var(--font-size-md);
  color: var(--text-main);
  margin-top: 4px;
  font-weight: 700;
}

.neptu-display {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.neptu-item {
  display: flex;
  flex-direction: column;
}

.neptu-item__label {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  color: var(--text-main);
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  font-weight: 700;
}

.neptu-item__value {
  font-size: var(--font-size-xl);
  color: var(--text-main);
  font-weight: 700;
}

.neptu-plus, .neptu-equals {
  display: none;
}

/* -----------------------------------------------------------------
   § TABLET (≤768px)
   ----------------------------------------------------------------- */
@media (max-width: 768px) {
  body {
    padding: 0 8px;
  }

  /* Header: stack vertikal */
  .app-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 16px 0 12px;
    margin-bottom: 4px;
  }
  .header-brand {
    justify-content: center;
    width: 100%;
  }
  .header-title {
    font-size: var(--font-size-lg);
    height: auto;
    line-height: 1.2;
  }
  .month-nav {
    width: 100%;
    justify-content: center;
    gap: 6px;
  }
  .nav-btn {
    width: 36px;
    height: 36px;
  }
  .today-btn {
    height: 36px;
    font-size: var(--font-size-xs);
    padding: 0 12px;
  }
  .month-label__text {
    font-size: var(--font-size-md);
  }
  .month-label__jawa {
    font-size: var(--font-size-xs);
  }

  /* Weekday header */
  .weekday-name {
    padding: 8px 4px;
    font-size: 0.6rem;
    text-align: center;
    letter-spacing: 0;
  }

  /* Day cells */
  .day-cell {
    padding: 6px;
    aspect-ratio: auto;
    min-height: 60px;
  }
  .day-cell__date {
    font-size: var(--font-size-xl);
    line-height: 1;
  }
  .day-cell__pasaran {
    font-size: 0.55rem;
  }
  .day-cell__neptu {
    bottom: 6px;
    right: 6px;
    font-size: 0.55rem;
  }
  .day-cell__naas-label {
    top: 2px;
    right: 3px;
    font-size: 0.5rem;
  }

  /* Detail panel full-screen */
  .detail-panel {
    width: 100%;
  }
  .detail-section--masehi {
    padding-top: 48px;
    padding-bottom: 24px;
  }
  .detail-date-number {
    font-size: 3rem;
  }
  .detail-panel__close {
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
  }
  .btn-naas-geblak {
    width: 34px;
    height: 34px;
    font-size: var(--font-size-lg);
  }
}

/* -----------------------------------------------------------------
   § PHONE (≤480px)
   ----------------------------------------------------------------- */
@media (max-width: 480px) {
  /* Day cells lebih compact */
  .day-cell {
    padding: 4px;
    min-height: 48px;
  }
  .day-cell__date {
    font-size: var(--font-size-md);
  }
  .day-cell__pasaran {
    font-size: 0.5rem;
  }
  .day-cell__neptu {
    bottom: 4px;
    right: 4px;
    font-size: 0.5rem;
  }
  .day-cell__naas-label {
    top: 1px;
    right: 2px;
    font-size: 0.45rem;
  }

  /* Header compact */
  .header-title {
    font-size: var(--font-size-md);
  }
  .nav-btn {
    width: 32px;
    height: 32px;
  }
  .nav-btn svg {
    width: 18px;
    height: 18px;
  }
  .today-btn {
    height: 32px;
    padding: 0 10px;
  }
  .month-label__text {
    font-size: var(--font-size-base);
  }
  .weekday-name {
    padding: 6px 2px;
    font-size: 0.5rem;
  }

  /* Detail panel compact */
  .detail-panel {
    width: 100%;
  }
  .detail-section {
    padding: 12px 16px;
  }
  .detail-section--masehi {
    padding-top: 40px;
    padding-bottom: 20px;
  }
  .detail-date-number {
    font-size: 2.5rem;
  }
  .detail-value--highlight {
    font-size: var(--font-size-lg);
  }
  .btn-naas-geblak {
    width: 30px;
    height: 30px;
    font-size: var(--font-size-md);
  }
  .detail-meta {
    gap: 8px;
    margin-top: 16px;
  }
  .detail-meta__val {
    font-size: var(--font-size-base);
  }
  .neptu-item__value {
    font-size: var(--font-size-lg);
  }
}

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