/* ==========================================================================
   2012 Skeuomorphic Aesthetic Architecture
   Pure CSS & Inline Scalable SVGs
   ========================================================================== */

/* Pebble-grain leather noise layer generated via inline SVG feTurbulence */
.leather-header {
  position: relative;
  background-color: var(--leather-mid);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='noise' x='0' y='0'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 0.14 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E"),
    var(--leather-gradient);
  padding: clamp(10px, 1.4vh, 16px) clamp(24px, 3.5vw, 56px) clamp(12px, 1.6vh, 18px) clamp(24px, 3.5vw, 56px);
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.25),
    inset 0 -2px 6px rgba(0, 0, 0, 0.7),
    0 3px 8px rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid rgba(40, 16, 4, 0.9);
  z-index: 10;
  box-sizing: border-box;
  flex-shrink: 0;
  width: 100%;
}

/* Recessed Stitching Container */
.stitch-border {
  position: absolute;
  pointer-events: none;
  inset: 5px;
  border-radius: 4px;
  border: 1px dashed var(--stitch-thread);
  border-top: 1.5px dashed var(--stitch-thread);
  border-bottom: 1px dashed var(--stitch-thread);
  box-shadow:
    inset 0 1px 0 var(--stitch-highlight),
    0 1px 1px var(--stitch-shadow);
  opacity: 0.8;
}

/* Brass Rivets (Grommets) at the Four Corners */
.brass-rivet {
  position: absolute;
  width: clamp(8px, 1vw, 11px);
  height: clamp(8px, 1vw, 11px);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6d6 0%, #e2ab3c 40%, #9e6414 75%, #502e05 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.7), inset 0 1px 1px rgba(255, 255, 255, 0.65);
  z-index: 12;
}

.brass-rivet::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60%;
  height: 1px;
  background: rgba(45, 22, 4, 0.85);
  box-shadow: 0 0.5px 0 rgba(255, 255, 255, 0.3);
}

.brass-rivet.top-left {
  top: 10px;
  left: 14px;
}

.brass-rivet.top-right {
  top: 10px;
  right: 14px;
}

.brass-rivet.bottom-left {
  bottom: 10px;
  left: 14px;
}

.brass-rivet.bottom-right {
  bottom: 10px;
  right: 14px;
}

/* Header Content Layout */
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 11;
  gap: clamp(10px, 1.5vw, 24px);
  width: 100%;
}

.header-left,
.header-center,
.header-right {
  display: flex;
  align-items: center;
  gap: clamp(6px, 0.9vw, 12px);
}

.header-right {
  position: relative;
  gap: clamp(8px, 1vw, 14px);
}

/* Navigation Segmented Group */
.nav-cluster {
  display: inline-flex;
  align-items: center;
  background: linear-gradient(180deg, #371808 0%, #200d04 100%);
  padding: 2px;
  border-radius: 6px;
  border: 1px solid #230f05;
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.7),
    0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Skeuomorphic Month Title */
.calendar-title-display {
  font-family: var(--font-serif);
  font-size: clamp(1.2rem, 1.7vw, 1.85rem);
  font-weight: 700;
  color: #fff6e9;
  text-shadow: var(--letterpress-leather);
  letter-spacing: -0.01em;
  margin: 0;
  user-select: none;
  white-space: nowrap;
}

/* 2012 Recessed Pill Segmented Control (Day / Week / Month) */
.segmented-control {
  display: inline-flex;
  background: linear-gradient(180deg, #371808 0%, #200d04 100%);
  padding: 2px;
  border-radius: 6px;
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.8),
    0 1px 0 rgba(255, 255, 255, 0.22);
  border: 1px solid #230f05;
}

.segmented-btn {
  appearance: none;
  background: transparent;
  border: none;
  color: #c9ab8d;
  font-family: var(--font-sans);
  font-size: clamp(0.75rem, 0.85vw, 0.875rem);
  font-weight: 600;
  padding: clamp(3px, 0.5vh, 6px) clamp(8px, 1.1vw, 16px);
  border-radius: 4px;
  cursor: pointer;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.9);
  transition: all 0.12s ease;
  outline: none;
  white-space: nowrap;
}

.segmented-btn:hover:not(.active) {
  color: #f7e6d2;
}

.segmented-btn.active {
  background: linear-gradient(180deg, #6c3614 0%, #46200a 100%);
  color: #fff9ed;
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.35),
    0 1px 2px rgba(0, 0, 0, 0.7);
  border: 1px solid #361706;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.8);
}

/* Skeuomorphic Tactile Navigation Buttons */
.nav-btn {
  appearance: none;
  background: linear-gradient(180deg, #6a3615 0%, #462009 100%);
  border: 1px solid #301404;
  color: #faebd7;
  font-family: var(--font-sans);
  font-size: clamp(0.75rem, 0.85vw, 0.875rem);
  font-weight: 700;
  padding: clamp(3px, 0.5vh, 6px) clamp(8px, 1vw, 14px);
  border-radius: 5px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 2px 4px rgba(0, 0, 0, 0.5);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.85);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: clamp(26px, 3.2vh, 34px);
  white-space: nowrap;
}

.nav-btn:hover {
  background: linear-gradient(180deg, #7a3e19 0%, #52260d 100%);
  color: #ffffff;
}

.nav-btn:active {
  background: linear-gradient(180deg, #3a1906 0%, #50230b 100%);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.8);
  transform: translateY(1px);
}

/* Brass Sync & Account Stamp */
.brass-stamp-btn {
  appearance: none;
  background: radial-gradient(ellipse at 40% 30%, #fadc78 0%, #cb9731 45%, #925f12 85%, #563305 100%);
  border: 1px solid #6c4208;
  color: #2b1803;
  font-family: var(--font-sans);
  font-size: clamp(0.6875rem, 0.75vw, 0.8125rem);
  font-weight: 700;
  padding: clamp(4px, 0.5vh, 6px) clamp(8px, 0.9vw, 13px);
  border-radius: 16px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.8),
    0 2px 5px rgba(0, 0, 0, 0.5);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.brass-stamp-btn:hover {
  filter: brightness(1.08);
}

.brass-stamp-btn:active {
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.6);
  transform: translateY(1px);
}

.sync-status-gem {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #9effb8 0%, #1da348 70%, #0d5422 100%);
  box-shadow: 0 0 3px rgba(34, 197, 94, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  flex-shrink: 0;
}

.sync-status-gem.offline {
  background: radial-gradient(circle at 35% 30%, #ffc0a8 0%, #df3a1b 70%, #7d1704 100%);
  box-shadow: 0 0 3px rgba(239, 68, 68, 0.6);
}

.sync-status-gem.syncing {
  background: radial-gradient(circle at 35% 30%, #ffe994 0%, #eab308 70%, #854d0e 100%);
  animation: pulse-gem 1s infinite alternate;
}

@keyframes pulse-gem {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

/* ==========================================================================
   Torn Paper Metaphor (Authentic Perforated Deckle Seam)
   ========================================================================== */

.torn-paper-assembly {
  position: relative;
  width: 100%;
  height: clamp(14px, 1.8vh, 20px);
  margin-top: -1px;
  margin-bottom: -1px;
  z-index: 15;
  filter: drop-shadow(0 2px 4px rgba(35, 20, 8, 0.22));
  flex-shrink: 0;
  overflow: visible;
  background: transparent;
  pointer-events: none;
}

.torn-paper-assembly svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* ==========================================================================
   Red Ribbon Bookmark (Marks Today / Dedicated Column in Header)
   ========================================================================== */

.ribbon-bookmark {
  position: relative;
  width: clamp(22px, 2.2vw, 30px);
  height: clamp(50px, 6.5vh, 68px);
  margin-top: clamp(-20px, -2.4vh, -28px);
  margin-bottom: clamp(-14px, -1.8vh, -20px);
  background: linear-gradient(180deg, #df3636 0%, var(--ribbon-red) 40%, var(--ribbon-red-dark) 100%);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 9px), 0 100%);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.45);
  z-index: 20;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: clamp(8px, 1vh, 12px);
  box-sizing: border-box;
  flex-shrink: 0;
}

.ribbon-bookmark::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.28) 0%, rgba(255, 255, 255, 0) 100%);
  pointer-events: none;
}

.ribbon-bookmark:hover {
  transform: translateY(3px);
}

.ribbon-text {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: var(--font-sans);
  font-size: clamp(0.5rem, 0.6vw, 0.625rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #fff3f3;
  text-shadow: 0 1px 2px rgba(80, 0, 0, 0.85);
  user-select: none;
}

/* ==========================================================================
   Tactile Skeuomorphic Popover & Dialog (Parchment Index Card)
   ========================================================================== */

dialog.skeuo-dialog {
  border: none;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  max-width: 480px;
  width: 90vw;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(0, 0, 0, 0.3);
  position: fixed;
  inset: 0;
  margin: auto;
  overflow: visible;
  z-index: 1000;
}

dialog.skeuo-dialog::backdrop {
  background: rgba(18, 14, 11, 0.65);
  backdrop-filter: blur(2px);
}

.index-card {
  position: relative;
  background: linear-gradient(180deg, #fdfbf7 0%, #f6f0e4 100%);
  border-radius: 8px;
  border: 1px solid #d4c8b2;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  padding: 24px 28px;
}

.card-pushpin {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff7ce 0%, #dfa838 45%, #8f580e 85%, #462602 100%);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.9);
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink-primary);
  text-shadow: var(--letterpress-light);
  margin-top: 0;
  margin-bottom: 16px;
  border-bottom: 1px dashed #d9cbba;
  padding-bottom: 8px;
}

.card-form-group {
  margin-bottom: 14px;
}

.card-label {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-secondary);
  text-shadow: var(--letterpress-light);
  margin-bottom: 4px;
}

.card-input,
.card-textarea,
.card-select {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  color: var(--ink-primary);
  background: #ffffff;
  border: 1px solid #c9bca9;
  border-radius: 4px;
  padding: 8px 10px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12);
  outline: none;
  box-sizing: border-box;
}

.card-input:focus,
.card-textarea:focus,
.card-select:focus {
  border-color: #8c572b;
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.15),
    0 0 0 3px rgba(167, 94, 43, 0.2);
}

.card-textarea {
  min-height: 70px;
  resize: vertical;
}

.color-palette-row {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.color-option {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.color-option:hover {
  transform: scale(1.15);
}

.color-option.selected {
  outline: 2px solid #7c481e;
  transform: scale(1.15);
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px dashed #d9cbba;
}

.btn-card-save {
  appearance: none;
  background: linear-gradient(180deg, #844319 0%, #5e2c0d 100%);
  color: #fff9f0;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 5px;
  border: 1px solid #3c1905;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 2px 4px rgba(0, 0, 0, 0.35);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.8);
  cursor: pointer;
}

.btn-card-save:hover {
  background: linear-gradient(180deg, #964f20 0%, #6d3310 100%);
}

.btn-card-cancel {
  appearance: none;
  background: linear-gradient(180deg, #f5f2eb 0%, #e2dac9 100%);
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 5px;
  border: 1px solid #c2b5a1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
  cursor: pointer;
}

.btn-card-delete {
  appearance: none;
  background: transparent;
  color: #b91c1c;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 8px 10px;
  border: none;
  cursor: pointer;
  text-decoration: underline;
}

.btn-card-delete:hover {
  color: #7f1d1d;
}

/* Tear-off shred animation for event deletion */
@keyframes paper-shred-tear {
  0% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
  30% {
    transform: scale(0.95) rotate(-3deg) translateY(-4px);
    opacity: 0.9;
  }
  70% {
    transform: scale(0.85) rotate(6deg) translateY(12px);
    opacity: 0.6;
    filter: blur(1px);
  }
  100% {
    transform: scale(0.6) rotate(14deg) translateY(30px);
    opacity: 0;
  }
}

.paper-shred-tear {
  animation: paper-shred-tear 0.35s ease-in forwards !important;
  pointer-events: none;
}
