:root {
  color-scheme: light dark;
  --corn: #f5c518;
  /* A cool grey page with flat white cards (Kwejk), and the dark equivalent. Corn is a fill with
     black text on it, never text on the light page. */
  --page: light-dark(#eef0f3, #121418);
  --surface: light-dark(#fff, #1e2128);
  --frame: light-dark(#dfe3e8, #14161a);
  --ink: light-dark(#14161a, #eceff4);
  --muted: light-dark(#5a6270, #a0a8b6);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 1rem;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

/* The rules below set `display` on these, which would otherwise beat the `hidden` attribute. */
.field[hidden],
.preview[hidden] {
  display: none;
}

/* Any class that sets `display` (the link card is a block today, a flex box tomorrow) must still
   lose to the hidden attribute: the fallback card of a player is hidden until the player fails. */
[hidden] {
  /* biome-ignore lint/complexity/noImportantStyles: the point of this rule is to beat any later display rule */
  display: none !important;
}

/* Text for screen readers only: the feed's heading. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

main {
  max-width: 40rem;
  margin: 0 auto;
}

h1 {
  margin: 0 0 0.5rem;
  border-bottom: 0.25rem solid var(--corn);
  display: inline-block;
}

/* Site header and footer. */
.site-header,
.site-footer {
  max-width: 40rem;
  margin-left: auto;
  margin-right: auto;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.25rem;
  border-bottom: 0.25rem solid var(--corn);
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 1rem;
}

.site-header a,
.link-button {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

.site-header form {
  margin: 0;
}

.brand {
  color: inherit;
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
}

/* The one loud thing in the header: a corn pill. */
.add-link {
  padding: 0 1rem;
  border-radius: 62.5rem;
  background: var(--corn);
  color: #000;
  font-weight: 700;
  text-decoration: none;
}

/* The bell: a link with a corn badge for the unread count. The script keeps both current. */
.bell {
  position: relative;
  justify-content: center;
  min-width: 2.75rem;
  color: inherit;
}

.bell-badge {
  position: absolute;
  top: 0.125rem;
  right: 0;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.25rem;
  border-radius: 62.5rem;
  background: var(--corn);
  color: #000;
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1.25rem;
  text-align: center;
}

/* The rule above sets `display`, which would otherwise beat the `hidden` attribute. */
.bell-badge[hidden] {
  display: none;
}

.site-footer {
  margin-top: 2rem;
  font-size: 0.875rem;
}

.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

/* A button that looks like a link: the header logout button. */
.link-button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: LinkText;
  text-decoration: underline;
  cursor: pointer;
}

:focus-visible {
  outline: 0.1875rem solid var(--corn);
  outline-offset: 0.125rem;
}

/* Forms: one column, controls at 16px so iOS does not zoom on focus, 44px touch targets. */
.form {
  display: grid;
  gap: 1rem;
  max-width: 26rem;
}

.field {
  display: grid;
  gap: 0.25rem;
}

.field label {
  font-weight: 600;
}

.hint {
  margin: 0;
  font-size: 0.875rem;
}

.field-error {
  margin: 0;
  font-size: 0.875rem;
  color: light-dark(#b00020, #ff8a80);
}

input[type="text"],
input[type="url"],
input[type="password"],
input[type="date"] {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid;
  border-radius: 0.375rem;
  font: inherit;
  font-size: 1rem;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: light-dark(#b00020, #ff8a80);
}

textarea {
  width: 100%;
  min-height: 5.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid;
  border-radius: 0.375rem;
  font: inherit;
  font-size: 1rem;
  resize: vertical;
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.checkbox input {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0.125rem 0 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.5rem 1.25rem;
  border: 0;
  text-decoration: none;
  border-radius: 0.375rem;
  background: var(--corn);
  color: #000;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

/* Errors and the no-recovery notice. */
.alert {
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  border-left: 0.25rem solid light-dark(#b00020, #ff8a80);
  background: light-dark(#fdecea, #3a1d1d);
}

.alert-notice {
  border-left-color: var(--corn);
  background: light-dark(#fff8d6, #3a3300);
}

.alert p {
  margin: 0;
}

.alert p + p {
  margin-top: 0.5rem;
}

/* The privacy notice: a wide table scrolls on its own instead of the page. */
.table-scroll {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.5rem;
  border-bottom: 1px solid light-dark(#ccc, #444);
  text-align: left;
  vertical-align: top;
}

/* The feed: one dense column of flat cards. A card is a bold title, a full-width picture and a quiet
   meta row. The title link is stretched over the whole card, so a tap anywhere opens the post. */
.feed {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card,
.post {
  position: relative;
  overflow: hidden;
  border-radius: 0.375rem;
  background: var(--surface);
}

.card-title,
.post-title {
  margin: 0;
  font-size: clamp(1.125rem, 4.6vw, 1.375rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.card-title a {
  display: block;
  padding: 0.75rem 0.875rem;
  color: inherit;
  text-decoration: none;
}

.card-title a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.card-title a:hover {
  text-decoration: underline 0.2em var(--corn);
}

.card-title a:focus-visible {
  outline: none;
}

.card-title a:focus-visible::after {
  outline: 0.1875rem solid var(--corn);
  outline-offset: -0.1875rem;
}

/* The picture. A thumbnail has its size in width and height, a hotlinked photo a fixed shape, and
   a post with no picture a tile of fixed height: nothing moves when an image arrives. */
.media-frame,
.media-link {
  position: relative;
  display: block;
  background: var(--frame);
}

.media {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.media-hotlink {
  width: 100%;
  aspect-ratio: 4 / 3;
  /* Never crop: the top and bottom text of a meme must stay readable. The frame fills the rest. */
  object-fit: contain;
}

.media-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 7.5rem;
  padding: 1.5rem 1rem;
  background: var(--corn);
  color: #000;
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  overflow-wrap: anywhere;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0 0.875rem;
  min-height: 2.75rem;
  padding: 0 0.875rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.card-author {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-age {
  white-space: nowrap;
}

.card-comments {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  margin-left: auto;
  color: inherit;
  font-weight: 700;
  text-decoration: none;
}

.card-comments:hover {
  color: var(--ink);
}

.icon {
  flex: none;
}

.pager {
  margin-top: 1rem;
}

.pager .button {
  display: flex;
  width: 100%;
}

.empty {
  padding: 2rem 1rem;
  border-radius: 0.375rem;
  background: var(--surface);
  text-align: center;
}

.empty-text {
  margin: 0 0 1rem;
  font-size: 1.125rem;
  font-weight: 700;
}

/* A post's own page: the same card, a larger title, the link out and a place for comments. */
.post-title {
  display: block;
  padding: 0.875rem;
  border: 0;
  font-size: clamp(1.375rem, 6vw, 1.75rem);
  line-height: 1.15;
}

.source {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.875rem;
  margin: 0;
  padding: 0.875rem;
}

.source-host {
  color: var(--muted);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.comments {
  margin-top: 1.5rem;
}

.comments h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.comment-login {
  margin: 0 0 1rem;
}

.comment-form {
  display: grid;
  gap: 0.75rem;
  margin: 0 0 1rem;
}

.comment-form .button {
  justify-self: start;
}

/* A thread is a flat list; depth is indentation. A reply gets a corn rail on its left, and the
   rail steps in by a small amount per level, so three levels still leave a phone column its text. */
.comment-list {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.comment {
  padding: 0.625rem 0.875rem 0;
  border-radius: 0.375rem;
  background: var(--surface);
  overflow-wrap: anywhere;
  scroll-margin-top: 1rem;
}

.comment[data-depth="2"],
.comment[data-depth="3"] {
  border-left: 0.125rem solid var(--corn);
  border-radius: 0 0.375rem 0.375rem 0;
}

.comment[data-depth="2"] {
  margin-left: 0.75rem;
}

.comment[data-depth="3"] {
  margin-left: 1.5rem;
}

@media (min-width: 40rem) {
  .comment[data-depth="2"] {
    margin-left: 1.5rem;
  }

  .comment[data-depth="3"] {
    margin-left: 3rem;
  }
}

/* The comment a link points at: just written, or opened from a notification. */
.comment:target,
.comment-focus {
  outline: 0.1875rem solid var(--corn);
}

.comment-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.75rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.comment-author {
  color: var(--ink);
  font-weight: 700;
}

.comment-to {
  overflow-wrap: anywhere;
}

.comment-age {
  white-space: nowrap;
}

.comment-text {
  margin: 0.25rem 0 0.625rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comment-gone {
  color: var(--muted);
}

.comment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1rem;
  margin-top: -0.375rem;
}

.comment-action summary {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.comment-action[open] {
  flex-basis: 100%;
}

.comment-action[open] summary {
  color: var(--ink);
}

.comment-action .comment-form {
  margin: 0 0 0.75rem;
}

.comment-pager {
  display: grid;
  gap: 0.5rem;
  margin-top: 1rem;
}

.comment-pager .button {
  display: flex;
  width: 100%;
}

/* The notifications page: one row per notification, a corn bar and dot on the unread ones. Opening
   a row is a form post (it marks the notification read), so the button is the whole row. */
.notification-all {
  margin: 0 0 1rem;
}

.notification-list {
  display: grid;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.notification {
  border-left: 0.25rem solid transparent;
  border-radius: 0 0.375rem 0.375rem 0;
  background: var(--surface);
}

.notification-unread {
  border-left-color: var(--corn);
}

.notification form {
  margin: 0;
}

.notification-open {
  display: grid;
  gap: 0.125rem;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.625rem 0.875rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.notification-who {
  font-weight: 800;
}

.notification-unread .notification-who::after {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-left: 0.5rem;
  border-radius: 50%;
  background: var(--corn);
}

.notification-what {
  overflow-wrap: anywhere;
}

.notification-post,
.notification-age {
  color: var(--muted);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

/* The add form: the thumbnail preview and its status line. */
.preview {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 0.375rem;
  background: var(--frame);
}

.status {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.status:empty {
  display: none;
}

/* The admin panel (task 9): wide tables of text that visitors chose. */
.admin-main {
  max-width: 72rem;
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1rem;
  margin-bottom: 0.5rem;
}

.admin-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

.admin-nav a[aria-current="page"] {
  font-weight: 700;
  text-decoration: none;
  border-bottom: 0.25rem solid var(--corn);
}

.admin-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem 1rem;
  margin: 0 0 1rem;
}

.admin-filter .field {
  min-width: 11rem;
}

.admin-filter a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

/* On a phone the table keeps a width of its own, so its scroll container scrolls and the cells do not
   shrink to a few letters; times, addresses and numbers stay in one piece, only what a visitor
   chose (path, user agent) wraps. */
.admin-table {
  min-width: 44rem;
}

.admin-table-compact {
  min-width: 0;
}

.admin-nowrap {
  white-space: nowrap;
}

.admin-wrap {
  overflow-wrap: anywhere;
}

.admin-summary {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
}

.admin-summary dt {
  font-weight: 600;
}

.admin-summary dd {
  margin: 0;
}

.admin-ip {
  overflow-wrap: anywhere;
}

/* The account page: the id is meant to be copied, so one click or tap selects all of it. */
.account-id {
  overflow-wrap: anywhere;
  user-select: all;
}

/* Videos. The feed and the facade show OUR stored thumbnail with a play badge and ask the platform
   for nothing; the player is created only after a click (src/client/media.ts). YouTube's frames are
   4:3 with black bars around a 16:9 picture, so they are cropped to 16:9; a TikTok thumbnail is tall
   and is capped. The badge lets a tap through to the link under it. */
.play-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.play-badge svg {
  width: 3.5rem;
  height: 3.5rem;
}

.media-video {
  width: 100%;
}

.media-video-youtube {
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.media-video-tiktok {
  max-height: 36rem;
  object-fit: cover;
}

/* The player's box has a fixed shape before and after the click, so the page does not jump. */
.embed {
  background: #000;
}

.embed-facade {
  position: relative;
  display: block;
  overflow: hidden;
}

.embed-facade .media,
.embed-facade .media-tile {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.embed-frame {
  display: block;
  width: 100%;
  border: 0;
  background: #000;
}

.embed-youtube .embed-facade,
.embed-youtube .embed-frame {
  aspect-ratio: 16 / 9;
}

.embed-tiktok {
  max-width: 24rem;
  margin: 0 auto;
}

.embed-tiktok .embed-facade,
.embed-tiktok .embed-frame {
  aspect-ratio: 325 / 740;
}

.embed-note,
.media-note {
  margin: 0;
  padding: 0.5rem 0.875rem;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.875rem;
}

/* A video that cannot be played here: the picture, why, and a way to the source. */
.link-card {
  background: var(--surface);
}

.link-card-text {
  margin: 0;
  padding: 0.875rem 0.875rem 0.5rem;
  font-weight: 700;
}

.link-card-action {
  margin: 0;
  padding: 0 0.875rem 0.875rem;
}
