/* ============================================================
   Tulu Dictionary — Design System
   ============================================================ */

:root {
  /* Palette */
  --bg:              #faf8f4;
  --surface:         #ffffff;
  --border:          #e5ddd0;
  --border-light:    #f0ebe2;

  --text:            #1c1812;
  --text-secondary:  #5c5040;
  --text-muted:      #9a8c7e;

  --accent:          #c9551e;
  --accent-hover:    #a8451a;
  --accent-light:    #fdf1ec;

  --blue:            #1a56db;
  --blue-hover:      #1447bd;

  --success:         #15803d;
  --warning:         #b45309;
  --error:           #c81e1e;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.07);
  --shadow-md:  0 4px 16px rgba(0,0,0,.09), 0 1px 4px rgba(0,0,0,.05);
  --shadow-lg:  0 12px 40px rgba(0,0,0,.11), 0 4px 8px rgba(0,0,0,.05);

  /* Radii */
  --r-sm:   4px;
  --r-md:   8px;
  --r-lg:  16px;
  --r-pill: 9999px;

  /* Fonts */
  --font:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-kn: 'Noto Sans Kannada', 'Lohit Kannada', sans-serif;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  margin: 0;
  min-height: 100%;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

h1, h2, h3, h4, h5 { margin: 0 0 .5em; line-height: 1.3; }
h4, h5 { font-weight: 500; }

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-hover); }

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* Kannada script class */
.kn {
  font-family: var(--font-kn);
  font-weight: 500;
}

/* ---- Form Elements ---- */
input:not([type="radio"]),
select, button, textarea, .button {
  font-family: var(--font);
  font-size: 1rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  line-height: 1.4;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201,85,30,.12);
}

button, .button {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
  cursor: pointer;
  padding: 10px 20px;
  font-weight: 500;
  transition: background .15s, border-color .15s;
}
button:hover, .button:hover {
  background: #444;
  border-color: #444;
}
.button-outline {
  background: transparent;
  color: var(--text);
}
.button-outline:hover {
  background: var(--border-light);
  color: var(--text);
}

.noul { list-style: none; margin: 0; padding: 0; }
.text-right { text-align: right; }
.center { text-align: center; }

/* ============================================================
   Layout — Container
   ============================================================ */
.container {
  width: 100%;
  padding: 0 16px;
}

.main {
  background: var(--surface);
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 48px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============================================================
   Homepage Hero
   ============================================================ */
body.home {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

body.home .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 24px;
}

body.home .main {
  min-height: unset;
  width: 100%;
  max-width: 640px;
  padding: 56px 48px 48px;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: fadeUp .5s ease both;
}

body.home .header {
  text-align: center;
  margin-bottom: 40px;
}

body.home .logo {
  width: 100%;
  margin-bottom: 28px;
}
body.home .logo img {
  height: 100px;
  width: auto;
  margin: 0 auto;
  transition: transform .2s ease;
}
body.home .logo img:hover {
  transform: scale(1.04);
}

body.home .search {
  width: 100%;
}

/* ---- Word count on homepage ---- */
.word-count {
  text-align: center;
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -.02em;
  margin: 32px 0 4px;
  line-height: 1;
}

.word-count-source {
  text-align: center;
  color: var(--text-muted);
  font-size: .78rem;
  margin: 0 0 8px;
  padding: 0 12px;
}
.word-count-source em { font-style: italic; }
.word-count-source a {
  color: var(--text-muted);
  border-bottom: 1px dotted var(--text-muted);
}
.word-count-source a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ============================================================
   Search Tabs + Form
   ============================================================ */
.search .tabs {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 12px;
}
.search .tabs .group { display: contents; }
.search .tabs input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}
.search .tab {
  display: inline-block;
  padding: 6px 16px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s ease;
  text-decoration: none;
  background: transparent;
}
.search .tabs input:checked + .tab,
.search .tab:hover {
  color: var(--accent);
  background: var(--accent-light);
  border-color: rgba(201,85,30,.2);
}

/* Search form */
.search-form { margin-top: 4px; }
.search-form > div {
  display: flex;
  align-items: stretch;
  border-radius: var(--r-pill);
  border: 2px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.search-form > div:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(201,85,30,.1);
}
.search-form input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 14px 20px;
  font-size: 1.05rem;
  font-family: var(--font-kn), var(--font);
  outline: none;
  color: var(--text);
  min-width: 0;
}
.search-form input::placeholder { color: var(--text-muted); }
.search-form button {
  border: none;
  border-radius: 0;
  background: var(--accent);
  color: #fff;
  padding: 14px 22px;
  cursor: pointer;
  transition: background .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.search-form button:hover { background: var(--accent-hover); }
.search-form button img {
  height: 18px;
  width: 18px;
  filter: brightness(0) invert(1);
}

/* ============================================================
   Header (non-homepage)
   ============================================================ */
.header {
  margin-bottom: 36px;
}

/* Non-home header: logo left, search right */
body:not(.home) .header .row {
  display: flex;
  align-items: center;
  gap: 24px;
}
body:not(.home) .logo {
  flex: 0 0 auto;
}
body:not(.home) .logo img {
  height: 36px;
  width: auto;
}
body:not(.home) .search {
  flex: 1;
}
body:not(.home) .search .tabs {
  justify-content: flex-start;
  margin-bottom: 8px;
}
body:not(.home) .search-form > div {
  border-radius: var(--r-pill);
}
body:not(.home) .search-form input {
  padding: 10px 18px;
  font-size: .95rem;
}
body:not(.home) .search-form button {
  padding: 10px 18px;
}

/* ============================================================
   Search Results — Entries
   ============================================================ */
.content.results {
  margin-top: 8px;
}

.entries {
  list-style: none;
  margin: 0;
  padding: 0;
}

.entries .entry {
  padding: 28px 0;
  border-bottom: 1px solid var(--border-light);
}
.entries .entry:last-child { border-bottom: none; }

/* Entry title */
.entries .head {
  position: relative;
  margin-bottom: 12px;
}
.entries .title {
  font-family: var(--font-kn);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  line-height: 1.3;
  letter-spacing: .01em;
}
.entries .pronun {
  display: inline-block;
  margin-top: 4px;
  font-size: .85rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Definitions list */
.entries .defs {
  margin: 8px 0 0 0;
  padding-left: 0;
  list-style: none;
}
.entries .defs > li {
  display: flex;
  gap: 12px;
  padding: 5px 0;
  line-height: 1.65;
  color: var(--text-secondary);
  font-size: .975rem;
  border-radius: var(--r-sm);
}
.entries .defs > li::before {
  content: counter(def-counter);
  counter-increment: def-counter;
  flex: 0 0 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  font-size: .7rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-light);
  border-radius: var(--r-pill);
  margin-top: 2px;
}
.entries .defs { counter-reset: def-counter; }

/* Part-of-speech label */
.entries .defs .types {
  display: block;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: 6px 0 2px;
  margin: 4px 0 2px;
  border-top: 1px solid var(--border-light);
  list-style: none;
}
.entries .defs .types:first-child {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

/* Edit link */
.entry .edit {
  position: absolute;
  right: 0; top: 0;
  font-size: .75rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: var(--r-pill);
  padding: 4px 10px;
  display: none;
  text-decoration: none;
  border: 1px solid rgba(201,85,30,.2);
  transition: background .15s;
}
.entry .edit:hover { background: rgba(201,85,30,.2); }
.entry .head:hover .edit,
.entries .defs li:hover .edit { display: inline-block; }

/* Related words sidebar */
.related {
  padding-left: 24px;
  border-left: 1px solid var(--border-light);
}
.related h4 {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.related ul {
  list-style: none;
  margin: 0; padding: 0;
  font-size: .9rem;
}
.related ul li { margin-bottom: 8px; }
.related ul a {
  font-family: var(--font-kn);
  color: var(--text-secondary);
}
.related ul a:hover { color: var(--accent); }

/* ============================================================
   Nav + Footer
   ============================================================ */
.nav {
  border-top: 1px solid var(--border-light);
  padding: 16px 0;
  text-align: center;
  margin: 32px -48px 0;
}
.nav a {
  font-size: .85rem;
  color: var(--text-muted);
  margin: 0 12px;
  text-decoration: none;
  transition: color .15s;
}
.nav a:hover { color: var(--accent); }

.footer {
  text-align: center;
  font-size: .8rem;
  color: var(--text-muted);
  padding: 24px 16px;
  margin-top: 48px;
  border-top: 1px solid var(--border-light);
}
.footer a {
  color: var(--text-muted);
  margin: 0 8px;
  transition: color .15s;
}
.footer a:hover { color: var(--accent); }
.footer .slash { margin: 0 6px; opacity: .5; }

/* ============================================================
   Glossary
   ============================================================ */
.glossary .index {
  background: var(--border-light);
  border-radius: var(--r-md);
  padding: 12px 16px;
  margin-bottom: 24px;
  line-height: 2;
}
.glossary .index a {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-family: var(--font-kn);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: .95rem;
  transition: background .15s, color .15s;
}
.glossary .index .sel,
.glossary .index a:hover {
  background: var(--accent);
  color: #fff;
}
.glossary .words {
  column-count: 3;
  column-gap: 32px;
}
.glossary .words li {
  page-break-inside: avoid;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 0;
  font-family: var(--font-kn);
}
.glossary .words a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: .95rem;
}
.glossary .words a:hover { color: var(--accent); }

/* ============================================================
   Pagination
   ============================================================ */
.pagination { margin: 24px 0; font-size: .9rem; }
.pagination a {
  display: inline-block;
  padding: 0 6px;
  text-decoration: none;
  color: var(--text-secondary);
}
.pagination .pg-selected {
  font-weight: 700;
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

/* ============================================================
   Submission form
   ============================================================ */
.form-submit {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 28px;
}
.form-submit fieldset { border: 0; margin: 0 0 20px; padding: 0; }
.form-submit label { display: block; color: var(--text-secondary); margin-bottom: 6px; font-size: .9rem; }
.form-submit select,
.form-submit input,
.form-submit textarea { width: 100%; }
.form-submit li { list-style: none; margin-bottom: 20px; }
.form-submit select { padding: 10px; }
.form-submit button[type="submit"] { background: var(--accent); border-color: var(--accent); }
.form-submit button[type="submit"]:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* Comments popup */
.form-comments {
  display: none;
  margin: 10px 0 40px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.form-comments textarea { width: 100%; min-height: 160px; }
.form-comments h3 { margin: 0 0 12px; font-size: 1rem; }
.form-comments button { margin: 8px 8px 0 0; }

/* ============================================================
   Static pages
   ============================================================ */
.page {
  margin: 24px 0;
  line-height: 1.7;
}
.page li { margin-bottom: 12px; }
.page a { color: var(--blue); }
.page a:hover { color: var(--blue-hover); }
.page textarea { width: 100%; min-height: 400px; }

/* ============================================================
   Animation
   ============================================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Responsive — 775px
   ============================================================ */
@media (max-width: 775px) {
  .main {
    padding: 24px 20px;
    box-shadow: none;
    border-radius: 0;
  }

  body.home .main {
    padding: 40px 24px 36px;
    box-shadow: none;
    border-radius: 0;
  }

  .nav {
    margin: 24px -20px 0;
  }

  .glossary .words { column-count: 2; }

  body:not(.home) .header .row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  body:not(.home) .logo img { height: 28px; }

  .related {
    border-left: none;
    border-top: 1px solid var(--border-light);
    padding-left: 0;
    padding-top: 20px;
    margin-top: 20px;
  }
}

/* ============================================================
   Responsive — 500px
   ============================================================ */
@media (max-width: 500px) {
  body.home .main { padding: 32px 20px 28px; }

  .word-count { font-size: 2rem; }

  .search .tabs {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px;
  }

  .glossary .words { column-count: 1; }

  .entries .title { font-size: 1.35rem; }

  .footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }
  .footer .slash { display: none; }

  .nav a { display: block; margin: 4px 0; }

  body:not(.home) .search .tabs { display: none; }
}

/* ============================================================
   High-DPI / Large screens
   ============================================================ */
@media (min-width: 2000px) {
  html { font-size: 20px; }
  .main { max-width: 1100px; }
  body.home .main { max-width: 720px; }
}

/* ============================================================
   Homepage — Tagline
   ============================================================ */
.hero-tagline {
  width: 100%;
  text-align: center;
  margin: 8px 0 28px;
  animation: fadeUp .5s ease .1s both;
}
.tagline-kn {
  font-family: var(--font-kn);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 6px;
  letter-spacing: .02em;
}
.tagline-en {
  font-size: .9rem;
  color: var(--text-muted);
  margin: 0;
  letter-spacing: .02em;
}

/* ============================================================
   Homepage — Search suggestion chips
   ============================================================ */
.hero-suggestions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 20px 0 0;
  animation: fadeUp .5s ease .2s both;
}
.suggestions-label {
  font-size: .78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
  margin-right: 4px;
}
.chip {
  font-family: var(--font-kn);
  font-size: .95rem;
  color: var(--text-secondary);
  background: var(--border-light);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 5px 14px;
  text-decoration: none;
  transition: background .15s, color .15s, border-color .15s, transform .15s;
  display: inline-block;
}
.chip:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: rgba(201,85,30,.25);
  transform: translateY(-1px);
}

/* ============================================================
   Homepage — Stats block
   ============================================================ */
.hero-stats {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  margin: 32px 0 4px;
  animation: fadeUp .5s ease .3s both;
}
.word-count {
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -.03em;
  line-height: 1;
}
.word-count-label {
  font-family: var(--font-kn);
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 400;
}
.word-count-source {
  text-align: center;
  color: var(--text-muted);
  font-size: .78rem;
  margin: 0 0 8px;
  padding: 0 12px;
  animation: fadeUp .5s ease .35s both;
}
.word-count-source em { font-style: italic; }
.word-count-source a {
  color: var(--text-muted);
  border-bottom: 1px dotted var(--text-muted);
  text-decoration: none;
}
.word-count-source a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

@media (max-width: 500px) {
  .tagline-kn { font-size: 1.25rem; }
  .word-count  { font-size: 2.1rem; }
  .hero-suggestions { gap: 6px; }
  .chip { font-size: .85rem; padding: 4px 12px; }
}
