/* ============================================
   R SHOP - Authenticated Pages Common Styles
   Shared header, footer, mobile menu, variables
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --black: #0a0a0a;
  --black-light: #121212;
  --black-card: #161616;
  --gold: #C9A84C;
  --gold-light: #E8D48B;
  --gold-dark: #A67C2E;
  --purple: #8B5CF6;
  --purple-light: #A78BFA;
  --purple-dark: #6D28D9;
  --crimson: #DC2626;
  --crimson-dark: #991B1B;
  --white: #F5F5F5;
  --gray: #888;
  --gray-dark: #333;
  --font-display: 'Cinzel Decorative', 'Cinzel', serif;
  --font-heading: 'Cinzel', serif;
  --font-body: 'Noto Sans JP', sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-height: 64px;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--black);
  color: var(--white);
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  transition: opacity 0.5s ease;
}

body.loaded { opacity: 1; }

a { color: inherit; text-decoration: none; }
button { -webkit-tap-highlight-color: transparent; }

/* Prevent double-tap zoom on interactive elements (keeps pinch zoom) */
a, button, input, select, textarea, label, [role="button"] {
  touch-action: manipulation;
}

/* Prevent iOS Safari auto-zoom on input focus (requires font-size >= 16px) */
@media screen and (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* --- App Header --- */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 10000;
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(201, 168, 76, 0.1);
  padding: 0 16px;
  padding-top: var(--safe-top);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: var(--header-height);
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
}

/* Left: hamburger + logo (must be horizontal row) */
.header-left {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}

/* Logo */
.header-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  flex-shrink: 0;
}

.header-logo-r {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--purple), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-logo-text {
  font-family: var(--font-heading);
  font-size: 12px;
  letter-spacing: 5px;
  color: var(--gold);
}

/* Desktop Nav */
.header-nav {
  display: none;
  align-items: center;
  gap: 32px;
}

.header-nav-link {
  font-family: var(--font-heading);
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--gray);
  transition: color 0.3s ease;
  position: relative;
  padding: 4px 0;
}

.header-nav-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--gold);
  transition: width 0.3s ease;
}

.header-nav-link:hover { color: var(--gold); }
.header-nav-link:hover::after { width: 100%; }
.header-nav-link.active { color: var(--gold); }
.header-nav-link.active::after { width: 100%; }

/* Admin nav link (crimson accent) */
.header-nav-link--admin { color: var(--crimson); }
.header-nav-link--admin::after { background: var(--crimson); }
.header-nav-link--admin:hover { color: #EF4444; }
.header-nav-link--admin.active { color: var(--crimson); }
.header-nav-link--admin.active::after { background: var(--crimson); width: 100%; }

/* Right section */
.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.header-username {
  display: none;
  font-family: var(--font-heading);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--gray);
}

.header-logout-btn {
  display: none;
  background: none;
  border: 1px solid rgba(201, 168, 76, 0.2);
  color: var(--gray);
  font-family: var(--font-heading);
  font-size: 9px;
  letter-spacing: 2px;
  padding: 6px 14px;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-height: 32px;
}

.header-logout-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* --- User Avatar --- */
.header-avatar {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  border: 1.5px solid rgba(201, 168, 76, 0.35);
  background: var(--black-card);
  flex-shrink: 0;
  cursor: pointer;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.header-avatar:hover {
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(201, 168, 76, 0.2);
}

.avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s ease;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.avatar-img.loaded {
  opacity: 1;
}

.avatar-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--purple-dark), var(--gold-dark));
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0;
  user-select: none;
}

.avatar-img.loaded + .avatar-fallback,
.avatar-img.loaded ~ .avatar-fallback {
  display: none;
}

/* Hamburger (mobile - left side) */
.header-hamburger {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}

.header-hamburger span {
  display: block;
  width: 20px;
  height: 1.5px;
  background: var(--gold);
  transition: all 0.3s ease;
}

.header-hamburger.active span:nth-child(1) {
  transform: rotate(45deg) translate(4px, 5px);
}
.header-hamburger.active span:nth-child(2) {
  opacity: 0;
}
.header-hamburger.active span:nth-child(3) {
  transform: rotate(-45deg) translate(4px, -5px);
}

/* Mobile Menu */
.mobile-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: rgba(10, 10, 10, 0.98);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s ease;
}

.mobile-menu.active {
  opacity: 1;
  visibility: visible;
}

/* Mobile menu avatar */
.mobile-menu-avatar {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(201, 168, 76, 0.3);
  background: var(--black-card);
  margin-bottom: 4px;
}

.mobile-menu-avatar .avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s ease;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.mobile-menu-avatar .avatar-img.loaded {
  opacity: 1;
}

.mobile-menu-avatar .avatar-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--purple-dark), var(--gold-dark));
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 700;
  color: var(--white);
  user-select: none;
}

.mobile-menu-avatar .avatar-img.loaded + .avatar-fallback,
.mobile-menu-avatar .avatar-img.loaded ~ .avatar-fallback {
  display: none;
}

.mobile-menu-user {
  font-family: var(--font-heading);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--gray);
  margin-bottom: 8px;
}

.mobile-menu-link {
  font-family: var(--font-heading);
  font-size: 15px;
  letter-spacing: 5px;
  color: var(--gray);
  transition: color 0.3s;
  padding: 12px 20px;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.mobile-menu-link:hover,
.mobile-menu-link:active { color: var(--gold); }
.mobile-menu-link.active { color: var(--gold); }

/* Admin mobile menu link (crimson accent) */
.mobile-menu-link--admin { color: var(--crimson); }
.mobile-menu-link--admin:hover,
.mobile-menu-link--admin:active { color: #EF4444; }
.mobile-menu-link--admin.active { color: var(--crimson); }

.mobile-menu-logout {
  margin-top: 8px;
  background: none;
  border: 1px solid rgba(201, 168, 76, 0.25);
  color: var(--gray);
  font-family: var(--font-heading);
  font-size: 10px;
  letter-spacing: 3px;
  padding: 14px 32px;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-height: 48px;
}

.mobile-menu-logout:hover,
.mobile-menu-logout:active {
  border-color: var(--gold);
  color: var(--gold);
}

/* --- Main Content --- */
.app-main {
  flex: 1;
  margin-top: calc(var(--header-height) + var(--safe-top));
}

/* --- App Footer --- */
.app-footer {
  border-top: 1px solid rgba(201, 168, 76, 0.08);
  padding: 32px 20px;
  padding-bottom: calc(32px + var(--safe-bottom));
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.footer-logo {
  display: flex;
  align-items: center;
  gap: 6px;
}

.footer-logo-r {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--purple), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.footer-logo-text {
  font-family: var(--font-heading);
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--gold);
}

.footer-copy {
  font-family: var(--font-heading);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--gray-dark);
}

/* --- Animations --- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes crownFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ================================================
   Member Card Modal
   ================================================ */

/* Grade color variables (extensible per tier) */
.mc-grade-standard  { --mc-accent: #888;    --mc-accent-rgb: 136,136,136; --mc-border: rgba(136,136,136,0.25); }
.mc-grade-gold      { --mc-accent: #C9A84C; --mc-accent-rgb: 201,168,76; --mc-border: rgba(201,168,76,0.35); }
.mc-grade-platinum  { --mc-accent: #A78BFA; --mc-accent-rgb: 167,139,250; --mc-border: rgba(167,139,250,0.35); }
.mc-grade-diamond   { --mc-accent: #60A5FA; --mc-accent-rgb: 96,165,250; --mc-border: rgba(96,165,250,0.4); }

/* Overlay */
.mc-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.mc-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Card wrapper (perspective for 3D tilt on PC) */
.mc-card-wrap {
  position: relative;
  width: 100%;
  max-width: 380px;
  perspective: 800px;
  transform: scale(0.92) translateY(16px);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.mc-overlay.active .mc-card-wrap {
  transform: scale(1) translateY(0);
}

/* Close button */
.mc-close {
  position: absolute;
  top: -14px;
  right: -8px;
  z-index: 2;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--black-card);
  border: 1px solid rgba(201, 168, 76, 0.15);
  border-radius: 50%;
  color: var(--gray);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.3s ease;
}

.mc-close:hover {
  color: var(--white);
  border-color: var(--gold);
}

/* Card body */
.mc-card {
  position: relative;
  background: linear-gradient(145deg, #1a1a2e 0%, #0f0f1a 50%, #1a1020 100%);
  border: 1px solid var(--mc-border);
  border-radius: 14px;
  overflow: hidden;
  transition: transform 0.15s ease;
}

/* Shimmer layer */
.mc-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(
    from 0deg,
    transparent,
    rgba(var(--mc-accent-rgb), 0.04),
    transparent,
    rgba(139, 92, 246, 0.03),
    transparent
  );
  animation: mcShimmer 8s linear infinite;
  pointer-events: none;
}

@keyframes mcShimmer {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Card glow */
.mc-glow {
  position: absolute;
  inset: -20px;
  background: radial-gradient(ellipse, rgba(var(--mc-accent-rgb), 0.12) 0%, transparent 70%);
  filter: blur(20px);
  pointer-events: none;
  animation: mcGlow 4s ease-in-out infinite;
}

@keyframes mcGlow {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 0.8; }
}

/* Inner padding */
.mc-inner {
  position: relative;
  z-index: 1;
  padding: 28px 24px 24px;
}

/* Header row: R SHOP logo + grade badge */
.mc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.mc-logo {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mc-logo-r {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--purple), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.mc-logo-text {
  font-family: var(--font-heading);
  font-size: 8px;
  letter-spacing: 3px;
  color: var(--gold);
}

.mc-grade-badge {
  font-family: var(--font-heading);
  font-size: 7px;
  letter-spacing: 2px;
  color: var(--mc-accent);
  border: 1px solid var(--mc-border);
  padding: 4px 10px;
  border-radius: 2px;
}

/* Profile section */
.mc-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}

.mc-avatar {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--mc-border);
  background: var(--black-card);
  margin-bottom: 14px;
}

.mc-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: -webkit-optimize-contrast;
}

.mc-avatar .avatar-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--purple-dark), var(--gold-dark));
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  color: var(--white);
}

.mc-display-name {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 4px;
}

.mc-handle {
  font-family: var(--font-heading);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--gray);
}

/* Divider */
.mc-divider {
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(var(--mc-accent-rgb), 0.2), transparent);
  margin-bottom: 20px;
}

/* Info grid: member no + since */
.mc-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.mc-info-label {
  font-family: var(--font-heading);
  font-size: 7px;
  letter-spacing: 2px;
  color: var(--gray);
  margin-bottom: 4px;
}

.mc-info-value {
  font-family: var(--font-heading);
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--white);
}

/* X ID row */
.mc-xid-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
}

.mc-xid-icon {
  flex-shrink: 0;
  color: var(--gray);
}

.mc-xid-value {
  font-family: var(--font-heading);
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--gray);
}

/* Grade progress bar (extensible) */
.mc-grade-section {
  margin-bottom: 20px;
}

.mc-grade-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.mc-grade-label {
  font-family: var(--font-heading);
  font-size: 7px;
  letter-spacing: 2px;
  color: var(--gray);
}

.mc-grade-name {
  font-family: var(--font-heading);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--mc-accent);
}

.mc-grade-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
}

.mc-grade-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--mc-accent), rgba(var(--mc-accent-rgb), 0.5));
  border-radius: 2px;
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Footer */
.mc-footer {
  text-align: center;
  padding-top: 16px;
  border-top: 1px solid rgba(var(--mc-accent-rgb), 0.08);
}

.mc-footer-text {
  font-family: var(--font-heading);
  font-size: 7px;
  letter-spacing: 3px;
  color: var(--gray-dark);
}

/* Sign out link inside card */
.mc-signout {
  display: inline-block;
  margin-top: 14px;
  font-family: var(--font-heading);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--gray);
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 16px;
  transition: color 0.3s ease;
}

.mc-signout:hover { color: var(--crimson); }

/* ================================================
   PC Enhancement (min-width: 769px)
   ================================================ */
@media (min-width: 769px) {
  :root {
    --header-height: 72px;
  }

  .app-header {
    padding: 0 40px;
  }

  .header-left { gap: 0; }

  .header-logo-r { font-size: 30px; }
  .header-logo-text { font-size: 13px; letter-spacing: 6px; }

  .header-nav {
    display: flex;
  }

  .header-nav-link {
    font-size: 12px;
    letter-spacing: 3px;
  }

  .header-username {
    display: block;
    font-size: 11px;
  }

  .header-logout-btn {
    display: block;
    font-size: 10px;
    padding: 7px 16px;
  }

  .header-hamburger {
    display: none;
  }

  .header-avatar {
    width: 42px;
    height: 42px;
    border-width: 2px;
  }

  .avatar-fallback {
    font-size: 15px;
  }

  .app-footer {
    padding: 40px 40px;
    padding-bottom: calc(40px + var(--safe-bottom));
  }

  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
  }

  .footer-logo-r { font-size: 20px; }
  .footer-logo-text { font-size: 10px; letter-spacing: 4px; }

  /* Card modal PC */
  .mc-card-wrap { max-width: 420px; }
  .mc-inner { padding: 36px 32px 28px; }
  .mc-avatar { width: 88px; height: 88px; }
  .mc-avatar .avatar-fallback { font-size: 32px; }
  .mc-display-name { font-size: 18px; }
  .mc-handle { font-size: 12px; }
  .mc-info-value { font-size: 13px; }
  .mc-close { top: -16px; right: -10px; width: 40px; height: 40px; font-size: 20px; }
}
