@import url('https://fonts.googleapis.com/css2?family=Cormorant:wght@400;500;600;700&family=Montserrat:wght@300;400;500;600;700&display=swap');

:root {
  --color-primary: #3e281e;
  --color-accent: #db471c;
  --color-muted: rgba(62, 40, 30, 0.15);
  --color-background-base: #fcf3e3;

  --font-heading: 'Cormorant', serif;
  --font-body: 'Montserrat', sans-serif;
}

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

html, body {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

/* Hide scrollbar for Chrome, Safari and Opera */
::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
  background: transparent;
}
html::-webkit-scrollbar, body::-webkit-scrollbar {
  display: none;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-background-base);
  color: var(--color-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Nav */
nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
}

nav.hidden {
  display: none !important;
}

.nav-brand {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-primary);
  text-decoration: none;
}

.nav-links button {
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-primary);
  cursor: pointer;
  padding-bottom: 4px;
}

/* Main Container */
main {
  flex: 1;
  padding: 2rem 1.5rem;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
}

.view {
  display: none;
}
.view.active {
  display: block;
}

/* Hero Section */
.hero-section {
  text-align: center;
  margin-top: 4rem;
  margin-bottom: 5rem;
}

.next-bday-label {
  font-family: var(--font-body);
  font-size: 0.75rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: #7a6357;
  margin-bottom: 1rem;
}

.main-name {
  font-family: var(--font-heading);
  font-size: 7.5rem;
  line-height: 1;
  font-weight: 500;
  color: #281710;
  margin-bottom: 1.5rem;
}

.main-date {
  font-family: var(--font-body);
  font-size: 1.1rem;
  color: #7a6357;
  margin-bottom: 3.5rem;
}

/* Countdown Row */
.countdown-row {
  display: flex;
  justify-content: center;
  gap: 3rem;
  margin-bottom: 4rem;
}

.cd-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.cd-num {
  font-family: var(--font-heading);
  font-size: 4.5rem;
  line-height: 1;
  color: #281710;
}

.cd-label {
  font-family: var(--font-body);
  font-size: 0.65rem;
  letter-spacing: 0.35em;
  color: #7a6357;
}

/* Button */
.btn-wall {
  background-color: var(--color-accent);
  color: white;
  border-radius: 0;
  padding: 1.2rem 3rem;
  border: none;
  font-family: var(--font-body);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s, background-color 0.2s;
}

.btn-wall:hover {
  transform: scale(1.02);
  background-color: #c93d15;
}

/* Divider */
.divider {
  border: none;
  border-top: 1px solid var(--color-muted);
  margin: 0;
  width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
}

/* Circle Section */
.circle-section {
  padding-top: 5rem;
  margin-bottom: 5rem;
}

.circle-label {
  font-family: var(--font-heading);
  font-size: 1rem;
  letter-spacing: 0.35em;
  color: #7a6357;
  margin-bottom: 3rem;
}

.circle-list {
  list-style: none;
}

.circle-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1.8rem 0;
  border-bottom: 1px solid var(--color-muted);
}

.circle-list li:last-child {
  border-bottom: none;
}

.circle-name {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  color: #281710;
}

.circle-details {
  display: flex;
  gap: 3rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: #7a6357;
  text-align: right;
}

.circle-date {
  min-width: 120px;
}
.circle-in-days {
  min-width: 100px;
}

.footer-note {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: #9c8a81;
  text-align: center;
  padding-top: 4rem;
  padding-bottom: 2rem;
}

/* Message Wall View */
.wall-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3rem;
  margin-top: 2rem;
}

.year-select {
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-muted);
  border-radius: 4px;
  font-family: var(--font-body);
  background: transparent;
  color: var(--color-primary);
}

.message-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
  margin-bottom: 4rem;
}

/* Envelopes */
.envelope-wrapper {
  position: relative;
  width: 100%;
  height: 220px;
  cursor: pointer;
  perspective: 1000px;
}

.envelope-bg {
  position: absolute;
  inset: 0;
  background: var(--env-color);
  border-radius: 4px;
  z-index: 1;
}

.envelope-front {
  position: absolute;
  inset: 0;
  background: var(--env-color);
  filter: brightness(0.92);
  clip-path: polygon(0 0, 50% 50%, 100% 0, 100% 100%, 0 100%);
  z-index: 3;
  pointer-events: none;
  border-radius: 4px;
}

.envelope-flap {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 60%;
  background: var(--env-color);
  filter: brightness(0.96);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1), z-index 0.6s;
  z-index: 4;
  border-radius: 4px 4px 0 0;
}

.letter {
  position: absolute;
  top: 15px; left: 15px; right: 15px;
  height: 180px;
  background: #fffdfa;
  padding: 1.5rem;
  border-radius: 4px;
  z-index: 2;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1), height 0.6s, box-shadow 0.6s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.envelope-wrapper.open .envelope-flap {
  transform: rotateX(180deg);
  z-index: 1; 
}

.envelope-wrapper.open .letter {
  transform: translateY(-60px) scale(1.02);
  z-index: 10;
  height: auto;
  min-height: 200px;
  box-shadow: 0 15px 35px rgba(62,40,30, 0.2);
  overflow: visible;
}

.rot-1 { transform: rotate(-2deg); }
.rot-2 { transform: rotate(1deg); }
.rot-3 { transform: rotate(3deg); }
.rot-4 { transform: rotate(-1deg); }
.rot-5 { transform: rotate(0deg); }

.message-text {
  font-size: 1rem;
  margin-bottom: 1.5rem;
  white-space: pre-wrap;
  flex: 1;
}

.message-sender {
  font-weight: 600;
  font-size: 0.85rem;
  text-align: right;
  color: var(--color-accent);
}

.message-date {
  font-size: 0.75rem;
  color: #7a6357;
  text-align: right;
  margin-top: 0.25rem;
}

/* Floating Action Button */
.fab-button {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 65px;
  height: 65px;
  border-radius: 50%;
  background: var(--color-accent);
  color: white;
  border: none;
  font-size: 2rem;
  font-weight: 300;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(219, 71, 28, 0.4);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.2s;
}

.fab-button:hover {
  transform: scale(1.1) rotate(90deg);
  background: #c93d15;
}

/* Compose Overlay */
.compose-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(252, 243, 227, 0.96);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.compose-wrapper.hidden {
  opacity: 0;
  visibility: hidden;
}

.compose-section {
  position: relative;
  background: transparent;
  padding: 3rem;
  width: 100%;
  max-width: 600px;
  border: none;
  margin: 0;
  transform: translateY(0);
  transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.compose-wrapper.hidden .compose-section {
  transform: translateY(30px);
}

.close-btn {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: transparent;
  border: none;
  font-size: 2.5rem;
  line-height: 1;
  color: var(--color-primary);
  cursor: pointer;
  transition: transform 0.2s;
}

.close-btn:hover {
  transform: scale(1.1);
}

.form-group {
  margin-bottom: 2.5rem;
}

.form-group label {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 0.8rem;
  color: #7a6357;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 1rem 0;
  border: none;
  border-bottom: 1px solid rgba(62, 40, 30, 0.3);
  border-radius: 0;
  font-family: var(--font-body);
  background: transparent;
  font-size: 1.2rem;
  color: #281710;
  transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-bottom: 1px solid var(--color-accent);
}

.form-group textarea {
  min-height: 100px;
  resize: none;
}

.btn-submit {
  width: auto;
  background: var(--color-accent);
  color: white;
  border: none;
  padding: 1rem 3rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 50px;
  cursor: pointer;
  display: block;
  margin: 3rem auto 0;
  transition: transform 0.2s, background-color 0.2s;
}

.btn-submit:hover:not(:disabled) {
  transform: scale(1.02);
  background-color: #c93d15;
}

.btn-submit:disabled {
  background: #dba291;
  cursor: not-allowed;
  transform: none;
}

.form-error {
  color: #db471c;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  text-align: center;
  display: none;
}

@media (max-width: 768px) {
  .main-name { font-size: 4.5rem; }
  .cd-num { font-size: 2.5rem; }
  .countdown-row { gap: 1.5rem; }
  .circle-name { font-size: 1.8rem; }
  .circle-details { font-size: 0.85rem; gap: 1rem; flex-direction: column; text-align: right; }
  .circle-list li { align-items: center; }
}
