:root {
  --community-cream: #ffe3ad;
  --community-paper: #fff8e8;
  --community-brown: #8f4f36;
  --community-brown-dark: #4b2b22;
  --community-green: #214936;
  --community-blue: #bceaf2;
}

.community-body {
  min-height: 100vh;
  background:
    linear-gradient(rgba(207, 237, 230, 0.36), rgba(114, 166, 86, 0.26)),
    url("../assets/images/menu/glass-effect.png") center top / cover fixed no-repeat;
}

.community-page {
  width: min(92%, 1480px);
  margin-inline: auto;
  padding: clamp(34px, 5vw, 78px) 0 clamp(56px, 7vw, 104px);
}

.community-page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: clamp(26px, 3vw, 42px);
  padding-inline: clamp(2px, 1.6vw, 24px);
}

.community-page-heading p,
.community-dialog-header p {
  margin: 0 0 7px;
  color: var(--community-green);
  font-family: "Atkinson Hyperlegible", Arial, sans-serif;
  font-size: clamp(16px, 1.25vw, 20px);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.community-page-heading h1 {
  margin: 0;
  color: #241813;
  font-family: "Pixelify Sans", monospace;
  font-size: clamp(42px, 5.4vw, 82px);
  font-weight: 600;
  line-height: 0.92;
}

.community-page-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 14px;
}

.community-add-button,
.dialog-close {
  position: relative;
  display: grid;
  width: 54px;
  height: 54px;
  padding: 0;
  place-items: center;
  border: 4px solid #5b3524;
  border-radius: 0;
  background: #a75f42;
  box-shadow: 4px 4px 0 rgba(36, 23, 17, 0.28);
  color: #fff7e7;
  cursor: pointer;
  font-family: "Pixelify Sans", monospace;
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  transition: filter 150ms ease, transform 150ms ease;
}

.community-add-button:hover,
.community-add-button:focus-visible,
.dialog-close:hover,
.dialog-close:focus-visible {
  filter: brightness(1.1);
  transform: translateY(-2px);
}

.dialog-close {
  color: transparent;
  font-size: 0;
}

.dialog-close::before,
.dialog-close::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 27px;
  height: 5px;
  background: #fff7e7;
  content: "";
}

.dialog-close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.dialog-close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.community-scene {
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 1.47 / 1;
  overflow: hidden;
  border: clamp(5px, 0.5vw, 8px) solid #70422e;
  background: #94583d;
  box-shadow: 12px 14px 0 rgba(63, 43, 31, 0.23);
}

.community-scene img {
  display: block;
  max-width: none;
}

.community-wall {
  position: absolute;
  inset: 0 0 auto;
  z-index: 0;
  width: 100%;
  height: 69%;
  object-fit: cover;
}

.community-wheat,
.community-soup,
.community-grandma-frame,
.community-purple-flower,
.community-sunflower,
.community-spices,
.community-counter {
  position: absolute;
}

.community-wheat {
  top: -1%;
  left: 1.2%;
  z-index: 2;
  width: 8.2%;
}

.community-soup {
  top: 16%;
  left: 42.5%;
  z-index: 2;
  width: 17.5%;
}

.community-grandma-frame {
  top: 5.5%;
  right: 14.2%;
  z-index: 2;
  width: 26.5%;
}

.community-purple-flower {
  top: -1%;
  right: 8.4%;
  z-index: 2;
  width: 7.3%;
}

.community-sunflower {
  top: -1%;
  right: 1.3%;
  z-index: 2;
  width: 8.4%;
}

.community-grandma {
  position: absolute;
  bottom: 23.5%;
  left: 26%;
  z-index: 4;
  width: 25%;
  aspect-ratio: 3 / 4;
  background-image: url("../assets/images/character-older-woman-6x.png");
  background-repeat: no-repeat;
  background-size: 800% 500%;
  background-position: 0 50%;
  transform: translateY(-20px);
  animation: community-grandma-idle 3.8s steps(1, end) infinite;
}

.community-spices {
  right: 28%;
  bottom: 26%;
  z-index: 7;
  width: 14%;
}

.community-counter {
  right: 0;
  bottom: -2%;
  left: 0;
  z-index: 6;
  width: 100%;
}

.scene-button {
  position: absolute;
  z-index: 3;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.scene-button img {
  width: 100%;
  height: auto;
  transition: filter 160ms ease, transform 160ms ease;
}

.board-button {
  top: 10%;
  left: 6%;
  width: 32%;
}

.book-button {
  right: 1.6%;
  bottom: 22.7%;
  z-index: 8;
  width: 25%;
}

.scene-button:hover img,
.scene-button:focus-visible img {
  filter: brightness(1.09) drop-shadow(0 0 12px rgba(255, 242, 177, 0.95));
  transform: translateY(-5px);
}

.scene-button:focus-visible {
  outline: 5px solid #fff8bf;
  outline-offset: 7px;
}

.scene-button-label {
  position: absolute;
  left: 50%;
  bottom: -8px;
  min-width: max-content;
  padding: 7px 12px;
  border: 3px solid var(--community-brown-dark);
  background: var(--community-paper);
  box-shadow: 4px 4px 0 rgba(49, 31, 23, 0.28);
  color: #211611;
  font-family: "Atkinson Hyperlegible", Arial, sans-serif;
  font-size: clamp(14px, 1.3vw, 19px);
  font-weight: 700;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.scene-button:hover .scene-button-label,
.scene-button:focus-visible .scene-button-label {
  opacity: 1;
  transform: translate(-50%, 0);
}

.community-instruction {
  position: absolute;
  bottom: 2.2%;
  left: 50%;
  z-index: 9;
  width: min(88%, 850px);
  margin: 0;
  padding: 11px 18px;
  border: 3px solid rgba(75, 43, 34, 0.9);
  background: rgba(255, 248, 232, 0.94);
  color: #211611;
  font-family: "Atkinson Hyperlegible", Arial, sans-serif;
  font-size: clamp(16px, 1.35vw, 21px);
  line-height: 1.25;
  text-align: center;
  transform: translateX(-50%);
}

.community-dialog {
  width: min(92vw, 980px);
  max-height: min(84vh, 850px);
  padding: 0;
  overflow: hidden;
  border: 6px solid var(--community-brown-dark);
  border-radius: 0;
  background: var(--community-paper);
  box-shadow: 12px 14px 0 rgba(42, 27, 21, 0.34);
  color: #241813;
}

.community-dialog::backdrop {
  background: rgba(28, 38, 36, 0.68);
  backdrop-filter: blur(5px);
}

.community-dialog[open] {
  animation: dialog-in 180ms ease-out;
}

.community-dialog-shell {
  display: flex;
  max-height: min(82vh, 820px);
  flex-direction: column;
}

.community-dialog-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: clamp(22px, 3vw, 34px);
  border-bottom: 4px solid #6e422f;
  background: #f5d596;
}

.community-dialog-header h2 {
  margin: 0;
  font-family: "Pixelify Sans", monospace;
  font-size: clamp(31px, 4vw, 52px);
  font-weight: 600;
  line-height: 1;
}

.community-dialog-header p {
  color: #65412f;
}

.comments-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px clamp(22px, 3vw, 34px);
  border-bottom: 2px solid #d7c8ae;
}

.comments-toolbar p {
  margin: 0;
  font-family: "Atkinson Hyperlegible", Arial, sans-serif;
  font-size: 18px;
  font-weight: 700;
}

.pixel-ui-button,
.back-to-comments {
  min-height: 48px;
  border: 4px solid var(--community-brown-dark);
  background: #a75f42;
  box-shadow: 4px 4px 0 #4b2b22;
  color: #fff8e8;
  cursor: pointer;
  font-family: "Pixelify Sans", monospace;
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 600;
  line-height: 1;
}

.pixel-ui-button {
  padding: 9px 18px;
}

.pixel-ui-button:hover,
.pixel-ui-button:focus-visible,
.back-to-comments:hover,
.back-to-comments:focus-visible {
  background: #ba6d4b;
  transform: translateY(-1px);
}

.comment-status {
  padding: 0 clamp(22px, 3vw, 34px);
  color: #7c3027;
  font-family: "Atkinson Hyperlegible", Arial, sans-serif;
  font-size: 17px;
  font-weight: 700;
}

.comment-list {
  min-height: 180px;
  max-height: min(52vh, 500px);
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.comment-card {
  padding: clamp(22px, 3vw, 34px);
  border-bottom: 2px solid #d7c8ae;
}

.comment-card:last-child {
  border-bottom: 0;
}

.comment-card header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 10px;
}

.comment-card h3 {
  margin: 0;
  color: var(--community-green);
  font-family: "Pixelify Sans", monospace;
  font-size: clamp(24px, 2.6vw, 34px);
  line-height: 1;
}

.comment-card time {
  color: #6d665d;
  font-family: "Atkinson Hyperlegible", Arial, sans-serif;
  font-size: 15px;
}

.comment-card p {
  margin: 0;
  color: #33241d;
  font-family: "Atkinson Hyperlegible", Arial, sans-serif;
  font-size: clamp(18px, 1.7vw, 22px);
  line-height: 1.48;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.empty-comments {
  display: grid;
  min-height: 240px;
  padding: 30px;
  place-items: center;
  color: #5c5148;
  font-family: "Atkinson Hyperlegible", Arial, sans-serif;
  font-size: 20px;
  text-align: center;
}

.community-composer-view {
  padding: clamp(24px, 4vw, 42px);
  overflow-y: auto;
}

.back-to-comments {
  margin-bottom: 26px;
  padding: 7px 14px;
  background: #77513e;
  font-size: 19px;
}

.community-form {
  display: grid;
  gap: 24px;
}

.form-field {
  display: grid;
  gap: 9px;
}

.form-field label {
  color: #2b211c;
  font-family: "Pixelify Sans", monospace;
  font-size: clamp(22px, 2.4vw, 30px);
  font-weight: 600;
}

.form-field input,
.form-field textarea {
  width: 100%;
  border: 3px solid #76513d;
  border-radius: 0;
  background: #fffdf8;
  color: #241813;
  font-family: "Atkinson Hyperlegible", Arial, sans-serif;
  font-size: 20px;
  line-height: 1.45;
}

.form-field input {
  min-height: 54px;
  padding: 10px 14px;
}

.form-field textarea {
  min-height: 160px;
  padding: 14px;
  resize: vertical;
}

.form-field input:focus,
.form-field textarea:focus {
  outline: 4px solid #80cdda;
  outline-offset: 2px;
}

.character-count,
.form-feedback {
  color: #685b50;
  font-family: "Atkinson Hyperlegible", Arial, sans-serif;
  font-size: 16px;
}

.character-count {
  justify-self: end;
}

.form-feedback {
  min-height: 24px;
  margin: -10px 0 0;
  color: #7c3027;
  font-weight: 700;
}

.submit-note {
  justify-self: start;
  min-width: min(100%, 300px);
}

@keyframes community-grandma-idle {
  0%, 42%, 100% { background-position: 0 50%; }
  43%, 56% { background-position: 0 75%; }
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 900px) {
  .community-page {
    width: min(94%, 760px);
    padding-top: 30px;
  }

  .community-page-heading {
    align-items: center;
  }

  .community-page-heading p {
    display: none;
  }

  .community-scene {
    aspect-ratio: 1.18 / 1;
  }

  .community-wall {
    height: 71%;
  }

  .community-wheat {
    width: 9.4%;
  }

  .board-button {
    top: 12%;
    left: 5%;
    width: 35%;
  }

  .community-soup {
    top: 18%;
    left: 45%;
    width: 18.5%;
  }

  .community-grandma-frame {
    top: 6.5%;
    right: 12%;
    width: 28%;
  }

  .community-grandma {
    bottom: 23.5%;
    left: 24%;
    width: 28%;
  }

  .community-spices {
    right: 28%;
    bottom: 26%;
    width: 15.5%;
  }

  .book-button {
    right: 0.8%;
    bottom: 22.5%;
    width: 27%;
  }

  .community-counter {
    bottom: 1%;
  }
}

@media (max-width: 600px) {
  .community-page {
    width: 100%;
    padding: 24px 0 52px;
  }

  .community-page-heading {
    padding-inline: 18px;
  }

  .community-page-heading h1 {
    max-width: 250px;
    font-size: clamp(38px, 12vw, 54px);
    line-height: 0.88;
  }

  .community-page-actions {
    gap: 9px;
  }

  .community-add-button,
  .community-close,
  .dialog-close {
    width: 48px;
    height: 48px;
  }

  .community-scene {
    aspect-ratio: 0.86 / 1;
    border-inline: 0;
    box-shadow: 0 10px 0 rgba(63, 43, 31, 0.23);
  }

  .community-wall {
    height: 72%;
  }

  .community-wheat {
    width: 12%;
  }

  .board-button {
    top: 11%;
    left: 4%;
    width: 44%;
  }

  .community-soup {
    top: 20%;
    left: 49%;
    width: 20%;
  }

  .community-grandma-frame {
    top: 8%;
    right: 2.5%;
    width: 30%;
  }

  .community-purple-flower {
    right: 8%;
    width: 9%;
  }

  .community-sunflower {
    right: 0;
    width: 10.8%;
  }

  .community-grandma {
    bottom: 23%;
    left: 24%;
    width: 34%;
  }

  .community-spices {
    right: 36.5%;
    bottom: 25.5%;
    width: 22%;
  }

  .book-button {
    right: 2%;
    bottom: 22.7%;
    width: 34%;
  }

  .community-counter {
    bottom: 7%;
    width: 125%;
    transform: translateX(-10%);
  }

  .community-instruction {
    bottom: 2%;
    width: 91%;
    padding: 9px 12px;
    font-size: 15px;
  }

  .scene-button-label {
    display: none;
  }

  .community-dialog {
    width: 96vw;
    max-height: 88vh;
  }

  .community-dialog-shell {
    max-height: 87vh;
  }

  .community-dialog-header {
    padding: 19px;
  }

  .community-dialog-header p {
    display: none;
  }

  .community-dialog-header h2 {
    font-size: 31px;
  }

  .comments-toolbar {
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
  }

  .pixel-ui-button {
    width: 100%;
  }

  .comment-list {
    max-height: 57vh;
  }

  .comment-card {
    padding: 22px 19px;
  }

  .comment-card header {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .community-composer-view {
    padding: 22px 19px 30px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .community-grandma,
  .community-dialog[open] {
    animation: none;
  }

  .scene-button img,
  .scene-button-label,
  .community-add-button,
  .dialog-close {
    transition: none;
  }
}
