/* Chinese Lunar Calendar tool styles.
 *
 * Rides on the site's .content-box (white box, 800px max, 40px padding), so
 * there are no global resets or body rules here - only a scoped box-sizing
 * and the calendar's own components. */

.calendar-tool {
  flex: 1 0 auto;
  color: #222;
}

.calendar-wrap,
.calendar-wrap * {
  box-sizing: border-box;
}

.calendar-wrap {
  width: 100%;
  font-family: "STKaiti", "Kaiti", "Kaiti SC", "KaiTi_GB2312", "SimSun", "Songti TC", serif;
}

.toolbar {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 4px 0 26px;
}
.toolbar label {
  font-size: 17px;
  font-weight: bold;
}
.toolbar input[type="number"] {
  font-family: inherit;
  font-size: 16px;
  padding: 5px 10px;
  width: 110px;
  border: 1px solid #111111;
  border-radius: 0;
  background: #ffffff;
}
#help-button {
  margin-left: auto;
  padding: 5px 12px;
  border: 1px solid #111111;
  border-radius: 0;
  background: #ffffff;
  color: #222222;
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
}
#help-button:hover,
#help-button:focus-visible {
  background: #eeeeee;
}

details.earlier-months {
  margin-bottom: 22px;
}
details.earlier-months summary {
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  user-select: none;
}
details.earlier-months[open] summary {
  margin-bottom: 14px;
}

.year-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  background: #333333;
  color: #ffffff;
  padding: 10px 20px;
  border: 1px solid #111111;
  margin: 28px 0 22px 0;
}
.year-header .yh-gz {
  font-size: 30px;
  font-weight: bold;
  letter-spacing: 3px;
}
.year-header .yh-year {
  font-size: 16px;
  color: #cccccc;
}

.month-block {
  margin-bottom: 44px;
}

.month-title {
  display: flex;
  align-items: baseline;
  gap: 18px;
  background: #111111;
  color: #ffffff;
  padding: 10px 20px;
  border: 1px solid #111111;
  border-bottom: none;
}
.month-title .mname {
  font-size: 32px;
  font-weight: bold;
  letter-spacing: 3px;
}
.month-title .msub {
  font-size: 20px;
  color: #cccccc;
}

table.month-grid {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
}

td.cell {
  position: relative;
  border: 1px solid #111111;
  background: #ffffff;
  text-align: center;
  vertical-align: middle;
  width: 20%;
  height: 132px;
}
.key-cell-table {
  position: absolute;
  top: 20px;
  left: 80px;
  width: 160px;
  height: 132px;
  border-collapse: collapse;
}
.key-cell-table .cell {
  width: 160px;
  height: 132px;
}
td.cell.holiday,
.key-cell-table .cell.holiday {
  color: #d80000;
}
td.cell.today {
  background: #fff2a8;
}

.lunar {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 35px;
  font-weight: bold;
  letter-spacing: 1px;
  white-space: nowrap;
}

.gz {
  position: absolute;
  top: 5px;
  left: 6px;
  font-size: 16px;
  line-height: 1.2;
  writing-mode: vertical-rl;
  text-orientation: upright;
  letter-spacing: 1px;
  font-weight: normal;
}
.gz.horz {
  writing-mode: horizontal-tb;
  text-orientation: initial;
  letter-spacing: 0;
  font-size: 16px;
  line-height: 1.2;
  font-weight: bold;
  text-align: left;
  white-space: nowrap;
}
.phase {
  position: absolute;
  top: 5px;
  right: 8px;
  font-size: 16px;
  font-weight: bold;
  color: inherit;
}
.solar {
  position: absolute;
  bottom: 4px;
  left: 8px;
  font-size: 16px;
  font-family: "Georgia", "Times New Roman", serif;
  font-weight: bold;
}
.solar.month {
  font-style: italic;
  font-size: 16px;
}
.solar.term {
  font-family: "LXGW WenKai GB", "STKaiti", "Kaiti", "KaiTi_GB2312", "SimSun", "Songti TC", serif;
  font-style: normal;
  font-size: 16px;
}
.wd {
  position: absolute;
  bottom: 4px;
  right: 8px;
  font-size: 16px;
  font-weight: bold;
}

/* Structured hover tooltip (built and positioned by JS) */
.tooltip {
  display: none;
  position: fixed;
  z-index: 2000;
  box-sizing: border-box;
  min-width: 240px;
  max-width: 320px;
  background: #fff9c4;
  color: #222222;
  border: 1px solid #d8cf7e;
  border-radius: 0;
  padding: 8px 10px;
  font-family: "Roboto Serif", Georgia, serif;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
.tooltip .tt-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid #d8cf7e;
  padding-bottom: 4px;
  margin-bottom: 5px;
}
.tooltip .tt-cat {
  font-weight: bold;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b5d00;
}
.tooltip .tt-py {
  font-style: italic;
  font-size: 12px;
  color: #555555;
}
.tooltip .tt-foot {
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px dashed #d8cf7e;
  font-size: 11px;
  color: #6b5d00;
}

.tool-credits {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 1.5rem 0 0;
}

/* Legend: annotated example cells showing each cell section */
.cell-key {
  margin: 0 0 2rem;
}
.cell-key .key-title {
  display: inline-block;
  margin: 0 0 1.25rem;
  font-size: 1.1rem;
}
.key-fig figcaption {
  margin-top: 8px;
  text-align: center;
  color: #000;
  font-size: 20px;
}
.key-fig figcaption span {
  display: inline-block;
}
.key-cells {
  display: flex;
  flex-wrap: nowrap;
  gap: 36px;
}
.key-fig {
  margin: 0;
}
.key-diagram {
  position: relative;
  width: 320px;
  height: 180px;
  font-family: "LXGW WenKai GB", "STKaiti", "Kaiti", "KaiTi_GB2312", "SimSun", "Songti TC", serif;
}
.key-label {
  position: absolute;
  z-index: 1;
  color: #222;
  font-size: 16px;
  line-height: 1.2;
  white-space: nowrap;
}
.key-label::after {
  content: "";
  position: absolute;
  border-color: #000;
  border-style: solid;
  border-width: 0;
}
.key-label-gz,
.key-label-corner {
  top: 26px;
  left: auto;
  right: 252px;
}
.key-label-gz::after,
.key-label-corner::after {
  top: 50%;
  left: 100%;
  width: 16px;
  border-top-width: 1.5px;
}
.key-label-lunar,
.key-label-festival {
  bottom: 0;
  left: 160px;
  transform: translateX(-50%);
}
.key-label-lunar::after,
.key-label-festival::after {
  bottom: 100%;
  left: 50%;
  height: 48px;
  border-left-width: 1.5px;
  border-top-width: 0;
}
.key-label-solar,
.key-label-term {
  top: 130px;
  left: auto;
  right: 252px;
}
.key-label-solar::after,
.key-label-term::after {
  top: 50%;
  left: 100%;
  width: 16px;
  border-top-width: 1.5px;
}
.key-label-wd,
.key-label-eclipse {
  top: 130px;
  left: 252px;
  right: auto;
}
.key-label-wd::after,
.key-label-eclipse::after {
  top: 50%;
  right: 100%;
  width: 16px;
  border-top-width: 1.5px;
}
.key-label-phase {
  top: 26px;
  left: 252px;
  right: auto;
}
.key-label-phase::after {
  top: 50%;
  right: 100%;
  width: 16px;
  border-top-width: 1.5px;
}

@media (max-width: 600px) {
  /* The site's content box has generous desktop padding. Let the calendar
     use nearly the full viewport on small screens instead. */
  .calendar-wrap {
    width: 100vw;
    margin-left: calc((100% - 100vw) / 2);
  }

  .toolbar {
    margin-right: 4px;
    margin-left: 4px;
  }

  details.earlier-months summary {
    margin-left: 8px;
  }

  .year-header,
  .month-title {
    padding-left: 8px;
    padding-right: 8px;
  }

  .year-header {
    margin-top: 28px;
  }

  .year-header .yh-gz {
    font-size: 24px;
  }

  .month-title {
    gap: 8px;
    flex-wrap: wrap;
  }

  .month-title .mname {
    font-size: 28px;
  }

  .month-title .msub {
    min-width: 0;
    font-size: 16px;
  }

  .month-title .msub-range {
    overflow-wrap: anywhere;
  }

  td.cell {
    height: 108px;
  }

  .lunar {
    font-size: 24px;
  }

  .gz,
  .gz.horz,
  .phase,
  .solar,
  .solar.month,
  .solar.term,
  .wd {
    font-size: 14px;
  }

  .cell-key {
    margin-right: 4px;
    margin-left: 4px;
  }

  .key-cells {
    flex-direction: column;
    align-items: center;
    gap: 28px;
  }

  .key-fig,
  .key-diagram {
    width: 320px;
    max-width: 100%;
  }

  .tooltip {
    min-width: 0;
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
  }
}
