/* The page, the sky, the shell (side panel / bottom bar) and the sun.  OWNER: Ultron. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font: 400 var(--t-body)/1.6 var(--font-body);
  color: var(--evergreen);
  background: var(--sky-low);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--tide); text-underline-offset: 3px; text-decoration-thickness: 1px; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-ctl); }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
p { margin: 0; text-wrap: pretty; }
h1, h2, h3 { margin: 0; text-wrap: balance; }

/* ---------------------------------------------------------------- the sky */
.sky {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, var(--sky-high) 0%, var(--sky-haze) 46%, var(--sky-low) 78%);
}
.sky::after {           /* mountains, evergreens and the Sound, low at the bottom */
  content: ""; position: absolute; inset: auto 0 0 0;
  height: clamp(150px, 30vh, 340px);
  background: url("../assets/sky.svg") center bottom / cover no-repeat;
  transition: opacity var(--slow) var(--ease);
}
.sky::before {          /* the veil that dims the sky behind reading */
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: rgb(253 244 232 / 0.45);
  opacity: 0; transition: opacity var(--slow) var(--ease);
}
body.is-reading .sky::before { opacity: 1; }
body.is-reading .sky::after { opacity: 0.3; }   /* keeps text on the sky at 4.5:1 over the trees */

/* ---------------------------------------------------------------- the sun */
.sun { position: relative; width: 112px; aspect-ratio: 1; flex: none; }
.sun svg { width: 100%; height: 100%; overflow: visible; }
.sun .glow { transform-box: fill-box; transform-origin: center; }
.sun .mouth-flat { display: none; }
.sun.is-neutral .mouth-smile { display: none; }
.sun.is-neutral .mouth-flat { display: inline; }
.sun.is-waiting .glow { animation: glow 2.4s var(--ease) infinite alternate; }
.sun.is-small { width: 56px; }
@keyframes glow { from { opacity: .55; transform: scale(.9); } to { opacity: 1; transform: scale(1.12); } }
@media (prefers-reduced-motion: reduce) {
  .sun.is-waiting .glow { animation: none; }
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; animation-iteration-count: 1 !important; }
}

/* ---------------------------------------------------------------- the shell */
.shell { min-height: 100dvh; }
.main { min-height: 100dvh; padding-left: var(--side); transition: padding var(--slow) var(--ease); }
.view { min-height: 100dvh; }

.side {
  position: fixed; inset: 0 auto 0 0; z-index: 20; width: var(--side);
  display: flex; flex-direction: column; gap: var(--s3);
  padding: var(--s3) var(--s2) calc(var(--s2) + 56px);
  background: rgb(253 244 232 / 0.52);
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  box-shadow: inset -1px 0 0 var(--hairline);
  transition: width var(--slow) var(--ease);
}
.side-logo { display: block; padding: 0 var(--s1); border-radius: var(--r-ctl); }
.side-logo img { width: 100%; max-width: 168px; height: auto; margin: 0 auto; }
.side-logo .emblem { display: none; width: 40px; height: 40px; }

.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-1); }
.nav a {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 0 12px; border-radius: var(--r-ctl);
  color: var(--evergreen-soft); font-weight: 500; text-decoration: none;
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.nav a:hover { background: rgb(255 255 255 / 0.5); color: var(--evergreen); }
.nav a[aria-current="page"] { background: var(--paper); color: var(--evergreen); box-shadow: var(--lift); }
.nav a:focus-visible, .nav a[aria-current="page"]:focus-visible { box-shadow: var(--ring); }
.nav .icon { width: 22px; height: 22px; flex: none; }

.side-foot { margin-top: auto; display: grid; gap: var(--s1); padding: 0 12px; }
.checked { font-size: var(--t-sm); color: var(--evergreen-soft); line-height: 1.45; }
.side-tools { display: flex; gap: var(--s1); }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  border: 0; border-radius: var(--r-ctl); background: transparent; color: var(--evergreen-soft);
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.icon-btn:hover { background: rgb(255 255 255 / 0.55); color: var(--evergreen); }
.icon-btn:active { transform: scale(0.97); }
.icon-btn .icon { width: 20px; height: 20px; }

/* collapsed: a 64 px strip of icons */
.shell.is-collapsed .main { padding-left: var(--side-closed); }
.shell.is-collapsed .side { width: var(--side-closed); padding-inline: 10px; }
.shell.is-collapsed .side-logo .full { display: none; }
.shell.is-collapsed .side-logo .emblem { display: block; }
.shell.is-collapsed .side-logo { padding: 0; }
.shell.is-collapsed .nav a { justify-content: center; padding: 0; }
.shell.is-collapsed .nav span,
.shell.is-collapsed .checked { display: none; }
.shell.is-collapsed .side-foot { padding: 0; }
.shell.is-collapsed .side-tools { flex-direction: column; align-items: center; }
.shell.is-collapsed .collapse-icon { transform: scaleX(-1); }

/* phone: no side panel, a bottom bar holds the three sections */
@media (max-width: 860px) {
  .main, .shell.is-collapsed .main { padding-left: 0; padding-bottom: 72px; }
  .side, .shell.is-collapsed .side {
    inset: auto 0 0 0; width: auto; height: calc(64px + env(safe-area-inset-bottom));
    padding: 6px var(--s1) env(safe-area-inset-bottom); flex-direction: row;
    box-shadow: inset 0 1px 0 var(--hairline);
    background: rgb(253 244 232 / 0.82);
  }
  .side-logo, .side-foot { display: none; }
  .sky::after { bottom: 64px; height: 200px; background-position: 8% bottom; }
  .nav { grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
  .nav a, .shell.is-collapsed .nav a {
    flex-direction: column; justify-content: center; gap: 2px; padding: 0;
    font-size: 12px; min-height: 52px;
  }
  .shell.is-collapsed .nav span { display: inline; }
  .nav a[aria-current="page"] { background: transparent; box-shadow: none; color: var(--evergreen); font-weight: 600; }
}

/* ---------------------------------------------------------------- sign in */
.signin {
  min-height: 100dvh; display: grid; place-items: center; padding: var(--s3) var(--s2) 30vh;
}
.signin form { width: min(360px, 100%); display: grid; justify-items: center; gap: var(--s2); }
.signin .sun { margin-bottom: var(--s1); }
.signin .field { width: 100%; }
.signin .btn-primary { width: 100%; }
.signin .error { min-height: 1.6em; font-size: var(--t-sm); color: var(--evergreen); font-weight: 600; text-align: center; }

/* the mockup's sample-data tag (only with ?demo) */
.demo-pill {
  position: fixed; top: var(--s1); right: var(--s1); z-index: -1;
  padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: rgb(255 255 255 / 0.7); color: var(--evergreen-soft); box-shadow: var(--lift);
}
