/* ================================================================
   Basic settings
   Zielgerät: iPad 8 / 9 im Hochformat, Seitenverhältnis 3:4
   ================================================================ */

:root {
  --bg: #efefef;
  --page-edge: #c7c7c7;
  --text: #111;
  --done: #b6b6b6;
  --line: #111;
  --date-bg: #151747;
  --urgent: #d92323;
  --urgent-bg: #ffe0e0;
  --important-bg: #d83a3a;
  --important-border: #b80000;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #222;
  color: var(--text);
  font-family: "Barlow Condensed", "Arial Narrow", Arial, sans-serif;
}

body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

/* Auf einem normalen Monitor bleibt die Vorschau im echten iPad-Verhältnis.
   Auf dem iPad selbst füllt sie automatisch den ganzen Bildschirm. */
.app {
  display: flex;
  flex-direction: column;
  width: min(100vw, 75vh);
  min-height: 100vh;
  background: var(--bg);
  border: clamp(8px, 1.5vw, 16px) solid var(--page-edge);
  transition: background-color .2s ease;
}

.app-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding:
    clamp(1rem, 2vh, 1.65rem)
    calc(3.3vw + var(--safe-right))
    calc(1.4vh + var(--safe-bottom))
    calc(3.3vw + var(--safe-left));
}

@supports (height: 100dvh) {
  body,
  .app {
    min-height: 100dvh;
  }

  .app {
    width: min(100vw, 75dvh);
  }
}


/* ================================================================
   Date header
   Dunkelgrauer, oben bündiger Datumsbalken.
   ================================================================ */

.date-header {
  margin: 0;
  padding:
    calc(clamp(.8rem, 1.7vh, 1.35rem) + var(--safe-top))
    calc(3.3vw + var(--safe-right))
    clamp(.8rem, 1.7vh, 1.35rem)
    calc(3.3vw + var(--safe-left));
  background: var(--date-bg);
  color: #fff;
  text-align: center;
}

.date {
  margin: 0;
  font-size: clamp(2.75rem, 6.75vw, 5.2rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.02em;
}


/* ================================================================
   Analog clock
   Mittig unter dem Datum, rund 20 Prozent grösser als zuvor.
   ================================================================ */

.clock-section {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: clamp(.7rem, 1.4vh, 1.1rem);
}

.clock {
  width: min(100%, 21.6vh);
  max-width: 100%;
  aspect-ratio: 1;
  position: relative;
  border-radius: 50%;
  background-image: url(../img/clock-face.png);
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
}

.clock-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.hand {
  position: absolute;
  left: 50%;
  bottom: 50%;
  transform-origin: bottom center;
  transform: translateX(-50%) rotate(0deg);
  border-radius: 999px;
}

.hour {
  width: 2.5%;
  height: 26%;
  background: #000;
}

.minute {
  width: 2.2%;
  height: 39%;
  background: #000;
}

.second {
  width: .75%;
  height: 41%;
  background: #cc2525;
}

.clock-center::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3.2%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #111;
  transform: translate(-50%, -50%);
}


/* ================================================================
   Today's appointments
   ================================================================ */

.agenda {
  border-top: 3px solid var(--line);
}

.agenda-item {
  display: grid;
  grid-template-columns:
    clamp(5.7rem, 18vw, 8.6rem)
    minmax(0, 1fr)
    clamp(3rem, 8vw, 4rem);
  align-items: center;
  gap: clamp(.35rem, 1.1vw, .7rem);
  min-height: clamp(4.15rem, 8.25vh, 5.65rem);
  padding: .12rem 0;
  border-bottom: 3px solid var(--line);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color .2s ease, color .2s ease, opacity .2s ease;
}

.agenda-item.is-important,
.agenda-item.is-urgent {
  color: var(--urgent);
}

.app.is-urgent {
  background: var(--urgent-bg);
}

.agenda-item.is-done {
  color: var(--done);
}

.agenda-time,
.agenda-label {
  font-size: clamp(2.28rem, 5vw, 3rem);
  line-height: .9;
}

.agenda-time {
  font-weight: 800;
  letter-spacing: .01em;
}

.agenda-label {
  min-width: 0;
  font-weight: 700;
  letter-spacing: .012em;
  overflow-wrap: anywhere;
}

.agenda-label strong {
  display: block;
}

.agenda-description {
  display: block;
  margin-top: .12em;
  font-size: .72em;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
}

.agenda-check {
  justify-self: end;
  width: clamp(3rem, 7vw, 3.5rem);
  height: clamp(3rem, 7vw, 3.5rem);
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  border: clamp(3px, .55vw, 5px) solid currentColor;
  background: transparent;
  position: relative;
  cursor: pointer;
}

.agenda-check:checked::after {
  content: "";
  position: absolute;
  left: 27%;
  top: 4%;
  width: 28%;
  height: 58%;
  border-right: clamp(4px, .65vw, 6px) solid currentColor;
  border-bottom: clamp(4px, .65vw, 6px) solid currentColor;
  transform: rotate(40deg);
}


/* ================================================================
   Tomorrow preview
   Erster Termin des Folgetags; wichtiger Termin zusätzlich.
   ================================================================ */

.next-day-preview {
  margin-top: auto;
  padding-top: clamp(.7rem, 1.35vh, 1rem);
}

.next-day-heading {
  padding: .28em .55em;
  background: var(--date-bg);
  color: #fff;
  font-size: clamp(1.35rem, 3.6vw, 2.35rem);
  font-weight: 600;
  line-height: 1;
  text-align: center;
}

.next-day-item {
  display: grid;
  grid-template-columns: clamp(4.7rem, 15vw, 7rem) minmax(0, 1fr);
  gap: clamp(.4rem, 1.2vw, .8rem);
  align-items: start;
  padding: clamp(.42rem, .9vh, .7rem) clamp(.45rem, 1vw, .75rem);
  border-right: 2px solid #aaa;
  border-bottom: 2px solid #aaa;
  border-left: 2px solid #aaa;
  background: #f8f8f8;
}

.next-day-item.is-important {
  color: var(--urgent);
}

.next-day-time,
.next-day-content {
  font-size: clamp(1.55rem, 4.2vw, 2.75rem);
  line-height: .95;
}

.next-day-time,
.next-day-content strong {
  font-weight: 700;
}

.next-day-content strong,
.next-day-description {
  display: block;
}

.next-day-description {
  margin-top: .12em;
  font-size: .72em;
  font-weight: 400;
  line-height: 1;
}


/* ================================================================
   Helpers and smaller screens
   ================================================================ */

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

@media (max-width: 520px) {
  .app {
    border-width: 6px;
  }

  .app-content {
    padding-right: 3vw;
    padding-left: 3vw;
  }
}
