/* ---------------------------------------------------------------------------
   iitalumkorea.org — layout and responsiveness improvements
   ---------------------------------------------------------------------------
   Loaded last, on top of the inherited Weebly theme. The theme's own CSS is
   left untouched, so everything here can be removed by deleting one <link>.

   Weebly's breakpoints are 480 / 768 / 1024, so these match them rather than
   introducing a competing set.

   Every override is scoped as narrowly as it can be. !important is used only
   where Weebly sets the property as an inline style on the element, which
   cannot be beaten any other way.
--------------------------------------------------------------------------- */


/* --- 1. Use the width of large screens -------------------------------------
   The theme caps content at 1140px, so a 1440px or wider monitor shows wide
   empty margins. Raise the cap a little on big screens only; below 1400px
   nothing changes. */
@media screen and (min-width: 1400px) {
  .container {
    max-width: 1320px;
  }
}


/* --- 2. Rebalance the home page's two columns ------------------------------
   The home page is one table row: the left cell holds About Us and the entire
   run of event highlights, the right cell holds the photo gallery. Weebly gave
   the text 44.7% and the gallery 55.3% as inline styles.

   Because a table row's cells are equal height and the gallery is far shorter
   than the event list, more than half the page width sits empty for thousands
   of pixels while the main content is squeezed into a 442px column.

   Giving the text the larger share makes the reading column ~590px at 1280px
   wide and leaves the gallery ample room. Scoped to the home page so other
   pages' column ratios are untouched, and only above the theme's 1024px
   breakpoint — below that the theme stacks the cells, which is correct. */
@media screen and (min-width: 1025px) {
  .wsite-page-index td.wsite-multicol-col:first-child {
    width: 58% !important;
  }
  .wsite-page-index td.wsite-multicol-col:last-child {
    width: 42% !important;
  }

  /* Keep the gallery beside the text it belongs to rather than floating in the
     middle of a very tall cell. */
  .wsite-page-index td.wsite-multicol-col {
    vertical-align: top;
  }
}


/* --- 2b. Stack the columns sooner --------------------------------------------
   The theme only stacks its layout columns below 768px, so a tablet — or a
   split-screen window — renders two columns in about 700px, leaving the text
   roughly 280 characters-per-line too narrow and the gallery thumbnails tiny.
   Stack below 900px instead, which covers tablets in both orientations. */
@media screen and (max-width: 900px) {
  /* Keep Weebly's 15px cell padding: the table wrapper carries a matching
     -15px margin to cancel it, so removing one without the other shifts the
     content left and clips it against the viewport edge. */
  #wsite-content td.wsite-multicol-col,
  #wsite-content .wsite-multicol-col {
    display: block;
    width: 100% !important;
    /* Without this the 15px cell padding is added *outside* the 100% width,
       making the cell 30px wider than the wrapper that clips it — which cuts
       the last word off every line. */
    box-sizing: border-box;
  }

  #wsite-content .wsite-multicol-col + .wsite-multicol-col {
    margin-top: 2em;
  }
}


/* --- 2c. Don't justify narrow text -------------------------------------------
   The theme justifies body copy. That reads well in a wide column, but in a
   narrow one it opens up large uneven gaps between words — visible on the home
   page's About Us text at tablet width. */
@media screen and (max-width: 900px) {
  #wsite-content .paragraph,
  #wsite-content .paragraph * {
    text-align: left !important;
  }
}


/* --- 3. Form fields that fit their container -------------------------------
   Weebly sizes inputs with fixed-pixel utility classes (370px, 500px). On a
   phone the wider ones are cut off; on a desktop they leave the contact page
   looking lopsided, with fields hugging the left edge of a much wider column.
   Make them fluid with a sensible cap. */
.wsite-form-input,
.wsite-input-width-285px,
.wsite-input-width-370px,
.wsite-input-width-500px {
  width: 100% !important;
  max-width: 520px;
  box-sizing: border-box;
}

.wsite-form-field textarea.wsite-form-input {
  max-width: 640px;
}

/* The first/last name pair sits in a two-up row; let it stack when there is no
   room rather than shrinking each field to an unusable width. */
@media screen and (max-width: 480px) {
  .wsite-form-field .wsite-form-input {
    max-width: 100%;
  }
}


/* --- 4. Comfortable tap targets --------------------------------------------
   Inputs inherit a desktop-sized line height that is fiddly on a phone, and
   iOS zooms the page in on any input with a font-size below 16px. */
@media screen and (max-width: 767px) {
  .wsite-form-input,
  .wsite-form-input[type="text"],
  .wsite-form-input[type="email"] {
    font-size: 16px;
    padding: 12px 10px;
  }

  .wsite-button .wsite-button-inner {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}


/* --- 5. Media that cannot overflow -----------------------------------------
   Some inline images and embeds carry hard-coded pixel widths from the Weebly
   editor, which force a sideways scroll on narrow screens. */
img,
video {
  max-width: 100%;
  height: auto;
}

/* Embedded maps, forms and videos (the Google Form on /join.html among them)
   are fixed-width iframes. Let them shrink. */
iframe {
  max-width: 100%;
}

/* Wide tables in page content scroll on their own instead of stretching the
   page. Weebly's own layout tables are excluded — they *are* the layout. */
#wsite-content table:not(.wsite-multicol-table) {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}


/* --- 6. Readable line length ----------------------------------------------
   With the home page's text column widened, and on pages that were already
   full width, paragraphs can otherwise run past a comfortable reading length. */
@media screen and (min-width: 1025px) {
  #wsite-content .paragraph {
    max-width: 78ch;
  }
}


/* --- 7. Gallery thumbnails that reflow -------------------------------------
   The photo gallery is a fixed four-across grid. In the narrowed column, and
   on tablets, four columns leave the thumbnails tiny. */
@media screen and (max-width: 768px) {
  .wsite-multicol-col .galleryImageHolder,
  .wsite-multicol-col .wsite-gallery-column {
    min-width: 33%;
  }
}

@media screen and (max-width: 480px) {
  .wsite-multicol-col .galleryImageHolder,
  .wsite-multicol-col .wsite-gallery-column {
    min-width: 50%;
  }
}
