/* ==========================================================================
   account.css — หน้าเข้าสู่ระบบ (/account/login/) และหน้าบัญชี (/account/)
   ใช้ token สีและกระจกจาก style.css ทั้งหมด ไม่ประกาศสีใหม่นอกจากสีแบรนด์
   ของ LINE / Facebook / Google ซึ่งเปลี่ยนตามใจไม่ได้
   ========================================================================== */

.auth-section {
  /* เผื่อที่ให้ header ที่ลอยอยู่ด้านบน ไม่งั้นการ์ดจะโดนทับตอนจอสั้น */
  padding-top: calc(var(--header-height) + clamp(2rem, 6vw, 4.5rem));
}

.auth-card {
  max-width: 480px;
  margin-inline: auto;
  text-align: center;
}

/* --------------------------------------------------------------------------
   ปุ่มผู้ให้บริการ
   -------------------------------------------------------------------------- */

.auth-providers {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.auth-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.85rem 1.1rem;
  border-radius: 12px;
  border: 1px solid transparent;
  font-family: var(--font-primary);
  font-size: var(--fs-small);
  font-weight: 500;
  text-decoration: none;
  transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}

/* display: flex ด้านบนชนะ [hidden] ของเบราว์เซอร์ ต้องประกาศทับเอง
   (แบบเดียวกับ .modal-actions[hidden] ใน style.css)
   ไม่งั้นปุ่มที่ยังไม่ได้ตั้ง Client ID จะโผล่ออกมาทั้งที่กดไม่ได้ */
.auth-btn[hidden] { display: none; }

.auth-btn:hover,
.auth-btn:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(20, 4, 4, 0.35);
  filter: brightness(1.04);
}

.auth-btn-icon {
  display: inline-flex;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
}

.auth-btn-icon svg { width: 100%; height: 100%; }

/* ข้อความอยู่กึ่งกลางปุ่มเสมอ แม้ไอคอนจะกินที่ด้านซ้าย
   ชดเชยด้วยความกว้างไอคอน + gap เพื่อให้สมดุลซ้ายขวาเท่ากัน */
.auth-btn-text {
  flex: 1;
  text-align: center;
  margin-right: calc(24px + 0.75rem);
}

/* สีแบรนด์ตามแนวทางของแต่ละเจ้า */
.auth-btn--line     { background: #06C755; color: #fff; }
.auth-btn--facebook { background: #1877F2; color: #fff; }
.auth-btn--google   { background: #fff; color: #1f1f1f; border-color: #dadce0; }

/* --------------------------------------------------------------------------
   ข้อความแจ้งผล
   -------------------------------------------------------------------------- */

.auth-alert {
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--gold-a25);
  background: var(--surface-card-soft);
  color: var(--color-cream);
  font-size: var(--fs-small);
  line-height: var(--lh-normal);
}

.auth-alert code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  color: var(--color-gold-bright);
  word-break: break-all;
}

.auth-note {
  margin-top: 1.5rem;
  font-size: var(--fs-xs);
  line-height: var(--lh-normal);
  color: var(--cream-a55);
}

/* --------------------------------------------------------------------------
   หน้าบัญชีของฉัน
   -------------------------------------------------------------------------- */

.account-identity {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.75rem;
  text-align: start;
}

.account-avatar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;

  width: 64px;
  height: 64px;

  border-radius: 50%;
  border: 2px solid var(--gold-a40);
  background: var(--gold-a10);
  color: var(--color-gold);
}

.account-name {
  font-size: var(--fs-h3);
  font-weight: 500;
  color: var(--color-gold-bright);
}

.account-email {
  font-size: var(--fs-small);
  color: var(--cream-a70);
  word-break: break-all;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

/* --------------------------------------------------------------------------
   ฟอร์มอีเมล / รหัสผ่าน
   -------------------------------------------------------------------------- */

.auth-form {
  margin-top: 1.75rem;
  /* .auth-card จัดกลาง แต่ label กับข้อความ error ต้องชิดซ้ายจึงอ่านง่าย */
  text-align: start;
}

.auth-form .field + .field {
  margin-top: 1rem;
}

.auth-form .btn {
  width: 100%;
  margin-top: 1.5rem;
}

.auth-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 1.25rem;
  font-size: var(--fs-small);
  color: var(--cream-a70);
}

/* --------------------------------------------------------------------------
   เส้นคั่น "หรือ" ระหว่างฟอร์มกับปุ่มผู้ให้บริการ
   -------------------------------------------------------------------------- */

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-top: 1.75rem;
  font-size: var(--fs-xs);
  color: var(--cream-a55);
}

/* เหตุผลเดียวกับ .auth-btn[hidden] — display: flex ทับ [hidden] */
.auth-divider[hidden] { display: none; }

/* เส้นสองข้างยืดเต็มที่ว่างที่เหลือ ข้อความจึงอยู่กลางเสมอ */
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--gold-a25);
}

/* --------------------------------------------------------------------------
   ประวัติการสั่งซื้อ
   -------------------------------------------------------------------------- */

.orders-wrap {
  max-width: 720px;
  margin: clamp(2rem, 5vw, 3rem) auto 0;
}

.orders-title {
  text-align: center;
  margin-bottom: 1.25rem;
}

/* --- หนึ่งออเดอร์ = หนึ่ง <details> --- */

.order {
  border: var(--border-gold);
  border-radius: 14px;
  background: var(--surface-card-soft);
  overflow: hidden;
}

.order + .order {
  margin-top: 0.75rem;
}

.order-head {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.95rem 1.1rem;
  cursor: pointer;
  font-size: var(--fs-small);
  list-style: none;               /* ซ่อนสามเหลี่ยมมาตรฐาน จะวาดเองด้านล่าง */
}

.order-head::-webkit-details-marker { display: none; }

.order-head::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--color-gold);
  border-bottom: 1.5px solid var(--color-gold);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .2s ease;
}

.order[open] .order-head::after {
  transform: rotate(-135deg) translate(-2px, -2px);
}

.order-head:hover { background: var(--gold-a10); }

.order-no    { font-weight: 500; color: var(--color-gold-bright); }
.order-date  { color: var(--cream-a55); font-size: var(--fs-xs); }
.order-total { font-weight: 500; }

/* --- ป้ายสถานะ --- */

.order-status {
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--gold-a25);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.order-status.is-paid      { border-color: rgba(120, 200, 140, 0.5); color: #8fd6a5; }
.order-status.is-shipped   { border-color: rgba(130, 180, 230, 0.5); color: #9cc9ee; }
.order-status.is-cancelled { border-color: rgba(220, 130, 130, 0.5); color: #e59a9a; }

/* --- เนื้อในเมื่อกดเปิด --- */

.order-body {
  padding: 0 1.1rem 1.1rem;
  border-top: 1px solid var(--gold-a18);
}

.order-mix {
  margin: 0.85rem 0 0;
  font-size: var(--fs-xs);
  color: var(--cream-a55);
}

.order-items {
  margin: 0.85rem 0 0;
  list-style: none;
}

.order-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--gold-a10);
  font-size: var(--fs-small);
}

.item-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.item-qty   { color: var(--cream-a55); }
.item-price { white-space: nowrap; }

/* --- ป้ายบอกว่าได้ของแบบไหน --- */

.item-tag {
  padding: 0.12rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.item-tag.is-digital  { background: rgba(120, 200, 140, 0.16); color: #8fd6a5; }
.item-tag.is-waiting  { background: var(--gold-a10);           color: var(--cream-a70); }
.item-tag.is-physical { background: rgba(130, 180, 230, 0.14); color: #9cc9ee; }

.item-open {
  font-size: var(--fs-xs);
  color: var(--color-gold-bright);
  text-decoration: underline;
}

/* --- สรุปยอด --- */

.order-sum {
  margin-top: 1rem;
  font-size: var(--fs-small);
}

.order-sum > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.25rem 0;
}

.order-sum dt { color: var(--cream-a70); }

.order-sum .is-total {
  margin-top: 0.35rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--gold-a18);
  font-weight: 500;
  color: var(--color-gold-bright);
}

/* --- ประวัติคำทำนาย (ใช้กรอบ .order ร่วมกับประวัติการสั่งซื้อ) --- */

.reading-saved-cards {
  margin: 0.85rem 0 0;
  list-style: none;
}

.reading-saved-card {
  display: flex;
  gap: 0.85rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--gold-a10);
}

.reading-saved-card img {
  flex: none;
  align-self: flex-start;          /* ไม่ให้ flex ยืดรูปสูงตามความยาวข้อความ */
  width: 72px;
  height: auto;
  aspect-ratio: 500 / 857;         /* สัดส่วนไพ่จริง */
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--gold-a18);
}

.reading-saved-pos {
  font-size: var(--fs-xs);
  color: var(--cream-a55);
}

.reading-saved-name {
  font-weight: 500;
  color: var(--color-gold-bright);
}

.reading-saved-name span {
  font-weight: 300;
  font-size: var(--fs-xs);
  color: var(--cream-a70);
}

.reading-saved-text {
  margin-top: 0.3rem;
  font-size: var(--fs-small);
  line-height: 1.7;
}

/* ย่อเหลือ 3 บรรทัด — กด "อ่านเพิ่มเติม" แล้ว JS ถอดคลาสนี้ออก */
.reading-saved-text.is-clamped {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}

.reading-more {
  margin-top: 0.35rem;
  padding: 0.2rem 0;
  border: 0;
  background: none;
  color: var(--color-gold-bright);
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.reading-more:hover { color: var(--color-gold); }

.reading-more:focus-visible {
  outline: 2px solid var(--color-gold-bright);
  outline-offset: 2px;
  border-radius: 4px;
}

/* จอแคบ: หัวรายการเรียงสองแถว ไม่งั้นเลขที่ออเดอร์กับยอดจะเบียดกันจนอ่านไม่ออก */
@media (max-width: 560px) {
  .order-head {
    grid-template-columns: 1fr auto;
    row-gap: 0.35rem;
  }
  .order-head::after { grid-row: 1; }
  .order-date   { grid-column: 1; }
  .order-status { grid-column: 2; }
}

/* --------------------------------------------------------------------------
   สำรับของฉัน — ไพ่ดิจิทัลที่เปิดใช้งานบนเว็บได้
   -------------------------------------------------------------------------- */

.decks-wrap {
  max-width: 720px;
  margin: clamp(2rem, 5vw, 3rem) auto 0;
}

.decks-title {
  text-align: center;
  margin-bottom: 1.25rem;
}

.decks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.85rem;
}

.deck-card {
  display: flex;
  gap: 0.9rem;
  padding: 0.9rem;
  border: var(--border-gold);
  border-radius: 14px;
  background: var(--surface-card-soft);
}

.deck-thumb {
  flex: 0 0 80px;
  align-self: flex-start;
  border-radius: 8px;
  overflow: hidden;
  background: var(--gold-a10);
}

.deck-thumb img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
}

.deck-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  min-width: 0;          /* ไม่งั้นข้อความยาวจะดันการ์ดจนล้นกริด */
  text-align: start;
}

.deck-name {
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--color-gold-bright);
  line-height: var(--lh-tight);
}

.deck-desc {
  font-size: var(--fs-xs);
  line-height: var(--lh-normal);
  color: var(--cream-a70);

  /* ตัดคำอธิบายไว้ 2 บรรทัด การ์ดทุกใบจะได้สูงใกล้เคียงกัน */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.deck-tag {
  padding: 0.12rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.deck-tag.is-owned { background: rgba(120, 200, 140, 0.16); color: #8fd6a5; }
.deck-tag.is-free  { background: var(--gold-a10);           color: var(--cream-a70); }

.deck-open {
  margin-top: 0.25rem;
}

/* ==========================================================================
   เมนูบัญชี — dropdown สลับแผงข้อมูลส่วนตัว / ประวัติการสั่งซื้อ / คอร์ส
   ========================================================================== */

/* เต็มความกว้างการ์ด แล้วคั่นด้วยเส้นบางๆ ให้อ่านเป็นแถบนำทางของการ์ด
   ไม่ใช่ก้อนปุ่มลอยอยู่ด้านซ้าย */
.account-menu {
  position: relative;
  margin: 1.1rem 0 0;
  padding-bottom: 1.1rem;
  border-bottom: var(--border-gold);
}

.account-menu-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  width: 100%;
  padding: .5rem .9rem;
  border: var(--border-gold);
  border-radius: 999px;
  background: var(--gold-a10);
  color: var(--color-gold-bright);
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
}

.account-menu-toggle:hover { border-color: var(--gold-a60); }

.account-menu-toggle svg { transition: transform var(--transition); }
.account-menu.is-open .account-menu-toggle svg { transform: rotate(180deg); }

.account-menu-list {
  position: absolute;
  z-index: 40;
  top: calc(100% + .35rem);
  left: 0;
  right: 0;
  margin: 0;
  padding: .3rem;
  list-style: none;
  border: var(--border-gold-strong);
  border-radius: 14px;
  background: linear-gradient(165deg, #6b1514, #35100d 70%);
  box-shadow: var(--shadow-soft);
  display: none;
}

.account-menu.is-open .account-menu-list { display: block; }

.account-menu-item {
  display: block;
  width: 100%;
  padding: .45rem .7rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--cream-a70);
  font: inherit;
  font-size: .88rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.account-menu-item:hover { background: var(--gold-a10); color: var(--color-cream); }

.account-menu-item.is-active {
  background: var(--gold-a10);
  color: var(--color-gold-bright);
}
