/* --- CSS RESET & VARIABLES --- */
:root {
  --primary: #1a1a1a;
  --accent: #c8956c;
  --accent-dark: #a97a55;
  --accent-soft: #f5e6d8;
  --accent-glow: rgba(200, 149, 108, 0.15);
  --bg: #f6f4f1;
  --card-bg: #ffffff;
  --surface: #f0ece7;
  --text-main: #1a1a1a;
  --text-secondary: #4a4540;
  --text-muted: #8a8580;
  --border: rgba(0, 0, 0, 0.06);
  --border-strong: rgba(0, 0, 0, 0.1);

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.1);
  --shadow-accent: 0 8px 30px rgba(200, 149, 108, 0.2);
  --transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --- BASE --- */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text-main);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-image: url(../assets/bg.jpg);
  background-size: cover;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 20px 60px;
  min-height: 100vh;
 
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  padding-top: calc(var(--body-padding-top) + var(--safe-top));
  padding-left: calc(var(--body-padding-x) + var(--safe-left));
  padding-right: calc(var(--body-padding-x) + var(--safe-right));
  padding-bottom: calc(var(--body-padding-bottom) + var(--safe-bottom) + 70px);  
}

.container {
  width: 100%;
  max-width: 900px;
}

.container > h1 {
  margin-top: 48px;
  margin-bottom: 8px;
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.container > .subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 36px;
  font-weight: 400;
}

h2 {
  font-size: 1.5rem;
  color: var(--text-main);
  margin-bottom: 0.6rem;
  letter-spacing: -0.3px;
}

p {
  font-size: 1rem;
  color: var(--text-muted);
  white-space: pre-wrap;
}

/* --- NAVBAR BASE --- */
.navbar {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;

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

  padding: 10px 18px;

  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(14px);

  border-radius: 18px;
  border: 1px solid rgba(0,0,0,0.05);

  box-shadow: 0 6px 25px rgba(0,0,0,0.06);

  position: sticky;
  top: 16px;
  z-index: 1000;
}

/* --- LEFT --- */
.nav-left {
  display: flex;
  align-items: center;
}

.nav-brand {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.5px;
  color: #1a1a1a;
}

/* --- RIGHT SIDE --- */
.nav-right {
  display: flex;
  align-items: center;
  gap: 10px; /* 🔥 THIS controls ALL spacing */
}

/* --- BUTTON BASE --- */
.nav-btn {
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 500;

  border-radius: 10px;
  text-decoration: none;

  color: #555;
  background: transparent;

  transition: all 0.25s ease;
}

/* --- HOVER --- */
.nav-btn:hover {
  background: #f2ebe5;
  color: #a97a55;
  transform: translateY(-1px);
}

/* --- PRIMARY BUTTON (Login / Signup) --- */
.nav-btn.primary {
  background: #1a1a1a;
  color: white;
  font-weight: 600;
}

.nav-btn.primary:hover {
  background: #333;
}

/* --- USER TEXT --- */
#userDisplay {
  font-size: 0.85rem;
  font-weight: 600;
  color: #444;
  margin-left: 4px;
}

/* --- LOGOUT BUTTON --- */
#logoutBtn {
  border: none;
  background: transparent;

  font-size: 0.85rem;
  color: #c0392b;
  cursor: pointer;

  padding: 6px 10px;
  border-radius: 8px;

  transition: 0.2s;
}

#logoutBtn:hover {
  background: rgba(192,57,43,0.1);
}

/* --- AUTH LINKS WRAPPER --- */
#authLinks {
  display: flex;
  gap: 10px; /* consistent spacing */
}

/* --- PRIMARY BUTTONS (LOGIN / SIGNUP / CREATE) --- */
.auth-btn {
  padding: 8px 14px;
  border-radius: 50px;
  font-weight: 600 !important;
  font-size: 0.85rem !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  text-decoration: none;
}


/* 🌿 main accent button */
.signup-style {
  background: linear-gradient(
    135deg,
    var(--primary),
    #2a2a2a
  );
  color: #fff !important;
  border: none;

  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

/* ✨ hover glow */
.signup-style:hover {
  background: linear-gradient(
    135deg,
    #2a2a2a,
    var(--primary)
  );
  transform: translateY(-1px);
  box-shadow: var(--shadow-accent);
}
/* --- POEM GRID --- */
#poems {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  width: 100%;
}

/* --- POEM CARD (unified, no conflicting selectors) --- */
/* --- POEM CARD --- */
#poems > div {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: var(--transition);
  cursor: default;
  position: relative;
  backdrop-filter: blur(5px);
}

#poems > div:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-accent);
  border-color: rgba(200, 149, 108, 0.2);
}

#poems > div .author-tag {
  color: var(--accent-dark);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

#poems > div .author-tag::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

#poems > div h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 10px;
  line-height: 1.3;
  letter-spacing: -0.3px;
}

#poems > div p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

/* Card footer / actions */
#poems > div .actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.9rem;
  margin-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.view-link {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition-fast);
}

.view-link:hover {
  color: var(--accent);
}

.view-link svg {
  width: 14px;
  height: 14px;
  transition: var(--transition-fast);
}

.view-link:hover svg {
  transform: translateX(2px);
}

/* Like button */
button[onclick*="toggleLike"] {
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 50px;
  padding: 5px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: var(--transition-fast);
  font-family: inherit;
}

button[onclick*="toggleLike"]:hover {
  background: #fff5f5;
  border-color: #e8a0a0;
  color: #c0392b;
}

button[onclick*="toggleLike"].liked {
  background: #fff0f0;
  border-color: #e74c3c;
  color: #e74c3c;
}

/* --- SINGLE POEM VIEW (#poem) --- */
#poem {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 2.5rem;
  margin-bottom: 1.5rem;
}

#poem h2 {
  font-size: 1.8rem;
  margin-bottom: 0.3rem;
}

#poem .author-tag {
  color: var(--accent-dark);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 1.5rem;
  display: block;
}

#poem p {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

/* --- COMMENTS --- */
.comment-section {
  display: flex;
  flex-direction: column;
  height: 420px;
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

#comments {
  flex-grow: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#comments::-webkit-scrollbar {
  width: 5px;
}

#comments::-webkit-scrollbar-track {
  background: transparent;
}

#comments::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 10px;
}

.comment-item {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  border: 1px solid var(--border);
  box-shadow: none;
}

.comment-item p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  white-space: normal;
  line-height: 1.5;
}

.comment-item .author-tag {
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-bottom: 4px;
}

.comment-input-area {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: var(--card-bg);
  display: flex;
  gap: 10px;
}

.comment-input-area input {
  flex-grow: 1;
  padding: 10px 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 50px;
  outline: none;
  font-size: 0.9rem;
  font-family: inherit;
  transition: var(--transition-fast);
  background: var(--surface);
}

.comment-input-area input:focus {
  border-color: var(--accent);
  background: var(--card-bg);
}

.comment-input-area button {
  padding: 9px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  font-family: inherit;
  transition: var(--transition);
  white-space: nowrap;
}

.comment-input-area button:hover {
  background: #333;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* --- FORMS --- */
form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

input,
textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--card-bg);
  color: var(--text-main);
  transition: var(--transition-fast);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.7;
}

/* --- BUTTONS --- */
button,
a.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--primary);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  font-family: inherit;
  transition: var(--transition);
  text-decoration: none;
}

button:hover,
a.btn-primary:hover {
  background: #333;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

button:active,
a.btn-primary:active {
  transform: translateY(0);
}

/* --- AUTH --- */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80vh;
  width: 100%;
}

.auth-card {
  margin-top: 10px;
  width: 100%;
  max-width: 420px;
  padding: 2.5rem;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.auth-card h2 {
  text-align: center;
  margin-bottom: 0.4rem;
  font-size: 1.6rem;
}

.auth-card .auth-subtitle {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.auth-card p {
  text-align: center;
  font-size: 0.85rem;
  margin-top: 1.2rem;
  color: var(--text-muted);
}

.error-msg {
  color: #c0392b;
  font-size: 0.85rem;
  padding: 8px 12px;
  background: #fff5f5;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(192, 57, 43, 0.15);
  display: none;
}

/* --- LINKS --- */
a {
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
  transition: var(--transition-fast);
}

a:hover {
  color: var(--accent-dark);
}

/* --- EMPTY STATE --- */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 1rem;
  margin-bottom: 1.2rem;
}

#request {
    position: fixed;
  bottom: 20px;
  right: 20px;
  width: 55px;
  height: 55px;
  border-radius: 50%;
  border: none;
  background-color: #4CAF50;
  color: white;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  z-index: 1000;
  transition: 0.3s;
}

#request:hover{
  background-color: #45a049;
  transition: 0.3;
}

#request:active {
  transition: 0.9;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
/* --- RESPONSIVE --- */
@media (max-width: 640px) {
  body {
    padding: calc(20px + var(--safe-top)) calc(16px + var(--safe-left)) calc(90px + var(--safe-bottom)) calc(16px + var(--safe-right));
  }

  .navbar {
    padding: 8px 12px;
    border-radius: 14px;
    top: calc(10px + var(--safe-top));
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  }

  .nav-brand {
    font-size: 0.92rem;
    flex-shrink: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 90px;
  }

  .nav-right {
    gap: 6px;
    flex-shrink: 0;
  }

  #authLinks {
    gap: 6px;
  }

  .auth-btn {
    padding: 7px 12px !important;
    font-size: 0.78rem !important;
    min-height: 36px;
    min-width: 36px;
  }

  #userDisplay {
    font-size: 0.78rem;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #logoutBtn {
    font-size: 0.78rem;
    padding: 7px 8px;
    min-height: 36px;
  }

  .container > h1 {
    font-size: 1.5rem;
    margin-top: 28px;
    margin-bottom: 6px;
  }

  .container > .subtitle {
    font-size: 0.85rem;
    margin-bottom: 28px;
  }

  h2 {
    font-size: 1.25rem;
  }

  #poems {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  #poems > div {
    padding: 1.1rem;
    border-radius: 12px;
  }

  #poems > div h2 {
    font-size: 1.05rem;
  }

  #poems > div p {
    font-size: 0.85rem;
    -webkit-line-clamp: 3;
    line-clamp: 3;
  }

  button[onclick*="toggleLike"] {
    padding: 8px 14px;
    font-size: 0.82rem;
    min-height: 38px;
  }

  .view-link {
    font-size: 0.82rem;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
  }

  #poem {
    padding: 1.4rem;
    border-radius: 14px;
  }

  #poem h2 {
    font-size: 1.4rem;
  }

  #poem p {
    font-size: 0.95rem;
    line-height: 1.7;
  }

  .comment-section {
    height: 320px;
    border-radius: 14px;
  }

  .comment-input-area {
    padding: 10px 12px;
    gap: 8px;
  }

  .comment-input-area input {
    padding: 10px 14px;
    font-size: 0.85rem;
    min-height: 42px;
  }

  .comment-input-area button {
    padding: 10px 16px;
    font-size: 0.82rem;
    min-height: 42px;
  }

  .comment-item {
    padding: 10px 12px;
  }

  .comment-item p {
    font-size: 0.85rem;
  }

  .auth-card {
    padding: 1.6rem 1.4rem;
    border-radius: 16px;
    margin: 0 -4px;
  }

  .auth-card h2 {
    font-size: 1.4rem;
  }

  input, textarea {
    padding: 12px 14px;
    font-size: 16px; /* prevents iOS zoom on focus */
    min-height: 48px;
  }

  textarea {
    min-height: 140px;
  }

  button, a.btn-primary {
    padding: 13px 20px;
    font-size: 0.92rem;
    min-height: 48px;
    border-radius: 12px;
  }

  .error-msg {
    font-size: 0.82rem;
    padding: 8px 10px;
  }

  #request {
    bottom: calc(16px + var(--safe-bottom));
    right: calc(16px + var(--safe-right));
    width: 50px;
    height: 50px;
    font-size: 20px;
  }

  .empty-state {
    padding: 40px 16px;
  }
}

/* === ADD: Extra small phones === */
@media (max-width: 374px) {
  .nav-brand {
    font-size: 0.85rem;
    max-width: 70px;
  }

  .auth-btn {
    padding: 6px 10px !important;
    font-size: 0.74rem !important;
  }

  .container > h1 {
    font-size: 1.35rem;
  }

  #poems > div {
    padding: 1rem;
  }

  #poem {
    padding: 1.2rem;
  }

  .auth-card {
    padding: 1.4rem 1.1rem;
  }
}

/* === ADD: Mobile landscape === */
@media (max-height: 500px) and (orientation: landscape) {
  .auth-container {
    min-height: auto;
    padding: 20px 0;
  }

  .auth-card {
    padding: 1.5rem;
  }

  .comment-section {
    height: 250px;
  }

  textarea {
    min-height: 100px;
  }
}

/* === ADD: Touch device improvements === */
@media (hover: none) and (pointer: coarse) {
  .nav-btn:hover,
  .view-link:hover,
  a:hover {
    transform: none;
  }

  #poems > div:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
    border-color: var(--border);
  }

  button[onclick*="toggleLike"]:hover {
    transform: none;
  }

  .comment-input-area button:hover {
    transform: none;
  }
}

/* === ADD: Dark mode preference hint (optional, respects system) === */
@media (prefers-color-scheme: dark) {
  /* uncomment below block if you add dark mode later
  :root {
    --bg: #121212;
    --card-bg: #1e1e1e;
    --surface: #2a2a2a;
    --text-main: #f0ece7;
    --text-secondary: #b8b4af;
    --text-muted: #787370;
    --border: rgba(255,255,255,0.06);
    --border-strong: rgba(255,255,255,0.1);
  }
  */
}
/* --- SUBTLE ENTRANCE ANIMATION --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#poems > div {
  animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

#poems > div:nth-child(1) { animation-delay: 0.05s; }
#poems > div:nth-child(2) { animation-delay: 0.1s; }
#poems > div:nth-child(3) { animation-delay: 0.15s; }
#poems > div:nth-child(4) { animation-delay: 0.2s; }
#poems > div:nth-child(5) { animation-delay: 0.25s; }
#poems > div:nth-child(6) { animation-delay: 0.3s; }
#poems > div:nth-child(7) { animation-delay: 0.35s; }
#poems > div:nth-child(8) { animation-delay: 0.4s; }
