/* ==========================================================================
   1CSD Digital Scrapbook – University of Santo Tomas
   styles.css — Scrapbook aesthetic with paper textures, handwritten fonts,
                polaroid frames, tape strips, and micro-interactions
   ========================================================================== */

/* ---------- Google Fonts (optional, falls back gracefully) ---------- */
@import url('https://fonts.googleapis.com/css2?family=Patrick+Hand&family=Caveat:wght@400;700&family=Indie+Flower&display=swap');

/* ---------- CSS Variables ---------- */
:root {
  --color-cream: #FFF8EC;
  --color-paper: #FDF6E3;
  --color-pastel-yellow: #FFF3CD;
  --color-light-brown: #C9A96E;
  --color-brown: #8B6914;
  --color-dark-brown: #5D4037;
  --color-pink: #FFB6C1;
  --color-soft-pink: #FDE2E4;
  --color-tape: rgba(255, 235, 170, 0.75);
  --color-tape-border: rgba(200, 180, 120, 0.5);
  --color-accent: #E8836B;
  --color-text: #4A3728;
  --color-text-light: #7B6B5D;
  --font-handwritten: 'Patrick Hand', 'Caveat', 'Indie Flower', 'Comic Sans MS', cursive;
  --font-body: 'Caveat', 'Patrick Hand', 'Comic Sans MS', cursive;
  --shadow-soft: 2px 3px 8px rgba(0,0,0,0.12);
  --shadow-card: 3px 4px 12px rgba(0,0,0,0.15);
  --transition: 0.3s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  /* Paper texture background using CSS */
  background-color: var(--color-cream);
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 28px,
      rgba(200,180,150,0.12) 28px,
      rgba(200,180,150,0.12) 29px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 28px,
      rgba(200,180,150,0.06) 28px,
      rgba(200,180,150,0.06) 29px
    );
}

a { color: var(--color-brown); text-decoration: none; }
a:hover { color: var(--color-accent); }
img { max-width: 100%; height: auto; display: block; }

/* ---------- Accessibility ---------- */
:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------- Navigation ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.5rem;
  background: var(--color-paper);
  border-bottom: 3px dashed var(--color-light-brown);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  flex-wrap: wrap;
}

.navbar .logo {
  font-family: var(--font-handwritten);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-dark-brown);
  white-space: nowrap;
}

.navbar .logo span { color: var(--color-accent); }

.nav-links {
  display: flex;
  list-style: none;
  gap: 0.25rem;
}

.nav-links a {
  display: inline-block;
  padding: 0.45rem 1rem;
  font-family: var(--font-handwritten);
  font-size: 1.1rem;
  border-radius: 6px;
  transition: background var(--transition), color var(--transition);
}

.nav-links a:hover,
.nav-links a:focus {
  background: var(--color-pastel-yellow);
  color: var(--color-dark-brown);
}

.nav-links a.active {
  background: var(--color-light-brown);
  color: #fff;
}

/* Hamburger (mobile) */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
}
.hamburger span {
  display: block;
  width: 24px;
  height: 3px;
  margin: 4px 0;
  background: var(--color-dark-brown);
  border-radius: 2px;
  transition: var(--transition);
}

/* ---------- Main Container ---------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ---------- HOME PAGE ---------- */
.hero {
  text-align: center;
  padding: 3rem 1rem 2rem;
}

.hero h1 {
  font-family: var(--font-handwritten);
  font-size: clamp(2rem, 5vw, 3.2rem);
  color: var(--color-dark-brown);
  margin-bottom: 0.5rem;
}

.hero p {
  font-size: 1.3rem;
  color: var(--color-text-light);
  max-width: 600px;
  margin: 0 auto 1.5rem;
}

/* CTA Button */
.btn {
  display: inline-block;
  padding: 0.75rem 2rem;
  font-family: var(--font-handwritten);
  font-size: 1.2rem;
  color: #fff;
  background: var(--color-accent);
  border: none;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  text-decoration: none;
}

.btn:hover, .btn:focus {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 3px 5px 14px rgba(0,0,0,0.2);
  background: #d6724e;
  color: #fff;
}

.btn:active { transform: scale(0.97); }

.btn-secondary {
  background: var(--color-light-brown);
}
.btn-secondary:hover, .btn-secondary:focus {
  background: var(--color-brown);
}

.btn-small {
  padding: 0.4rem 1rem;
  font-size: 1rem;
}

/* Section Headers */
.section-title {
  font-family: var(--font-handwritten);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  text-align: center;
  color: var(--color-dark-brown);
  margin: 2rem 0 1.2rem;
  position: relative;
}

.section-title::after {
  content: '';
  display: block;
  width: 120px;
  height: 3px;
  margin: 0.5rem auto 0;
  background: linear-gradient(90deg, transparent, var(--color-light-brown), transparent);
}

/* ---------- Scrapbook Cards (Home & Timeline) ---------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
  padding: 1rem 0;
}

.scrapbook-card {
  background: #fff;
  border: 2px solid #e8dcc8;
  border-radius: 4px;
  padding: 1.2rem;
  position: relative;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), box-shadow var(--transition);
  overflow: hidden;
}

.scrapbook-card::before {
  /* Tape decoration on top */
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 80px;
  height: 22px;
  background: var(--color-tape);
  border: 1px solid var(--color-tape-border);
  border-radius: 2px;
  z-index: 2;
}

.scrapbook-card:hover {
  transform: rotate(-1deg) translateY(-4px);
  box-shadow: 5px 8px 20px rgba(0,0,0,0.18);
}

.scrapbook-card .card-thumb {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border: 3px solid #f0e6d3;
  border-radius: 2px;
  margin-bottom: 0.75rem;
  background: var(--color-pastel-yellow);
}

.scrapbook-card .card-placeholder {
  width: 100%;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-pastel-yellow);
  border: 3px dashed #e0d4c0;
  border-radius: 2px;
  margin-bottom: 0.75rem;
  color: var(--color-text-light);
  font-size: 3rem;
}

.scrapbook-card h3 {
  font-family: var(--font-handwritten);
  font-size: 1.3rem;
  margin-bottom: 0.3rem;
}

.scrapbook-card .card-date {
  font-size: 0.95rem;
  color: var(--color-text-light);
  margin-bottom: 0.4rem;
}

.scrapbook-card .card-desc {
  font-size: 1rem;
  color: var(--color-text);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.scrapbook-card .card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* ---------- EDITOR PAGE ---------- */
.editor-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1rem;
  min-height: calc(100vh - 120px);
}

.editor-sidebar {
  background: var(--color-paper);
  border: 2px solid #e0d4c0;
  border-radius: 6px;
  padding: 1rem;
  overflow-y: auto;
  max-height: calc(100vh - 120px);
  position: sticky;
  top: 70px;
}

.editor-sidebar h3 {
  font-family: var(--font-handwritten);
  font-size: 1.15rem;
  margin-bottom: 0.6rem;
  color: var(--color-dark-brown);
  border-bottom: 1px dashed var(--color-light-brown);
  padding-bottom: 0.3rem;
}

.editor-sidebar .field-group {
  margin-bottom: 1rem;
}

.editor-sidebar label {
  display: block;
  font-family: var(--font-handwritten);
  font-size: 1rem;
  margin-bottom: 0.25rem;
  color: var(--color-text-light);
}

.editor-sidebar input[type="text"],
.editor-sidebar input[type="date"],
.editor-sidebar textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #d4c5a9;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 1rem;
  background: #fff;
  color: var(--color-text);
}

.editor-sidebar textarea {
  resize: vertical;
  min-height: 60px;
}

/* Sticker palette */
.sticker-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.sticker-palette .sticker-btn {
  width: 48px;
  height: 48px;
  background: #fff;
  border: 2px solid #e0d4c0;
  border-radius: 6px;
  cursor: pointer;
  padding: 4px;
  transition: transform var(--transition), border-color var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sticker-palette .sticker-btn:hover,
.sticker-palette .sticker-btn:focus {
  transform: scale(1.15);
  border-color: var(--color-accent);
}

.sticker-palette .sticker-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Decoration buttons */
.deco-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.deco-btn {
  padding: 0.35rem 0.75rem;
  font-family: var(--font-handwritten);
  font-size: 0.95rem;
  background: var(--color-pastel-yellow);
  border: 1px solid #e0d4c0;
  border-radius: 20px;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.deco-btn:hover, .deco-btn:focus {
  background: var(--color-pink);
  transform: scale(1.05);
}

/* Canvas area */
.canvas-wrapper {
  position: relative;
  background: #fff;
  border: 3px solid #e0d4c0;
  border-radius: 4px;
  min-height: 600px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  /* Notebook lines */
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 31px,
      rgba(200,180,150,0.18) 31px,
      rgba(200,180,150,0.18) 32px
    );
  background-color: #fff;
}

/* Canvas element (photo/sticker/text/tape/frame/doodle on canvas) */
.canvas-element {
  position: absolute;
  cursor: grab;
  user-select: none;
  transition: box-shadow 0.15s ease;
}

.canvas-element:active { cursor: grabbing; }

.canvas-element.selected {
  outline: 2px dashed var(--color-accent);
  outline-offset: 3px;
}

/* Resize handles */
.canvas-element .resize-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--color-accent);
  border: 2px solid #fff;
  border-radius: 50%;
  z-index: 10;
  cursor: nwse-resize;
}

.canvas-element .resize-handle.tl { top: -6px; left: -6px; cursor: nwse-resize; }
.canvas-element .resize-handle.tr { top: -6px; right: -6px; cursor: nesw-resize; }
.canvas-element .resize-handle.bl { bottom: -6px; left: -6px; cursor: nesw-resize; }
.canvas-element .resize-handle.br { bottom: -6px; right: -6px; cursor: nwse-resize; }

/* Rotate handle */
.canvas-element .rotate-handle {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 18px;
  background: var(--color-light-brown);
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: grab;
  z-index: 10;
}

.canvas-element .rotate-handle::after {
  content: '↻';
  color: #fff;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

/* Photo element on canvas */
.canvas-element.type-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 4px solid #fff;
  box-shadow: 1px 2px 6px rgba(0,0,0,0.15);
}

/* Polaroid style */
.canvas-element.type-photo.polaroid img {
  border: none;
}
.canvas-element.type-photo.polaroid .polaroid-wrap {
  background: #fff;
  padding: 8px 8px 32px 8px;
  box-shadow: 2px 3px 10px rgba(0,0,0,0.18);
}
.canvas-element.type-photo.polaroid .polaroid-wrap img {
  border: none;
  box-shadow: none;
}

/* Sticker element */
.canvas-element.type-sticker img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(1px 2px 3px rgba(0,0,0,0.15));
}

/* Text note element */
.canvas-element.type-text {
  background: var(--color-pastel-yellow);
  border: 1px solid #e0d4c0;
  padding: 0.5rem 0.75rem;
  min-width: 80px;
  min-height: 40px;
  font-family: var(--font-handwritten);
  font-size: 1.1rem;
  color: var(--color-text);
  box-shadow: 2px 2px 6px rgba(0,0,0,0.1);
  border-radius: 2px;
}

.canvas-element.type-text .text-content {
  outline: none;
  min-height: 20px;
}

/* Tape element */
.canvas-element.type-tape {
  width: 120px;
  height: 28px;
  background: var(--color-tape);
  border: 1px solid var(--color-tape-border);
  opacity: 0.85;
}

/* Frame element */
.canvas-element.type-frame {
  border: 6px double var(--color-light-brown);
  background: transparent;
  width: 180px;
  height: 140px;
  border-radius: 2px;
}

/* Doodle element */
.canvas-element.type-doodle svg {
  width: 100%;
  height: 100%;
}

/* Element controls bar */
.element-controls {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  gap: 0.4rem;
  background: var(--color-paper);
  border: 2px solid #e0d4c0;
  border-radius: 30px;
  padding: 0.4rem 0.8rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 900;
}

.element-controls.visible { display: flex; }

.element-controls button {
  padding: 0.35rem 0.75rem;
  font-family: var(--font-handwritten);
  font-size: 0.95rem;
  background: #fff;
  border: 1px solid #e0d4c0;
  border-radius: 20px;
  cursor: pointer;
  transition: background var(--transition);
}

.element-controls button:hover,
.element-controls button:focus {
  background: var(--color-pastel-yellow);
}

.element-controls button.delete-btn:hover {
  background: #ffe0e0;
  color: #c00;
}

/* Save status */
.save-status {
  position: fixed;
  top: 70px;
  right: 1rem;
  padding: 0.4rem 1rem;
  font-family: var(--font-handwritten);
  font-size: 0.95rem;
  background: var(--color-pastel-yellow);
  border: 1px solid #e0d4c0;
  border-radius: 20px;
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 800;
  pointer-events: none;
}

.save-status.show { opacity: 1; }

/* ---------- TIMELINE PAGE ---------- */
.timeline-container {
  position: relative;
  padding-left: 40px;
}

.timeline-container::before {
  content: '';
  position: absolute;
  left: 18px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, var(--color-light-brown), var(--color-pink), var(--color-light-brown));
  border-radius: 3px;
}

.timeline-entry {
  position: relative;
  margin-bottom: 2rem;
  padding-left: 1.5rem;
  animation: fadeSlideIn 0.4s ease both;
}

.timeline-entry::before {
  content: '';
  position: absolute;
  left: -29px;
  top: 12px;
  width: 14px;
  height: 14px;
  background: var(--color-accent);
  border: 3px solid var(--color-cream);
  border-radius: 50%;
  z-index: 2;
}

.timeline-entry .scrapbook-card {
  cursor: pointer;
}

/* ---------- GALLERY PAGE ---------- */
.gallery-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  padding: 1rem;
}

.polaroid-item {
  background: #fff;
  padding: 10px 10px 40px 10px;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: pointer;
  flex: 0 0 auto;
  width: 200px;
}

.polaroid-item:nth-child(odd) { transform: rotate(-3deg); }
.polaroid-item:nth-child(even) { transform: rotate(2deg); }
.polaroid-item:nth-child(3n) { transform: rotate(-1deg); }

.polaroid-item:hover {
  transform: rotate(0deg) scale(1.05) translateY(-6px);
  box-shadow: 4px 6px 20px rgba(0,0,0,0.2);
  z-index: 10;
}

.polaroid-item img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.polaroid-item .polaroid-caption {
  font-family: var(--font-handwritten);
  font-size: 0.95rem;
  text-align: center;
  margin-top: 8px;
  color: var(--color-text-light);
}

/* ---------- Lightbox ---------- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 2rem;
}

.lightbox-overlay.active { display: flex; }

.lightbox-content {
  background: #fff;
  padding: 1rem 1rem 2rem;
  max-width: 90vw;
  max-height: 85vh;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  text-align: center;
  position: relative;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 65vh;
  object-fit: contain;
  margin-bottom: 0.75rem;
}

.lightbox-content .lb-title {
  font-family: var(--font-handwritten);
  font-size: 1.3rem;
  color: var(--color-dark-brown);
}

.lightbox-content .lb-date {
  font-size: 0.95rem;
  color: var(--color-text-light);
}

.lightbox-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 34px;
  height: 34px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-soft);
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--color-text-light);
}

.empty-state .empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

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

/* ---------- Size Warning ---------- */
.size-warning {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #856404;
  padding: 0.75rem 1.2rem;
  border-radius: 8px;
  font-family: var(--font-handwritten);
  box-shadow: var(--shadow-soft);
  display: none;
  z-index: 900;
  max-width: 350px;
}

.size-warning.visible { display: block; }

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

@keyframes popIn {
  0%   { transform: scale(0); opacity: 0; }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes dropIn {
  0%   { transform: translateY(-40px) rotate(-5deg); opacity: 0; }
  60%  { transform: translateY(5px) rotate(1deg); opacity: 1; }
  100% { transform: translateY(0) rotate(0deg); opacity: 1; }
}

@keyframes pageFlip {
  0%   { transform: perspective(800px) rotateY(0deg); opacity: 1; }
  50%  { transform: perspective(800px) rotateY(-5deg); opacity: 0.7; }
  100% { transform: perspective(800px) rotateY(0deg); opacity: 1; }
}

.anim-pop   { animation: popIn 0.35s ease both; }
.anim-drop  { animation: dropIn 0.45s ease both; }
.anim-flip  { animation: pageFlip 0.5s ease both; }
.anim-fade  { animation: fadeSlideIn 0.4s ease both; }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  margin-top: 3rem;
  border-top: 2px dashed var(--color-light-brown);
  color: var(--color-text-light);
  font-size: 0.95rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .hamburger { display: block; }

  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    padding-top: 0.5rem;
  }

  .nav-links.open { display: flex; }

  .editor-layout {
    grid-template-columns: 1fr;
  }

  .editor-sidebar {
    position: relative;
    top: auto;
    max-height: none;
  }

  .polaroid-item { width: 160px; }

  .gallery-grid { gap: 1rem; }

  .element-controls {
    flex-wrap: wrap;
    bottom: 0.5rem;
    padding: 0.3rem 0.5rem;
    border-radius: 12px;
    max-width: 95vw;
  }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 1.6rem; }
  .cards-grid { grid-template-columns: 1fr; }
  .polaroid-item { width: 140px; }
}
