:root{
  --primary:#1d4ed8;
  --card:#d6e7ff;
  --ink:#12458c;
  --bg:#2461b7;
  --ring:rgba(29,78,216,.18);
  --line:#9cb5dd;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:Inter,system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  background:var(--bg);
  color:var(--ink);
  font-size: 14px;
}
.page{min-height:100%;display:flex;justify-content:center;align-items:flex-start;padding:24px 12px}
.card{
  width:100%;max-width:760px;background:var(--card);border-radius:12px;
  padding:20px 18px 28px;box-shadow:0 6px 20px rgba(0,0,0,.12)
}
h1{margin:0 0 4px;text-align:center;font-size:24px}
.sub{margin:0 0 18px;text-align:center}
.row{margin:12px 0}
label{display:block;font-weight:600;margin-bottom:6px}
.help{font-size:13px;color:#2c5fa6}
input[type="text"],input[type="email"],input[type="date"],input[type="file"],select,textarea{
  width:100%;max-width:310px;padding:8px;border:1px solid var(--line);border-radius:6px;background:#fff
}
textarea{min-height:90px;max-width:100%}
.inline{display:flex;gap:14px;flex-wrap:wrap}
.inline label{font-weight:500;display:inline-flex;gap:6px;align-items:center}
hr{border:none;border-bottom:1px solid var(--line);margin:16px 0}

.btn{display:inline-flex;justify-content:center;align-items:center;padding:10px 16px;border:none;border-radius:8px;
     background:var(--primary);color:#fff;font-weight:700;cursor:pointer;transition:background .12s,transform .05s,box-shadow .12s}
.btn:hover{background:#1e40af;transform:translateY(-1px);box-shadow:0 2px 8px rgba(15,23,42,.2)}
.btn:disabled{background:#9ca3af;cursor:default;box-shadow:none}
.btn-full{width:100%;max-width:310px}

.btn-outline {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
  border-radius: 20px;
  padding: 6px 16px;
  text-transform: uppercase;
  font-weight: 600;
}
.btn-outline:hover {
  background: rgba(30, 64, 175, 0.05);
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.warning{font-size:13px;color:#b91c1c;margin-top:6px;display:none}
.warning.visible{display:block}

/* Info Box & Buttons */
.info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    color: #ffffff;
    border: none;
    font-family: serif;
    font-style: italic;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    margin-left: 8px;
    vertical-align: middle;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: background 0.2s, transform 0.1s;
}

.info-btn:hover {
    background: #1e40af;
    transform: scale(1.05);
}
.info-box {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    color: var(--ink);
    padding: 12px;
    border-radius: 8px;
    margin-top: 8px;
    font-size: 14px;
    line-height: 1.5;
    display: none;
}
.info-box.visible {
    display: block;
}

#map{
  width:100%;
  height:320px;
  border:1px solid var(--line);
  border-radius:8px;
  background:#eef5ff;
  overflow:hidden;
}

/* Image Preview */
.image-preview-box {
    border: 2px solid #1d4ed8;
    padding: 12px 16px;
    border-radius: 12px;
    background: #ffffff;
    margin-top: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.image-preview-box h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #1d4ed8;
    font-weight: 600;
}
#previewContainer {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}
.image-thumbnail {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid #e5e7eb;
    transition: transform 0.22s ease, box-shadow 0.22s ease;
}
.image-thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(29,78,216,0.35);
}

/* ======== COLOR GRID ======== */
.color-section-title{font-weight:700;margin:8px 0 8px}
.color-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(64px,1fr));gap:10px;width:100%}
@media (max-width:420px){.color-grid{grid-template-columns:repeat(auto-fill,minmax(56px,1fr));gap:8px}}
.color-btn{
  display:flex;align-items:center;justify-content:center;padding:6px;border-radius:10px;
  background:transparent;border:1px solid transparent;cursor:pointer;
  transition:box-shadow .12s ease, transform .05s ease, border-color .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.color-btn:active{transform:translateY(1px);box-shadow:0 2px 6px rgba(0,0,0,.12)}
.color-btn:hover{box-shadow:0 3px 10px rgba(15,23,42,.18)}
.color-btn.selected{border-color:var(--primary);box-shadow:0 0 0 3px var(--ring) inset}

.swatch{width:100%;height:28px;border-radius:8px;overflow:hidden;display:flex;border:1px solid rgba(18,69,140,.25)}
.part{height:100%}

/* Solid colors */
.c-nero{background:#000}
.c-bianco{background:#fff}
.c-verde{background:#a0a06a}
.c-rosso{background:#cf3b32}
.c-marrone{background:#744532}
.c-marrone-scuro{background:#5c352f}
.c-giallo{background:#f6f069}
.c-arancio{background:#f28a3c}
.c-azzurro{background:#66ade5}

/* ======== SPECIES CARDS (Butterfly Specific) ======== */

.species-card{
  background:#fff;
  border-radius:10px;
  border:1px solid var(--line);
  padding:10px 12px;
}

/* Stacked Layout: Images on top, Text below */
.species-body{
  margin-top:8px;
  display:block;
}

.species-images{
  margin-bottom:10px;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.species-images img {
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
  border-radius: 12px;
  display: block;
}

.img-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 8px;
  overflow: hidden;
}

.caption {
  font-size: 12px;
  color: #555;
  margin-top: 4px;
  font-style: italic;
}

.species-text{
  width:100%;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.species-text .btn{
  align-self:flex-start;
}

/* Reduced gap for phenology/description */
.species-text .help {
  margin-top: 0;
}

/* Pieris Group Cards Layout */
.pieris-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
@media (min-width: 768px) {
  .pieris-cards {
    flex-direction: row;
  }
  .pieris-cards .species-card {
    flex: 1;
  }
}

/* ======== LIGHTBOX (Simple ID-based) ======== */
#lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.95);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

#lightboxImage {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
}

.close-button {
  position: absolute;
  top: 20px;
  right: 20px;
  color: white;
  font-size: 40px;
  cursor: pointer;
  z-index: 10002;
  font-family: sans-serif;
}

/* ======== SUCCESS OVERLAY ======== */
#successOverlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

#successModal {
    background: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    max-width: 90%;
    width: 400px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

#successCheck {
    width: 60px;
    height: 60px;
    background: #10b981;
    color: white;
    font-size: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

#successModal h2 {
    margin: 0 0 10px;
    color: #1f2937;
    font-size: 22px;
}

#successModal p {
    color: #4b5563;
    line-height: 1.5;
    margin: 0;
}

/* Phenology Chart Redesign (Rounded Boxes) */
.phenology-container {
  display: flex;
  gap: 2px;
  width: 96%;
  margin-left: 2%;
  margin-right: 2%;
  margin-top: 12px;
  margin-bottom: 2px;
  border: none;
}

.phen-month-box {
  position: relative;
  flex: 1;
  aspect-ratio: 1.3; /* Shorter/Smaller (Wider than tall) */
  background: #e5e7eb; /* Default Inactive Gray */
  border-radius: 2px;
  overflow: hidden;
  display: flex;
}

.phen-decade {
  flex: 1;
  height: 100%;
  border: none;
}

.phen-letter {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #374151; /* Dark Grey Text */
  z-index: 2;
}

/* Colors */
.phen-green { background-color: #8cc63f; }
.phen-yellow { background-color: #fff200; }
.phen-white { background-color: #e5e7eb; } /* Match inactive gray */

/* Species Header Styles (Matched to UCCELLI_CITTADINI) */
.species-card-header {
  padding: 12px 16px 8px;
  background: #fff;
}

.species-common-name {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: #0056b3; /* Bold Blue */
  margin-bottom: 2px;
}

.species-sci-name {
  display: block;
  font-size: 14px;
  font-style: italic;
  color: #555;
}
