/* ==========================================================
   css/guestbook.css — Community app styles
   Guestbook main pane + creator subpanel + side dialogues
   ========================================================== */

/* --- Community shell --- */
.community-content {
  position: relative;
  display: flex;
  flex-direction: row;
  height: 100%;
  padding: 0;
  font-family: "VT323", monospace;
  background: #f7f7f7;
  overflow: hidden;
}

/* In-window dialogue over the Community panes — not a separate OS window. */
.community-dialog {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.community-dialog[hidden] {
  display: none !important;
}

.community-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

.community-dialog-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 340px);
  padding: 18px 18px 16px;
  border: 3px solid #000;
  background: #fff;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.9);
}

.community-dialog-panel h3 {
  margin: 0 0 10px;
  font-size: 22px;
  line-height: 1.1;
}

.community-dialog-panel p {
  margin: 0 0 16px;
  font-size: 17px;
  line-height: 1.35;
}

.community-dialog-actions {
  display: flex;
  justify-content: flex-end;
}

.community-main,
.community-creator-panel {
  flex: 1 1 50%;
  width: 50%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.community-creator-panel {
  border-left: 3px solid #000;
  background: #f0f0f0;
}

.community-creator-panel[hidden] {
  display: none !important;
}

.community-creator-header {
  background: #e0e0e0;
  border-bottom: 2px solid #000;
  padding: 12px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.community-creator-header h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.1;
}

.community-creator-panel .noticeboard-posts {
  flex: 1;
  min-height: 0;
  padding: 15px;
  gap: 12px;
}

.community-nb-compose {
  border-top: 2px solid #000;
  max-height: 55%;
  overflow-y: auto;
}

.community-nb-compose textarea {
  height: 120px;
}

.community-nb-card .nb-card-header {
  background: #fff;
  border-bottom: none;
  padding: 14px 15px 0;
}

.community-nb-card .nb-card-author {
  display: block;
  font-size: 19px;
  font-weight: bold;
  margin-bottom: 4px;
}

.community-nb-card .nb-card-title {
  font-size: 18px;
  font-weight: bold;
}

.community-nb-card .nb-card-date {
  margin-top: 4px;
  margin-bottom: 0;
}

.community-nb-card .nb-card-body {
  padding: 10px 15px 14px;
  font-size: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
}

/* Wrappers dissolve into the header grid so desktop can be one row and
   mobile can stack without fighting nested flex. */
.gb-list-header-top,
.gb-list-header-tools {
  display: contents;
}

.gb-post-label-short {
  display: none;
}

.community-creator-header-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

/* Mobile-only pane switcher. A span + link styling, so theme `button`
   rules cannot fatten it back into a second full-width slab. */
.community-view-toggle {
  display: none;
  font-family: "VT323", monospace;
  font-size: 15px;
  line-height: 1.15;
  padding: 0;
  border: none;
  background: transparent;
  color: #1a5bc4;
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
  user-select: none;
}

.community-view-toggle:hover {
  color: #000;
}

#community .community-title-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Layout --- */
.guestbook-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  font-family: "VT323", monospace;
  background: #f7f7f7;
}

#gb-view-list,
#gb-view-detail,
#gb-view-compose {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* --- List View Header --- */
.gb-list-header {
  background: #e0e0e0;
  border-bottom: 2px solid #000;
  padding: 12px 15px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px 14px;
  align-items: center;
  flex-shrink: 0;
}

.gb-list-header h3 {
  margin: 0;
  font-size: 22px;
  min-width: 0;
  grid-column: 1;
  grid-row: 1;
}

.gb-search {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
  min-width: 0;
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  width: 100%;
}

.gb-post-btn {
  flex-shrink: 0;
  white-space: nowrap;
  grid-column: 3;
  grid-row: 1;
}

.gb-search-label {
  font-size: 15px;
  color: #444;
  flex-shrink: 0;
}

.gb-search input {
  flex: 1;
  min-width: 0;
  font-family: "VT323", monospace;
  font-size: 16px;
  padding: 5px 8px;
  border: 2px solid #000;
  background: #fff;
  outline: none;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.85);
}

/* --- Detail / Compose Headers --- */
.gb-detail-header {
  background: #e0e0e0;
  border-bottom: 2px solid #000;
  padding: 10px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.gb-detail-header h3 {
  margin: 0;
  font-size: 20px;
}

/* --- Message List --- */
.guestbook-list {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guestbook-loader {
  width: 100%;
  min-height: 100%;
  padding: 12px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.guestbook-loader-panel {
  width: min(100%, 440px);
  border: 3px solid #000;
  background: #fff;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.9);
  padding: 18px 18px 16px;
}

.guestbook-loader-title {
  margin-bottom: 12px;
  text-align: center;
  font-size: 24px;
  color: #000;
}

.guestbook-loader-track {
  position: relative;
  height: 24px;
  border: 2px solid #000;
  background: #dcdcdc;
  overflow: hidden;
}

.guestbook-loader-track::before {
  content: "";
  position: absolute;
  inset: 3px;
  background: repeating-linear-gradient(
    90deg,
    #f5f5f5 0 12px,
    #bdbdbd 12px 24px
  );
  animation: gbLoaderGrid 0.9s linear infinite;
}

.guestbook-loader-track::after {
  content: "";
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: -24%;
  width: 24%;
  background: #32cd32;
  animation: gbLoaderSweep 1.1s steps(6, end) infinite;
}

.guestbook-loader-copy {
  margin-top: 14px;
  text-align: center;
  font-size: 18px;
  color: #555;
}

@keyframes gbLoaderGrid {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 24px 0;
  }
}

@keyframes gbLoaderSweep {
  from {
    left: -24%;
  }
  to {
    left: 100%;
  }
}

.guestbook-list-item {
  background: #fff;
  border: 2px solid #000;
  padding: 12px 15px;
  cursor: pointer;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.9);
  transition:
    transform 0.1s,
    box-shadow 0.1s;
}

.guestbook-list-item:hover {
  background: #fdfdfd;
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.9);
}

.guestbook-list-item:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.9);
}

.gb-list-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.guestbook-list-item .gb-name {
  font-size: 19px;
  font-weight: bold;
  display: block;
}

.gb-list-delete {
  flex-shrink: 0;
  padding: 3px 8px;
  font-size: 14px;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.9);
}

.guestbook-list-item .gb-preview {
  font-size: 15px;
  color: #555;
  display: -webkit-box;
  margin-top: 6px;
  white-space: pre-wrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
}

.guestbook-list-item .gb-date {
  font-size: 13px;
  color: #888;
  display: block;
  margin-top: 6px;
}

/* --- Detail Body --- */
.guestbook-detail-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  font-size: 18px;
  line-height: 1.7;
  background: #fff;
}

/* --- Compose Area --- */
.guestbook-compose {
  flex: 1;
  background: #f7f7f7;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guestbook-compose input,
.guestbook-compose textarea {
  width: 100%;
  font-family: "VT323", monospace;
  font-size: 18px;
  padding: 10px 12px;
  border: 2px solid #000;
  background: #fff;
  box-sizing: border-box;
  outline: none;
}

.guestbook-compose input {
  margin-bottom: 0;
}

.guestbook-compose textarea {
  flex: 1;
  resize: none;
  min-height: 150px;
  margin-bottom: 0;
}

.guestbook-compose-actions {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 3px;
}

.gb-emoji-anchor {
  position: relative;
  display: flex;
  align-items: flex-end;
}

.gb-emoji-toggle {
  min-width: 110px;
  padding: 6px 12px;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.9);
}

.gb-emoji-toggle[aria-expanded="true"] {
  background: #000;
  color: #fff;
}

.gb-emoji-picker {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  z-index: 30;
  width: min(320px, calc(100vw - 90px));
  border: 2px solid #000;
  background: rgba(240, 240, 240, 0.78);
  backdrop-filter: blur(8px);
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.65);
  padding: 10px;
}

.gb-emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.gb-emoji-option {
  font-family: "VT323", monospace;
  font-size: 24px;
  min-height: 42px;
  border: 1px solid rgba(0, 0, 0, 0.35);
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  box-shadow: none;
  transition: background 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gb-emoji-option:hover {
  background: rgba(255, 255, 255, 0.95);
}

.gb-emoji-option:active {
  background: #000;
  color: #fff;
}

/* --- Buttons --- */
.gb-btn {
  font-family: "VT323", monospace;
  font-size: 16px;
  padding: 6px 16px;
  border: 2px solid #000;
  background: #fff;
  cursor: pointer;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.9);
  transition: background 0.1s;
}

.gb-btn:hover {
  background: #e0e0e0;
}

.gb-btn:active {
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.9);
  transform: translate(2px, 2px);
}

.gb-btn-send {
  background: #4a90e2;
  color: #fff;
  border-color: #000;
}

.gb-btn-send:hover {
  background: #357abd;
}

.gb-btn-delete {
  background: #fff;
  color: #ff3b30;
  border-color: #ff3b30;
  font-size: 14px;
  padding: 4px 10px;
  box-shadow: 3px 3px 0 rgba(255, 59, 48, 0.5);
}

.gb-btn-delete:hover {
  background: #ff3b30;
  color: #fff;
}

/* --- Empty State --- */
.guestbook-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #666;
  font-size: 18px;
  text-align: center;
  padding: 20px;
}

.guestbook-empty p {
  margin: 5px 0;
}

/* --- Notification --- */
.gb-notification {
  position: fixed;
  top: 40px;
  right: 20px;
  padding: 10px 20px;
  font-family: "VT323", monospace;
  font-size: 16px;
  border: 3px solid #000;
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.9);
  z-index: 10000;
  animation: gbSlideIn 0.3s ease-out;
}

.gb-notification.success {
  background: #32cd32;
  color: #000;
}

.gb-notification.error {
  background: #ff3b30;
  color: #fff;
}

@keyframes gbSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* --- Profanity Warning --- */
.gb-warning {
  color: #ff3b30;
  font-size: 14px;
  margin-bottom: 8px;
}

/* --- Detail meta --- */
.gb-detail-meta {
  color: #888;
  font-size: 15px;
  margin-bottom: 15px;
}

/* =====================================================================
   💬 Community Desktop Prompt
   ===================================================================== */

/* Same bubble idiom as Morphy's speech bubble in css/trash.css. Points at the
   Community desktop icon from the left; the tail points right and rides
   --side-bubble-tail-y. */
.guestbook-prompt {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 5050;
  max-width: 260px;
  padding: 8px 12px;
  border: 3px solid #000;
  background: #fffdf2;
  color: #000;
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.9);
  font-family: "VT323", monospace;
  font-size: 20px;
  line-height: 1.1;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  /* On the way out visibility is held back until the fade finishes, so the
     bubble is actually seen leaving. */
  transition: opacity 0.4s ease, visibility 0s 0.4s;
}

.guestbook-prompt.visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.4s ease, visibility 0s 0s;
}

/* The rotated square points with whichever corner has no borders drawn on the
   far side of it; top+right send it right, where the dock bubbles use
   right+bottom to send it down. */
.guestbook-prompt::after {
  content: "";
  position: absolute;
  top: var(--side-bubble-tail-y, 22px);
  right: -13px;
  width: 18px;
  height: 18px;
  border-top: 3px solid #000;
  border-right: 3px solid #000;
  background: #fffdf2;
  transform: rotate(45deg);
}

/* Creator dialogue hangs off the right edge; tail points left. */
.guestbook-prompt-right::after {
  left: -13px;
  right: auto;
  border-top: none;
  border-right: none;
  border-bottom: 3px solid #000;
  border-left: 3px solid #000;
}

/* A maximized window covers the desktop, and there is no longer a side edge to
   hang off. */
body.has-fullscreen-window .guestbook-prompt {
  display: none !important;
}

@media (max-width: 700px) {
  #community .community-view-toggle {
    display: inline;
  }

  /* One pane at a time on phones; the in-header link switches them. */
  .community-content.creator-open {
    flex-direction: row;
  }

  .community-content.creator-open .community-main,
  .community-content.creator-open .community-creator-panel {
    flex: 1 1 100%;
    width: 100%;
    border-left: none;
  }

  .community-content.creator-open:not(.mobile-show-creator) .community-creator-panel {
    display: none !important;
  }

  .community-content.creator-open.mobile-show-creator .community-main {
    display: none !important;
  }

  .community-content.creator-open.mobile-show-creator .community-creator-panel {
    display: flex !important;
  }

  /* Compact chrome, roomy comments:
     title + Post on one row, search below, creator as a light link. */
  .gb-list-header {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
    padding: 12px 14px 14px;
    gap: 10px 12px;
    background: linear-gradient(#ececec, #e2e2e2);
  }

  .gb-list-header h3 {
    font-size: 20px;
    letter-spacing: 0.2px;
    grid-column: 1;
    grid-row: 1;
  }

  .gb-post-btn {
    grid-column: 2;
    grid-row: 1;
    padding: 6px 14px;
    font-size: 16px;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.85);
  }

  .gb-search {
    grid-column: 1 / -1;
    grid-row: 2;
    max-width: none;
    justify-self: stretch;
    width: 100%;
  }

  .gb-list-header .community-view-toggle {
    grid-column: 1 / -1;
    grid-row: 3;
    font-size: 16px;
    padding-top: 2px;
  }

  .gb-search-label {
    display: none;
  }

  .gb-search input {
    width: 100%;
    padding: 8px 10px;
    font-size: 17px;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.8);
  }

  .gb-post-label-full {
    display: none;
  }

  .gb-post-label-short {
    display: inline;
  }

  .community-creator-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px 14px;
  }

  .community-creator-header-text {
    gap: 8px;
  }

  .community-creator-header h3 {
    font-size: 20px;
  }

  .guestbook-list {
    padding: 16px 14px 22px;
    gap: 14px;
    background:
      repeating-linear-gradient(
        0deg,
        transparent,
        transparent 27px,
        rgba(0, 0, 0, 0.035) 27px,
        rgba(0, 0, 0, 0.035) 28px
      );
  }

  .guestbook-list-item {
    padding: 14px 14px 12px;
    border-width: 3px;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.88);
  }

  .guestbook-list-item .gb-name {
    font-size: 20px;
  }

  .guestbook-list-item .gb-preview {
    margin-top: 8px;
    font-size: 16px;
    line-height: 1.35;
  }

  .guestbook-list-item .gb-date {
    margin-top: 10px;
    font-size: 13px;
  }

  .community-creator-panel .noticeboard-posts {
    padding: 16px 14px 22px;
    gap: 14px;
  }
}

@media (max-width: 600px) {
  .guestbook-compose {
    padding: 15px;
  }

  .gb-emoji-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    max-height: 140px;
  }

  .guestbook-compose-actions {
    align-items: stretch;
  }

  .gb-emoji-anchor {
    flex: 1;
  }

  .gb-emoji-picker {
    width: min(280px, calc(100vw - 60px));
  }

  .gb-emoji-toggle,
  .guestbook-compose-actions .gb-btn-send {
    width: auto;
  }
}
