/* 店主への便り(public/feedback.js)。わら半紙の便箋に朱の二重罫、その下に
   封筒の口が覗く。幕と開け閉めは modal.css の .modal-overlay。
   キャンバス「棋楽軒 ご意見箱」の C 案。 */

/* --- 道具の段の木札。丸い札の見た目は base.css の 木札 と同じ一式 --- */
.feedback-control {
  position: fixed;
  right: 20px;
  bottom: calc(var(--tool-stack-base) + 290px);
  z-index: 5;
}
body:not(.in-room) .feedback-control { display: none; }

/* --- 便箋と封筒 --- */
.feedback-letter {
  position: relative;
  width: min(560px, calc(100vw - 28px));
  padding-bottom: 36px;
  color: var(--shop-ink);
  font-family: var(--shop-font-body);
}
/* 便箋の下から覗く封筒。便箋より少し狭く、色は一段濃い紙。 */
.feedback-letter::after {
  content: '';
  position: absolute;
  left: 30px;
  right: 30px;
  bottom: 0;
  height: 110px;
  background: var(--shop-paper-deep);
  border-radius: 2px;
  box-shadow: 0 6px 14px rgba(40, 28, 10, 0.35);
}
.feedback-sheet,
.feedback-done {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  padding: 24px 28px 22px;
  background-color: var(--shop-paper);
  background-image: var(--shop-wara-ground);
  border: 1px solid var(--shop-paper-deep);
  border-radius: 2px;
  box-shadow: 0 4px 12px rgba(40, 28, 10, 0.3);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
/* 帳面と同じ朱の二重罫(shop.css の .paper-sheet)を、便箋の縁の内側に。 */
.feedback-sheet::before,
.feedback-done::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid var(--shop-sheet-rule);
  outline: 1px solid var(--shop-sheet-rule-outer);
  outline-offset: 3px;
  pointer-events: none;
}
.feedback-sheet.hidden,
.feedback-done.hidden { display: none; }

.feedback-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.feedback-head h2 {
  margin: 0;
  flex: 1;
  font-family: var(--shop-font-display);
  font-weight: 900;
  font-size: 1.4rem;
  letter-spacing: 0.15em;
  color: var(--shop-ink);
}
.feedback-from {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding-left: 10px;
  min-height: 32px;
  border-radius: 3px;
  background: rgba(222, 208, 170, 0.8);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.feedback-from.hidden { display: none; }
.feedback-from-remove,
.feedback-close {
  border: none;
  background: none;
  padding: 0;
  color: var(--shop-ink-soft);
  cursor: pointer;
}
.feedback-from-remove {
  width: 32px;
  height: 32px;
  font-size: 0.95rem;
}
.feedback-close {
  width: 44px;
  height: 44px;
  margin: -10px -12px -10px 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.feedback-close svg { width: 20px; height: 20px; }
.feedback-from-remove:hover,
.feedback-close:hover { color: var(--shop-seal); }

.feedback-lead {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.8;
  color: var(--shop-ink-soft);
}
/* 見出しが「便りの文面」を言っているので、欄の名前は読み上げだけに。 */
.feedback-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
/* 罫の引いた欄。行の高さと罫の間隔をそろえて、字が罫の上に乗るように。 */
.feedback-text {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 210px;
  margin: 0;
  padding: 4px 2px;
  resize: none;
  border: none;
  border-radius: 0;
  background: repeating-linear-gradient(180deg,
    transparent 0 29px, rgba(42, 36, 28, 0.16) 29px 30px);
  background-attachment: local;
  box-shadow: none;
  font-family: var(--shop-font-body);
  font-size: 16px;
  line-height: 30px;
  color: var(--shop-ink);
}
.feedback-text::placeholder { color: #8a7d68; }
.feedback-text:focus {
  outline: 2px solid rgba(168, 53, 43, 0.35);
  outline-offset: 2px;
}
/* 機械だけが埋める欄。display:none だと埋めない作りの機械もあるので、
   画面の外に追いやる。 */
.feedback-trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.feedback-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.72rem;
  line-height: 1.6;
  color: var(--shop-ink-soft);
}
.feedback-count { flex: none; font-variant-numeric: tabular-nums; }
.feedback-count.over { color: var(--shop-seal); font-weight: 700; }
.feedback-error {
  margin: 0;
  font-size: 0.82rem;
  color: var(--shop-seal-deep);
}
.feedback-error.hidden { display: none; }

.feedback-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.feedback-cancel,
.feedback-send {
  min-height: 44px;
  border-radius: 3px;
  cursor: pointer;
}
.feedback-cancel {
  padding: 0 18px;
  border: 1px solid var(--shop-ink-soft);
  background: transparent;
  font-family: var(--shop-font-body);
  font-size: 0.9rem;
  color: var(--shop-ink);
}
.feedback-cancel:hover { background: rgba(42, 36, 28, 0.06); }
.feedback-send {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 0 10px;
  border: none;
  background: var(--shop-ink);
  font-family: var(--shop-font-display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.1em;
  color: var(--shop-paper-light);
}
.feedback-send:hover { background: #3d352a; }
.feedback-send:disabled { opacity: 0.6; cursor: wait; }
.feedback-seal {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  background: var(--shop-seal);
  color: var(--shop-paper-light);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--shop-font-display);
  font-size: 0.95rem;
  letter-spacing: 0;
}

/* --- 出したあと: 封をした封筒と一言 --- */
.feedback-done {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 16px;
}
.feedback-done p {
  margin: 0;
  flex: 1 1 200px;
  font-family: var(--shop-font-display);
  font-weight: 700;
  font-size: 1rem;
}
.feedback-done-envelope {
  position: relative;
  width: 64px;
  height: 42px;
  flex: none;
  box-sizing: border-box;
  background: var(--shop-paper-deep);
  border: 1px solid #c4b48a;
}
.feedback-done-envelope::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 20px;
  background: #e8dcbc;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.feedback-done-envelope .feedback-seal {
  position: absolute;
  left: 50%;
  top: 9px;
  width: 22px;
  height: 22px;
  margin-left: -11px;
  font-size: 0.7rem;
}

/* --- スマホ: 画面いっぱいの便箋。キーボードが出ても出すボタンが残るよう、
   縮むのは書く欄だけ --- */
@media (max-width: 600px) {
  #feedback-modal { align-items: stretch; }
  #feedback-modal > .feedback-letter { margin: 0; }
  .feedback-letter {
    width: 100%;
    min-height: 100%;
    padding: 12px 10px 0;
    display: flex;
    flex-direction: column;
  }
  .feedback-letter::after { display: none; }
  .feedback-sheet {
    flex: 1;
    padding: 14px 18px 16px;
    border-bottom: none;
    border-radius: 2px 2px 0 0;
  }
  /* 見出しと × で一段、卓の札はその下の段に。 */
  .feedback-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 6px;
  }
  .feedback-head h2 { letter-spacing: 0.1em; }
  .feedback-from {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: start;
  }
  .feedback-lead { display: none; }
  .feedback-text {
    flex: 1;
    min-height: 120px;
    height: auto;
  }
  .feedback-actions { flex-direction: column-reverse; }
  .feedback-send { justify-content: center; }
  .feedback-done { margin-top: 30vh; }
}

/* --- 店主より(#276、public/shopkeeper.js) ---
   便りと同じ便箋と封筒に、お知らせを新しい順に並べる。一通は「墨の日付の判
   ＋題＋本文」。この端末でまだ読んでいなかった通は、判を朱にする。
   キャンバス「棋楽軒 店主より」の窓 A(スマホは PhoneA)。 */
.shopkeeper-sheet { gap: 14px; }
.shopkeeper-list {
  display: flex;
  flex-direction: column;
  max-height: min(430px, calc(100vh - 260px));
  overflow-y: auto;
  padding-right: 4px;
}
.shopkeeper-msg {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 2px;
  border-top: 1px solid rgba(42, 36, 28, 0.14);
}
.shopkeeper-msg:first-child { border-top: none; padding-top: 4px; }
/* 判は品書きの下の店主の便り(shop.css の .shop-note-date)と同じ墨の判。 */
.shopkeeper-date {
  flex: none;
  margin-top: 2px;
  padding: 3px 9px 4px;
  border: 1.2px solid var(--shop-sumi);
  border-radius: 2px;
  outline: 0.6px solid var(--shop-sumi);
  outline-offset: -3.8px;
  font-family: var(--shop-font-display);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.06em;
  color: var(--shop-sumi);
  white-space: nowrap;
}
.shopkeeper-date.new {
  border-color: var(--shop-seal);
  outline-color: var(--shop-seal);
  color: var(--shop-seal);
}
.shopkeeper-body { min-width: 0; flex: 1; }
.shopkeeper-body h3 {
  margin: 0 0 6px;
  font-family: var(--shop-font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--shop-ink);
}
.shopkeeper-body p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.85;
  color: var(--shop-ink-soft);
  white-space: pre-line;
}
/* 便りの窓はスマホで書きやすいよう画面いっぱいの一枚になる(上の 600px)。
   こちらは読むだけなので、便箋と封筒の形のまま真ん中に置き、一文も残す(PhoneA)。 */
@media (max-width: 600px) {
  #shopkeeper-modal { align-items: center; }
  #shopkeeper-modal .feedback-letter {
    width: calc(100vw - 28px);
    min-height: 0;
    padding: 0 0 30px;
    display: block;
  }
  #shopkeeper-modal .feedback-letter::after { display: block; left: 22px; right: 22px; height: 90px; }
  #shopkeeper-modal .feedback-sheet {
    padding: 20px 18px 18px;
    border-bottom: 1px solid var(--shop-paper-deep);
    border-radius: 2px;
  }
  #shopkeeper-modal .feedback-head { display: flex; }
  #shopkeeper-modal .feedback-lead { display: block; font-size: 0.75rem; line-height: 1.7; }
}
/* スマホ縦は判を題の上に置き、本文の幅を広く取る。 */
@media (max-width: 640px) {
  .shopkeeper-msg { flex-direction: column; gap: 6px; padding: 14px 0; }
  .shopkeeper-msg:first-child { padding-top: 2px; }
  .shopkeeper-date { align-self: flex-start; font-size: 12px; }
  .shopkeeper-body h3 { font-size: 15px; line-height: 1.5; }
  .shopkeeper-body p { font-size: 0.84rem; line-height: 1.8; }
  .shopkeeper-list { max-height: calc(100vh - 240px); }
}
