/*

MIT License

Copyright (c) 2022 Neatnik LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

*/

@media print {
  @page {
    margin: 0;
  }
  /* Clip any sub-pixel/rounding overflow so the page background doesn't
     spill onto a phantom second page when printing. */
  html, body {
    height: 100%;
    overflow: hidden;
  }
  #ui_info {
    display: none;
  }
  .ics-drop-overlay {
    display: none;
  }
  .ics-legend {
    display: none;
  }
}

html {
  font-family: 'Fira Sans';
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

#ui_header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2em;
  padding: 0 1em 0.4em;
  flex: 0 0 auto;
}

#ui_year {
  width: 100%;
}

table {
  width: 100%;
  height: calc(100% - 4em);
  border-collapse: separate;
  border-spacing: .5em 0;
}

td, th {
  font-weight: normal;
  text-transform: uppercase;
  border-bottom: 1px solid #888;
  padding: .3vmin .3vmin;
  font-size: .9vmin;
  font-weight: 300;
  color: #000;
}

th {
  font-size: 1.1vmin;
  /* font-size: var(--month-font-size); */
  padding: 0;
}

td:empty {
  border: 0;
}

.date {
  display: inline-block;
  width: 1.1em;
}

.day {
  display: inline-block;
  text-align: center;
  width: 1em;
  color: #888;
}

.weekend {
  /* background: #d8d8d8; */
  background: #eee;
  font-weight: 400;
}

p {
  margin: 0 0 .5em 0;
  text-align: center;
}

* {
  color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

#ui_info {
  font-family: 'Inter', sans-serif;
  position: absolute;
  top: 0;
  left: 0;
  margin: 5em 2em;
  width: calc(100% - 6em);
  background: #333;
  color: #eee;
  padding: 1em 1em .5em 1em;
  font-size: 2vmax;
  border-radius: .2em;
}
#ui_info p {
  text-align: left;
  margin: 0 0 1em 0;
  line-height: 135%;
}
#ui_info a {
  color: inherit;
}

/* Moon phase styles */
.moon-container {
  display: block;
  text-align: center;
  margin-top: 0.2em;
}

.moon-inline {
  margin-left: 0.2em;
}

.moon-symbol {
  font-size: 1.1em;
}

.moon-name {
  font-size: 0.7em;
  color: #666;
  text-transform: none;
}

.moon-phase {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: middle;
}

.moon-phase svg {
  width: 100%;
  height: 100%;
  display: block;
}

.event {
  font-size: .7vmin;
  line-height: 1.2;
  margin-top: 0.2em;
  padding: 0.05em 0.3em;
  background: #dfe7f7;
  color: #222;
  border-radius: 0.3em;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

.event-span {
  border-radius: 0;
  margin-left: -0.1em;
  margin-right: -0.1em;
}

.event-span-start {
  border-top-left-radius: 0.3em;
  border-bottom-left-radius: 0.3em;
}

.event-span-end {
  border-top-right-radius: 0.3em;
  border-bottom-right-radius: 0.3em;
}

.ics-drop-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 20, 20, 0.6);
  z-index: 9999;
}

.ics-drop-overlay.visible {
  display: flex;
}

.ics-drop-box {
  background: #f7f2e8;
  border: 2px dashed #a68a64;
  padding: 2em 3em;
  text-align: center;
  color: #3d3326;
  border-radius: 0.5em;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.ics-drop-title {
  font-size: 2vmax;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ics-drop-subtitle {
  margin-top: 0.6em;
  font-size: 1.2vmax;
  text-transform: none;
}

#ics_file_input {
  display: none;
}

.ics-legend {
  color: #3d3326;
  width: 100%;
  font-size: 0.9vmin;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6em 1em;
}

.ics-legend-row {
  display: flex;
  align-items: center;
  gap: 0.6em;
}

.ics-legend-row:last-child {
  margin-bottom: 0;
}

.ics-legend-swatch {
  display: inline-block;
  width: 1em;
  height: 1em;
  border-radius: 0.2em;
  cursor: pointer;
  flex-shrink: 0;
  margin-bottom: 0.15em;
}

.ics-legend-name {
  cursor: pointer;
  text-transform: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.ics-legend-input {
  width: 100%;
  font-size: inherit;
  font-family: inherit;
  border: 1px solid #a68a64;
  border-radius: 0.2em;
  padding: 0.2em 0.4em;
  color: inherit;
  background: #fffaf0;
}

.ics-legend-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3em;
  max-width: 12em;
}

.ics-legend-palette-item {
  display: inline-block;
  width: 1em;
  height: 1em;
  border-radius: 0.2em;
  cursor: pointer;
}

.ics-legend-remove {
  display: inline-block;
  cursor: pointer;
  color: #a68a64;
  font-size: 1.4em;
  line-height: 1;
  padding: 0 0.2em;
  margin-left: -0.2em;
  opacity: 0.6;
  transition: opacity 0.2s, color 0.2s;
  margin-top: 0.15em;
}

.ics-legend-remove:hover {
  opacity: 1;
  color: #c9302c;
}

/* ============================================================
   adesso-year layout — recreation of the adesso year wall planner.
   Colours sampled directly from the official Jahreskalender PDF.
   All tweakable values are CSS custom properties so the whole
   theme (blue, gradients, accents) can be re-parametrized.
   ============================================================ */
body.adesso-year-body {
  --ay-blue:          #0e88d3;   /* page background / adesso blue */
  --ay-month-bg:      #0e88d3;   /* month header band            */
  --ay-month-fg:      #ffffff;   /* month header text            */
  --ay-weekday-bg:    #ffffff;   /* normal weekday cell          */
  --ay-weekend-grad:  linear-gradient(to right, #ebebf5 0%, #ffffff 100%);
  --ay-holiday-grad:  linear-gradient(to right, #95cce5 0%, #bce7d5 100%);
  --ay-event-bg:      #0e88d3;   /* adesso event pill            */
  --ay-event-fg:      #ffffff;   /* adesso event text            */
  --ay-date-fg:       #0e88d3;   /* day number + weekday code    */
  --ay-accent:        #5dc699;   /* holiday names / week numbers */
  --ay-gap-x:         0.45vmin;  /* gap between month columns     */
  --ay-gap-y:         0.32vmin;  /* gap between day rows          */
  --ay-radius:        0.9em;     /* pill corner radius            */

  background: var(--ay-blue);
}

/* Header band: "2026" (large, bold, white, left) + adesso logo (right).
   The logo element is injected by the adesso-year layout only. */
body.adesso-year-body #ui_header {
  color: var(--ay-month-fg);
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0.8vmin 0.8vmin 0.3vmin;
}

body.adesso-year-body #ui_year {
  width: auto;
}

body.adesso-year-body #ui_year span {
  width: auto !important;
  text-align: left !important;
  /* Lift the year so its baseline lines up with the "adesso" wordmark —
     the logo's diagonal element occupies its lower portion. */
  margin: 0 0 1.8vmin 0 !important;
  line-height: 1;
}

body.adesso-year-body #adessocal_logo {
  display: block;
  height: 6vmin;
  width: auto;
  filter: brightness(0) invert(1);
}

body.adesso-year-body #ics_legend {
  flex-basis: 100%;
  order: 3;
}

body.adesso-year-body table {
  border-spacing: var(--ay-gap-x) var(--ay-gap-y);
  table-layout: fixed;
  /* Reserve room for the taller header so the grid still fits one page */
  height: calc(100% - 8.5vmin);
}

/* Month header row */
.adesso-year-month-header {
  background: var(--ay-month-bg);
  color: var(--ay-month-fg);
  font-weight: 700;
  font-size: 1.6vmin;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-align: left;
  padding: 0.2em 0.6em !important;
  border: 0;
}

/* Day cells */
.adesso-year-date-cell {
  background: var(--ay-weekday-bg);
  border: 0;
  border-radius: var(--ay-radius);
  padding: 0 !important;
  vertical-align: middle;
  overflow: hidden;
  position: relative;
}

.adesso-year-date-cell:empty {
  background: transparent;
}

.adesso-year-date-cell.weekend {
  background: var(--ay-weekend-grad);
}

.adesso-year-date-cell.adesso-year-holiday {
  background: var(--ay-holiday-grad);
}

.adesso-year-date-cell.adesso-year-event {
  background: var(--ay-event-bg);
}

/* Flex pill inside each cell: number+weekday on the left, name on the right */
.adesso-year-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0.1vmin 0.7em;
  box-sizing: border-box;
  gap: 0.4em;
  line-height: 1.05;
}

.adesso-year-left {
  display: flex;
  align-items: baseline;
  gap: 0.35em;
  flex: 0 0 auto;
}

.adesso-year-date-cell .date {
  font-size: 1.7vmin;
  font-weight: 300;
  color: var(--ay-date-fg);
  width: auto;
}

.adesso-year-date-cell.weekend .date {
  font-weight: 700;
}

.adesso-year-date-cell .day {
  font-size: 0.95vmin;
  color: var(--ay-date-fg);
  text-transform: none;
  width: auto;
  text-align: left;
}

.adesso-year-date-cell.weekend .day {
  font-weight: 700;
}

/* adesso event pill: light text on blue */
.adesso-year-event .date,
.adesso-year-event .day {
  color: var(--ay-event-fg);
}

/* Holiday / event name on the right side of the cell */
.adesso-year-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  flex: 1 1 auto;
  min-width: 0;
}

.adesso-year-name {
  font-size: 0.8vmin;
  font-style: italic;
  font-weight: 500;
  text-transform: none;
  color: var(--ay-accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.adesso-year-name--wrap {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  hyphens: auto;
  word-break: break-word;
}

.adesso-year-regions {
  font-size: 0.65vmin;
  font-style: italic;
  text-transform: none;
  color: var(--ay-accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.adesso-year-event .adesso-year-name,
.adesso-year-event .adesso-year-regions {
  color: var(--ay-event-fg);
}

/* Today highlight: keep text readable on the pink fill */
.adesso-year-date-cell.adessocal-today .date,
.adesso-year-date-cell.adessocal-today .day,
.adesso-year-date-cell.adessocal-today .adesso-year-name,
.adesso-year-date-cell.adessocal-today .adesso-year-regions,
.adesso-year-date-cell.adessocal-today .adesso-year-week {
  color: #ffffff;
}

.adesso-year-week {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7vmin;
  font-style: italic;
  font-weight: 300;
  color: var(--ay-accent);
  opacity: 0.45;
  pointer-events: none;
}

/* Context columns (prev_month / next_month): faded so the blue page shows
   through, matching the overlapping months of the printed planner. */
body.adesso-year-body .adesso-year-month-header.adesso-context {
  opacity: 0.6;
}

body.adesso-year-body .adesso-year-date-cell.adesso-context {
  opacity: 0.5;
}

/* ============================================================
   adesso-planner layout — page 2 of the adesso wall planner.
   Transpose of adesso-year: months run down as rows, the day of
   the month (1..31) runs across as columns. Reuses the shared
   adesso theme (--ay-* vars, header, logo, background, table
   sizing) via the adesso-year-body class that the layout also
   applies; only the grid-specific styling lives here.
   ============================================================ */

/* Column header: day-of-month numbers (white, bold, centered) */
body.adesso-planner-body .adesso-planner-daynum {
  background: transparent;
  border: 0;
  color: var(--ay-month-fg);
  font-weight: 700;
  font-size: 1.5vmin;
  text-align: center;
  padding: 0.1em 0 0.5em !important;
}

/* Empty corner cell above the month-label column; also fixes the
   width of that first column for the whole table (table-layout: fixed). */
body.adesso-planner-body .adesso-planner-corner {
  background: transparent;
  border: 0;
  width: 6.5%;
}

/* Row header: month label (white, bold, left-aligned) */
body.adesso-planner-body .adesso-planner-month {
  background: transparent;
  border: 0;
  text-align: left;
  padding: 0 0.6em 0 0.2em !important;
  white-space: nowrap;
}

body.adesso-planner-body .adesso-planner-month .month {
  font-weight: 700;
  font-size: 1.4vmin;
  width: auto;
  text-align: left;
  text-transform: none;
  color: var(--ay-month-fg);
}

/* Day cells. The grid stretches to fill the page (inherited table height from
   adesso-year-body); rows are kept equal by taking the cell content out of the
   normal flow (see .adesso-planner-box) so a multi-line name can't make its row
   taller than the others. */
body.adesso-planner-body .adesso-planner-cell {
  background: var(--ay-weekday-bg);
  border: 0;
  border-radius: 0.6em;
  padding: 0 !important;
  text-align: center;
  vertical-align: middle;
  position: relative;
  overflow: hidden;
}

/* Content box: absolutely fills the cell so it contributes no intrinsic height.
   Every row then gets an equal share of the table's height — uniform rows that
   still fill the page — and long names are clipped to the cell rather than
   stretching it. */
body.adesso-planner-body .adesso-planner-box {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-sizing: border-box;
  padding: 0.1em 0.15em;
}

body.adesso-planner-body .adesso-planner-empty {
  background: transparent;
}

body.adesso-planner-body .adesso-planner-cell.weekend {
  background: var(--ay-weekend-grad);
}

body.adesso-planner-body .adesso-planner-cell.adesso-year-holiday {
  background: var(--ay-holiday-grad);
}

body.adesso-planner-body .adesso-planner-cell.adesso-year-event {
  background: var(--ay-event-bg);
}

/* Weekday letter — the main content of a normal cell */
body.adesso-planner-body .adesso-planner-wd {
  display: block;
  font-size: 1.7vmin;
  font-weight: 300;
  color: var(--ay-date-fg);
  width: auto;
  text-align: center;
  text-transform: none;
}

body.adesso-planner-body .adesso-planner-cell.weekend .adesso-planner-wd {
  font-weight: 700;
}

/* Special-day name shown in place of the weekday letter. Cells are narrow, so
   names rely on German hyphenation (hyphens: auto + lang="de", set in JS) to
   break long words at syllable boundaries rather than at arbitrary characters. */
body.adesso-planner-body .adesso-planner-name {
  font-size: 0.8vmin;
  font-style: italic;
  font-weight: 500;
  line-height: 1.08;
  text-transform: none;
  color: var(--ay-accent);
  padding: 0 0.25em;
  overflow-wrap: break-word;
  hyphens: auto;
}

body.adesso-planner-body .adesso-planner-regions {
  font-size: 0.62vmin;
  font-style: italic;
  line-height: 1.1;
  text-transform: none;
  color: var(--ay-accent);
  padding: 0 0.3em;
}

/* Names read white on the holiday gradient / event fill, as in the PDF */
body.adesso-planner-body .adesso-year-holiday .adesso-planner-name,
body.adesso-planner-body .adesso-year-holiday .adesso-planner-regions,
body.adesso-planner-body .adesso-year-event .adesso-planner-name,
body.adesso-planner-body .adesso-year-event .adesso-planner-regions {
  color: var(--ay-event-fg);
}

/* Week number in the cell's top-right corner */
body.adesso-planner-body .adesso-planner-week {
  position: absolute;
  top: 0.1em;
  right: 0.4em;
  width: auto;
  font-size: 1.0vmin;
  font-style: italic;
  font-weight: 700;
  color: var(--ay-accent);
  opacity: 0.85;
  pointer-events: none;
}

/* Context rows (the months either side of the range): faded so the blue page
   shows through, matching the dimmed Dez '25 / Jan '27 rows in the PDF */
body.adesso-planner-body .adesso-planner-context .adesso-planner-cell,
body.adesso-planner-body .adesso-planner-context .adesso-planner-month .month {
  opacity: 0.5;
}

/* Today highlight: keep text legible on the pink fill */
body.adesso-planner-body .adesso-planner-cell.adessocal-today .adesso-planner-wd,
body.adesso-planner-body .adesso-planner-cell.adessocal-today .adesso-planner-name,
body.adesso-planner-body .adesso-planner-cell.adessocal-today .adesso-planner-regions,
body.adesso-planner-body .adesso-planner-cell.adessocal-today .adesso-planner-week {
  color: #ffffff;
}