/* Modern, restrained design for religious community website */

* {
  box-sizing: border-box;
}

body {
  background: linear-gradient(135deg, #f5f3f0 0%, #e8e5e0 100%);
  background-attachment: fixed;
  margin: 0;
  padding: 20px;
  font-family: 'Open Sans', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #2c2419;
  line-height: 1.7;
  font-size: 16px;
}

img {
  border: none;
  max-width: 100%;
  height: auto;
}

a:link {
  color: #66483d;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:visited {
  color: #4f4440;
}

a:hover {
  color: #9f3713;
  text-decoration: underline;
}

a:active {
  color: #1f130f;
}

/* Main container */
#kokosivu {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  position: relative;
  background-color: #ffffff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  overflow: hidden;
}

/* Header */
#ylatunniste {
  width: 100%;
  position: relative;
  min-height: 180px;
  background-color: #ffffff;
  padding: 20px;
  border-bottom: 3px solid #88776b;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
}

#ylatunniste img {
  display: block;
  height: auto;
}

/* Scale header images down on narrow viewports */
#ylatunniste p {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 15px;
  flex-wrap: nowrap;
  max-width: 100%;
  min-width: 0;
}

#ylatunniste p img {
  flex: 0 1 auto;
  min-width: 0;
  width: auto;
  height: auto;
  max-width: 100%;
  object-fit: contain;
}

/* Content area */
#wrapper {
  display: flex;
  flex-direction: row;
  min-height: 500px;
}

#sisalto {
  flex: 1;
  padding: 40px;
  color: #2c2419;
  line-height: 1.8;
  font-size: 16px;
  background-color: #ffffff;
}

#sisalto h2 {
  color: #3d261d;
  margin-top: 0;
  margin-bottom: 1.5em;
  font-size: 2.2em;
  font-weight: 600;
  letter-spacing: -0.5px;
  border-bottom: 2px solid #e8e5e0;
  padding-bottom: 0.5em;
}

#sisalto h3 {
  color: #66483d;
  font-size: 1.6em;
  margin-top: 2em;
  margin-bottom: 1em;
  font-weight: 600;
}

#sisalto h4 {
  color: #66483d;
  font-size: 1.3em;
  margin-top: 1.5em;
  margin-bottom: 0.8em;
  font-weight: 600;
}

#sisalto p {
  margin: 1.2em 0;
  color: #3d3d3d;
}

#sisalto ul {
  margin: 1.2em 0;
  padding-left: 1.5em;
}

#sisalto li {
  margin: 0.8em 0;
  line-height: 1.7;
}

#sisalto hr {
  border: none;
  border-top: 1px solid #e0ddd8;
  margin: 2em 0;
}

/* Image styling */
#sisalto img {
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin: 1.5em 0;
}

/* Images within text – float and row */
#sisalto .sisalto-kuva-oikea {
  float: right;
  max-width: 42%;
  margin: 0 0 1em 1.5em;
  clear: right;
}

#sisalto .sisalto-kuva-oikea img {
  margin: 0;
  display: block;
  width: 100%;
  height: auto;
}

#sisalto .sisalto-kuvat-rivi {
  display: flex;
  gap: 1.25em;
  margin: 2em 0;
  flex-wrap: wrap;
  justify-content: center;
  clear: both;
}

#sisalto .sisalto-kuvat-rivi img {
  flex: 1 1 240px;
  max-width: 280px;
  width: 100%;
  height: auto;
  margin: 0;
}

#navigointi img {
  border-radius: 4px;
  margin: 10px 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Navigation */
#navigointi {
  font-family: 'Open Sans', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 15px;
  min-width: 240px;
  background: linear-gradient(to bottom, #f9f8f6 0%, #f5f3f0 100%);
  padding: 30px 0;
  border-right: 1px solid #e8e5e0;
}

#navigointi ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

#menu1 {
  width: 100%;
}

#menu1 li {
  margin: 0;
}

#menu1 li a {
  display: block;
  padding: 14px 20px;
  text-decoration: none;
  color: #3d261d;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
  font-weight: 500;
}

#menu1 li a:link,
#menu1 li a:visited {
  background-color: transparent;
}

#menu1 li a:hover {
  background-color: #ffffff;
  color: #9f3713;
  text-decoration: none;
  border-left-color: #88776b;
  padding-left: 25px;
}

#menu1 li a:active {
  background-color: #f5f3f0;
}

/* Footer */
#alatunniste {
  position: relative;
  background: linear-gradient(to bottom, #88776b 0%, #6b5d52 100%);
  font-family: 'Open Sans', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 13px;
  text-align: center;
  color: #ebe3be;
  padding: 25px;
  clear: both;
  margin-top: 40px;
}

#extra {
  clear: both;
  height: 0;
}

/* Calendar specific styles */
#kalenteri-kokosivu {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  background-color: #ffffff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  overflow: hidden;
  padding: 0;
}

#kalenteri-kokosivu h2 {
  color: #3d261d;
  margin: 0;
  padding: 30px 40px 20px;
  font-size: 2.2em;
  font-weight: 600;
  letter-spacing: -0.5px;
  border-bottom: 2px solid #e8e5e0;
  background-color: #ffffff;
}

#kalenteri-kokosivu #alatunniste {
  margin-top: 0;
}

#loading {
  text-align: center;
  padding: 60px 40px;
  color: #66483d;
  font-size: 16px;
  font-weight: 500;
}

#loading div {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Modern event table */
#event-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 0;
  background-color: #ffffff;
  font-size: 16px;
}

#event-table thead {
  background: linear-gradient(to bottom, #88776b 0%, #6b5d52 100%);
  color: #ffffff;
  position: sticky;
  top: 0;
  z-index: 10;
}

#event-table th {
  padding: 16px 20px;
  text-align: left;
  font-weight: 600;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: none;
}

#event-table th:first-child {
  border-top-left-radius: 0;
}

#event-table th:last-child {
  border-top-right-radius: 0;
}

#event-table tbody {
  background-color: #ffffff;
}

#event-table td {
  padding: 16px 20px;
  border-bottom: 1px solid #f0ede8;
  vertical-align: top;
}

#event-table tbody tr {
  transition: background-color 0.2s ease;
}

#event-table tbody tr:hover {
  background-color: #f9f8f6;
}

#event-table tbody tr:last-child td {
  border-bottom: none;
}

/* Aika-sarake: päivämäärä + kello (kapealla eri riveillä) */
#event-table .event-aika-cell {
  font-weight: 600;
  color: #66483d;
  min-width: 120px;
  vertical-align: top;
}

#event-table .event-aika-time {
  color: #6b5d52;
  font-weight: 500;
}

#event-table tbody tr td:nth-child(2) {
  font-weight: 500;
  color: #3d261d;
  min-width: 180px;
  word-wrap: break-word;
}

#event-table tbody tr td:nth-child(3) {
  font-weight: 500;
  color: #6b5d52;
  min-width: 120px;
}

/* Desktop: piilota chevron (4.), näytä Lisätietoa (5.); mobiilissa päinvastoin */
#event-table .chevron-col,
#event-table .chevron-cell {
  display: none;
}

#event-table .event-details-row {
  display: none;
}

#kalenteri-sisalto {
  padding: 0 40px 30px;
}

#kalenteri-back-link {
  margin-top: 30px;
}

#kalenteri-back-link a {
  display: inline-block;
  padding: 10px 20px;
  color: #66483d;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.2s ease;
}

#kalenteri-back-link a:hover {
  background-color: #f5f3f0;
  padding-left: 25px;
  text-decoration: none;
}

#moreorless {
  font-weight: 600;
  text-align: center;
  margin: 30px 0;
  padding: 0 40px;
}

#moreorless a {
  display: inline-block;
  padding: 12px 30px;
  background: linear-gradient(to bottom, #88776b 0%, #6b5d52 100%);
  color: #ffffff;
  border-radius: 6px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  text-decoration: none;
}

#moreorless a:hover {
  background: linear-gradient(to bottom, #9f3713 0%, #8b2f0f 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  text-decoration: none;
}

#moreorless a:active {
  transform: translateY(0);
}


/* Responsive design */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  #kokosivu,
  #kalenteri-kokosivu {
    border-radius: 0;
  }

  #wrapper {
    flex-direction: column;
  }

  #navigointi {
    min-width: 100%;
    order: -1;
    border-right: none;
    border-bottom: 1px solid #e8e5e0;
    padding: 20px 0;
  }

  #sisalto {
    padding: 25px;
  }

  #sisalto .sisalto-kuva-oikea {
    float: none;
    max-width: 100%;
    margin: 1.5em 0;
  }

  #sisalto h2 {
    font-size: 1.8em;
  }

  #ylatunniste {
    padding: 15px;
    min-height: auto;
  }

  #kalenteri-kokosivu h2 {
    padding: 20px 15px 15px;
    font-size: 1.8em;
  }

  #kalenteri-sisalto {
    padding: 0 10px 20px;
    overflow-x: hidden;
  }

  #event-table {
    font-size: 16px;
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
  }

  /* Sarakkeenleveydet: Aika kiinteä, Tilaisuus isompi osuus, sitten Paikka */
  #event-table col.col-aika { width: 110px; }
  #event-table col.col-tilaisuus { width: calc((100% - 138px) * 0.62); }
  #event-table col.col-paikka { width: calc((100% - 138px) * 0.38); }
  #event-table col.col-chevron { width: 28px; }
  #event-table col.col-info { width: 0; min-width: 0; }

  /* Kapealla: päivämäärä ja kello omille riveilleen */
  #event-table .event-aika-date { display: block; }
  #event-table .event-aika-time { display: block; margin-top: 0.25em; font-size: 0.95em; }

  #event-table th,
  #event-table td {
    padding: 10px 6px;
  }

  #event-table th:nth-child(1),
  #event-table td:nth-child(1) {
    padding-left: 4px;
    padding-right: 4px;
    box-sizing: border-box;
  }

  #event-table .event-name-cell {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  /* Piilota Lisätietoa (5.), näytä chevron (4.) */
  #event-table th:nth-child(5),
  #event-table td:nth-child(5) {
    display: none;
  }

  #event-table .chevron-col,
  #event-table .chevron-cell {
    display: table-cell;
  }

  #event-table .chevron-cell {
    text-align: center;
    padding: 12px 4px;
    vertical-align: middle;
  }

  #event-table .info-chevron {
    display: inline-block;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 0.9em;
    color: #66483d;
    user-select: none;
  }

  #event-table .event-details-row {
    display: none;
  }

  #event-table .event-details-row.open {
    display: table-row !important;
  }

  #event-table .event-details-cell {
    padding: 12px 16px;
    background-color: #f9f8f6;
    border-bottom: 1px solid #e8e5e0;
    font-size: 1em;
    color: #3d3d3d;
    box-sizing: border-box;
  }

  #event-table .event-details-inner {
    overflow-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    line-height: 1.4;
  }

  #event-table .event-row.event-has-details {
    cursor: pointer;
  }

  #moreorless {
    padding: 0 10px;
    margin: 20px 0;
  }

  #kalenteri-back-link {
    padding: 0 10px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 5px;
    font-size: 15px;
  }

  #sisalto {
    padding: 20px;
    font-size: 15px;
  }

  #sisalto h2 {
    font-size: 1.6em;
  }

  #sisalto h3 {
    font-size: 1.4em;
  }

  #event-table {
    font-size: 14px;
  }

  #event-table th,
  #event-table td {
    padding: 10px 8px;
  }

  #event-table th {
    font-size: 12px;
  }

  #kalenteri-kokosivu h2 {
    padding: 15px 10px 10px;
    font-size: 1.6em;
  }

  #kalenteri-sisalto {
    padding: 0 5px 15px;
    overflow-x: hidden;
  }

  #event-table th,
  #event-table td {
    padding: 8px 4px;
  }

  #event-table col.col-aika { width: 100px; }
  #event-table col.col-tilaisuus { width: calc((100% - 128px) * 0.62); }
  #event-table col.col-paikka { width: calc((100% - 128px) * 0.38); }
  #event-table col.col-chevron { width: 28px; }

  #event-table th:nth-child(1),
  #event-table td:nth-child(1) {
    padding-left: 3px;
    padding-right: 3px;
    font-size: 12px;
    box-sizing: border-box;
  }

  #event-table th:nth-child(2),
  #event-table td:nth-child(2) {
    padding-left: 4px;
    padding-right: 4px;
    box-sizing: border-box;
  }

  #moreorless {
    padding: 0 5px;
    margin: 15px 0;
  }

  #kalenteri-back-link {
    padding: 0 5px;
  }

  #moreorless a {
    padding: 10px 20px;
    font-size: 14px;
  }
}

/* Erittäin kapea näyttö: Aika tiiviimmin */
@media (max-width: 400px) {
  #event-table col.col-aika { width: 90px; }
  #event-table col.col-tilaisuus { width: calc((100% - 118px) * 0.62); }
  #event-table col.col-paikka { width: calc((100% - 118px) * 0.38); }
  #event-table col.col-chevron { width: 28px; }

  #event-table th:nth-child(1),
  #event-table td:nth-child(1) {
    padding-left: 2px;
    padding-right: 2px;
  }

  #event-table th:nth-child(2),
  #event-table td:nth-child(2) {
    padding-left: 2px;
    padding-right: 2px;
  }
}
