/* 플래시카드 도구 전용 스타일
   테마: 학습 도구답게 차분한 틸(teal) 계열을 기본색으로 씁니다. 카드는 CSS 3D
   transform(perspective + rotateY + backface-visibility)으로 실제 카드를 뒤집는
   듯한 애니메이션을 구현합니다 — 앞면/뒷면을 같은 자리에 절대 위치로 겹쳐두고,
   .is-flipped 클래스가 붙으면 안쪽 래퍼 전체를 180도 회전시키면서 뒷면이
   backface-visibility 덕분에 자연스럽게 드러나는 방식입니다. */

:root {
  --fc-primary: #0d9488;
  --fc-primary-dark: #0f766e;
  --fc-bg: #f7f7f7;
  --fc-card-bg: #ffffff;
  --fc-border: #e2e8f0;
  --fc-text: #212529;
  --fc-text-muted: #53575e;
  --fc-radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--fc-bg);
  color: var(--fc-text);
  line-height: 1.6;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 16px;
  background: var(--fc-bg);
}

/* PC처럼 넓은 화면에서는 스크롤을 올렸을 때 상단바 전체가 화면을 가리지 않도록,
   막대(.top-bar) 자체를 폭 전체가 아니라 버튼 크기만큼만 남기고 배경도 지웁니다.
   .back-link 자체가 이미 불투명한 배경(pill 버튼)을 갖고 있어서 겹침 문제 없이
   버튼만 떠 있는 것처럼 보입니다. */
@media (min-width: 768px) {
  .top-bar {
    width: fit-content;
    height: auto;
    padding: 12px 16px 0;
    background: transparent;
  }
}

.back-link {
  display: inline-block;
  padding: 6px 14px;
  background: var(--fc-card-bg);
  border: 1px solid var(--fc-border);
  border-radius: 999px;
  color: var(--fc-text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
}

.back-link:hover {
  color: var(--fc-primary);
}

.page-header {
  text-align: center;
  padding: 10px 16px 16px;
}

.page-header h1 {
  margin: 0 0 8px;
  font-family: "Encode Sans Expanded", -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 800;
  font-size: 2.2rem;
  letter-spacing: -0.01em;
  color: var(--fc-primary-dark);
}

.subtitle {
  margin: 0;
  color: var(--fc-text-muted);
  font-size: 1.1rem;
}

.tagline-extra {
  margin: 6px 0 0;
  color: var(--fc-text-muted);
  font-size: 0.9rem;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

.fc-study-section {
  margin-top: 24px;
  text-align: center;
}

.fc-progress {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fc-text-muted);
}

.fc-card {
  perspective: 1200px;
  height: 220px;
  cursor: pointer;
  outline: none;
}

.fc-card:focus-visible .fc-card-inner {
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.35);
  border-radius: var(--fc-radius);
}

.fc-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s;
  transform-style: preserve-3d;
}

.fc-card-inner.is-flipped {
  transform: rotateY(180deg);
}

.fc-card-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--fc-card-bg);
  border: 2px solid var(--fc-border);
  border-radius: var(--fc-radius);
  backface-visibility: hidden;
}

.fc-card-front {
  border-color: var(--fc-primary);
}

.fc-card-back {
  transform: rotateY(180deg);
  background: #f0fdfa;
  border-color: var(--fc-primary);
}

.fc-card-text {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--fc-text);
  word-break: break-word;
}

.fc-flip-hint {
  margin: 10px 0 0;
  font-size: 0.85rem;
  color: var(--fc-text-muted);
}

.fc-study-controls {
  margin-top: 16px;
  display: flex;
  gap: 10px;
}

.fc-btn {
  flex: 1;
  padding: 13px 0;
  font-size: 1rem;
  font-weight: 700;
  border: 1px solid var(--fc-border);
  border-radius: 999px;
  background: var(--fc-card-bg);
  color: var(--fc-text-muted);
  cursor: pointer;
  transition: background 0.12s ease, transform 0.08s ease;
}

.fc-btn:hover:not(:disabled) {
  background: #f0fdfa;
  color: var(--fc-primary-dark);
}

.fc-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.fc-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.fc-manage-section {
  margin-top: 36px;
  background: var(--fc-card-bg);
  border: 1px solid var(--fc-border);
  border-radius: var(--fc-radius);
  padding: 20px;
}

.fc-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.fc-field {
  flex: 1;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fc-field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--fc-text-muted);
}

.fc-field input {
  padding: 11px 12px;
  font-size: 1rem;
  border: 2px solid var(--fc-border);
  border-radius: 8px;
  outline: none;
  color: var(--fc-text);
  font-family: inherit;
  transition: border-color 0.15s ease;
}

.fc-field input:focus {
  border-color: var(--fc-primary);
}

.fc-add-btn {
  padding: 11px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  background: var(--fc-primary);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}

.fc-add-btn:hover {
  background: var(--fc-primary-dark);
}

.fc-error {
  margin: 10px 0 0;
  padding: 10px 14px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #b91c1c;
  font-size: 0.85rem;
}

.fc-list-heading {
  margin: 20px 0 10px;
  font-size: 1rem;
  color: var(--fc-text);
}

.fc-empty {
  margin: 0;
  color: var(--fc-text-muted);
  font-size: 0.9rem;
}

.fc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fc-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--fc-bg);
  border: 1px solid var(--fc-border);
  border-radius: 8px;
}

.fc-list-item-text {
  font-size: 0.9rem;
  color: var(--fc-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fc-list-item-delete {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--fc-border);
  border-radius: 999px;
  background: var(--fc-card-bg);
  color: #b91c1c;
  cursor: pointer;
}

.fc-list-item-delete:hover {
  background: #fef2f2;
}

.ads-container {
  margin: 40px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--fc-card-bg);
  border: 1px solid var(--fc-border);
  border-radius: var(--fc-radius);
  color: var(--fc-text-muted);
  font-size: 0.85rem;
}

.ads-rail {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 160px;
  margin: 0;
  display: none;
  z-index: 5;
}

.ads-rail-left {
  left: 16px;
}

.ads-rail-right {
  right: 16px;
}

@media (min-width: 892px) {
  .ads-rail {
    display: flex;
  }
}

.info-section {
  margin-top: 24px;
}

.info-section h2 {
  color: var(--fc-primary-dark);
  font-size: 1.35rem;
  margin-top: 32px;
}

.faq-list .faq-item {
  margin-bottom: 16px;
}

.faq-list dt {
  font-weight: 600;
  color: var(--fc-text);
  margin-bottom: 4px;
}

.faq-list dd {
  margin: 0;
  color: var(--fc-text-muted);
}

.footer-links {
  margin: 8px 0 0;
}

.footer-links a {
  color: var(--fc-text-muted);
  text-decoration: underline;
}

.footer-links a:hover {
  color: var(--fc-primary);
}

.page-footer {
  text-align: center;
  padding: 24px 16px 40px;
  color: var(--fc-text-muted);
  font-size: 0.85rem;
}

.scroll-top-btn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--fc-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(13, 148, 136, 0.3);
  transition: background 0.12s ease, transform 0.12s ease;
}

.scroll-top-btn:hover {
  background: var(--fc-primary-dark);
  transform: translateY(-2px);
}

.scroll-top-btn[hidden] {
  display: none;
}

@media (max-width: 480px) {
  .page-header h1 {
    font-size: 1.7rem;
  }

  .fc-card {
    height: 190px;
  }

  .fc-form-row {
    flex-direction: column;
    align-items: stretch;
  }
}
