/* Háttércsomag választó az emlékhely szerkesztőben */
#emlekhely_editor .temeto-hatter {
  background-position: center top;
  background-repeat: no-repeat;
  background-size: cover;
}

#emlekhely_editor .hatterkepek {
  display: none;
  position: absolute;
  left: 15px;
  right: 15px;
  top: 14px;
  height: 126px;
  padding: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  background: rgba(97, 64, 34, .82);
  color: #fff8ea;
  border-radius: 12px;
  box-shadow: 0 4px 18px rgba(0,0,0,.18);
  z-index: 68;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
}

#emlekhely_editor .temeto-hatter.edit .hatterkepek {
  display: block;
}

.hatterkep-panel-head {
  display: flex;
  align-items: baseline;
  /*justify-content: space-between;*/
  gap: 10px;
  margin-bottom: 6px;
  font-size: 13px;
}

.hatterkep-panel-head strong {
  font-size: 15px;
}

.hatterkep-panel-head span {
  opacity: .82;
  font-size: 12px;
}

.hatterkep-editor-options {
  display: flex;
  gap: 8px;
  align-items: stretch;
  min-width: min-content;
}

.hatterkep-empty {
  margin: 6px 0;
  font-size: 13px;
  color: #fff8ea;
}

.hatterkep-empty.error {
  color: #ffd0d0;
}

.hatterkep-package {
  display: grid;
  grid-template-columns: 56px minmax(120px, 1fr) 34px;
  align-items: center;
  gap: 7px;
  min-width: 250px;
  max-width: 310px;
  height: 76px;
  padding: 6px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: rgba(255, 248, 234, .92);
  color: #4b2c15;
  cursor: pointer;
  box-sizing: border-box;
}

.hatterkep-package:hover,
.hatterkep-package:focus-visible {
  border-color: rgba(255, 245, 200, .86);
  outline: none;
}

.hatterkep-package.selected {
  border-color: #d9f2a3;
  background: #fff1d6;
}

.hatterkep-package-thumb {
  display: block;
  width: 56px;
  height: 64px;
  border-radius: 8px;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
}

.hatterkep-package-text {
  min-width: 0;
}

.hatterkep-package-name,
.hatterkep-package-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hatterkep-package-name {
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}

.hatterkep-package-meta {
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.25;
  color: rgba(66, 43, 22, .75);
  max-height: 28px;
}

.hatterkep-preview-btn {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  margin-left: 5px;
  padding: 0;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;

  border-radius: 8px;

  background: linear-gradient(
    145deg,
    #9a6840,
    #68401f
  );

  color: #fff8ea;
  cursor: pointer;

  box-shadow:
    0 3px 8px rgba(50, 29, 13, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);

  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

.hatterkep-preview-btn svg {
  display: block;
  width: 23px;
  height: 23px;

  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;

  pointer-events: none;
}

.hatterkep-preview-btn:hover {
  background: linear-gradient(
    145deg,
    #ad784c,
    #583417
  );

  transform: translateY(-1px);

  box-shadow:
    0 5px 12px rgba(50, 29, 13, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.hatterkep-preview-btn:active {
  transform: translateY(1px);
}

.hatterkep-preview-btn:focus-visible {
  outline: 3px solid rgba(255, 248, 234, 0.95);
  outline-offset: 2px;
}

.hatterkep-preview-btn:hover,
.hatterkep-preview-btn:focus-visible {
  background: #4b2c15;
  outline: 2px solid #fff8ea;
}

/* 12 képes előnézeti modal */
.hatterkep-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hatterkep-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.62);
}

.hatterkep-modal-box {
  position: relative;
  width: min(960px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  background: #fff8ea;
  color: #4b2c15;
  border-radius: 16px;
  box-shadow: 0 18px 60px rgba(0,0,0,.42);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.hatterkep-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(75,44,21,.16);
}

.hatterkep-modal-head h3 {
  margin: 0;
  font-size: 20px;
}

.hatterkep-modal-head p {
  margin: 4px 0 0;
  font-size: 13px;
  opacity: .78;
}

.hatterkep-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;

  width: 62px;
  height: 42px;
  padding: 0;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border: 1px solid rgba(82, 46, 20, 0.25);
  border-radius: 50%;

  background: rgba(255, 250, 240, 0.96);
  color: #5d351a;

  cursor: pointer;

  box-shadow:
    0 3px 10px rgba(40, 22, 10, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);

  transition:
    transform 0.15s ease,
    background 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}

.hatterkep-modal-close svg {
  display: block;
  width: 22px;
  height: 22px;

  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;

  pointer-events: none;
}

.hatterkep-modal-close:hover {
  background: #75451f;
  color: #fffaf0;

  /*transform: rotate(5deg) scale(1.06);*/

  box-shadow:
    0 5px 14px rgba(40, 22, 10, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.hatterkep-modal-close:active {
  transform: scale(0.96);
}

.hatterkep-modal-close:focus-visible {
  outline: 3px solid rgba(117, 69, 31, 0.4);
  outline-offset: 3px;
}

@media (max-width: 600px) {
  .hatterkep-modal-close {
    top: 8px;
    right: 8px;

    width: 44px;
    height: 44px;
  }
}

.hatterkep-modal-content {
  display: grid;
  grid-template-columns: minmax(260px, 380px) minmax(0, 1fr);
  gap: 14px;
  padding: 14px 16px;

  min-height: 0;
  overflow: auto;
}

.hatterkep-modal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
}

.hatterkep-modal-card {
  position: relative;
  display: grid;
  grid-template-rows: 118px auto;
  gap: 4px;
  padding: 5px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  color: #4b2c15;
  text-align: center;
}

.hatterkep-modal-card.active {
  border-color: #7b4f2a;
}

.hatterkep-modal-card.current {
  box-shadow: 0 0 0 2px rgba(150, 190, 70, .35);
}

.hatterkep-modal-card.missing {
  opacity: .58;
}

.hatterkep-modal-thumb {
  display: block;
  border-radius: 8px;
  background-color: #e9deca;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

.hatterkep-modal-label {
  font-size: 12px;
  line-height: 1.15;
  font-weight: 700;
}

.hatterkep-current-badge,
.hatterkep-missing-badge {
  position: absolute;
  left: 7px;
  top: 7px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}

.hatterkep-current-badge {
  background: #d9f2a3;
  color: #3b4217;
}

.hatterkep-missing-badge {
  background: #ead6c5;
  color: #7d2d1a;
}

.hatterkep-modal-large {
  min-width: 0;
  min-height: 440px;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;

  padding: 10px;

  overflow: hidden;
  box-sizing: border-box;

  border-radius: 12px;
  background: rgba(255, 255, 255, 0.62);
}

.hatterkep-large-label {
  width: 100%;
  height: auto;

  margin: 0 0 8px;

  line-height: normal;
  text-align: center;
  font-weight: 700;

  overflow: visible;
}

.hatterkep-modal-large img {
  display: block;

  width: auto;
  height: auto;

  max-width: 100%;
  max-height: min(70vh, 680px);

  object-fit: contain;
  object-position: center center;

  border-radius: 10px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.18);
}

.hatterkep-large-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 360px;
  width: 100%;
  border-radius: 10px;
  background: #ead6c5;
  color: #7d2d1a;
  font-weight: 700;
  text-align: center;
  padding: 18px;
  box-sizing: border-box;
}

.hatterkep-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(75,44,21,.16);
}

.hatterkep-modal-actions button {
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
}

.hatterkep-modal-actions .secondary {
  background: #ead6c5;
  color: #4b2c15;
  font-size: 15px;
}

.hatterkep-modal-select {
  background: #7b4f2a;
  color: #fff8ea;
}

/* Mobil szerkesztő: háttér fül felülről nyíló panelként */
@media (max-width: 640px) {
  #emlekhely_editor .temeto-hatter.edit .mobile-editor-tab-hatterkepek {
    top: 0;
    left: 50%;
    right: auto;
    width: auto;
    min-width: 112px;
    min-height: 38px;
    height: 38px;
    padding: 0 16px;
    border-radius: 0 0 14px 14px;
    flex-direction: row;
    transform: translateX(-50%);
    letter-spacing: .04em;
  }

  #emlekhely_editor.mobile-panel-hatterkepek .temeto-hatter.edit .mobile-editor-tab-hatterkepek {
    display: none !important;
  }

  #emlekhely_editor.mobile-panel-hatterkepek .mobile-editor-shade {
    display: block;
  }

  #emlekhely_editor .temeto-hatter.edit .hatterkepek {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: auto;
    width: 100vw;
    height: min(58vh, 430px);
    max-height: none;
    padding: 16px 12px 18px;
    overflow-x: hidden;
    overflow-y: auto;
    border-radius: 0 0 18px 18px;
    opacity: .98;
    background: var(--linkek);
    box-shadow: 0 0 26px rgba(0,0,0,.32);
    z-index: 126;
    transform: translateY(-105%);
    transition: transform .22s ease;
  }

  #emlekhely_editor.mobile-panel-hatterkepek .temeto-hatter.edit .hatterkepek {
    transform: translateY(0);
  }

  .hatterkep-editor-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .hatterkep-package {
    grid-template-columns: 58px minmax(0, 1fr) 38px;
    min-width: 0;
    max-width: none;
    width: 100%;
    height: 78px;
  }

  .hatterkep-package-thumb {
    width: 58px;
    height: 66px;
  }

  .hatterkep-modal {
    align-items: stretch;
    justify-content: stretch;
  }

  .hatterkep-modal-box {
    width: 100vw;
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
  }

	.hatterkep-modal-content {
	  display: flex;
	  flex: 1 1 auto;
	  flex-direction: column;

	  min-height: 0;
	  gap: 14px;
	  padding: 10px;

	  overflow-x: hidden;
	  overflow-y: auto;
	  -webkit-overflow-scrolling: touch;
	}
	
  .hatterkep-modal-grid {
	  position: relative;
	  z-index: 1;

	  order: 2;
	  flex: 0 0 auto;

	  display: grid;
	  grid-template-columns: repeat(4, minmax(0, 1fr));

	  width: 100%;
	  margin: 0;
  }

  .hatterkep-modal-card {
    grid-template-rows: 84px auto;
    padding: 4px;
  }

	.hatterkep-modal-large {
	  order: 1;
	  flex: 0 0 auto;

	  width: 100%;
	  height: 44vh;
	  min-height: 240px;
	  max-height: 420px;

	  padding: 10px;
	  margin: 0;

	  overflow: hidden;
	  box-sizing: border-box;
	}

	.hatterkep-large-label {
	  flex: 0 0 auto;

	  width: 100%;
	  height: 24px;

	  margin: 0 0 8px;

	  line-height: 24px;
	  text-align: center;
	  font-weight: 700;

	  overflow: hidden;
	}

	.hatterkep-modal-large img {
	  display: block;

	  width: 100%;
	  height: calc(100% - 32px);

	  max-width: 100%;
	  max-height: none;

	  object-fit: contain;
	  object-position: center center;
	}

  .hatterkep-modal-actions {
    position: sticky;
    bottom: 0;
    background: #fff8ea;
  }
}

@media (max-width: 380px) {
  .hatterkep-modal-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .hatterkep-modal-card {
    grid-template-rows: 78px auto;
  }
}

/* =========================================================
   Mobil háttérfül – végleges pozicionálás
   A mobil editor látható területe 104 px-nél kezdődik.
   ========================================================= */
@media only screen and (max-width: 640px) {

  #emlekhely_editor .temeto-hatter.edit .mobile-editor-tab-hatterkepek {
    display: flex !important;
    position: fixed !important;

    top: 104px !important;
    left: 50% !important;
    right: auto !important;

    width: auto !important;
    min-width: 118px !important;
    min-height: 40px !important;
    height: 40px !important;

    padding: 0 16px !important;

    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;

    border: 0 !important;
    border-radius: 0 0 14px 14px !important;

    background: var(--linkek) !important;
    color: var(--vilagos) !important;

    font-size: 13px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    letter-spacing: 0.04em !important;

    transform: translateX(-50%) !important;

    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28) !important;

    z-index: 2290 !important;
  }

  #emlekhely_editor .temeto-hatter.edit .mobile-editor-tab-hatterkepek
  .mobile-editor-tab-char {
    display: inline-block !important;
    line-height: 1 !important;
  }

  #emlekhely_editor.mobile-panel-hatterkepek
  .temeto-hatter.edit
  .mobile-editor-tab-hatterkepek {
    display: none !important;
  }

  #emlekhely_editor.mobile-panel-hatterkepek {
    overflow: visible !important;
  }

  #emlekhely_editor.mobile-panel-hatterkepek .mobile-editor-shade {
    display: block !important;
  }

  #emlekhely_editor .temeto-hatter.edit .hatterkepek {
    display: block !important;
    position: fixed !important;

    top: 104px !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 50px !important;

    width: 100vw !important;
    height: auto !important;
    max-height: none !important;

    padding: 16px 12px 20px !important;

    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;

    border-radius: 0 0 18px 18px !important;

    background: var(--linkek) !important;

    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.34) !important;

    box-sizing: border-box !important;

    z-index: 2300 !important;

    transform: translateY(-110%) !important;
    transition: transform 0.22s ease !important;
  }

  #emlekhely_editor.mobile-panel-hatterkepek
  .temeto-hatter.edit
  .hatterkepek {
    transform: translateY(0) !important;
  }
}

/* =========================================================
   Háttérválasztó panel bezárógomb
   ========================================================= */

.hatterkep-panel-title {
  min-width: 0;
}

.hatterkep-panel-title strong,
.hatterkep-panel-title span {
  display: block;
}

.hatterkep-panel-close {
  display: none;
}


/* =========================================================
   Mobil háttérpanel
   - kevés csomagnál csak a tartalom aljáig ér
   - sok csomagnál legfeljebb az emlékhely képének aljáig ér
   - ezután belül görgethető
   ========================================================= */

@media only screen and (max-width: 640px) {

  #emlekhely_editor .temeto-hatter.edit .hatterkepek {
    position: fixed !important;

    top: 104px !important;
    left: 0 !important;
    right: 0 !important;

    /*
     * Fontos: ne legyen bottom: 50px,
     * mert attól mindig teljes magasságú lesz.
     */
    bottom: auto !important;

    width: 100vw !important;

    /*
     * Kevés háttércsomagnál a panel csak a tartalom
     * tényleges magasságát veszi fel.
     */
    height: auto !important;

    /*
     * Legfeljebb az emlékhely látható képterületének
     * aljáig nőhet.
     */
    max-height: calc(100vh - 154px) !important;
    max-height: calc(100dvh - 154px) !important;

    padding: 0 12px 16px !important;

    overflow-x: hidden !important;
    overflow-y: auto !important;

    box-sizing: border-box !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;

    border-radius: 0 0 18px 18px !important;

    background: var(--linkek) !important;

    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.34) !important;

    z-index: 2300 !important;
  }

  /*
   * A fejléc a panel görgetése közben is maradjon látható.
   */
  #emlekhely_editor .hatterkepek .hatterkep-panel-head {
    position: sticky;
    top: 0;
    z-index: 5;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;

    margin: 0 -12px 10px;
    padding: 10px 12px;

    background: var(--linkek);

    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
  }

  #emlekhely_editor .hatterkep-panel-title {
    flex: 1 1 auto;
    min-width: 0;
  }

  #emlekhely_editor .hatterkep-panel-title strong {
    font-size: 16px;
    line-height: 1.2;
  }

  #emlekhely_editor .hatterkep-panel-title span {
    margin-top: 3px;

    font-size: 11px;
    line-height: 1.25;

    opacity: 0.82;
  }

  #emlekhely_editor .hatterkep-panel-close {
    flex: 0 0 42px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 42px;
    height: 42px;
    padding: 0;

    border: 1px solid rgba(255, 248, 234, 0.42);
    border-radius: 50%;

    background: rgba(255, 248, 234, 0.14);
    color: #fff8ea;

    cursor: pointer;

    box-shadow:
      0 3px 10px rgba(0, 0, 0, 0.22),
      inset 0 1px 0 rgba(255, 255, 255, 0.15);

    -webkit-tap-highlight-color: transparent;
  }

  #emlekhely_editor .hatterkep-panel-close svg {
    display: block;

    width: 22px;
    height: 22px;

    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;

    pointer-events: none;
  }

  #emlekhely_editor .hatterkep-panel-close:active {
    transform: scale(0.94);
  }

  #emlekhely_editor .hatterkep-panel-close:focus-visible {
    outline: 3px solid rgba(255, 248, 234, 0.75);
    outline-offset: 2px;
  }
}