/* episode-picker.css - the searchable episode sheet that replaces the #sList modal on viewer pages.
 * Light palette by default; html[data-theme="dark"] switches the variables. */
:root {
  --epk-bg: #ffffff;
  --epk-surface: #f4f5f7;
  --epk-text: #1a1a1a;
  --epk-muted: #6b6b6b;
  --epk-border: #e3e3e3;
  --epk-accent: #e50020;
  --epk-read: #c9c9c9;
  --epk-shadow: 0 -12px 40px rgba(0, 0, 0, .25);
}
html[data-theme="dark"] {
  --epk-bg: #1b1b1b;
  --epk-surface: #262626;
  --epk-text: #e6e6e6;
  --epk-muted: #9a9a9a;
  --epk-border: #333333;
  --epk-read: #555555;
  --epk-shadow: 0 -12px 48px rgba(0, 0, 0, .7);
}

/* once the script is active the Bootstrap modal must never flash */
html.epk-ready #sList { display: none !important; }
html.epk-lock { overflow: hidden; }
html.epk-lock body { overflow: hidden; }   /* position/top are set inline by the script so iOS cannot pan the page */

.epk { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 2000; display: none; font-family: inherit; overflow: hidden; }
.epk.is-open { display: block; }
.epk__backdrop { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, .55); backdrop-filter: blur(2px); }
/* phones: a floating card 8px inside every screen edge, never wider than the screen */
.epk__panel {
  position: absolute; left: 8px; right: 8px; bottom: 8px; height: 84%; max-height: 84%; max-width: calc(100% - 16px); box-sizing: border-box;
  display: flex; flex-direction: column; background: var(--epk-bg); color: var(--epk-text);
  border-radius: 18px; box-shadow: var(--epk-shadow); overflow: hidden; touch-action: pan-y;
  animation: epk-up .22s cubic-bezier(.2, .8, .2, 1);
}
@keyframes epk-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.epk__panel::before { content: ""; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--epk-border); }

.epk__head { display: flex; align-items: center; justify-content: space-between; padding: 20px 16px 8px; }
.epk__title { font-size: 17px; font-weight: 700; line-height: 1.3; }
.epk__count { margin-left: 8px; font-size: 12px; font-weight: 500; color: var(--epk-muted); }
.epk__close { width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--epk-surface); color: var(--epk-text); font-size: 22px; line-height: 36px; cursor: pointer; }

.epk__tools { display: flex; gap: 8px; padding: 0 16px 10px; }
.epk__search {
  flex: 1; min-width: 0; height: 40px; padding: 0 14px; border: 1px solid var(--epk-border); border-radius: 12px;
  background: var(--epk-surface); color: var(--epk-text); font-size: 15px; outline: none; -webkit-appearance: none;
}
.epk__search:focus { border-color: var(--epk-accent); box-shadow: 0 0 0 3px rgba(229, 0, 32, .15); }
.epk__sort { height: 40px; padding: 0 14px; border: 1px solid var(--epk-border); border-radius: 12px; background: var(--epk-surface); color: var(--epk-text); font-size: 13px; white-space: nowrap; cursor: pointer; }

.epk__chips { display: flex; gap: 6px; padding: 0 16px 10px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.epk__chips::-webkit-scrollbar { display: none; }
.epk__chip { flex: 0 0 auto; height: 30px; padding: 0 12px; border: 1px solid var(--epk-border); border-radius: 999px; background: transparent; color: var(--epk-muted); font-size: 12px; cursor: pointer; transition: background-color .15s, color .15s, border-color .15s; }
.epk__chip.is-on { background: var(--epk-accent); border-color: var(--epk-accent); color: #fff; font-weight: 600; }

.epk__body { position: relative; flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 36px 12px 16px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }
.epk__grid { display: flex; flex-wrap: wrap; gap: 8px; }
.epk__cell {
  flex: 0 0 calc(33.333% - 6px); display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-height: 54px; padding: 8px 10px; border: 1px solid var(--epk-border); border-radius: 10px;
  background: var(--epk-surface); color: var(--epk-text); text-align: left; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05); transition: transform .12s, border-color .12s, background-color .12s;
}
.epk__cell[hidden] { display: none; }
.epk__cell:active { transform: scale(.97); }
.epk__num { font-size: 11px; font-weight: 700; color: var(--epk-muted); letter-spacing: .02em; }
.epk__label { font-size: 13px; line-height: 1.25; max-height: 2.5em; overflow: hidden; }
.epk__cell.is-read { color: var(--epk-read); }
.epk__cell.is-read .epk__num { color: var(--epk-read); }
.epk__cell.is-last-read { border-color: var(--epk-accent); }
.epk__cell.is-last-read .epk__num::after { content: " · 마지막"; color: var(--epk-accent); }
.epk__cell.is-current { background: var(--epk-accent); border-color: var(--epk-accent); color: #fff; box-shadow: 0 6px 16px rgba(229, 0, 32, .35); }
.epk__cell.is-current .epk__num { color: rgba(255, 255, 255, .85); }
.epk__empty { padding: 32px 0; text-align: center; color: var(--epk-muted); }

.epk__rail { position: absolute; right: 6px; top: 150px; bottom: 70px; width: 26px; display: flex; flex-direction: column; justify-content: space-between; align-items: center; padding: 6px 0; border-radius: 13px; background: var(--epk-surface); font-size: 10px; color: var(--epk-muted); user-select: none; touch-action: none; }
.epk__rail-mark { flex: 1; display: flex; align-items: center; cursor: pointer; }
.epk__rail[hidden] { display: none; }

.epk__foot { display: flex; gap: 8px; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--epk-border); background: var(--epk-bg); }
.epk__btn { flex: 1; height: 42px; border: 1px solid var(--epk-border); border-radius: 12px; background: var(--epk-surface); color: var(--epk-text); font-size: 14px; font-weight: 600; cursor: pointer; }
.epk__btn--accent { background: var(--epk-accent); border-color: var(--epk-accent); color: #fff; box-shadow: 0 6px 16px rgba(229, 0, 32, .3); }

/* tablets: four columns */
@media (min-width: 600px) { .epk__cell { flex-basis: calc(25% - 6px); } }

/* desktop: a centred panel instead of a bottom sheet, six columns, hover states */
@media (min-width: 1024px) {
  .epk__panel { left: 50%; right: auto; top: 50%; bottom: auto; width: 720px; max-width: none; height: 80%; max-height: 760px; transform: translate(-50%, -50%); border-radius: 18px; animation: epk-pop .2s ease-out; }
  @keyframes epk-pop { from { transform: translate(-50%, -48%); opacity: 0; } to { transform: translate(-50%, -50%); opacity: 1; } }
  .epk__panel::before { display: none; }
  .epk__cell { flex-basis: calc(16.666% - 7px); }
  .epk__cell:hover { border-color: var(--epk-accent); transform: translateY(-2px); }
  .epk__chip:hover { color: var(--epk-text); border-color: var(--epk-text); }
}
