/* Shared chrome: background, headings, and the four floating info boxes.
   Lifted from the original pages, with the duplicated and self-contradicting
   media queries collapsed into one ladder. */

@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/static/font.ttf) format('truetype');
}

html, body {
  margin: 0;
  padding: 0;
  /* Never hidden on the y axis. The old build set `overflow: hidden` here,
     which on a short screen left the login form's submit button below the
     fold with no way to scroll down to it. */
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #f0f4ff 0%, #d9e4ff 50%, #c4d4ff 100%);
  color: #333;
  text-align: center;
  min-height: 100vh;
  position: relative;
}

h1 {
  margin: 30px 0 50px;
  font-size: 9em;
  color: #1a1a1a;
  font-family: 'Poppins', sans-serif;
}

p {
  font-size: 1.2em;
  margin-bottom: 60px;
  color: #555;
}

a { color: #3355ff; }

hr { border: none; border-top: 1px solid rgba(0, 0, 0, 0.12); }

/* Was style="color:red" inline, which a strict CSP will not allow. */
.alert { color: #c00; }

/* --- the three tiles on the homepage ------------------------------------ */

.container {
  display: flex;
  justify-content: center;
  gap: 50px;
  flex-wrap: wrap;
  margin-bottom: 80px;
}

.box {
  position: relative;   /* anchors the unread badge to this tile */
  background: linear-gradient(145deg, #ffffff, #e6f0ff);
  border-radius: 20px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  width: 140px;
  height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-decoration: none;
  color: #1a1a1a;
  transition: transform 0.3s, box-shadow 0.3s, background 0.3s;
}

/* Unread-message count on the messages tile. Rendered only when there is one
   to show (see routes/pages.py), and cleared the moment the messages page is
   opened, so its mere presence means "new". */
.msg-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e5342b;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  border-radius: 13px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.box:hover {
  transform: translateY(-10px) scale(1.05);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  background: linear-gradient(145deg, #d0e0ff, #ffffff);
}

.box img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-bottom: 10px;
}

.box span {
  font-size: 1.1em;
  font-weight: 600;
}

/* --- floating info boxes ------------------------------------------------- */

.visit-counter,
.click-counter,
.ip-box,
.username-box {
  position: fixed;
  font-size: 0.9em;
  color: #333;
  background: rgba(255, 255, 255, 0.8);
  padding: 5px 10px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 100;
}

.visit-counter { bottom: 10px; left: 10px; }
.click-counter { bottom: 10px; right: 10px; }
.ip-box        { top: 10px;    left: 10px; }
.username-box  { top: 10px;    right: 10px; }

/* Logging out changes state, so it is a form rather than a link -- styled to
   read as a link so the corner box looks the way it always did. */
.logout-form { display: inline; }

.logout-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: #3355ff;
  text-decoration: underline;
  cursor: pointer;
}

/* --- responsive ladder --------------------------------------------------- */

@media (max-width: 1000px) {
  .visit-counter, .click-counter, .ip-box, .username-box {
    font-size: 0.8em;
    padding: 4px 8px;
    max-width: 90vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 900px) {
  h1 { font-size: 6em; }
}

/* The boxes keep shrinking as the screen does, but never below legibility:
   the old ladder bottomed out at 0.3em (~5px), and the top-right box is where
   the login link and logout button live -- at that size they could neither be
   read nor tapped. */

@media (max-width: 768px) {
  .visit-counter, .click-counter, .ip-box, .username-box {
    font-size: 0.7em;
    padding: 3px 6px;
  }

  .container { flex-direction: column; gap: 30px; align-items: center; }
}

@media (max-width: 600px) {
  h1 { font-size: 4em; }
}

@media (max-width: 500px) {
  .visit-counter, .click-counter, .ip-box, .username-box {
    font-size: 0.65em;
    padding: 2px 5px;
    max-width: 95vw;
  }
}

@media (max-width: 400px) {
  .visit-counter, .click-counter, .ip-box, .username-box {
    font-size: 0.6em;
    padding: 2px 4px;
    max-width: 98vw;
  }
}

/* On a phone the two bottom boxes leave their corners, center horizontally and
   stack -- pinned bottom-left and bottom-right they crowd the edges once the
   font shrinks, and a centered pair reads better. Scoped away from the
   chat/notes/inbox pages, whose fixed composer already owns the bottom edge.
   The boxes are single-line here (nowrap, from the 1000px step up the ladder),
   so lifting the upper one by its own height keeps the gap right at every
   font-size this ladder lands on. */
@media (max-width: 600px) {
  body:not(.page-message) .visit-counter,
  body:not(.page-message) .click-counter {
    left: 50%;
    right: auto;
    text-align: center;
  }

  body:not(.page-message) .click-counter {
    bottom: 10px;
    transform: translateX(-50%);
  }

  body:not(.page-message) .visit-counter {
    bottom: 10px;
    transform: translate(-50%, calc(-100% - 6px));
  }
}

/* --- error pages ---------------------------------------------------------
   The originals were unstyled fragments of raw HTML. They get the site's
   look now, at a heading size that suits "500 Internal Server Error". */

body.page-error h1 {
  font-size: 3.5em;
  margin: 40px 0 20px;
}

body.page-error h3 {
  max-width: 900px;
  margin: 0 auto 20px;
  padding: 0 20px;
  font-size: 1.1em;
  font-weight: 600;
  color: #444;
}

body.page-error .error-body {
  max-width: 900px;
  margin: 20px auto 60px;
  padding: 0 20px;
  text-align: left;
}

body.page-error .error-body p {
  font-size: 1em;
  line-height: 1.5;
  margin-bottom: 20px;
}

/* The 99.9-recurring joke needs its overline back. */
.repeating { text-decoration: overline; }

@media (max-width: 600px) {
  body.page-error h1 { font-size: 2em; }
}
