/**
 * The Stoic Wire - Authentication Button and Modal Styles
 * Marcus Aurelius icon with lock badge design + Modal window
 */

/* ============================================ */
/* 1. BUTTON BASE STYLES                        */
/* ============================================ */

/* Button Base */
.stoic-auth-button {
  all: initial;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  padding: 4px;
  border-radius: 8px;
  transition: background-color 0.2s ease;
  cursor: pointer;
  position: relative;
  font-family: 'Philosopher', 'EB Garamond', serif;
}

.stoic-auth-button:active {
  background-color: rgba(0, 0, 0, 0.05);
}

/* Icon Container */
.stoic-auth-icon-container {
  width: 50px;
  height: 50px;
  position: relative;
}

.stoic-auth-icon {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

/* Lock Badge */
.stoic-auth-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: #9c6644;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

.stoic-auth-badge svg {
  width: 10px;
  height: 10px;
  fill: white;
}

/* Logged In State */
.stoic-auth-button.logged-in .stoic-auth-badge {
  display: none;
}

/* ============================================ */
/* 2. AUTHENTICATION MODAL                      */
/* ============================================ */

.stoic-auth-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: none;
  font-family: 'EB Garamond', serif;
}

.stoic-auth-modal.active {
  display: block;
}

/* Modal Backdrop */
.stoic-auth-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease-out;
}

/* Modal Content Container */
.stoic-auth-modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #faf9f5;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 400px;
  padding: 48px 32px 32px;
  text-align: center;
  animation: modalSlideIn 0.3s ease-out;
}

/* Close Button */
.stoic-auth-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s ease;
  padding: 0;
}

.stoic-auth-modal-close:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.stoic-auth-modal-close:focus {
  outline: 2px solid #9c6644;
  outline-offset: 2px;
}

.stoic-auth-modal-close svg {
  width: 24px;
  height: 24px;
  stroke: #666;
}

/* Modal Logo Section */
.stoic-auth-modal-logo {
  margin-bottom: 24px;
}

.stoic-auth-modal-logo img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin-bottom: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stoic-auth-modal-brand {
  font-size: 1.5rem;
  font-weight: 400;
  color: #2c3e50;
  margin: 0;
  letter-spacing: 1px;
}

/* Modal Title */
.stoic-auth-modal-title {
  font-size: 1.75rem;
  font-weight: 400;
  color: #2c3e50;
  margin: 0 0 32px 0;
  line-height: 1.3;
}

/* Modal Action Buttons */
.stoic-auth-modal-actions {
  margin-bottom: 24px;
}

.stoic-auth-modal-button {
  display: inline-block;
  width: 100%;
  padding: 16px 32px;
  font-size: 1.125rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: 50px;
  transition: all 0.2s ease;
  cursor: pointer;
  letter-spacing: 0.5px;
}

.stoic-auth-modal-button-primary {
  background: #9c6644;
  color: white;
  border: 2px solid #9c6644;
}

.stoic-auth-modal-button-primary:hover {
  background: #7a513a;
  border-color: #7a513a;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(156, 102, 68, 0.3);
}

.stoic-auth-modal-button-primary:active {
  transform: translateY(0);
}

.stoic-auth-modal-button-primary:focus {
  outline: 2px solid #9c6644;
  outline-offset: 3px;
}

/* Modal Footer */
.stoic-auth-modal-footer {
  color: #666;
  font-size: 1rem;
}

.stoic-auth-modal-footer p {
  margin: 0;
}

.stoic-auth-modal-link {
  color: #9c6644;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.stoic-auth-modal-link:hover {
  color: #7a513a;
  text-decoration: underline;
}

.stoic-auth-modal-link:focus {
  outline: 2px solid #9c6644;
  outline-offset: 2px;
  border-radius: 2px;
}

/* Modal Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translate(-50%, -48%) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* ============================================ */
/* 3. ACCOUNT MENU DROPDOWN                     */
/* ============================================ */

.stoic-auth-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  min-width: 200px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  z-index: 1000;
}

.stoic-auth-menu.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.stoic-auth-menu-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
}

.stoic-auth-menu-item {
  margin: 0;
}

.stoic-auth-menu-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  color: #2c3e50;
  text-decoration: none;
  font-family: 'Philosopher', 'EB Garamond', serif;
  font-size: 0.95rem;
  transition: background-color 0.2s ease;
  white-space: nowrap;
}

.stoic-auth-menu-icon {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.stoic-auth-menu-link:hover,
.stoic-auth-menu-link:focus {
  background-color: #f8f7f5;
  outline: none;
}

.stoic-auth-menu-link:active {
  background-color: #f0ebe5;
}

/* Menu Divider */
.stoic-auth-menu-divider {
  height: 1px;
  background: #e0e0e0;
  margin: 8px 0;
}

/* ============================================ */
/* 4. LOADING STATE                             */
/* ============================================ */

.stoic-auth-button.loading .stoic-auth-icon {
  opacity: 0.5;
}

.stoic-auth-button.loading .stoic-auth-badge {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.7; }
}

/* ============================================ */
/* 5. MOBILE ADAPTATIONS                        */
/* ============================================ */

@media (max-width: 767px) {
  /* Button sizing on mobile */
  .stoic-auth-icon-container {
    width: 40px;
    height: 40px;
  }
  
  .stoic-auth-icon {
    width: 40px;
    height: 40px;
  }
  
  .stoic-auth-badge {
    width: 14px;
    height: 14px;
  }
  
  .stoic-auth-badge svg {
    width: 8px;
    height: 8px;
  }
  
  /* Modal adjustments for mobile */
  .stoic-auth-modal-content {
    width: calc(100% - 32px);
    max-width: 400px;
    padding: 40px 24px 24px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-height: 90vh;
    overflow-y: auto;
  }
  
  .stoic-auth-modal-close {
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
  }
  
  .stoic-auth-modal-close svg {
    width: 20px;
    height: 20px;
  }
  
  .stoic-auth-modal-logo img {
    width: 70px;
    height: 70px;
  }
  
  .stoic-auth-modal-brand {
    font-size: 1.3rem;
  }
  
  .stoic-auth-modal-title {
    font-size: 1.5rem;
    margin-bottom: 24px;
  }
  
  .stoic-auth-modal-button {
    font-size: 1rem;
    padding: 14px 28px;
  }
  
  .stoic-auth-modal-footer {
    font-size: 0.95rem;
  }
}

/* ============================================ */
/* 6. DESKTOP HOVER STATES                      */
/* ============================================ */

@media (min-width: 768px) {
  .stoic-auth-button:hover {
    background-color: rgba(0, 0, 0, 0.03);
  }
}

/* ============================================ */
/* 7. ACCESSIBILITY                             */
/* ============================================ */

/* Focus Styles */
.stoic-auth-button:focus {
  outline: 2px solid #0A64BC;
  outline-offset: 2px;
}

.stoic-auth-button:focus:not(:focus-visible) {
  outline: none;
}

/* Screen Reader Only Text */
.stoic-auth-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============================================ */
/* 8. POSITION WRAPPER                          */
/* ============================================ */

.stoic-auth-button-wrapper {
  position: absolute;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  z-index: 100;
}

/* Header Positioning */
.site-header {
  position: relative;
}

.site-header .stoic-auth-button-wrapper {
  position: absolute;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
}

/* Mobile Header Adjustments */
@media (max-width: 767px) {
  .site-header .stoic-auth-button-wrapper {
    right: 16px;
  }
}

/* Mobile Bottom Nav Position */
@media (max-width: 767px) {
  .stoic-auth-button-wrapper.mobile-nav {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 900;
  }
  
  .stoic-auth-button-wrapper.mobile-nav .stoic-auth-menu {
    bottom: calc(100% + 8px);
    top: auto;
    transform-origin: bottom right;
  }
}